diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandbanip.java b/Essentials/src/com/earth2me/essentials/commands/Commandbanip.java index 591542bcb..eab34b122 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandbanip.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandbanip.java @@ -30,7 +30,12 @@ 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")); } } 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/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()) { 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..a7976e8a6 --- /dev/null +++ b/Essentials/src/com/earth2me/essentials/commands/Commandsudo.java @@ -0,0 +1,41 @@ +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, false); + final String command = args[1]; + 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()); + + final PluginCommand pc = ess.getServer().getPluginCommand(command); + if (pc != null) + { + pc.execute(user.getBase(), command, arguments); + } + + } +} 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()), 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: / diff --git a/EssentialsGroupManager/src/Changelog.txt b/EssentialsGroupManager/src/Changelog.txt index d71bc135a..e9e21d407 100644 --- a/EssentialsGroupManager/src/Changelog.txt +++ b/EssentialsGroupManager/src/Changelog.txt @@ -70,4 +70,6 @@ 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. + - 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); 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. 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()