Added new command /powertooltoggle, enables / disables all powertools assigned (does not remove them) Test #919

This commit is contained in:
ementalo 2011-09-19 22:41:39 +01:00
parent 5831cde90e
commit bd74bd1286
10 changed files with 87 additions and 1 deletions

View file

@ -430,7 +430,7 @@ public class EssentialsPlayerListener extends PlayerListener
} }
final User user = ess.getUser(event.getPlayer()); final User user = ess.getUser(event.getPlayer());
final ItemStack is = user.getItemInHand(); final ItemStack is = user.getItemInHand();
if (is == null || is.getType() == Material.AIR) if (is == null || is.getType() == Material.AIR || !user.arePowerToolsEnabled())
{ {
return; return;
} }

View file

@ -57,6 +57,7 @@ public abstract class UserData extends PlayerExtension implements IConf
geolocation = _getGeoLocation(); geolocation = _getGeoLocation();
isSocialSpyEnabled = _isSocialSpyEnabled(); isSocialSpyEnabled = _isSocialSpyEnabled();
isNPC = _isNPC(); isNPC = _isNPC();
arePowerToolsEnabled = _arePowerToolsEnabled();
} }
private double money; private double money;
@ -264,6 +265,12 @@ public abstract class UserData extends PlayerExtension implements IConf
config.setProperty("powertools", powertools); config.setProperty("powertools", powertools);
config.save(); config.save();
} }
public boolean hasPowerTools()
{
return powertools.size() > 0;
}
private Location lastLocation; private Location lastLocation;
private Location _getLastLocation() private Location _getLastLocation()
@ -772,4 +779,31 @@ public abstract class UserData extends PlayerExtension implements IConf
config.setProperty("npc", set); config.setProperty("npc", set);
config.save(); 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);
}
} }

View file

@ -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"));
}
}

View file

@ -204,6 +204,7 @@ noMailSendPerm = \u00a7cYou do not have the \u00a7fessentials.mail.send\u00a7c p
noMotd = \u00a7cThere is no message of the day. noMotd = \u00a7cThere is no message of the day.
noNewMail = \u00a77You have no new mail. noNewMail = \u00a77You have no new mail.
noPendingRequest = You do not have a pending request. 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. noPlacePermission = \u00a7cYou do not have permission to place a block near that sign.
noRules = \u00a7cThere are no rules specified yet. noRules = \u00a7cThere are no rules specified yet.
noWarpsDefined = No warps defined 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}. powerToolNoSuchCommandAssigned = Command \u00a7c{0}\u00a7f has not been assigned to {1}.
powerToolRemove = Command \u00a7c{0}\u00a7f removed from {1}. powerToolRemove = Command \u00a7c{0}\u00a7f removed from {1}.
powerToolRemoveAll = All commands removed from {0}. 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} protectionOwner = \u00a76[EssentialsProtect] Protection owner: {0}
questionFormat = \u00a77[Question]\u00a7f {0} questionFormat = \u00a77[Question]\u00a7f {0}
reloadAllPlugins = \u00a77Reloaded all plugins. reloadAllPlugins = \u00a77Reloaded all plugins.

View file

@ -366,3 +366,6 @@ year = \u00e5r
years = \u00e5r years = \u00e5r
youAreHealed = \u00a77Du er blevet helbredt. youAreHealed = \u00a77Du er blevet helbredt.
youHaveNewMail = \u00a7cDu har {0} beskeder!\u00a7f Type \u00a77/post l\u00e6s\u00a7f for at se din post. 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.

View file

@ -365,3 +365,7 @@ year = Jahr
years = Jahre years = Jahre
youAreHealed = \u00a77Du wurdest geheilt. youAreHealed = \u00a77Du wurdest geheilt.
youHaveNewMail = \u00a7cDu hast {0} Nachrichten!\u00a7f Schreibe \u00a77/mail read\u00a7f um deine Nachrichten anzuzeigen. 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.

View file

@ -366,3 +366,6 @@ year = year
years = years years = years
youAreHealed = \u00a77You have been healed. youAreHealed = \u00a77You have been healed.
youHaveNewMail = \u00a7cYou have {0} messages!\u00a7f Type \u00a77/mail read\u00a7f to view your mail. 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.

View file

@ -366,3 +366,6 @@ year = ann\u00e9e
years = ann\u00e9es years = ann\u00e9es
youAreHealed = \u00a77Vous avez \u00e9t\u00e9 soign\u00e9. youAreHealed = \u00a77Vous avez \u00e9t\u00e9 soign\u00e9.
youHaveNewMail = \u00a7cVous avez {0} messages! \u00a7fEntrez \u00a77/mail read\u00a7f pour voir votre courrier. 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.

View file

@ -366,3 +366,6 @@ year = jaar
years = jaren years = jaren
youAreHealed = \u00a77Je bent genezen. youAreHealed = \u00a77Je bent genezen.
youHaveNewMail = \u00a7cJe hebt {0} berichten!\u00a7f Type \u00a77/mail read\u00a7f om je berichten te bekijken. 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.

View file

@ -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. 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> usage: /<command> [l:|a:|r:][command] <arguments>
aliases: [pt,epowertool,ept] aliases: [pt,epowertool,ept]
powertooltoggle:
description: Enables or disables all current powertools
usage: /<command>
aliases: [ptt,epowertooltoggle,eptt]
ptime: ptime:
description: Adjust player's client time. Add @ prefix to fix. description: Adjust player's client time. Add @ prefix to fix.
usage: /<command> [list|reset|day|night|dawn|17:30|4pm|4000ticks] <player|*> usage: /<command> [list|reset|day|night|dawn|17:30|4pm|4000ticks] <player|*>