Skip to content

Commit

Permalink
Bugfixes and removal of chatProvider hook
Browse files Browse the repository at this point in the history
  • Loading branch information
Fido2603 committed Apr 17, 2020
1 parent 5292911 commit a520044
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 16 deletions.
14 changes: 1 addition & 13 deletions src/main/java/dk/fido2603/semihardcore/PermissionsManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,15 @@ public class PermissionsManager
private String pluginName = "null";
private SemiHardcore plugin;
private Permission vaultPermission = null;
private Chat vaultChat = null;

public PermissionsManager(SemiHardcore p)
{
this.plugin = p;

if (p.vaultEnabled) {
RegisteredServiceProvider<Permission> permissionProvider = plugin.getServer().getServicesManager().getRegistration(Permission.class);
assert permissionProvider != null;
vaultPermission = permissionProvider.getProvider();

RegisteredServiceProvider<Chat> chatProvider = plugin.getServer().getServicesManager().getRegistration(Chat.class);
vaultChat = chatProvider.getProvider();
}
}

Expand Down Expand Up @@ -68,15 +65,6 @@ public String getGroup(String playerName)
return "";
}

public String getPrefix(String playerName)
{
if (this.plugin.vaultEnabled) {
Player player = plugin.getServer().getPlayer(playerName);
return vaultChat.getPlayerPrefix(player);
}
return "";
}

public void setGroup(String playerName, String groupName)
{
if (this.plugin.vaultEnabled) {
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/dk/fido2603/semihardcore/PlayerManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ private long timeDiff(UUID playerId) {
public boolean banPlayer(Player player, UUID playerId)
{
if (isBanned(playerId)) {
plugin.log("Tried to ban a killed player that is already banned... UUID: " + playerId.toString());
plugin.log("Check config - Tried to ban a killed player that is already banned... UUID: " + playerId.toString());
return false;
}

Expand All @@ -211,10 +211,12 @@ public boolean banPlayer(Player player, UUID playerId)
String timeTillBanMessage = plugin.messageTimeTillBan.replace("{time}", Long.toString(plugin.timeBeforeBan));
player.sendMessage(ChatColor.translateAlternateColorCodes('&', timeTillBanMessage));
}
plugin.logDebug("Delay before player is banned: " + delay);

// Delay the kick, to not have the console make a "Removing entity while ticking!" Exception
SemiHardcore.server.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
public void run() {
plugin.logDebug("Banning player...");
String kickMessage = plugin.messageKickPlayerOnBan.replace("{banTime}",plugin.timeToBanStringUF);
player.kickPlayer(ChatColor.translateAlternateColorCodes('&', kickMessage));
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/dk/fido2603/semihardcore/SemiHardcore.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class SemiHardcore extends JavaPlugin
private String timeToBanString = "24h";
public String timeToBanStringUF = "24 hours";
public long timeToBan = 0;
public long timeBeforeBan = 0;
public Integer timeBeforeBan = 0;
private static FileConfiguration config = null;
private static PlayerManager playerManager = null;
private static PermissionsManager permissionsManager = null;
Expand Down Expand Up @@ -226,7 +226,7 @@ public void loadSettings()
this.debug = config.getBoolean("Settings.Debug", false);
this.instantSave = config.getBoolean("Settings.InstantSave", false);
this.timeToBanString = config.getString("Settings.TimeToBan", "24h");
this.timeBeforeBan = config.getLong("Settings.TimeBeforeBan", 0);
this.timeBeforeBan = config.getInt("Settings.TimeBeforeBan", 0);

this.uhcDayEnabled = config.getBoolean("Misc.UHCDayEnabled", false);
this.uhcDay = config.getInt("Misc.UHCDay", 2);
Expand Down

0 comments on commit a520044

Please sign in to comment.