mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-27 02:21:22 +01:00
Allow syntax: /god <player> <on/off>
This commit is contained in:
parent
c958bc78dd
commit
23283426e0
@ -114,7 +114,7 @@ public class EssentialsPlayerListener implements Listener
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (ess.getSettings().removeGodOnDisconnect() && user.isGodModeEnabled())
|
||||
{
|
||||
user.toggleGodModeEnabled();
|
||||
user.setGodModeEnabled(false);
|
||||
}
|
||||
ess.getVanishedPlayers().remove(user.getName());
|
||||
user.setLastLocation();
|
||||
|
@ -561,16 +561,6 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
return afkPosition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean toggleGodModeEnabled()
|
||||
{
|
||||
if (!isGodModeEnabled())
|
||||
{
|
||||
setFoodLevel(20);
|
||||
}
|
||||
return super.toggleGodModeEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGodModeEnabled()
|
||||
{
|
||||
|
@ -494,12 +494,6 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
config.save();
|
||||
}
|
||||
|
||||
public boolean toggleGodModeEnabled()
|
||||
{
|
||||
boolean ret = !isGodModeEnabled();
|
||||
setGodModeEnabled(ret);
|
||||
return ret;
|
||||
}
|
||||
private boolean muted;
|
||||
|
||||
private boolean getMuted()
|
||||
|
@ -2,8 +2,6 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import java.util.Locale;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -51,13 +49,13 @@ public class Commandfly extends EssentialsCommand
|
||||
if (player.isHidden())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (args.length > 1)
|
||||
{
|
||||
if (args[1].contains("on") || args[1].contains("ena") || args[1].equalsIgnoreCase("1"))
|
||||
{
|
||||
player.setAllowFlight(!player.getAllowFlight());
|
||||
player.setAllowFlight(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -68,7 +66,7 @@ public class Commandfly extends EssentialsCommand
|
||||
{
|
||||
player.setAllowFlight(!player.getAllowFlight());
|
||||
}
|
||||
|
||||
|
||||
if (!player.getAllowFlight())
|
||||
{
|
||||
player.setFlying(false);
|
||||
|
@ -22,7 +22,7 @@ public class Commandgod extends EssentialsCommand
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
godOtherPlayers(server, sender, args[0]);
|
||||
godOtherPlayers(server, sender, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -30,23 +30,45 @@ public class Commandgod extends EssentialsCommand
|
||||
{
|
||||
if (args.length > 0 && args[0].trim().length() > 2 && user.isAuthorized("essentials.god.others"))
|
||||
{
|
||||
godOtherPlayers(server, user, args[0]);
|
||||
godOtherPlayers(server, user, args);
|
||||
return;
|
||||
}
|
||||
|
||||
user.sendMessage(_("godMode", (user.toggleGodModeEnabled() ? _("enabled") : _("disabled"))));
|
||||
user.setGodModeEnabled(!user.isGodModeEnabled());
|
||||
user.sendMessage(_("godMode", (user.isGodModeEnabled() ? _("enabled") : _("disabled"))));
|
||||
}
|
||||
|
||||
private void godOtherPlayers(final Server server, final CommandSender sender, final String name)
|
||||
private void godOtherPlayers(final Server server, final CommandSender sender, final String[] args)
|
||||
{
|
||||
for (Player matchPlayer : server.matchPlayer(name))
|
||||
for (Player matchPlayer : server.matchPlayer(args[0]))
|
||||
{
|
||||
final User player = ess.getUser(matchPlayer);
|
||||
if (player.isHidden())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
final boolean enabled = player.toggleGodModeEnabled();
|
||||
|
||||
if (args.length > 1)
|
||||
{
|
||||
if (args[1].contains("on") || args[1].contains("ena") || args[1].equalsIgnoreCase("1"))
|
||||
{
|
||||
player.setGodModeEnabled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.setGodModeEnabled(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
player.setGodModeEnabled(!player.isGodModeEnabled());
|
||||
}
|
||||
|
||||
final boolean enabled = player.isGodModeEnabled();
|
||||
if (enabled)
|
||||
{
|
||||
player.setFoodLevel(20);
|
||||
}
|
||||
|
||||
player.sendMessage(_("godMode", (enabled ? _("enabled") : _("disabled"))));
|
||||
sender.sendMessage(_("godMode", _(enabled ? "godEnabledFor" : "godDisabledFor", matchPlayer.getDisplayName())));
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ commands:
|
||||
aliases: [efeed,eat,eeat]
|
||||
fly:
|
||||
description: Take off, and soar!
|
||||
usage: /<command> [player]
|
||||
usage: /<command> [player] [on|off]
|
||||
aliases: [efly]
|
||||
itemdb:
|
||||
description: Searches for an item.
|
||||
@ -133,7 +133,7 @@ commands:
|
||||
aliases: [egive]
|
||||
god:
|
||||
description: Enables your godly powers.
|
||||
usage: /<command> [player]
|
||||
usage: /<command> [player] [on|off]
|
||||
aliases: [tgm,godmode,egod,etgm,egodmode]
|
||||
hat:
|
||||
description: Get some cool new headgear
|
||||
|
Loading…
Reference in New Issue
Block a user