diff options
author | ementalo <ementalodev@gmx.co.uk> | 2012-08-02 13:48:13 +0100 |
---|---|---|
committer | ementalo <ementalodev@gmx.co.uk> | 2012-08-02 13:52:11 +0100 |
commit | 766f9b4dbdcb36169bc83f0d5b1c50f0f0077662 (patch) | |
tree | 5028076eba6ebeb19087cc3a1329aa8825ff0eeb | |
parent | a1ac58d17c72b0ba7547c816c3d818d114c5c856 (diff) | |
download | Essentials-766f9b4dbdcb36169bc83f0d5b1c50f0f0077662.tar Essentials-766f9b4dbdcb36169bc83f0d5b1c50f0f0077662.tar.gz Essentials-766f9b4dbdcb36169bc83f0d5b1c50f0f0077662.tar.lz Essentials-766f9b4dbdcb36169bc83f0d5b1c50f0f0077662.tar.xz Essentials-766f9b4dbdcb36169bc83f0d5b1c50f0f0077662.zip |
CB #2267 Bukkit #1505
Updates to gamemode command, mode is now mandatory [creative|survival|adventure]
Updates to gamemode sign, now requires another line with gamemode
-rw-r--r-- | Essentials/src/com/earth2me/essentials/Essentials.java | 2 | ||||
-rw-r--r-- | Essentials/src/com/earth2me/essentials/OfflinePlayer.java | 18 | ||||
-rw-r--r-- | Essentials/src/com/earth2me/essentials/commands/Commandgamemode.java | 46 | ||||
-rw-r--r-- | Essentials/src/com/earth2me/essentials/craftbukkit/FakeWorld.java | 6 | ||||
-rw-r--r-- | Essentials/src/com/earth2me/essentials/signs/SignGameMode.java | 27 | ||||
-rw-r--r-- | Essentials/src/plugin.yml | 2 | ||||
-rw-r--r-- | Essentials/test/com/earth2me/essentials/FakeServer.java | 12 | ||||
-rw-r--r-- | lib/bukkit.jar | bin | 4716391 -> 4727963 bytes | |||
-rw-r--r-- | lib/craftbukkit.jar | bin | 11592470 -> 11672027 bytes |
9 files changed, 89 insertions, 24 deletions
diff --git a/Essentials/src/com/earth2me/essentials/Essentials.java b/Essentials/src/com/earth2me/essentials/Essentials.java index 8790e7022..3b2549307 100644 --- a/Essentials/src/com/earth2me/essentials/Essentials.java +++ b/Essentials/src/com/earth2me/essentials/Essentials.java @@ -67,7 +67,7 @@ import org.yaml.snakeyaml.error.YAMLException; public class Essentials extends JavaPlugin implements IEssentials { - public static final int BUKKIT_VERSION = 2149; + public static final int BUKKIT_VERSION = 2267; private static final Logger LOGGER = Logger.getLogger("Minecraft"); private transient ISettings settings; private final transient TNTExplodeListener tntListener = new TNTExplodeListener(this); diff --git a/Essentials/src/com/earth2me/essentials/OfflinePlayer.java b/Essentials/src/com/earth2me/essentials/OfflinePlayer.java index c6230f5e0..e7241f0f8 100644 --- a/Essentials/src/com/earth2me/essentials/OfflinePlayer.java +++ b/Essentials/src/com/earth2me/essentials/OfflinePlayer.java @@ -1051,4 +1051,22 @@ public class OfflinePlayer implements Player { throw new UnsupportedOperationException("Not supported yet."); } + + @Override + public int getExpToLevel() + { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean hasLineOfSight(Entity entity) + { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public boolean isValid() + { + throw new UnsupportedOperationException("Not supported yet."); + } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandgamemode.java b/Essentials/src/com/earth2me/essentials/commands/Commandgamemode.java index 5fdc69d68..a4ee58178 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandgamemode.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandgamemode.java @@ -19,24 +19,27 @@ public class Commandgamemode extends EssentialsCommand @Override protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception { - if (args.length < 1) + if (args.length < 2) { throw new NotEnoughArgumentsException(); } - gamemodeOtherPlayers(server, sender, args); } @Override protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception { - if (args.length > 0 && args[0].trim().length() > 2 && user.isAuthorized("essentials.gamemode.others")) + if(args.length < 1) + { + throw new NotEnoughArgumentsException(); + } + + if (args.length > 1 && args[0].trim().length() > 2 && user.isAuthorized("essentials.gamemode.others")) { gamemodeOtherPlayers(server, user, args); return; - } - - user.setGameMode(user.getGameMode() == GameMode.SURVIVAL ? GameMode.CREATIVE : GameMode.SURVIVAL); + } + performSetMode(args[0], user); user.sendMessage(_("gameMode", _(user.getGameMode().toString().toLowerCase(Locale.ENGLISH)), user.getDisplayName())); } @@ -48,24 +51,25 @@ public class Commandgamemode extends EssentialsCommand if (player.isHidden()) { continue; + } + performSetMode(args[1], player); + sender.sendMessage(_("gameMode", _(player.getGameMode().toString().toLowerCase(Locale.ENGLISH)), player.getDisplayName())); + } + } + + private void performSetMode(String mode, Player player) + { + if (mode.contains("survi") || mode.equalsIgnoreCase("0")) + { + player.setGameMode(GameMode.SURVIVAL); } - - if (args.length > 1) + else if (mode.contains("creat") || mode.equalsIgnoreCase("1")) { - if (args[1].contains("creat") || args[1].equalsIgnoreCase("1")) - { - player.setGameMode(GameMode.CREATIVE); - } - else - { - player.setGameMode(GameMode.SURVIVAL); - } + player.setGameMode(GameMode.CREATIVE); } - else + else if (mode.contains("advent") || mode.equalsIgnoreCase("2")) { - player.setGameMode(player.getGameMode() == GameMode.SURVIVAL ? GameMode.CREATIVE : GameMode.SURVIVAL); + player.setGameMode(GameMode.ADVENTURE); } - sender.sendMessage(_("gameMode", _(player.getGameMode().toString().toLowerCase(Locale.ENGLISH)), player.getDisplayName())); - } } -} +}
\ No newline at end of file diff --git a/Essentials/src/com/earth2me/essentials/craftbukkit/FakeWorld.java b/Essentials/src/com/earth2me/essentials/craftbukkit/FakeWorld.java index ce617fcd5..93a33fcea 100644 --- a/Essentials/src/com/earth2me/essentials/craftbukkit/FakeWorld.java +++ b/Essentials/src/com/earth2me/essentials/craftbukkit/FakeWorld.java @@ -669,4 +669,10 @@ public class FakeWorld implements World { throw new UnsupportedOperationException("Not supported yet."); } + + @Override + public Entity spawnEntity(Location lctn, EntityType et) + { + throw new UnsupportedOperationException("Not supported yet."); + } } diff --git a/Essentials/src/com/earth2me/essentials/signs/SignGameMode.java b/Essentials/src/com/earth2me/essentials/signs/SignGameMode.java index 37a9fb1b8..636faf469 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignGameMode.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignGameMode.java @@ -7,6 +7,7 @@ import com.earth2me.essentials.Trade; import com.earth2me.essentials.User; import java.util.Locale; import org.bukkit.GameMode; +import org.bukkit.entity.Player; public class SignGameMode extends EssentialsSign @@ -27,11 +28,35 @@ public class SignGameMode extends EssentialsSign 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); + final String mode = sign.getLine(2).trim(); + + if(mode.isEmpty()) + { + throw new SignException(_("invalidSignLine", 3)); + } + charge.isAffordableFor(player); - player.setGameMode(player.getGameMode() == GameMode.SURVIVAL ? GameMode.CREATIVE : GameMode.SURVIVAL); + performSetMode(mode, player); player.sendMessage(_("gameMode", _(player.getGameMode().toString().toLowerCase(Locale.ENGLISH)), player.getDisplayName())); charge.charge(player); return true; } + + private void performSetMode(String mode, Player player) + { + if (mode.contains("survi") || mode.equalsIgnoreCase("0")) + { + player.setGameMode(GameMode.SURVIVAL); + } + else if (mode.contains("creat") || mode.equalsIgnoreCase("1")) + { + player.setGameMode(GameMode.CREATIVE); + } + else if (mode.contains("advent") || mode.equalsIgnoreCase("2")) + { + player.setGameMode(GameMode.ADVENTURE); + } + } + } diff --git a/Essentials/src/plugin.yml b/Essentials/src/plugin.yml index 1d0a64d6a..b44bc7802 100644 --- a/Essentials/src/plugin.yml +++ b/Essentials/src/plugin.yml @@ -117,7 +117,7 @@ commands: aliases: [efireball] gamemode: description: Change player gamemode. - usage: /<command> [player] + usage: /<command> [player] <creative|survival|adventure> aliases: [gm,creative,creativemode,egamemode,ecreative,ecreativemode,egm] getpos: description: Get your current coordinates or those of a player. diff --git a/Essentials/test/com/earth2me/essentials/FakeServer.java b/Essentials/test/com/earth2me/essentials/FakeServer.java index 53763b8ca..796599e09 100644 --- a/Essentials/test/com/earth2me/essentials/FakeServer.java +++ b/Essentials/test/com/earth2me/essentials/FakeServer.java @@ -741,4 +741,16 @@ public class FakeServer implements Server { throw new UnsupportedOperationException("Not supported yet."); } + + @Override + public boolean isPrimaryThread() + { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String getMotd() + { + throw new UnsupportedOperationException("Not supported yet."); + } } diff --git a/lib/bukkit.jar b/lib/bukkit.jar Binary files differindex cc304c6dd..c3f110e8f 100644 --- a/lib/bukkit.jar +++ b/lib/bukkit.jar diff --git a/lib/craftbukkit.jar b/lib/craftbukkit.jar Binary files differindex 39c783fa3..672f55080 100644 --- a/lib/craftbukkit.jar +++ b/lib/craftbukkit.jar |