From 6b85b306efbeeaf136e272bea971d35ff0b02520 Mon Sep 17 00:00:00 2001 From: snowleo Date: Tue, 19 Jul 2011 00:59:43 +0200 Subject: [PATCH 1/5] Another fix for /tjail offline players --- .../essentials/commands/Commandtogglejail.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtogglejail.java b/Essentials/src/com/earth2me/essentials/commands/Commandtogglejail.java index 4f199e472..ccb1e6781 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtogglejail.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtogglejail.java @@ -35,7 +35,15 @@ public class Commandtogglejail extends EssentialsCommand p.setJailed(true); p.sendMessage(Util.i18n("userJailed")); p.setJail(null); - ess.getJail().sendToJail(p, args[1]); + if (!(p.getBase() instanceof OfflinePlayer)) + { + ess.getJail().sendToJail(p, args[1]); + } + else + { + // Check if jail exists + ess.getJail().getJail(args[1]); + } p.setJail(args[1]); long timeDiff = 0; if (args.length > 2) From a65390ed98986028feeb44a566a76086736e35cb Mon Sep 17 00:00:00 2001 From: snowleo Date: Tue, 19 Jul 2011 01:12:19 +0200 Subject: [PATCH 2/5] More fixes to /tjail Don't prevent unjailing an admin Fix time change --- .../essentials/commands/Commandtogglejail.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtogglejail.java b/Essentials/src/com/earth2me/essentials/commands/Commandtogglejail.java index ccb1e6781..8e5480e74 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtogglejail.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtogglejail.java @@ -23,14 +23,14 @@ public class Commandtogglejail extends EssentialsCommand } User p = getPlayer(server, args, 0, true); - if (p.isAuthorized("essentials.jail.exempt")) - { - sender.sendMessage(Util.i18n("mayNotJail")); - return; - } if (args.length >= 2 && !p.isJailed()) { + if (p.isAuthorized("essentials.jail.exempt")) + { + sender.sendMessage(Util.i18n("mayNotJail")); + return; + } charge(sender); p.setJailed(true); p.sendMessage(Util.i18n("userJailed")); @@ -64,7 +64,7 @@ public class Commandtogglejail extends EssentialsCommand return; } - if (args.length >= 2 && p.isJailed() && !args[1].equalsIgnoreCase(p.getJail())) + if (args.length >= 2 && p.isJailed() && args[1].equalsIgnoreCase(p.getJail())) { String time = getFinalArg(args, 2); long timeDiff = Util.parseDateDiff(time, true); From c8ba06f0ee55abf09a0ab0968945cb9ab1f52a21 Mon Sep 17 00:00:00 2001 From: snowleo Date: Tue, 19 Jul 2011 01:27:16 +0200 Subject: [PATCH 3/5] We can't test for essentials.jail.exempt, if the player is offline, so added a new permission essentials.togglejail.offline --- .../commands/Commandtogglejail.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtogglejail.java b/Essentials/src/com/earth2me/essentials/commands/Commandtogglejail.java index 8e5480e74..3312dafc0 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtogglejail.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtogglejail.java @@ -5,6 +5,7 @@ import org.bukkit.Server; import org.bukkit.command.CommandSender; import com.earth2me.essentials.User; import com.earth2me.essentials.Util; +import org.bukkit.entity.Player; public class Commandtogglejail extends EssentialsCommand @@ -26,10 +27,22 @@ public class Commandtogglejail extends EssentialsCommand if (args.length >= 2 && !p.isJailed()) { - if (p.isAuthorized("essentials.jail.exempt")) + if (p.getBase() instanceof OfflinePlayer) { - sender.sendMessage(Util.i18n("mayNotJail")); - return; + if (sender instanceof Player + && !ess.getUser(sender).isAuthorized("essentials.togglejail.offline")) + { + sender.sendMessage(Util.i18n("mayNotJail")); + return; + } + } + else + { + if (p.isAuthorized("essentials.jail.exempt")) + { + sender.sendMessage(Util.i18n("mayNotJail")); + return; + } } charge(sender); p.setJailed(true); From d388290427f8d16dd6418bdcea9badfff2461ec3 Mon Sep 17 00:00:00 2001 From: snowleo Date: Tue, 19 Jul 2011 01:27:56 +0200 Subject: [PATCH 4/5] user.dispose() should be called on every quit. --- .../src/com/earth2me/essentials/EssentialsPlayerListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java index f539227f0..36654b91f 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java @@ -215,11 +215,11 @@ public class EssentialsPlayerListener extends PlayerListener user.getInventory().setContents(user.getSavedInventory()); user.setSavedInventory(null); } + user.dispose(); if (!ess.getSettings().getReclaimSetting()) { return; } - user.dispose(); final Thread thread = new Thread(new Runnable() { public void run() From 150a0e0ddddc421e2a68dc7fa9d39b565beca439 Mon Sep 17 00:00:00 2001 From: snowleo Date: Tue, 19 Jul 2011 01:32:48 +0200 Subject: [PATCH 5/5] /tempban and /ban have the same problem as /tjail new permissions: essentials.ban.offline essentials.tempban.offline --- .../essentials/commands/Commandban.java | 23 +++++++++++++++---- .../essentials/commands/Commandtempban.java | 20 +++++++++++++--- 2 files changed, 35 insertions(+), 8 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandban.java b/Essentials/src/com/earth2me/essentials/commands/Commandban.java index 1499b10ac..2bd09831d 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandban.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandban.java @@ -1,9 +1,11 @@ package com.earth2me.essentials.commands; +import com.earth2me.essentials.OfflinePlayer; import org.bukkit.Server; import org.bukkit.command.CommandSender; import com.earth2me.essentials.User; import com.earth2me.essentials.Util; +import org.bukkit.entity.Player; public class Commandban extends EssentialsCommand @@ -21,12 +23,24 @@ public class Commandban extends EssentialsCommand throw new NotEnoughArgumentsException(); } final User player = getPlayer(server, args, 0, true); - if (player.isAuthorized("essentials.ban.exempt")) + if (player.getBase() instanceof OfflinePlayer) { - sender.sendMessage(Util.i18n("banExempt")); - return; + if (sender instanceof Player + && !ess.getUser(sender).isAuthorized("essentials.ban.offline")) + { + sender.sendMessage(Util.i18n("banExempt")); + return; + } } - + else + { + if (player.isAuthorized("essentials.ban.exempt")) + { + sender.sendMessage(Util.i18n("banExempt")); + return; + } + } + String banReason; if (args.length > 1) { @@ -42,4 +56,3 @@ public class Commandban extends EssentialsCommand server.broadcastMessage(Util.format("playerBanned", player.getName(), banReason)); } } - diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtempban.java b/Essentials/src/com/earth2me/essentials/commands/Commandtempban.java index 639c2bda0..c9495401e 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtempban.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtempban.java @@ -1,9 +1,11 @@ package com.earth2me.essentials.commands; +import com.earth2me.essentials.OfflinePlayer; import org.bukkit.Server; import org.bukkit.command.CommandSender; import com.earth2me.essentials.User; import com.earth2me.essentials.Util; +import org.bukkit.entity.Player; public class Commandtempban extends EssentialsCommand @@ -21,10 +23,22 @@ public class Commandtempban extends EssentialsCommand throw new NotEnoughArgumentsException(); } final User player = getPlayer(server, args, 0, true); - if (player.isAuthorized("essentials.tempban.exempt")) + if (player.getBase() instanceof OfflinePlayer) { - sender.sendMessage(Util.i18n("tempbanExempt")); - return; + if (sender instanceof Player + && !ess.getUser(sender).isAuthorized("essentials.tempban.offline")) + { + sender.sendMessage(Util.i18n("tempbanExempt")); + return; + } + } + else + { + if (player.isAuthorized("essentials.tempban.exempt")) + { + sender.sendMessage(Util.i18n("tempbanExempt")); + return; + } } final String time = getFinalArg(args, 1); final long banTimestamp = Util.parseDateDiff(time, true);