Skip to content

feat: Add /powertoollist #6096

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: 2.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,10 @@ public boolean hasPowerTools() {
return !holder.powertools().isEmpty();
}

public Map<String, List<String>> getAllPowertools() {
return holder.powertools();
}

public Location getLastLocation() {
final LazyLocation lastLocation = holder.lastLocation();
return lastLocation != null ? lastLocation.location() : null;
Expand Down
Original file line number Diff line number Diff line change
@@ -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<String, List<String>> powertools = user.getAllPowertools();
for (Map.Entry<String, List<String>> entry : powertools.entrySet()) {
final String itemName = entry.getKey().toLowerCase(Locale.ENGLISH).replaceAll("_", " ");
final List<String> commands = entry.getValue();
user.sendTl("powerToolList", StringUtil.joinList(commands), itemName);
}
}
}
2 changes: 2 additions & 0 deletions Essentials/src/main/resources/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -992,6 +992,8 @@ powertoolCommandUsage4=/<command> <cmd>
powertoolCommandUsage4Description=Sets the powertool command of the held item to the given command
powertoolCommandUsage5=/<command> a\:<cmd>
powertoolCommandUsage5Description=Adds the given powertool command to the held item
powertoollistCommandDescription=Lists all current powertools.
powertoollistCommandUsage=/<command>
powertooltoggleCommandDescription=Enables or disables all current powertools.
powertooltoggleCommandUsage=/<command>
ptimeCommandDescription=Adjust player's client time. Add @ prefix to fix.
Expand Down
4 changes: 4 additions & 0 deletions Essentials/src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,10 @@ commands:
description: Assigns a command to the item in hand.
usage: /<command> [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: /<command>
aliases: [epowertoollist,ptlist,eptlist]
powertooltoggle:
description: Enables or disables all current powertools.
usage: /<command>
Expand Down