summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKHobbits <rob@khobbits.co.uk>2012-06-10 19:20:24 +0100
committerKHobbits <rob@khobbits.co.uk>2012-06-10 19:20:43 +0100
commitf75f69ca4272ee31ebd3f271a53aef0fb4bc847e (patch)
tree1da6f401f0c481e77a6c31dcf61994f272be8b21
parentf3eaa5bf12b7733c6de6c8605a2854f677af6184 (diff)
downloadEssentials-f75f69ca4272ee31ebd3f271a53aef0fb4bc847e.tar
Essentials-f75f69ca4272ee31ebd3f271a53aef0fb4bc847e.tar.gz
Essentials-f75f69ca4272ee31ebd3f271a53aef0fb4bc847e.tar.lz
Essentials-f75f69ca4272ee31ebd3f271a53aef0fb4bc847e.tar.xz
Essentials-f75f69ca4272ee31ebd3f271a53aef0fb4bc847e.zip
Allow syntax: /god <player> <on/off>
-rw-r--r--Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/User.java10
-rw-r--r--Essentials/src/com/earth2me/essentials/UserData.java6
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandfly.java10
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandgod.java36
-rw-r--r--Essentials/src/plugin.yml4
6 files changed, 36 insertions, 32 deletions
diff --git a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java
index 8eee65182..1f59648e9 100644
--- a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java
+++ b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java
@@ -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();
diff --git a/Essentials/src/com/earth2me/essentials/User.java b/Essentials/src/com/earth2me/essentials/User.java
index f9206206a..22b772f78 100644
--- a/Essentials/src/com/earth2me/essentials/User.java
+++ b/Essentials/src/com/earth2me/essentials/User.java
@@ -562,16 +562,6 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
}
@Override
- public boolean toggleGodModeEnabled()
- {
- if (!isGodModeEnabled())
- {
- setFoodLevel(20);
- }
- return super.toggleGodModeEnabled();
- }
-
- @Override
public boolean isGodModeEnabled()
{
return (super.isGodModeEnabled() && !ess.getSettings().getNoGodWorlds().contains(getLocation().getWorld().getName()))
diff --git a/Essentials/src/com/earth2me/essentials/UserData.java b/Essentials/src/com/earth2me/essentials/UserData.java
index c994eeed5..e0f638fb0 100644
--- a/Essentials/src/com/earth2me/essentials/UserData.java
+++ b/Essentials/src/com/earth2me/essentials/UserData.java
@@ -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()
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandfly.java b/Essentials/src/com/earth2me/essentials/commands/Commandfly.java
index deb2da781..86347d3e9 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandfly.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandfly.java
@@ -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);
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandgod.java b/Essentials/src/com/earth2me/essentials/commands/Commandgod.java
index 6e611d869..5ca2aad9a 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandgod.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandgod.java
@@ -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())));
}
diff --git a/Essentials/src/plugin.yml b/Essentials/src/plugin.yml
index 55fb38de0..45f5c5f5f 100644
--- a/Essentials/src/plugin.yml
+++ b/Essentials/src/plugin.yml
@@ -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