From 4cb314dbee52314a0dd7f91766b72b375f5aa2be Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sun, 14 Nov 2021 13:06:43 +0100 Subject: [PATCH] Add Echoactionbar Add Constants region-type Signed-off-by: yoyosource --- .../features/script/ScriptCommand.java | 6 ++- .../script/command/io/Echoactionbar.java | 50 +++++++++++++++++++ .../features/script/variables/Constants.java | 8 +++ 3 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/script/command/io/Echoactionbar.java diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/ScriptCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/ScriptCommand.java index 46e847de..9c013cf2 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/ScriptCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/ScriptCommand.java @@ -80,7 +80,7 @@ public class ScriptCommand extends SWCommand { }); swItems.add(new SWListInv.SWListEntry<>(swItem, specialCommand)); }); - for (int i = 0; i < 9; i++) { + for (int i = 0; i < 8; i++) { swItems.add(new SWListInv.SWListEntry<>(new SWItem(Material.GRAY_STAINED_GLASS_PANE, "§7", new ArrayList<>(), false, clickType -> { }), null)); } @@ -122,7 +122,9 @@ public class ScriptCommand extends SWCommand { }), null)); 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.MAP, "§7Constant §eregion-type", Arrays.asList("§eRegionstype§7 der jetztigen Region"), false, clickType -> { + }), null)); + for (int i = 0; i < 1 + 2 * 9; i++) { swItems.add(new SWListInv.SWListEntry<>(new SWItem(Material.GRAY_STAINED_GLASS_PANE, "§7", new ArrayList<>(), false, clickType -> { }), null)); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/io/Echoactionbar.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/io/Echoactionbar.java new file mode 100644 index 00000000..ff253cdf --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/command/io/Echoactionbar.java @@ -0,0 +1,50 @@ +package de.steamwar.bausystem.features.script.command.io; + +import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.SWUtils; +import de.steamwar.bausystem.features.script.ScriptExecutor; +import de.steamwar.bausystem.features.script.SpecialCommand; +import de.steamwar.bausystem.linkage.LinkageType; +import de.steamwar.bausystem.linkage.Linked; +import net.md_5.bungee.api.ChatColor; +import org.bukkit.Material; + +@Linked(LinkageType.SCRIPT_COMMAND) +public class Echoactionbar implements SpecialCommand { + + @Override + public String[] description() { + return new String[]{ + "§eechoactionbar §8<§7Wert§8>", + "", + "§7Schreibe etwas dem Spieler in der ActionBar. Wenn kein Wert angegeben wurde ist die Nachricht leer." + }; + } + + @Override + public Material material() { + return Material.BIRCH_SIGN; + } + + @Override + public String command() { + return "echoactionbar"; + } + + @Override + public boolean execute(String[] command, ScriptExecutor scriptExecutor) { + if (command.length <= 1) { + SWUtils.sendToActionbar(scriptExecutor.getPlayer(), ""); + return true; + } + StringBuilder st = new StringBuilder(); + for (int i = 1; i < command.length; i++) { + if (i != 1) { + st.append(" "); + } + st.append(command[i]); + } + SWUtils.sendToActionbar(scriptExecutor.getPlayer(), ChatColor.translateAlternateColorCodes('&', st.toString())); + return true; + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/variables/Constants.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/variables/Constants.java index eeb53f07..2add5240 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/variables/Constants.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/variables/Constants.java @@ -1,6 +1,7 @@ package de.steamwar.bausystem.features.script.variables; import de.steamwar.bausystem.features.tracer.record.RecordStateMachine; +import de.steamwar.bausystem.region.GlobalRegion; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.bausystem.region.flags.flagvalues.FireMode; @@ -215,6 +216,13 @@ public class Constants { CONSTANTS.put("offhandmaterial", player -> { return new ConstantStringValue(() -> player.getInventory().getItemInOffHand().getType().name()); }); + CONSTANTS.put("region-type", player -> { + Region region = Region.getRegion(player.getLocation()); + if (region.isGlobal()) { + return new ConstantStringValue(() -> "global"); + } + return new ConstantStringValue(() -> region.getPrototype().getDisplayName().replace(' ', '_').toLowerCase()); + }); } public Set allVariables() {