mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-04-26 00:19:43 +00:00
implement GodStatusChangeEvent
This commit is contained in:
parent
cc34c02623
commit
375caa6f9e
3 changed files with 24 additions and 18 deletions
|
@ -2,8 +2,10 @@ package com.earth2me.essentials.commands;
|
|||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import net.ess3.api.events.GodStatusChangeEvent;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class Commandgod extends EssentialsToggleCommand
|
||||
|
@ -35,7 +37,7 @@ public class Commandgod extends EssentialsToggleCommand
|
|||
}
|
||||
}
|
||||
else if (args.length == 2 && user.isAuthorized(othersPermission))
|
||||
{
|
||||
{
|
||||
toggleOtherPlayers(server, user.getBase(), args);
|
||||
}
|
||||
else
|
||||
|
@ -47,23 +49,29 @@ public class Commandgod extends EssentialsToggleCommand
|
|||
@Override
|
||||
void togglePlayer(CommandSender sender, User user, Boolean enabled)
|
||||
{
|
||||
if (enabled == null)
|
||||
final User controller = sender instanceof Player ? ess.getUser(sender) : null;
|
||||
final GodStatusChangeEvent godEvent = new GodStatusChangeEvent(controller, user, enabled);
|
||||
ess.getServer().getPluginManager().callEvent(godEvent);
|
||||
if (!godEvent.isCancelled())
|
||||
{
|
||||
enabled = !user.isGodModeEnabled();
|
||||
}
|
||||
|
||||
user.setGodModeEnabled(enabled);
|
||||
if (enabled == null)
|
||||
{
|
||||
enabled = !user.isGodModeEnabled();
|
||||
}
|
||||
|
||||
if (enabled && user.getHealth() != 0)
|
||||
{
|
||||
user.setHealth(user.getMaxHealth());
|
||||
user.setFoodLevel(20);
|
||||
}
|
||||
user.setGodModeEnabled(enabled);
|
||||
|
||||
user.sendMessage(_("godMode", enabled ? _("enabled") : _("disabled")));
|
||||
if (!sender.equals(user.getBase()))
|
||||
{
|
||||
sender.sendMessage(_("godMode", _(enabled ? "godEnabledFor" : "godDisabledFor", user.getDisplayName())));
|
||||
if (enabled && user.getHealth() != 0)
|
||||
{
|
||||
user.setHealth(user.getMaxHealth());
|
||||
user.setFoodLevel(20);
|
||||
}
|
||||
|
||||
user.sendMessage(_("godMode", enabled ? _("enabled") : _("disabled")));
|
||||
if (!sender.equals(user.getBase()))
|
||||
{
|
||||
sender.sendMessage(_("godMode", _(enabled ? "godEnabledFor" : "godDisabledFor", user.getDisplayName())));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ import static com.earth2me.essentials.I18n._;
|
|||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.utils.FormatUtil;
|
||||
import java.util.Locale;
|
||||
import net.ess3.api.events.LocalChatSpyEvent;
|
||||
import net.ess3.api.events.NickChangeEvent;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
@ -115,7 +114,7 @@ public class Commandnick extends EssentialsLoopCommand
|
|||
|| lowerNick.equals(onlinePlayer.getName().toLowerCase(Locale.ENGLISH)))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ess.getUser(lowerNick) != null && ess.getUser(lowerNick) != target) {
|
||||
return true;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import java.util.List;
|
||||
import org.bukkit.Server;
|
||||
|
|
Loading…
Reference in a new issue