diff --git a/Essentials/src/main/java/com/earth2me/essentials/UserData.java b/Essentials/src/main/java/com/earth2me/essentials/UserData.java index c5e8fc67ff9..e37c0146e22 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/UserData.java +++ b/Essentials/src/main/java/com/earth2me/essentials/UserData.java @@ -271,6 +271,10 @@ public boolean hasPowerTools() { return !holder.powertools().isEmpty(); } + public Map> getAllPowertools() { + return holder.powertools(); + } + public Location getLastLocation() { final LazyLocation lastLocation = holder.lastLocation(); return lastLocation != null ? lastLocation.location() : null; diff --git a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandpowertoollist.java b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandpowertoollist.java new file mode 100644 index 00000000000..ab35ac910af --- /dev/null +++ b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandpowertoollist.java @@ -0,0 +1,29 @@ +package com.earth2me.essentials.commands; + +import com.earth2me.essentials.User; +import com.earth2me.essentials.utils.StringUtil; +import org.bukkit.Server; + +import java.util.List; +import java.util.Locale; +import java.util.Map; + +public class Commandpowertoollist extends EssentialsCommand { + public Commandpowertoollist() { + super("powertoollist"); + } + + @Override + protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception { + if (!user.hasPowerTools()) { + user.sendTl("noPowerTools"); + return; + } + final Map> powertools = user.getAllPowertools(); + for (Map.Entry> entry : powertools.entrySet()) { + final String itemName = entry.getKey().toLowerCase(Locale.ENGLISH).replaceAll("_", " "); + final List commands = entry.getValue(); + user.sendTl("powerToolList", StringUtil.joinList(commands), itemName); + } + } +} diff --git a/Essentials/src/main/resources/messages.properties b/Essentials/src/main/resources/messages.properties index 25891860263..d4db18a6ac8 100644 --- a/Essentials/src/main/resources/messages.properties +++ b/Essentials/src/main/resources/messages.properties @@ -992,6 +992,8 @@ powertoolCommandUsage4=/ powertoolCommandUsage4Description=Sets the powertool command of the held item to the given command powertoolCommandUsage5=/ a\: powertoolCommandUsage5Description=Adds the given powertool command to the held item +powertoollistCommandDescription=Lists all current powertools. +powertoollistCommandUsage=/ powertooltoggleCommandDescription=Enables or disables all current powertools. powertooltoggleCommandUsage=/ ptimeCommandDescription=Adjust player's client time. Add @ prefix to fix. diff --git a/Essentials/src/main/resources/plugin.yml b/Essentials/src/main/resources/plugin.yml index 8efb209ad23..68de6b0cb50 100644 --- a/Essentials/src/main/resources/plugin.yml +++ b/Essentials/src/main/resources/plugin.yml @@ -360,6 +360,10 @@ commands: description: Assigns a command to the item in hand. usage: / [l:|a:|r:|c:|d:][command] [arguments] - {player} can be replaced by name of a clicked player. aliases: [epowertool,pt,ept] + powertoollist: + description: Lists all current powertools. + usage: / + aliases: [epowertoollist,ptlist,eptlist] powertooltoggle: description: Enables or disables all current powertools. usage: /