Skip to content

Commit 9978534

Browse files
Add support for multiple commands in hotbar custom items (#180)
1 parent 318b026 commit 9978534

File tree

4 files changed

+14
-9
lines changed

4 files changed

+14
-9
lines changed

Plugin/src/main/java/dev/lrxh/neptune/feature/hotbar/HotbarService.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,11 @@ public void load() {
110110
byte slot = (byte) config.getInt(path + "SLOT");
111111
List<String> lore = config.getStringList(path + "LORE");
112112
String command = config.getString(path + "COMMAND");
113+
List<String> commands = config.getStringList(path + "COMMANDS");
113114
ProfileState profileState = ProfileState.valueOf(config.getString(path + "STATE"));
114115
int customModelData = config.getInt(path + "CUSTOM_MODEL_DATA", 0);
115-
116-
CustomItem customItem = new CustomItem(displayName, material, lore, slot, command, customModelData);
116+
if (command != null && !command.isEmpty() && !commands.contains(command)) commands.add(command);
117+
CustomItem customItem = new CustomItem(displayName, material, lore, slot, commands, customModelData);
117118
items.get(profileState).addItem(customItem, slot);
118119
}
119120
}

Plugin/src/main/java/dev/lrxh/neptune/feature/hotbar/impl/CustomItem.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66

77
@Getter
88
public class CustomItem extends Item {
9-
private final String command;
9+
private final List<String> commands;
1010

11-
public CustomItem(String displayName, String material, List<String> lore, byte slot, String command, int customModelData) {
11+
public CustomItem(String displayName, String material, List<String> lore, byte slot, List<String> commands, int customModelData) {
1212
super(null, displayName, material, lore, true, slot, customModelData);
13-
this.command = command;
13+
this.commands = commands;
1414
}
1515
}

Plugin/src/main/java/dev/lrxh/neptune/feature/hotbar/listener/ItemListener.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
import org.bukkit.event.player.PlayerSwapHandItemsEvent;
2222
import org.bukkit.inventory.ItemStack;
2323

24+
import java.util.List;
25+
2426
public class ItemListener implements Listener {
2527

2628
@EventHandler
@@ -113,9 +115,11 @@ private void handleAction(Profile profile, ItemStack item) {
113115
return;
114116

115117
if (clickedItem instanceof CustomItem customItem) {
116-
String command = customItem.getCommand();
117-
if (!command.equalsIgnoreCase("none")) {
118-
profile.getPlayer().performCommand(customItem.getCommand());
118+
List<String> commands = customItem.getCommands();
119+
for (String command : commands) {
120+
if (!command.equalsIgnoreCase("none")) {
121+
profile.getPlayer().performCommand(command);
122+
}
119123
}
120124
} else {
121125
clickedItem.getAction().execute(profile.getPlayer());

docs/placeholders.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ May not be up-to-date.
3333
| Plugin | PlaceholderAPI | Description |
3434
|-----------------|---------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------|
3535
| \<kit> | %neptune_kit_name% | The display name of the kit the player is playing on |
36-
| \<kit-division | %neptune_kit_division% | The division |
36+
| \<kit-division> | %neptune_kit_division% | The division |
3737
| \<max-ping> | %neptune_max_ping% | The maximum ping allowed by the player in their settings |
3838
| \<time> | %neptune_time% | The time in minutes and seconds that the player has been queueing for |
3939
| None | %neptune_kit_(name/elo/division/rounds/current_win_streak/best_win_streak/wins/losses/kills/deaths/queued/in_match) | Kit-specific stats |

0 commit comments

Comments
 (0)