diff options
Diffstat (limited to 'Essentials/src/com/earth2me/essentials/commands/Commandgod.java')
-rw-r--r-- | Essentials/src/com/earth2me/essentials/commands/Commandgod.java | 38 |
1 files changed, 14 insertions, 24 deletions
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandgod.java b/Essentials/src/com/earth2me/essentials/commands/Commandgod.java index 17b54d809..1c5352319 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandgod.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandgod.java @@ -2,7 +2,6 @@ package com.earth2me.essentials.commands; import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.User; -import net.ess3.api.events.UserToggleGodmodeEvent; import org.bukkit.Server; import org.bukkit.command.CommandSender; @@ -28,20 +27,20 @@ public class Commandgod extends EssentialsToggleCommand Boolean toggle = matchToggleArgument(args[0]); if (toggle == null && user.isAuthorized(othersPermission)) { - toggleOtherPlayers(server, user, args); + toggleOtherPlayers(server, user.getBase(), args); } else { - togglePlayer(user, user, toggle); + togglePlayer(user.getBase(), user, toggle); } } else if (args.length == 2 && user.isAuthorized(othersPermission)) - { - toggleOtherPlayers(server, user, args); + { + toggleOtherPlayers(server, user.getBase(), args); } else { - togglePlayer(user, user, null); + togglePlayer(user.getBase(), user, null); } } @@ -52,28 +51,19 @@ public class Commandgod extends EssentialsToggleCommand { enabled = !user.isGodModeEnabled(); } + + user.setGodModeEnabled(enabled); - UserToggleGodmodeEvent event = new UserToggleGodmodeEvent(user, enabled); - ess.getServer().getPluginManager().callEvent(event); - if (!event.isCancelled()) + if (enabled && user.getHealth() != 0) { - user.setGodModeEnabled(enabled); - - if (enabled && user.getHealth() != 0) - { - user.setHealth(user.getMaxHealth()); - user.setFoodLevel(20); - } - - user.sendMessage(_("godMode", enabled ? _("enabled") : _("disabled"))); - if (!sender.equals(user)) - { - sender.sendMessage(_("godMode", _(enabled ? "godEnabledFor" : "godDisabledFor", user.getDisplayName()))); - } + user.setHealth(user.getMaxHealth()); + user.setFoodLevel(20); } - else + + user.sendMessage(_("godMode", enabled ? _("enabled") : _("disabled"))); + if (!sender.equals(user.getBase())) { - sender.sendMessage("Could not enable godmode, UserToggleGodmodeEvent was cancelled"); //TODO: a better message + sender.sendMessage(_("godMode", _(enabled ? "godEnabledFor" : "godDisabledFor", user.getDisplayName()))); } } } |