From f51b92c99e5527c76ffa248fc47d0f74c00d11ed Mon Sep 17 00:00:00 2001 From: KHobbits Date: Tue, 15 Nov 2011 23:01:15 +0000 Subject: [PATCH 1/8] Updating banip to support offline players. --- .../src/com/earth2me/essentials/commands/Commandbanip.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandbanip.java b/Essentials/src/com/earth2me/essentials/commands/Commandbanip.java index 591542bcb..36ea479f9 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandbanip.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandbanip.java @@ -30,7 +30,11 @@ public class Commandbanip extends EssentialsCommand } else { - ess.getServer().banIP(u.getAddress().getAddress().getHostAddress()); + final String ipAddress = u.getLastLoginAddress(); + if (ipAddress.length() == 0) { + throw new Exception(Util.i18n("playerNotFound")); + } + ess.getServer().banIP(u.getLastLoginAddress()); sender.sendMessage(Util.i18n("banIpAddress")); } } From e4c3f7b11576e8baafa511a509d4f6041823257b Mon Sep 17 00:00:00 2001 From: KHobbits Date: Tue, 15 Nov 2011 23:54:26 +0000 Subject: [PATCH 2/8] New permission: essentials.repair.armor If a player has this permission '/repair all' will also repair equipped armor. --- .../src/com/earth2me/essentials/commands/Commandbanip.java | 3 ++- .../src/com/earth2me/essentials/commands/Commandrepair.java | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandbanip.java b/Essentials/src/com/earth2me/essentials/commands/Commandbanip.java index 36ea479f9..eab34b122 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandbanip.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandbanip.java @@ -31,7 +31,8 @@ public class Commandbanip extends EssentialsCommand else { final String ipAddress = u.getLastLoginAddress(); - if (ipAddress.length() == 0) { + if (ipAddress.length() == 0) + { throw new Exception(Util.i18n("playerNotFound")); } ess.getServer().banIP(u.getLastLoginAddress()); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandrepair.java b/Essentials/src/com/earth2me/essentials/commands/Commandrepair.java index d6bcad464..26882ded4 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandrepair.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandrepair.java @@ -50,7 +50,9 @@ public class Commandrepair extends EssentialsCommand final List repaired = new ArrayList(); repairItems(user.getInventory().getContents(), user, repaired); - repairItems(user.getInventory().getArmorContents(), user, repaired); + if (user.isAuthorized("essentials.repair.armor")) { + repairItems(user.getInventory().getArmorContents(), user, repaired); + } if (repaired.isEmpty()) { From c0d046841fe2a1f21f81e43649d7b8a4068864c7 Mon Sep 17 00:00:00 2001 From: KHobbits Date: Wed, 16 Nov 2011 00:21:55 +0000 Subject: [PATCH 3/8] Gamemode sign, standard sign permissions. --- .../essentials/commands/Commandgamemode.java | 1 - .../essentials/signs/SignGameMode.java | 36 +++++++++++++++++++ .../com/earth2me/essentials/signs/Signs.java | 1 + 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 Essentials/src/com/earth2me/essentials/signs/SignGameMode.java diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandgamemode.java b/Essentials/src/com/earth2me/essentials/commands/Commandgamemode.java index 90e9df143..b19aa5d14 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandgamemode.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandgamemode.java @@ -38,7 +38,6 @@ public class Commandgamemode extends EssentialsCommand } } player.setGameMode(player.getGameMode() == GameMode.SURVIVAL ? GameMode.CREATIVE : GameMode.SURVIVAL); - //TODO: add this to messages? sender.sendMessage(Util.format("gameMode", Util.i18n(player.getGameMode().toString().toLowerCase()), player.getDisplayName())); } } diff --git a/Essentials/src/com/earth2me/essentials/signs/SignGameMode.java b/Essentials/src/com/earth2me/essentials/signs/SignGameMode.java new file mode 100644 index 000000000..a3b8cd275 --- /dev/null +++ b/Essentials/src/com/earth2me/essentials/signs/SignGameMode.java @@ -0,0 +1,36 @@ +package com.earth2me.essentials.signs; + +import com.earth2me.essentials.Trade; +import com.earth2me.essentials.ChargeException; +import com.earth2me.essentials.IEssentials; +import com.earth2me.essentials.User; +import com.earth2me.essentials.Util; +import org.bukkit.GameMode; + + +public class SignGameMode extends EssentialsSign +{ + public SignGameMode() + { + super("GameMode"); + } + + @Override + protected boolean onSignCreate(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException + { + validateTrade(sign, 1, ess); + return true; + } + + @Override + protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException, ChargeException + { + final Trade charge = getTrade(sign, 1, ess); + charge.isAffordableFor(player); + + player.setGameMode(player.getGameMode() == GameMode.SURVIVAL ? GameMode.CREATIVE : GameMode.SURVIVAL); + player.sendMessage(Util.format("gameMode", Util.i18n(player.getGameMode().toString().toLowerCase()), player.getDisplayName())); + charge.charge(player); + return true; + } +} diff --git a/Essentials/src/com/earth2me/essentials/signs/Signs.java b/Essentials/src/com/earth2me/essentials/signs/Signs.java index 53ed1d6b0..d7c0d2086 100644 --- a/Essentials/src/com/earth2me/essentials/signs/Signs.java +++ b/Essentials/src/com/earth2me/essentials/signs/Signs.java @@ -7,6 +7,7 @@ public enum Signs BUY(new SignBuy()), DISPOSAL(new SignDisposal()), FREE(new SignFree()), + GAMEMODE(new SignGameMode()), HEAL(new SignHeal()), MAIL(new SignMail()), PROTECTION(new SignProtection()), From 4be1797592cded0d123c9378ca5afb393195f469 Mon Sep 17 00:00:00 2001 From: KHobbits Date: Wed, 16 Nov 2011 03:00:31 +0000 Subject: [PATCH 4/8] Sudo Command This might never make it to release, needs tidying first at least. --- .../essentials/commands/Commandsudo.java | 39 +++++++++++++++++++ Essentials/src/plugin.yml | 4 ++ 2 files changed, 43 insertions(+) create mode 100644 Essentials/src/com/earth2me/essentials/commands/Commandsudo.java diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandsudo.java b/Essentials/src/com/earth2me/essentials/commands/Commandsudo.java new file mode 100644 index 000000000..19b1fd084 --- /dev/null +++ b/Essentials/src/com/earth2me/essentials/commands/Commandsudo.java @@ -0,0 +1,39 @@ +package com.earth2me.essentials.commands; + +import com.earth2me.essentials.User; +import org.bukkit.Server; +import org.bukkit.command.CommandSender; +import org.bukkit.command.PluginCommand; + + +public class Commandsudo extends EssentialsCommand +{ + public Commandsudo() + { + super("sudo"); + } + + @Override + public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception + { + if (args.length < 2) + { + throw new NotEnoughArgumentsException(); + } + + final User user = getPlayer(server, args, 0, true); + final String command = args[1]; + String[] arguments = new String[args.length - 2]; + System.arraycopy(args, 2, arguments, 0, args.length - 2); + + //TODO: Translate this. + sender.sendMessage("Running the command as " + user.getDisplayName()); + + final PluginCommand pc = ess.getServer().getPluginCommand(command); + if (pc != null) + { + pc.execute(user, command, arguments); + } + + } +} diff --git a/Essentials/src/plugin.yml b/Essentials/src/plugin.yml index 3817234d5..dd7bb2ec3 100644 --- a/Essentials/src/plugin.yml +++ b/Essentials/src/plugin.yml @@ -274,6 +274,10 @@ commands: description: Spawns a mob. usage: / [:data][,[:data]] [amount] aliases: [espawnmob] + sudo: + description: Make another user do something. + usage: / + aliases: [esudo] suicide: description: Causes you to perish. usage: / From b9daf6aaa5c2b659599f6ebea0ce6e36c515201c Mon Sep 17 00:00:00 2001 From: snowleo Date: Wed, 16 Nov 2011 04:26:24 +0100 Subject: [PATCH 5/8] Sudo: This would break horrible for offline players and the original player object has to be used. --- .../com/earth2me/essentials/commands/Commandsudo.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandsudo.java b/Essentials/src/com/earth2me/essentials/commands/Commandsudo.java index 19b1fd084..a7976e8a6 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandsudo.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandsudo.java @@ -21,10 +21,12 @@ public class Commandsudo extends EssentialsCommand throw new NotEnoughArgumentsException(); } - final User user = getPlayer(server, args, 0, true); + final User user = getPlayer(server, args, 0, false); final String command = args[1]; - String[] arguments = new String[args.length - 2]; - System.arraycopy(args, 2, arguments, 0, args.length - 2); + final String[] arguments = new String[args.length - 2]; + if (arguments.length > 0) { + System.arraycopy(args, 2, arguments, 0, args.length - 2); + } //TODO: Translate this. sender.sendMessage("Running the command as " + user.getDisplayName()); @@ -32,7 +34,7 @@ public class Commandsudo extends EssentialsCommand final PluginCommand pc = ess.getServer().getPluginCommand(command); if (pc != null) { - pc.execute(user, command, arguments); + pc.execute(user.getBase(), command, arguments); } } From 022f7ab1d45492ce5cebba077cb4ffad8c637e9b Mon Sep 17 00:00:00 2001 From: ElgarL Date: Thu, 17 Nov 2011 05:46:01 +0000 Subject: [PATCH 6/8] Fixed GM holding files open and causing the time stamp to be incorrect. This caused GM to require a '/mansave force' when it shouldn't be needed. --- EssentialsGroupManager/src/Changelog.txt | 3 ++- .../groupmanager/dataholder/WorldDataHolder.java | 12 ++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/EssentialsGroupManager/src/Changelog.txt b/EssentialsGroupManager/src/Changelog.txt index d71bc135a..6a7fd1795 100644 --- a/EssentialsGroupManager/src/Changelog.txt +++ b/EssentialsGroupManager/src/Changelog.txt @@ -70,4 +70,5 @@ v 1.5: If the files on Disc have changed AND there have been changes to it's in-memory data it will show a warning. You then MUST issue a '/mansave force' to overwrite the disc files, or a '/manload' to overwrite the memory data. - Fix for an error in checkFullUserPermission caused by players disconnecting mid perms update. - - Notification of being moved to the default group only happens if it's a demotion/promotion (not on join). \ No newline at end of file + - Notification of being moved to the default group only happens if it's a demotion/promotion (not on join). + - Fixed GM holding files open and causing the time stamp to be incorrect. This caused GM to require a '/mansave force' when it shouldn't be needed. \ No newline at end of file diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java index e8e01967f..7dbeea7b1 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java @@ -338,7 +338,7 @@ public class WorldDataHolder { } this.setDefaultGroup(this.getGroup(ph.getDefaultGroup().getName())); this.removeGroupsChangedFlag(); - this.timeStampGroups = ph.getTimeStampGroups(); + this.timeStampGroups = getGroupsFile().lastModified(); ph = null; } catch (Exception ex) { @@ -368,7 +368,7 @@ public class WorldDataHolder { tempUser.clone(this); } this.removeUsersChangedFlag(); - this.timeStampUsers = ph.getTimeStampUsers(); + this.timeStampUsers = getUsersFile().lastModified(); ph = null; } catch (Exception ex) { @@ -925,6 +925,7 @@ public class WorldDataHolder { out.write(newLine); yaml.dump(root, out); + out.close(); } catch (UnsupportedEncodingException ex) { } catch (FileNotFoundException ex) { } catch (IOException e) { @@ -995,10 +996,13 @@ public class WorldDataHolder { opt.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); final Yaml yaml = new Yaml(opt); try { - yaml.dump(root, new OutputStreamWriter(new FileOutputStream(usersFile), "UTF-8")); + OutputStreamWriter out = new OutputStreamWriter(new FileOutputStream(usersFile), "UTF-8"); + yaml.dump(root, out); + out.close(); } catch (UnsupportedEncodingException ex) { } catch (FileNotFoundException ex) { - } + } catch (IOException e) { + } } // Update the LastModified time. From af5a86c48c83067b05d4489745e4e5335f68c1d2 Mon Sep 17 00:00:00 2001 From: snowleo Date: Thu, 17 Nov 2011 14:23:35 +0100 Subject: [PATCH 7/8] Fix water/lava bucket bug with mobs --- .../essentials/protect/EssentialsProtectPlayerListener.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectPlayerListener.java b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectPlayerListener.java index 7543a5244..e39970d06 100644 --- a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectPlayerListener.java +++ b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectPlayerListener.java @@ -25,10 +25,11 @@ public class EssentialsProtectPlayerListener extends PlayerListener @Override public void onPlayerInteract(final PlayerInteractEvent event) { - if (event.isCancelled()) + // Do not return if cancelled, because the interact event has 2 cancelled states. + /*if (event.isCancelled()) { return; - } + }*/ final User user = ess.getUser(event.getPlayer()); if (event.hasItem() From 7b7d1f557f193599222ca90e74a967b3c7c0fe3c Mon Sep 17 00:00:00 2001 From: ElgarL Date: Thu, 17 Nov 2011 14:28:33 +0000 Subject: [PATCH 8/8] Fixed a crash on reload due to bukkit not unloading plugins before reloading. --- EssentialsGroupManager/src/Changelog.txt | 3 ++- .../src/org/anjocaido/groupmanager/GroupManager.java | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/EssentialsGroupManager/src/Changelog.txt b/EssentialsGroupManager/src/Changelog.txt index 6a7fd1795..e9e21d407 100644 --- a/EssentialsGroupManager/src/Changelog.txt +++ b/EssentialsGroupManager/src/Changelog.txt @@ -71,4 +71,5 @@ v 1.5: You then MUST issue a '/mansave force' to overwrite the disc files, or a '/manload' to overwrite the memory data. - Fix for an error in checkFullUserPermission caused by players disconnecting mid perms update. - Notification of being moved to the default group only happens if it's a demotion/promotion (not on join). - - Fixed GM holding files open and causing the time stamp to be incorrect. This caused GM to require a '/mansave force' when it shouldn't be needed. \ No newline at end of file + - Fixed GM holding files open and causing the time stamp to be incorrect. This caused GM to require a '/mansave force' when it shouldn't be needed. + - Fixed a crash on reload due to bukkit not unloading plugins before reloading. \ No newline at end of file diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java index d2d8d3b27..d8b7a15e1 100644 --- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java +++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java @@ -130,6 +130,9 @@ public class GroupManager extends JavaPlugin { throw new IllegalStateException("An error ocurred while loading GroupManager"); } + // Set a few defaults (reloads) + setLoaded(false); + // Initialize the world listener and bukkit permissions to handle // events. WorldEvents = new GMWorldListener(this);