summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandgod.java27
1 files changed, 16 insertions, 11 deletions
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandgod.java b/Essentials/src/com/earth2me/essentials/commands/Commandgod.java
index 2e27fa192..571003c73 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandgod.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandgod.java
@@ -33,10 +33,20 @@ public class Commandgod extends EssentialsCommand
godOtherPlayers(server, user, args);
return;
}
- user.setGodModeEnabled(!user.isGodModeEnabled());
+ godPlayer(user, !user.isGodModeEnabled());
user.sendMessage(_("godMode", (user.isGodModeEnabled() ? _("enabled") : _("disabled"))));
}
+ private void godPlayer(User player, boolean enabled)
+ {
+ player.setGodModeEnabled(enabled);
+ if (enabled)
+ {
+ player.setHealth(player.getMaxHealth());
+ player.setFoodLevel(20);
+ }
+ }
+
private void godOtherPlayers(final Server server, final CommandSender sender, final String[] args)
{
for (Player matchPlayer : server.matchPlayer(args[0]))
@@ -47,29 +57,24 @@ public class Commandgod extends EssentialsCommand
continue;
}
+ boolean enabled;
if (args.length > 1)
{
if (args[1].contains("on") || args[1].contains("ena") || args[1].equalsIgnoreCase("1"))
{
- player.setGodModeEnabled(true);
+ enabled = true;
}
else
{
- player.setGodModeEnabled(false);
+ enabled = false;
}
}
else
{
- player.setGodModeEnabled(!player.isGodModeEnabled());
- }
-
- final boolean enabled = player.isGodModeEnabled();
- if (enabled)
- {
- player.setHealth(player.getMaxHealth());
- player.setFoodLevel(20);
+ enabled = !player.isGodModeEnabled();
}
+ godPlayer(player, enabled);
player.sendMessage(_("godMode", (enabled ? _("enabled") : _("disabled"))));
sender.sendMessage(_("godMode", _(enabled ? "godEnabledFor" : "godDisabledFor", matchPlayer.getDisplayName())));
}