use of me.RockinChaos.itemjoin.item.ItemCommand in project ItemJoin by RockinChaos.
the class APIUtils method getCommands.
/**
* Fetches commands that are defined for the custom item.
*
* @param itemNode - that is the custom items config node.
* @return List of commands for the custom item.
*/
public List<String> getCommands(String itemNode) {
ItemMap itemMap = this.getMap(null, null, itemNode);
List<String> commands = new ArrayList<String>();
if (itemMap != null && itemMap.getCommands() != null && itemMap.getCommands().length > 0) {
for (ItemCommand command : itemMap.getCommands()) {
commands.add(command.getRawCommand());
}
return commands;
}
return null;
}
use of me.RockinChaos.itemjoin.item.ItemCommand in project ItemJoin by RockinChaos.
the class Menu method orderPane.
/**
* Opens the Pane for the Player.
* This Pane is for modifying an items list of commands.
*
* @param player - The Player to have the Pane opened.
* @param itemMap - The ItemMap currently being modified.
* @param action - The action to be matched.
* @param command - The ItemCommand instance being modified.
* @param orderNumber - The current number that dictates the ItemCommands "place in line".
*/
private static void orderPane(final Player player, final ItemMap itemMap, final Action action, final ItemCommand command, final int orderNumber) {
Interface orderPane = new Interface(true, 2, GUIName, player);
SchedulerUtils.runAsync(() -> {
orderPane.setReturnButton(new Button(ItemHandler.getItem("BARRIER", 1, false, "&c&l&nReturn", "&7", "&7*Returns you to the command modify menu."), event -> {
modifyCommandsPane(player, itemMap, action, command, orderNumber);
}));
for (int i = 1; i <= getCommandSize(itemMap, action); i++) {
final int k = i;
orderPane.addButton(new Button(ItemHandler.getItem((ServerUtils.hasSpecificUpdate("1_13") ? "LIGHT_BLUE_STAINED_GLASS_PANE" : "STAINED_GLASS_PANE:3"), k, false, "&9&lOrder Number: &a&l" + k, "&7", "&7*Click to set the order", "&7number of the command."), event -> {
List<ItemCommand> arrayCommands = new ArrayList<ItemCommand>();
int l = 0;
for (ItemCommand Command : itemMap.getCommands()) {
if (Command.matchAction(action)) {
if ((l + 1) == k) {
arrayCommands.add(command);
}
l++;
}
if (!Command.equals(command)) {
arrayCommands.add(Command);
}
}
final ItemCommand[] commands = new ItemCommand[arrayCommands.size()];
for (int j = 0; j < arrayCommands.size(); ++j) {
commands[j] = arrayCommands.get(j);
}
itemMap.setCommands(commands);
commandListPane(player, itemMap, action);
}));
}
});
orderPane.open(player);
}
use of me.RockinChaos.itemjoin.item.ItemCommand in project ItemJoin by RockinChaos.
the class Menu method commandListPane.
/**
* Opens the Pane for the Player.
* This Pane is for modifying an items list of commands.
*
* @param player - The Player to have the Pane opened.
* @param itemMap - The ItemMap currently being modified.
* @param action - The action to be matched.
*/
private static void commandListPane(final Player player, final ItemMap itemMap, final Action action) {
Interface commandListPane = new Interface(true, 2, GUIName, player);
SchedulerUtils.runAsync(() -> {
commandListPane.setReturnButton(new Button(ItemHandler.getItem("BARRIER", 1, false, "&c&l&nReturn", "&7", "&7*Returns you to the click type menu."), event -> {
actionPane(player, itemMap);
}));
commandListPane.addButton(new Button(ItemHandler.getItem("FEATHER", 1, true, "&e&lNew Line", "&7", "&7*Add a new command to be executed", "&7by &9&l" + action.name()), event -> {
executorPane(player, itemMap, action);
}));
ItemCommand[] commandList = itemMap.getCommands();
int l = 1;
for (ItemCommand command : commandList) {
if (command.matchAction(action)) {
final int k = l;
commandListPane.addButton(new Button(ItemHandler.getItem("FEATHER", 1, false, "&f" + command.getRawCommand(), "&7", "&7*Click to &lmodify &7this command.", "&9&lOrder Number: &a" + k), event -> {
modifyCommandsPane(player, itemMap, action, command, k);
}));
l++;
}
}
});
commandListPane.open(player);
}
Aggregations