Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
Ursprung
91c64fa26b
Commit
8173703855
@ -11,7 +11,6 @@ import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
@ -27,8 +26,6 @@ public class ScriptCommand extends SWCommand {
|
||||
@LinkedInstance
|
||||
private CustomScriptManager customScriptManager = null;
|
||||
|
||||
private static List<SWListInv.SWListEntry<SpecialCommand>> swItems = new ArrayList<>();
|
||||
|
||||
private List<String> loreBuilder(Player p, String prefix, int start, int end) {
|
||||
List<String> lore = new ArrayList<>();
|
||||
for (int i = start; i <= end; i++) {
|
||||
@ -48,103 +45,43 @@ public class ScriptCommand extends SWCommand {
|
||||
|
||||
@Register(description = "SCRIPT_COMMAND_HELP")
|
||||
public void menuCommand(Player p) {
|
||||
if (swItems.isEmpty()) {
|
||||
addEmptyItems(3);
|
||||
swItems.add(new SWListInv.SWListEntry<>(new SWItem(Material.BOOK, BauSystem.MESSAGE.parse("SCRIPT_GUI_CUSTOM_COMMANDS", p), loreBuilder(p, "SCRIPT_GUI_CUSTOM_COMMANDS_LORE_", 1, 13), false, clickType -> {
|
||||
}), null));
|
||||
swItems.add(new SWListInv.SWListEntry<>(new SWItem(Material.BOOK, BauSystem.MESSAGE.parse("SCRIPT_GUI_CUSTOM_EVENTS", p), loreBuilder(p, "SCRIPT_GUI_CUSTOM_EVENTS_LORE_", 1, 20, loreBuilder(p, "SCRIPT_GUI_CUSTOM_EVENTS_LORE_STAR_", 1, 2)), false, clickType -> {
|
||||
}), null));
|
||||
swItems.add(new SWListInv.SWListEntry<>(new SWItem(Material.BOOK, BauSystem.MESSAGE.parse("SCRIPT_GUI_OTHER", p), loreBuilder(p, "SCRIPT_GUI_OTHER_LORE_", 1, 9), false, clickType -> {
|
||||
}), null));
|
||||
addEmptyItems(3);
|
||||
List<SpecialCommand> specialCommands = new ArrayList<>(SPECIAL_COMMANDS);
|
||||
specialCommands.sort(Comparator.comparing(specialCommand -> specialCommand.getClass().getTypeName()));
|
||||
specialCommands.forEach(specialCommand -> {
|
||||
List<String> strings = new ArrayList<>();
|
||||
boolean b = false;
|
||||
for (String s : specialCommand.description()) {
|
||||
if (s.isEmpty()) {
|
||||
b = true;
|
||||
strings.add("");
|
||||
continue;
|
||||
}
|
||||
s = BauSystem.MESSAGE.parse(s, p);
|
||||
while (b && s.length() > 50) {
|
||||
int index = s.indexOf(' ', 50);
|
||||
if (index == -1) {
|
||||
strings.add("§7" + s);
|
||||
s = null;
|
||||
break;
|
||||
} else {
|
||||
strings.add("§7" + s.substring(0, index));
|
||||
s = s.substring(index + 1);
|
||||
}
|
||||
}
|
||||
if (s != null) {
|
||||
strings.add("§7" + s);
|
||||
}
|
||||
}
|
||||
|
||||
SWItem swItem = new SWItem(specialCommand.material(), BauSystem.MESSAGE.parse("SCRIPT_GUI_COMMAND_NAME", p, specialCommand.command()), strings, false, clickType -> {
|
||||
});
|
||||
swItems.add(new SWListInv.SWListEntry<>(swItem, specialCommand));
|
||||
});
|
||||
addEmptyItems(3 + 45);
|
||||
swItems.add(new SWListInv.SWListEntry<>(new SWItem(Material.BOOK, BauSystem.MESSAGE.parse("SCRIPT_GUI_CUSTOM_VARIABLES", p), new ArrayList<>(), false, clickType -> {
|
||||
}), null));
|
||||
addEmptyItems(4);
|
||||
swItems.add(new SWListInv.SWListEntry<>(new SWItem(Material.TNT_MINECART, BauSystem.MESSAGE.parse("SCRIPT_GUI_CONSTANT_TRACE_NAME", p), Arrays.asList(BauSystem.MESSAGE.parse("SCRIPT_GUI_CONSTANT_TRACE_LORE", p)), false, clickType -> {
|
||||
}), null));
|
||||
swItems.add(new SWListInv.SWListEntry<>(new SWItem(Material.TNT_MINECART, BauSystem.MESSAGE.parse("SCRIPT_GUI_CONSTANT_AUTO_TRACE_NAME", p), Arrays.asList(BauSystem.MESSAGE.parse("SCRIPT_GUI_CONSTANT_AUTO_TRACE_LORE", p)), false, clickType -> {
|
||||
}), null));
|
||||
swItems.add(new SWListInv.SWListEntry<>(new SWItem(Material.TNT, BauSystem.MESSAGE.parse("SCRIPT_GUI_CONSTANT_TNT_NAME", p), Arrays.asList(BauSystem.MESSAGE.parse("SCRIPT_GUI_CONSTANT_TNT_LORE", p)), false, clickType -> {
|
||||
}), null));
|
||||
swItems.add(new SWListInv.SWListEntry<>(new SWItem(Material.TNT, BauSystem.MESSAGE.parse("SCRIPT_GUI_CONSTANT_ONLY_TB_NAME", p), Arrays.asList(BauSystem.MESSAGE.parse("SCRIPT_GUI_CONSTANT_ONLY_TB_LORE", p)), false, clickType -> {
|
||||
}), null));
|
||||
swItems.add(new SWListInv.SWListEntry<>(new SWItem(Material.GUNPOWDER, BauSystem.MESSAGE.parse("SCRIPT_GUI_CONSTANT_FREEZE_NAME", p), Arrays.asList(BauSystem.MESSAGE.parse("SCRIPT_GUI_CONSTANT_FREEZE_LORE", p)), false, clickType -> {
|
||||
}), null));
|
||||
swItems.add(new SWListInv.SWListEntry<>(new SWItem(Material.FIRE_CHARGE, BauSystem.MESSAGE.parse("SCRIPT_GUI_CONSTANT_FIRE_NAME", p), Arrays.asList(BauSystem.MESSAGE.parse("SCRIPT_GUI_CONSTANT_FIRE_LORE", p)), false, clickType -> {
|
||||
}), null));
|
||||
swItems.add(new SWListInv.SWListEntry<>(new SWItem(Material.OBSIDIAN, BauSystem.MESSAGE.parse("SCRIPT_GUI_CONSTANT_PROTECT_NAME", p), Arrays.asList(BauSystem.MESSAGE.parse("SCRIPT_GUI_CONSTANT_PROTECT_LORE", p)), false, clickType -> {
|
||||
}), null));
|
||||
swItems.add(new SWListInv.SWListEntry<>(new SWItem(Material.IRON_SWORD, BauSystem.MESSAGE.parse("SCRIPT_GUI_CONSTANT_DAMAGE_NAME", p), Arrays.asList(BauSystem.MESSAGE.parse("SCRIPT_GUI_CONSTANT_DAMAGE_LORE", p)), false, clickType -> {
|
||||
}), null));
|
||||
swItems.add(new SWListInv.SWListEntry<>(new SWItem(Material.PLAYER_HEAD, BauSystem.MESSAGE.parse("SCRIPT_GUI_CONSTANT_X_NAME", p), Arrays.asList(BauSystem.MESSAGE.parse("SCRIPT_GUI_CONSTANT_X_LORE", p), BauSystem.MESSAGE.parse("SCRIPT_GUI_CONSTANT_OVERRIDEABLE", p)), false, clickType -> {
|
||||
}), null));
|
||||
swItems.add(new SWListInv.SWListEntry<>(new SWItem(Material.PLAYER_HEAD, BauSystem.MESSAGE.parse("SCRIPT_GUI_CONSTANT_Y_NAME", p), Arrays.asList(BauSystem.MESSAGE.parse("SCRIPT_GUI_CONSTANT_Y_LORE", p), BauSystem.MESSAGE.parse("SCRIPT_GUI_CONSTANT_OVERRIDEABLE", p)), false, clickType -> {
|
||||
}), null));
|
||||
swItems.add(new SWListInv.SWListEntry<>(new SWItem(Material.PLAYER_HEAD, BauSystem.MESSAGE.parse("SCRIPT_GUI_CONSTANT_Z_NAME", p), Arrays.asList(BauSystem.MESSAGE.parse("SCRIPT_GUI_CONSTANT_Z_LORE", p), BauSystem.MESSAGE.parse("SCRIPT_GUI_CONSTANT_OVERRIDEABLE", p)), false, clickType -> {
|
||||
}), null));
|
||||
swItems.add(new SWListInv.SWListEntry<>(new SWItem(Material.NAME_TAG, BauSystem.MESSAGE.parse("SCRIPT_GUI_CONSTANT_NAME_NAME", p), Arrays.asList(BauSystem.MESSAGE.parse("SCRIPT_GUI_CONSTANT_NAME_LORE", p)), false, clickType -> {
|
||||
}), null));
|
||||
swItems.add(new SWListInv.SWListEntry<>(new SWItem(Material.IRON_BOOTS, BauSystem.MESSAGE.parse("SCRIPT_GUI_CONSTANT_SNEAK_NAME", p), Arrays.asList(BauSystem.MESSAGE.parse("SCRIPT_GUI_CONSTANT_SNEAK_LORE", p)), false, clickType -> {
|
||||
}), null));
|
||||
swItems.add(new SWListInv.SWListEntry<>(new SWItem(Material.DIAMOND_BOOTS, BauSystem.MESSAGE.parse("SCRIPT_GUI_CONSTANT_SPRINTING_NAME", p), Arrays.asList(BauSystem.MESSAGE.parse("SCRIPT_GUI_CONSTANT_SPRINTING_LORE", p)), false, clickType -> {
|
||||
}), null));
|
||||
swItems.add(new SWListInv.SWListEntry<>(new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("SCRIPT_GUI_CONSTANT_SLOT_NAME", p), Arrays.asList(BauSystem.MESSAGE.parse("SCRIPT_GUI_CONSTANT_SLOT_LORE", p), BauSystem.MESSAGE.parse("SCRIPT_GUI_CONSTANT_OVERRIDEABLE", p)), false, clickType -> {
|
||||
}), null));
|
||||
swItems.add(new SWListInv.SWListEntry<>(new SWItem(Material.GRASS_BLOCK, BauSystem.MESSAGE.parse("SCRIPT_GUI_CONSTANT_SLOT_MATERIAL_NAME", p), Arrays.asList(BauSystem.MESSAGE.parse("SCRIPT_GUI_CONSTANT_SLOT_MATERIAL_LORE", p)), false, clickType -> {
|
||||
}), null));
|
||||
swItems.add(new SWListInv.SWListEntry<>(new SWItem(Material.IRON_BLOCK, BauSystem.MESSAGE.parse("SCRIPT_GUI_CONSTANT_OFF_HAND_MATERIAL_NAME", p), Arrays.asList(BauSystem.MESSAGE.parse("SCRIPT_GUI_CONSTANT_OFF_HAND_MATERIAL_LORE", p)), false, clickType -> {
|
||||
}), null));
|
||||
swItems.add(new SWListInv.SWListEntry<>(new SWItem(Material.BIRCH_SIGN, BauSystem.MESSAGE.parse("SCRIPT_GUI_CONSTANT_SLOT_MATERIAL_DISPLAY_NAME", p), Arrays.asList(BauSystem.MESSAGE.parse("SCRIPT_GUI_CONSTANT_SLOT_MATERIAL_DISPLAY_LORE", p)), false, clickType -> {
|
||||
}), null));
|
||||
swItems.add(new SWListInv.SWListEntry<>(new SWItem(Material.ACACIA_SIGN, BauSystem.MESSAGE.parse("SCRIPT_GUI_CONSTANT_OFF_HAND_MATERIAL_DISPLAY_NAME", p), Arrays.asList(BauSystem.MESSAGE.parse("SCRIPT_GUI_CONSTANT_OFF_HAND_MATERIAL_DISPLAY_LORE", p)), false, clickType -> {
|
||||
}), null));
|
||||
swItems.add(new SWListInv.SWListEntry<>(new SWItem(Material.MAP, BauSystem.MESSAGE.parse("SCRIPT_GUI_CONSTANT_REGION_TYPE_NAME", p), Arrays.asList(BauSystem.MESSAGE.parse("SCRIPT_GUI_CONSTANT_REGION_TYPE_LORE", p)), false, clickType -> {
|
||||
}), null));
|
||||
addEmptyItems(2 * 9 - 2);
|
||||
}
|
||||
List<SWListInv.SWListEntry<SpecialCommand>> swItems = new ArrayList<>();
|
||||
addEmptyItems(swItems, 3);
|
||||
swItems.add(new SWListInv.SWListEntry<>(createItem(p, Material.BOOK, "SCRIPT_GUI_CUSTOM_COMMANDS", loreBuilder(p, "SCRIPT_GUI_CUSTOM_COMMANDS_LORE_", 1, 13)), null));
|
||||
swItems.add(new SWListInv.SWListEntry<>(createItem(p, Material.BOOK, "SCRIPT_GUI_CUSTOM_EVENTS", loreBuilder(p, "SCRIPT_GUI_CUSTOM_EVENTS_LORE_", 1, 20, loreBuilder(p, "SCRIPT_GUI_CUSTOM_EVENTS_LORE_STAR_", 1, 2))), null));
|
||||
swItems.add(new SWListInv.SWListEntry<>(createItem(p, Material.BOOK, "SCRIPT_GUI_OTHER", loreBuilder(p, "SCRIPT_GUI_OTHER_LORE_", 1, 9)), null));
|
||||
addEmptyItems(swItems, 3);
|
||||
addCustomScriptsItems(swItems, p);
|
||||
addEmptyItems(swItems, 44 + 4);
|
||||
swItems.add(new SWListInv.SWListEntry<>(createItem(p, Material.BOOK, "SCRIPT_GUI_CUSTOM_VARIABLES", new ArrayList<>()), null));
|
||||
addEmptyItems(swItems, 4);
|
||||
addConstantItem(swItems, p, Material.TNT_MINECART, "SCRIPT_GUI_CONSTANT_TRACE_NAME", "SCRIPT_GUI_CONSTANT_TRACE_LORE", false);
|
||||
addConstantItem(swItems, p, Material.TNT_MINECART, "SCRIPT_GUI_CONSTANT_AUTO_TRACE_NAME", "SCRIPT_GUI_CONSTANT_AUTO_TRACE_LORE", false);
|
||||
addConstantItem(swItems, p, Material.TNT, "SCRIPT_GUI_CONSTANT_TNT_NAME", "SCRIPT_GUI_CONSTANT_TNT_LORE", false);
|
||||
addConstantItem(swItems, p, Material.TNT, "SCRIPT_GUI_CONSTANT_ONLY_TB_NAME", "SCRIPT_GUI_CONSTANT_ONLY_TB_LORE", false);
|
||||
addConstantItem(swItems, p, Material.GUNPOWDER, "SCRIPT_GUI_CONSTANT_FREEZE_NAME", "SCRIPT_GUI_CONSTANT_FREEZE_LORE", false);
|
||||
addConstantItem(swItems, p, Material.FIRE_CHARGE, "SCRIPT_GUI_CONSTANT_FIRE_NAME", "SCRIPT_GUI_CONSTANT_FIRE_LORE", false);
|
||||
addConstantItem(swItems, p, Material.OBSIDIAN, "SCRIPT_GUI_CONSTANT_PROTECT_NAME", "SCRIPT_GUI_CONSTANT_PROTECT_LORE", false);
|
||||
addConstantItem(swItems, p, Material.IRON_SWORD, "SCRIPT_GUI_CONSTANT_DAMAGE_NAME", "SCRIPT_GUI_CONSTANT_DAMAGE_LORE", false);
|
||||
addConstantItem(swItems, p, Material.PLAYER_HEAD, "SCRIPT_GUI_CONSTANT_X_NAME", "SCRIPT_GUI_CONSTANT_X_LORE", true);
|
||||
addConstantItem(swItems, p, Material.PLAYER_HEAD, "SCRIPT_GUI_CONSTANT_Y_NAME", "SCRIPT_GUI_CONSTANT_Y_LORE", true);
|
||||
addConstantItem(swItems, p, Material.PLAYER_HEAD, "SCRIPT_GUI_CONSTANT_Z_NAME", "SCRIPT_GUI_CONSTANT_Z_LORE", true);
|
||||
addConstantItem(swItems, p, Material.NAME_TAG, "SCRIPT_GUI_CONSTANT_NAME_NAME", "SCRIPT_GUI_CONSTANT_NAME_LORE", false);
|
||||
addConstantItem(swItems, p, Material.IRON_BOOTS, "SCRIPT_GUI_CONSTANT_SNEAK_NAME", "SCRIPT_GUI_CONSTANT_SNEAK_LORE", false);
|
||||
addConstantItem(swItems, p, Material.DIAMOND_BOOTS, "SCRIPT_GUI_CONSTANT_SPRINTING_NAME", "SCRIPT_GUI_CONSTANT_SPRINTING_LORE", false);
|
||||
addConstantItem(swItems, p, Material.ARROW, "SCRIPT_GUI_CONSTANT_SLOT_NAME", "SCRIPT_GUI_CONSTANT_SLOT_LORE", false);
|
||||
addConstantItem(swItems, p, Material.GRASS_BLOCK, "SCRIPT_GUI_CONSTANT_SLOT_MATERIAL_NAME", "SCRIPT_GUI_CONSTANT_SLOT_MATERIAL_LORE", false);
|
||||
addConstantItem(swItems, p, Material.IRON_BLOCK, "SCRIPT_GUI_CONSTANT_OFF_HAND_MATERIAL_NAME", "SCRIPT_GUI_CONSTANT_OFF_HAND_MATERIAL_LORE", false);
|
||||
addConstantItem(swItems, p, Material.BIRCH_SIGN, "SCRIPT_GUI_CONSTANT_SLOT_MATERIAL_DISPLAY_NAME", "SCRIPT_GUI_CONSTANT_SLOT_MATERIAL_DISPLAY_LORE", false);
|
||||
addConstantItem(swItems, p, Material.ACACIA_SIGN, "SCRIPT_GUI_CONSTANT_OFF_HAND_MATERIAL_DISPLAY_NAME", "SCRIPT_GUI_CONSTANT_OFF_HAND_MATERIAL_DISPLAY_LORE", false);
|
||||
addConstantItem(swItems, p, Material.MAP, "SCRIPT_GUI_CONSTANT_REGION_TYPE_NAME", "SCRIPT_GUI_CONSTANT_REGION_TYPE_LORE", false);
|
||||
addEmptyItems(swItems, 2 * 9 - 2);
|
||||
|
||||
SWListInv<SpecialCommand> swListInv = new SWListInv<>(p, BauSystem.MESSAGE.parse("SCRIPT_GUI_NAME", p), swItems, (clickType, o) -> {
|
||||
if (o != null) {
|
||||
BauSystem.MESSAGE.send("SCRIPT_GUI_COMMAND_CHAT", p, o.command());
|
||||
for (String s : o.description()) {
|
||||
if (s.isEmpty()) {
|
||||
BauSystem.MESSAGE.send("PREFIX", p);
|
||||
} else {
|
||||
BauSystem.MESSAGE.send(s, p);
|
||||
}
|
||||
BauSystem.MESSAGE.send(s.isEmpty() ? "PREFIX" : s, p);
|
||||
}
|
||||
p.closeInventory();
|
||||
}
|
||||
@ -152,13 +89,60 @@ public class ScriptCommand extends SWCommand {
|
||||
swListInv.open();
|
||||
}
|
||||
|
||||
private void addEmptyItems(int count) {
|
||||
private void addEmptyItems(List<SWListInv.SWListEntry<SpecialCommand>> swItems, int count) {
|
||||
for (int i = 0; i < count; i++) {
|
||||
swItems.add(new SWListInv.SWListEntry<>(new SWItem(Material.GRAY_STAINED_GLASS_PANE, "§7", new ArrayList<>(), false, clickType -> {
|
||||
}), null));
|
||||
}
|
||||
}
|
||||
|
||||
private SWItem createItem(Player p, Material material, String name, List<String> lore) {
|
||||
return new SWItem(material, BauSystem.MESSAGE.parse(name, p), lore, false, clickType -> {
|
||||
});
|
||||
}
|
||||
|
||||
private void addConstantItem(List<SWListInv.SWListEntry<SpecialCommand>> swItems, Player p, Material material, String name, String lore, boolean overrideable) {
|
||||
List<String> itemLore = new ArrayList<>();
|
||||
itemLore.add(BauSystem.MESSAGE.parse(lore, p));
|
||||
if (overrideable) itemLore.add(BauSystem.MESSAGE.parse("SCRIPT_GUI_CONSTANT_OVERRIDEABLE", p));
|
||||
swItems.add(new SWListInv.SWListEntry<>(createItem(p, material, name, itemLore), null));
|
||||
}
|
||||
|
||||
private void addCustomScriptsItems(List<SWListInv.SWListEntry<SpecialCommand>> swItems, Player p) {
|
||||
List<SpecialCommand> specialCommands = new ArrayList<>(SPECIAL_COMMANDS);
|
||||
specialCommands.sort(Comparator.comparing(specialCommand -> specialCommand.getClass().getTypeName()));
|
||||
specialCommands.forEach(specialCommand -> {
|
||||
List<String> strings = new ArrayList<>();
|
||||
boolean b = false;
|
||||
for (String s : specialCommand.description()) {
|
||||
if (s.isEmpty()) {
|
||||
b = true;
|
||||
strings.add("");
|
||||
continue;
|
||||
}
|
||||
s = BauSystem.MESSAGE.parse(s, p);
|
||||
while (b && s.length() > 50) {
|
||||
int index = s.indexOf(' ', 50);
|
||||
if (index == -1) {
|
||||
strings.add("§7" + s);
|
||||
s = null;
|
||||
break;
|
||||
} else {
|
||||
strings.add("§7" + s.substring(0, index));
|
||||
s = s.substring(index + 1);
|
||||
}
|
||||
}
|
||||
if (s != null) {
|
||||
strings.add("§7" + s);
|
||||
}
|
||||
}
|
||||
|
||||
SWItem swItem = new SWItem(specialCommand.material(), BauSystem.MESSAGE.parse("SCRIPT_GUI_COMMAND_NAME", p, specialCommand.command()), strings, false, clickType -> {
|
||||
});
|
||||
swItems.add(new SWListInv.SWListEntry<>(swItem, specialCommand));
|
||||
});
|
||||
}
|
||||
|
||||
@Register(value = "menu", description = "SCRIPT_COMMAND_HELP_MENU")
|
||||
public void menuGUICommand(Player p) {
|
||||
customScriptManager.openCommandsMenu(p);
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren