SteamWar/BauSystem2.0
Archiviert
12
0

Add Constant for sprinting and offhandmaterial

Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
yoyosource 2021-09-21 15:51:54 +02:00
Ursprung 663f380e18
Commit ef1bdbbcf6
3 geänderte Dateien mit 23 neuen und 6 gelöschten Zeilen

Datei anzeigen

@ -173,6 +173,13 @@ public class CustomScriptListener implements Listener {
List<SWListInv.SWListEntry<CustomScript.MenuScript>> menuCommands = new ArrayList<>(); List<SWListInv.SWListEntry<CustomScript.MenuScript>> menuCommands = new ArrayList<>();
playerMap.getOrDefault(p, new ArrayList<>()).stream().filter(CustomScript.MenuScript.class::isInstance).map(CustomScript.MenuScript.class::cast).forEach(menuItem -> { playerMap.getOrDefault(p, new ArrayList<>()).stream().filter(CustomScript.MenuScript.class::isInstance).map(CustomScript.MenuScript.class::cast).forEach(menuItem -> {
SWItem swItem = menuItem.toItem(); SWItem swItem = menuItem.toItem();
ItemStack itemStack = swItem.getItemStack();
if (menuItem instanceof CustomScript.MenuEvent) {
itemStack.setType(Material.REPEATING_COMMAND_BLOCK);
} else {
itemStack.setType(Material.COMMAND_BLOCK);
}
swItem.setItemStack(itemStack);
swItem.setLore(Arrays.asList("§7Klicke zum rausnehmen", "§7Middle Klicke zum kopieren")); swItem.setLore(Arrays.asList("§7Klicke zum rausnehmen", "§7Middle Klicke zum kopieren"));
menuCommands.add(new SWListInv.SWListEntry<>(swItem, menuItem)); menuCommands.add(new SWListInv.SWListEntry<>(swItem, menuItem));
@ -291,9 +298,7 @@ public class CustomScriptListener implements Listener {
<T extends Event> EventType(Class<T> eventType, Function<T, Map<String, Value>> eventValues) { <T extends Event> EventType(Class<T> eventType, Function<T, Map<String, Value>> eventValues) {
this.eventType = eventType; this.eventType = eventType;
this.eventValues = event -> { this.eventValues = event -> eventValues.apply((T) event);
return eventValues.apply((T) event);
};
} }
} }
@ -309,14 +314,16 @@ public class CustomScriptListener implements Listener {
if (variables == null) { if (variables == null) {
variables = new HashMap<>(); variables = new HashMap<>();
} }
if (e instanceof Cancellable) {
variables.put("cancel", new Value.BooleanValue(false));
}
customEvent.execute(e, p, variables); customEvent.execute(e, p, variables);
if (e instanceof Cancellable && variables.containsKey("cancel")) { if (variables.containsKey("cancel")) {
Value value = variables.get("cancel"); Value value = variables.get("cancel");
if (value.asBoolean()) { if (value.asBoolean()) {
((Cancellable) e).setCancelled(true); ((Cancellable) e).setCancelled(true);
} }
} }
return;
} }
} }
} }

Datei anzeigen

@ -114,11 +114,15 @@ public class ScriptCommand extends SWCommand {
}), null)); }), null));
swItems.add(new SWListInv.SWListEntry<>(new SWItem(Material.IRON_BOOTS, "§7Constant §esneak", Arrays.asList("§etrue§7 wenn der Spieler gerade sneakt."), false, clickType -> { swItems.add(new SWListInv.SWListEntry<>(new SWItem(Material.IRON_BOOTS, "§7Constant §esneak", Arrays.asList("§etrue§7 wenn der Spieler gerade sneakt."), false, clickType -> {
}), null)); }), null));
swItems.add(new SWListInv.SWListEntry<>(new SWItem(Material.DIAMOND_BOOTS, "§7Constant §esprinting", Arrays.asList("§etrue§7 wenn der Spieler gerade rennt."), false, clickType -> {
}), null));
swItems.add(new SWListInv.SWListEntry<>(new SWItem(Material.ARROW, "§7Constant §eslot", Arrays.asList("§e0-8§7 für den ausgewählten slot.", "§eÜberschreibbar"), false, clickType -> { swItems.add(new SWListInv.SWListEntry<>(new SWItem(Material.ARROW, "§7Constant §eslot", Arrays.asList("§e0-8§7 für den ausgewählten slot.", "§eÜberschreibbar"), false, clickType -> {
}), null)); }), null));
swItems.add(new SWListInv.SWListEntry<>(new SWItem(Material.GRASS_BLOCK, "§7Constant §eslotmaterial", Arrays.asList("§eMaterial§7 des Items im Slot"), false, clickType -> { swItems.add(new SWListInv.SWListEntry<>(new SWItem(Material.GRASS_BLOCK, "§7Constant §eslotmaterial", Arrays.asList("§eMaterial§7 des Items im Slot"), false, clickType -> {
}), null)); }), null));
for (int i = 0; i < 4 + 2 * 9; i++) { swItems.add(new SWListInv.SWListEntry<>(new SWItem(Material.IRON_BLOCK, "§7Constant §eoffhandmaterial", Arrays.asList("§eMaterial§7 des Items in oder Off Hand"), false, clickType -> {
}), null));
for (int i = 0; i < 2 + 2 * 9; i++) {
swItems.add(new SWListInv.SWListEntry<>(new SWItem(Material.GRAY_STAINED_GLASS_PANE, "§7", new ArrayList<>(), false, clickType -> { swItems.add(new SWListInv.SWListEntry<>(new SWItem(Material.GRAY_STAINED_GLASS_PANE, "§7", new ArrayList<>(), false, clickType -> {
}), null)); }), null));
} }

Datei anzeigen

@ -195,6 +195,9 @@ public class Constants {
CONSTANTS.put("sneaking", player -> { CONSTANTS.put("sneaking", player -> {
return new ConstantBooleanValue(player::isSneaking); return new ConstantBooleanValue(player::isSneaking);
}); });
CONSTANTS.put("sprinting", player -> {
return new ConstantBooleanValue(player::isSprinting);
});
CONSTANTS.put("slot", player -> { CONSTANTS.put("slot", player -> {
return new ConstantLongValue(() -> (long) player.getInventory().getHeldItemSlot(), slot -> { return new ConstantLongValue(() -> (long) player.getInventory().getHeldItemSlot(), slot -> {
if (slot > 8) { if (slot > 8) {
@ -209,6 +212,9 @@ public class Constants {
CONSTANTS.put("slotmaterial", player -> { CONSTANTS.put("slotmaterial", player -> {
return new ConstantStringValue(() -> player.getInventory().getItemInMainHand().getType().name()); return new ConstantStringValue(() -> player.getInventory().getItemInMainHand().getType().name());
}); });
CONSTANTS.put("offhandmaterial", player -> {
return new ConstantStringValue(() -> player.getInventory().getItemInOffHand().getType().name());
});
} }
public Set<String> allVariables() { public Set<String> allVariables() {