summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorementalo <suror@gmx.co.uk>2011-09-19 22:41:39 +0100
committerementalo <suror@gmx.co.uk>2011-09-19 22:41:39 +0100
commitdc2cf220e5aa92ea7309d18633122c7c0a876490 (patch)
treeb0cff28400da40a956b1b54892bc2b2739532b6a
parent5506312b83bddb5bf08bf9f551a8f3dd4e788da6 (diff)
downloadEssentials-dc2cf220e5aa92ea7309d18633122c7c0a876490.tar
Essentials-dc2cf220e5aa92ea7309d18633122c7c0a876490.tar.gz
Essentials-dc2cf220e5aa92ea7309d18633122c7c0a876490.tar.lz
Essentials-dc2cf220e5aa92ea7309d18633122c7c0a876490.tar.xz
Essentials-dc2cf220e5aa92ea7309d18633122c7c0a876490.zip
Added new command /powertooltoggle, enables / disables all powertools assigned (does not remove them) Test #919
-rw-r--r--Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/UserData.java34
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandpowertooltoggle.java29
-rw-r--r--Essentials/src/messages.properties3
-rw-r--r--Essentials/src/messages_da.properties3
-rw-r--r--Essentials/src/messages_de.properties4
-rw-r--r--Essentials/src/messages_en.properties3
-rw-r--r--Essentials/src/messages_fr.properties3
-rw-r--r--Essentials/src/messages_nl.properties3
-rw-r--r--Essentials/src/plugin.yml4
10 files changed, 87 insertions, 1 deletions
diff --git a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java
index 4751c8d85..5c9d1e102 100644
--- a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java
+++ b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java
@@ -430,7 +430,7 @@ public class EssentialsPlayerListener extends PlayerListener
}
final User user = ess.getUser(event.getPlayer());
final ItemStack is = user.getItemInHand();
- if (is == null || is.getType() == Material.AIR)
+ if (is == null || is.getType() == Material.AIR || !user.arePowerToolsEnabled())
{
return;
}
diff --git a/Essentials/src/com/earth2me/essentials/UserData.java b/Essentials/src/com/earth2me/essentials/UserData.java
index 30bb7a2b8..75d126c3e 100644
--- a/Essentials/src/com/earth2me/essentials/UserData.java
+++ b/Essentials/src/com/earth2me/essentials/UserData.java
@@ -57,6 +57,7 @@ public abstract class UserData extends PlayerExtension implements IConf
geolocation = _getGeoLocation();
isSocialSpyEnabled = _isSocialSpyEnabled();
isNPC = _isNPC();
+ arePowerToolsEnabled = _arePowerToolsEnabled();
}
private double money;
@@ -264,6 +265,12 @@ public abstract class UserData extends PlayerExtension implements IConf
config.setProperty("powertools", powertools);
config.save();
}
+
+ public boolean hasPowerTools()
+ {
+ return powertools.size() > 0;
+ }
+
private Location lastLocation;
private Location _getLastLocation()
@@ -772,4 +779,31 @@ public abstract class UserData extends PlayerExtension implements IConf
config.setProperty("npc", set);
config.save();
}
+
+ private boolean arePowerToolsEnabled;
+
+ public boolean arePowerToolsEnabled()
+ {
+ return arePowerToolsEnabled;
+ }
+
+ public void setPowerToolsEnabled(boolean set)
+ {
+ arePowerToolsEnabled = set;
+ config.setProperty("powertoolsenabled", set);
+ config.save();
+ }
+
+ public boolean togglePowerToolsEnabled()
+ {
+ boolean ret = !arePowerToolsEnabled();
+ setPowerToolsEnabled(ret);
+ return ret;
+ }
+
+ private boolean _arePowerToolsEnabled()
+ {
+ return config.getBoolean("powertoolsenabled", true);
+ }
+
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandpowertooltoggle.java b/Essentials/src/com/earth2me/essentials/commands/Commandpowertooltoggle.java
new file mode 100644
index 000000000..af51f2628
--- /dev/null
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandpowertooltoggle.java
@@ -0,0 +1,29 @@
+package com.earth2me.essentials.commands;
+
+import com.earth2me.essentials.User;
+import com.earth2me.essentials.Util;
+import org.bukkit.Server;
+
+
+public class Commandpowertooltoggle extends EssentialsCommand
+{
+ public Commandpowertooltoggle()
+ {
+ super("powertooltoggle");
+ }
+
+ @Override
+ protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
+ {
+ if(!user.hasPowerTools())
+ {
+ user.sendMessage(Util.i18n("noPowerTools"));
+ return;
+ }
+ user.sendMessage(user.togglePowerToolsEnabled()
+ ? Util.i18n("powerToolsEnabled")
+ : Util.i18n("powerToolsDisabled"));
+ }
+
+
+}
diff --git a/Essentials/src/messages.properties b/Essentials/src/messages.properties
index b7e215c10..d90d788eb 100644
--- a/Essentials/src/messages.properties
+++ b/Essentials/src/messages.properties
@@ -204,6 +204,7 @@ noMailSendPerm = \u00a7cYou do not have the \u00a7fessentials.mail.send\u00a7c p
noMotd = \u00a7cThere is no message of the day.
noNewMail = \u00a77You have no new mail.
noPendingRequest = You do not have a pending request.
+noPowerTools = You have no power tools assigned.
noPlacePermission = \u00a7cYou do not have permission to place a block near that sign.
noRules = \u00a7cThere are no rules specified yet.
noWarpsDefined = No warps defined
@@ -250,6 +251,8 @@ powerToolListEmpty = {0} has no commands assigned.
powerToolNoSuchCommandAssigned = Command \u00a7c{0}\u00a7f has not been assigned to {1}.
powerToolRemove = Command \u00a7c{0}\u00a7f removed from {1}.
powerToolRemoveAll = All commands removed from {0}.
+powerToolsEnabled = All of your power tools have been enabled.
+powerToolsDisabled = All of your power tools have been disabled.
protectionOwner = \u00a76[EssentialsProtect] Protection owner: {0}
questionFormat = \u00a77[Question]\u00a7f {0}
reloadAllPlugins = \u00a77Reloaded all plugins.
diff --git a/Essentials/src/messages_da.properties b/Essentials/src/messages_da.properties
index 114b63f7e..826957d28 100644
--- a/Essentials/src/messages_da.properties
+++ b/Essentials/src/messages_da.properties
@@ -366,3 +366,6 @@ year = \u00e5r
years = \u00e5r
youAreHealed = \u00a77Du er blevet helbredt.
youHaveNewMail = \u00a7cDu har {0} beskeder!\u00a7f Type \u00a77/post l\u00e6s\u00a7f for at se din post.
+noPowerTools= You have no power tools assigned.
+powerToolsEnabled= All of your power tools have been enabled.
+powerToolsDisabled= All of your power tools have been disabled.
diff --git a/Essentials/src/messages_de.properties b/Essentials/src/messages_de.properties
index 181c9efcd..2545d8627 100644
--- a/Essentials/src/messages_de.properties
+++ b/Essentials/src/messages_de.properties
@@ -365,3 +365,7 @@ year = Jahr
years = Jahre
youAreHealed = \u00a77Du wurdest geheilt.
youHaveNewMail = \u00a7cDu hast {0} Nachrichten!\u00a7f Schreibe \u00a77/mail read\u00a7f um deine Nachrichten anzuzeigen.
+powerToolClearAll= All powertool commands have been cleared.
+noPowerTools=You have no power tools assigned.
+powerToolsEnabled=All of your power tools have been enabled.
+powerToolsDisabled=All of your power tools have been disabled.
diff --git a/Essentials/src/messages_en.properties b/Essentials/src/messages_en.properties
index 25064cbc7..04d444984 100644
--- a/Essentials/src/messages_en.properties
+++ b/Essentials/src/messages_en.properties
@@ -366,3 +366,6 @@ year = year
years = years
youAreHealed = \u00a77You have been healed.
youHaveNewMail = \u00a7cYou have {0} messages!\u00a7f Type \u00a77/mail read\u00a7f to view your mail.
+noPowerTools=You have no power tools assigned.
+powerToolsEnabled=All of your power tools have been enabled.
+powerToolsDisabled=All of your power tools have been enabled.
diff --git a/Essentials/src/messages_fr.properties b/Essentials/src/messages_fr.properties
index a2793cdd7..a14455935 100644
--- a/Essentials/src/messages_fr.properties
+++ b/Essentials/src/messages_fr.properties
@@ -366,3 +366,6 @@ year = ann\u00e9e
years = ann\u00e9es
youAreHealed = \u00a77Vous avez \u00e9t\u00e9 soign\u00e9.
youHaveNewMail = \u00a7cVous avez {0} messages! \u00a7fEntrez \u00a77/mail read\u00a7f pour voir votre courrier.
+noPowerTools=You have no power tools assigned.
+powerToolsEnabled=All of your power tools have been enabled.
+powerToolsDisabled=All of your power tools have been disabled.
diff --git a/Essentials/src/messages_nl.properties b/Essentials/src/messages_nl.properties
index 4c96d800e..418497cdb 100644
--- a/Essentials/src/messages_nl.properties
+++ b/Essentials/src/messages_nl.properties
@@ -366,3 +366,6 @@ year = jaar
years = jaren
youAreHealed = \u00a77Je bent genezen.
youHaveNewMail = \u00a7cJe hebt {0} berichten!\u00a7f Type \u00a77/mail read\u00a7f om je berichten te bekijken.
+noPowerTools=You have no power tools assigned.
+powerToolsEnabled=All of your power tools have been enabled.
+powerToolsDisabled=All of your power tools have been disabled.
diff --git a/Essentials/src/plugin.yml b/Essentials/src/plugin.yml
index 24049354c..0c5f689a7 100644
--- a/Essentials/src/plugin.yml
+++ b/Essentials/src/plugin.yml
@@ -210,6 +210,10 @@ commands:
description: Assigns a command to the item in hand, {player} will be replaced by the name of the player that you click.
usage: /<command> [l:|a:|r:][command] <arguments>
aliases: [pt,epowertool,ept]
+ powertooltoggle:
+ description: Enables or disables all current powertools
+ usage: /<command>
+ aliases: [ptt,epowertooltoggle,eptt]
ptime:
description: Adjust player's client time. Add @ prefix to fix.
usage: /<command> [list|reset|day|night|dawn|17:30|4pm|4000ticks] <player|*>