diff --git a/BauSystem_15/src/de/steamwar/bausystem/utils/NMSWrapper15.java b/BauSystem_15/src/de/steamwar/bausystem/utils/NMSWrapper15.java index 48c0d3a0..cd674b63 100644 --- a/BauSystem_15/src/de/steamwar/bausystem/utils/NMSWrapper15.java +++ b/BauSystem_15/src/de/steamwar/bausystem/utils/NMSWrapper15.java @@ -24,7 +24,7 @@ import de.steamwar.bausystem.entities.DetonatorEntity15; import de.steamwar.bausystem.entities.SimulatorEntity15; import de.steamwar.bausystem.entities.TraceEntity15; import de.steamwar.bausystem.features.detonator.AbstractDetonatorEntity; -import de.steamwar.bausystem.features.other.NoClipCommand; +import de.steamwar.bausystem.features.util.NoClipCommand; import de.steamwar.bausystem.features.simulator.AbstractSimulatorEntity; import de.steamwar.bausystem.features.tracer.AbstractTraceEntity; import de.steamwar.bausystem.features.warp.AbstractWarpEntity; diff --git a/BauSystem_18/src/de/steamwar/bausystem/utils/NMSWrapper18.java b/BauSystem_18/src/de/steamwar/bausystem/utils/NMSWrapper18.java index de2f6876..46b79f19 100644 --- a/BauSystem_18/src/de/steamwar/bausystem/utils/NMSWrapper18.java +++ b/BauSystem_18/src/de/steamwar/bausystem/utils/NMSWrapper18.java @@ -26,7 +26,7 @@ import de.steamwar.bausystem.entities.SimulatorEntity18; import de.steamwar.bausystem.entities.TraceEntity18; import de.steamwar.bausystem.entities.WarpEntity18; import de.steamwar.bausystem.features.detonator.AbstractDetonatorEntity; -import de.steamwar.bausystem.features.other.NoClipCommand; +import de.steamwar.bausystem.features.util.NoClipCommand; import de.steamwar.bausystem.features.simulator.AbstractSimulatorEntity; import de.steamwar.bausystem.features.tracer.AbstractTraceEntity; import de.steamwar.bausystem.features.warp.AbstractWarpEntity; diff --git a/BauSystem_Main/src/BauSystem.properties b/BauSystem_Main/src/BauSystem.properties index e87b9da4..c5ba051b 100644 --- a/BauSystem_Main/src/BauSystem.properties +++ b/BauSystem_Main/src/BauSystem.properties @@ -647,8 +647,8 @@ SMART_PLACE_DISABLE = §cSmartPlace deaktiviert BLOCK_COUNTER_HELP_TOGGLE = §8/§eblockcounter §8- §7Wechsel zwischen an und aus BLOCK_COUNTER_HELP_ENABLE = §8/§eblockcounter enable §8- §7Schalte den BlockCounter an BLOCK_COUNTER_HELP_DISABLE = §8/§eblockcounter disable §8- §7Schalte den BlockCounter aus -BLOCK_COUNTER_MESSAGE = §e{0} §7Blöcke §e{1} §7TNT §e{2} §7Blöcke/TNT §e{3} §7Blöcke/tick -BLOCK_COUNTER_MESSAGE_SECOND = §e{0} §7Blöcke §e{1} §7TNT §e{2} §7Blöcke/TNT §e{3} §7Blöcke/s +BLOCK_COUNTER_MESSAGE = §7Tiefe §8> §e{0} §7Blöcke §e{1} §7TNT §e{2} §7Blöcke/TNT §e{3} §7Blöcke/tick +BLOCK_COUNTER_MESSAGE_SECOND = §7Tiefe §8> §e{0} §7Blöcke §e{1} §7TNT §e{2} §7Blöcke/TNT §e{3} §7Blöcke/s BLOCK_COUNTER_ENABLE = §7BlockCounter angemacht BLOCK_COUNTER_DISABLE = §7BlockCounter ausgemacht diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/gui/BauGUICommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/gui/BauGUICommand.java index dd03c091..344937cd 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/gui/BauGUICommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/gui/BauGUICommand.java @@ -19,18 +19,11 @@ package de.steamwar.bausystem.features.gui; -import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.gui.editor.BauGuiEditor; -import de.steamwar.bausystem.features.gui.editor.BauGuiImportExport; -import de.steamwar.bausystem.features.gui.editor.BauGuiMapping; import de.steamwar.bausystem.linkage.LinkageType; import de.steamwar.bausystem.linkage.Linked; import de.steamwar.command.SWCommand; import de.steamwar.inventory.SWItem; -import net.md_5.bungee.api.ChatColor; -import net.md_5.bungee.api.chat.ClickEvent; -import net.md_5.bungee.api.chat.HoverEvent; -import net.md_5.bungee.api.chat.TextComponent; import org.bukkit.entity.Player; @Linked(LinkageType.COMMAND) @@ -54,29 +47,4 @@ public class BauGUICommand extends SWCommand { public void openEditor(Player p) { BauGuiEditor.openGuiEditor(p, new SWItem().getItemStack()); } - - @Register("export") - public void exportGui(Player p) { - String export = BauGuiImportExport.exportGui(BauGuiMapping.getGuiMapping(p)); - TextComponent component = new TextComponent(); - component.setColor(ChatColor.YELLOW); - component.setBold(true); - component.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(BauSystem.MESSAGE.parse("GUI_EXPORT_CODE_HOVER", p)))); - component.setClickEvent(new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, export)); - component.setText(export); - BauSystem.MESSAGE.send("GUI_EXPORT_CODE", p); - p.spigot().sendMessage(component); - } - - @Register("import") - public void importGui(Player p, String code) { - try { - if (BauGuiImportExport.importGui(code, p)) { - BauSystem.MESSAGE.send("GUI_IMPORT_CODE_SUCCESSFUL", p); - } - } catch (Exception e) { - e.printStackTrace(); - BauSystem.MESSAGE.send("GUI_IMPORT_INVALID_CODE", p); - } - } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/gui/editor/BauGuiImportExport.java b/BauSystem_Main/src/de/steamwar/bausystem/features/gui/editor/BauGuiImportExport.java deleted file mode 100644 index cba3307f..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/gui/editor/BauGuiImportExport.java +++ /dev/null @@ -1,168 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2021 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bausystem.features.gui.editor; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.features.gui.BauGUI; -import lombok.experimental.UtilityClass; -import org.bukkit.entity.Player; - -import java.util.*; -import java.util.stream.Collectors; - -@UtilityClass -public class BauGuiImportExport { - - private static final String VERSION = "00000"; - - public String exportGui(BauGuiMapping mapping) { - StringBuilder st = new StringBuilder(); - st.append(VERSION); // Version in Binary (0 - 32) - append(st, Integer.toBinaryString(mapping.getSize() / 9), 3); // Menu Size - - Map map = new HashMap<>(); - mapping.getMapping().forEach((integer, integer2) -> map.put(integer2, integer)); - - List integerList = map.keySet().stream().sorted().collect(Collectors.toList()); - for (int i = 0; i < integerList.size(); i++) { - int current = integerList.get(i); - int last = i == 0 ? -1 : integerList.get(i - 1); - if (current - last > 1) { - binaryConvert(st, Integer.toBinaryString(current - last - 1), '0'); - } - binaryConvert(st, Integer.toBinaryString(map.get(current)), '1'); - } - - byte[] bytes = new byte[st.length() / 8 + 1]; - if (st.length() / 8 == (int) Math.ceil(st.length() / 8.0)) { - bytes = new byte[st.length() / 8]; - } - - int index = 0; - while (st.length() > 0) { - byte result = 0; - for (int i = 0; i < Math.min(8, st.length()); i++) { - result |= (st.charAt(i) - '0') << (7 - i); - } - bytes[index] = result; - index++; - st.delete(0, Math.min(8, st.length())); - } - - return Base64.getEncoder().encodeToString(bytes); - } - - private static void append(StringBuilder st, String s, int length) { - for (int i = 0; i < length - s.length(); i++) { - st.append("0"); - } - st.append(s); - } - - private static void binaryConvert(StringBuilder st, String s, char identifier) { - StringBuilder current = new StringBuilder().append(identifier).append(s); - char reverseIdentifier = identifier == '0' ? '1' : '0'; - boolean added = false; - while (current.length() % 4 != 0) { - current.insert(0, reverseIdentifier); - added = true; - } - if (!added) { - current.insert(0, reverseIdentifier); - current.insert(0, reverseIdentifier); - current.insert(0, reverseIdentifier); - current.insert(0, reverseIdentifier); - } - while (current.length() > 4) { - st.append('1').append(current.substring(0, 4)); - current.delete(0, 4); - } - st.append('0').append(current); - } - - public static boolean importGui(String str, Player p) { - byte[] bytes = Base64.getDecoder().decode(str); - StringBuilder st = new StringBuilder(); - for (byte b : bytes) { - append(st, Integer.toBinaryString(b & 0xFF), 8); - } - if (!st.substring(0, 5).equals(VERSION)) { - BauSystem.MESSAGE.send("GUI_IMPORT_INVALID_CODE", p); - return false; - } - int size = Integer.parseInt(st.substring(5, 8), 2); - if (size <= 0 || size > 5) { - BauSystem.MESSAGE.send("GUI_IMPORT_INVALID_CODE", p); - return false; - } - size *= 9; - - st.delete(0, 8); - List blobs = new ArrayList<>(); - if (st.length() > 0) { - blobs.add(""); - } - while (st.length() > 4) { - String current = st.substring(0, 5); - int last = blobs.size() - 1; - blobs.set(last, blobs.get(last) + current.substring(1)); - if (current.startsWith("0")) { - blobs.add(""); - } - st.delete(0, 5); - } - blobs.removeIf(String::isEmpty); - blobs.replaceAll(s -> { - char start = s.charAt(0); - for (int i = 0; i < s.length(); i++) { - if (s.charAt(i) != start) { - return s.substring(i); - } - } - return s; - }); - - int currentIndex = 0; - Map map = new HashMap<>(); - boolean initial = true; - for (String s : blobs) { - if (s.startsWith("0")) { - currentIndex += Integer.parseInt(s.substring(1), 2); - } else { - if (!initial) { - currentIndex++; - } - initial = false; - s = s.substring(1); - int itemID = Integer.parseInt(s, 2); - if (!BauGUI.getITEMS().containsKey(itemID)) { - BauSystem.MESSAGE.send("GUI_IMPORT_INVALID_CODE", p); - return false; - } - map.put(itemID, currentIndex); - } - } - - BauGuiMapping mapping = BauGuiMapping.getGuiMapping(p); - mapping.setMapping(map); - mapping.setSize(size); - return true; - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/other/WorldSpawnCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/other/WorldSpawnCommand.java deleted file mode 100644 index 56357ef2..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/other/WorldSpawnCommand.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2021 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bausystem.features.other; - -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; -import de.steamwar.command.SWCommand; -import org.bukkit.Bukkit; -import org.bukkit.World; -import org.bukkit.entity.Player; -import org.bukkit.event.player.PlayerTeleportEvent; - -@Linked(LinkageType.COMMAND) -public class WorldSpawnCommand extends SWCommand { - - private static final World WORLD = Bukkit.getWorlds().get(0); - - public WorldSpawnCommand() { - super("worldspawn"); - } - - @Register(description = "OTHER_WORLDSPAWN_HELP") - public void genericCommand(Player p) { - p.teleport(WORLD.getSpawnLocation().add(0.5, 0, 0.5), PlayerTeleportEvent.TeleportCause.COMMAND); - } -} \ No newline at end of file diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/other/items/WorldSpawnBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/other/items/WorldSpawnBauGuiItem.java deleted file mode 100644 index 2c9ea43e..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/other/items/WorldSpawnBauGuiItem.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2021 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bausystem.features.other.items; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.features.other.WorldSpawnCommand; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; -import de.steamwar.bausystem.linkage.LinkedInstance; -import de.steamwar.bausystem.linkage.specific.BauGuiItem; -import de.steamwar.inventory.SWItem; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.event.inventory.ClickType; -import org.bukkit.inventory.ItemStack; - -@Linked(LinkageType.BAU_GUI_ITEM) -public class WorldSpawnBauGuiItem extends BauGuiItem { - - @LinkedInstance - private WorldSpawnCommand worldSpawnCommand; - - public WorldSpawnBauGuiItem() { - super(33); - } - - @Override - public ItemStack getItem(Player player) { - return new SWItem(Material.ENDER_EYE, BauSystem.MESSAGE.parse("OTHER_ITEMS_WORLDSPAWN_NAME", player)).getItemStack(); - } - - @Override - public boolean click(ClickType click, Player p) { - p.closeInventory(); - worldSpawnCommand.genericCommand(p); - return false; - } - - @Override - public Permission permission() { - return Permission.MEMBER; - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/DamageCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/DamageCommand.java deleted file mode 100644 index cedb7851..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/DamageCommand.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2021 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bausystem.features.region; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; -import de.steamwar.bausystem.region.Region; -import de.steamwar.bausystem.region.RegionUtils; -import de.steamwar.bausystem.region.flags.Flag; -import de.steamwar.bausystem.region.flags.flagvalues.DamageMode; -import de.steamwar.command.GuardCheckType; -import de.steamwar.command.GuardChecker; -import de.steamwar.command.GuardResult; -import de.steamwar.command.SWCommand; -import org.bukkit.entity.Player; - - -@Linked(LinkageType.COMMAND) -public class DamageCommand extends SWCommand { - - protected DamageCommand() { - super("damage", "dmg"); - } - - @Register(description = "REGION_DAMAGE_HELP") - public void toggleCommand(@Guard Player p) { - Region region = Region.getRegion(p.getLocation()); - if (toggle(region)) { - RegionUtils.actionBar(region, getEnableMessage()); - } else { - RegionUtils.actionBar(region, getDisableMessage()); - } - } - - private String getNoPermMessage() { - return "REGION_DAMAGE_NO_PERMS"; - } - - private String getEnableMessage() { - return "REGION_DAMAGE_ENABLED"; - } - - private String getDisableMessage() { - return "REGION_DAMAGE_DISABLED"; - } - - private boolean toggle(Region region) { - switch (region.getPlain(Flag.DAMAGE, DamageMode.class)) { - case ALLOW: - region.set(Flag.DAMAGE, DamageMode.DENY); - return true; - default: - case DENY: - region.set(Flag.DAMAGE, DamageMode.ALLOW); - return false; - } - } - - @ClassGuard(value = Player.class, local = true) - public GuardChecker guard() { - return (commandSender, guardCheckType, strings, s) -> { - Player player = (Player) commandSender; - if (!Permission.hasPermission(player, Permission.WORLD)) { - if (guardCheckType != GuardCheckType.TAB_COMPLETE) { - BauSystem.MESSAGE.send(getNoPermMessage(), player); - } - return GuardResult.DENIED; - } - return GuardResult.ALLOWED; - }; - } -} \ No newline at end of file diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/DamageListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/DamageListener.java deleted file mode 100644 index 0441d310..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/DamageListener.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2021 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bausystem.features.region; - -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; -import de.steamwar.bausystem.region.Region; -import de.steamwar.bausystem.region.flags.Flag; -import de.steamwar.bausystem.region.flags.flagvalues.DamageMode; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.entity.EntityDamageEvent; - - -@Linked(LinkageType.LISTENER) -public class DamageListener implements Listener { - - @EventHandler - public void onPlayerDamage(EntityDamageEvent e) { - if (e.getEntity() instanceof Player && Region.getRegion(e.getEntity().getLocation()).get(Flag.DAMAGE) == DamageMode.DENY) e.setCancelled(true); - } -} \ No newline at end of file diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionCommand.java index 3c8f7dfe..894e6619 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionCommand.java @@ -28,7 +28,6 @@ import de.steamwar.bausystem.linkage.LinkedInstance; import de.steamwar.bausystem.region.Prototype; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.RegionUtils; -import de.steamwar.bausystem.region.flags.flagvalues.ColorMode; import de.steamwar.bausystem.region.utils.RegionExtensionType; import de.steamwar.bausystem.region.utils.RegionType; import de.steamwar.command.*; @@ -40,7 +39,6 @@ import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerTeleportEvent; import java.io.IOException; -import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.logging.Level; @@ -126,21 +124,6 @@ public class RegionCommand extends SWCommand { } } - @Register(description = "REGION_REGION_HELP_SELECT") - public void baurahmenCommand(Player p, RegionType regionType) { - selectCommand.baurahmenCommand(p, regionType, RegionExtensionType.NORMAL); - } - - @Register(description = "REGION_REGION_HELP_SELECT_EXTENSION") - public void baurahmenCommand(Player p, RegionType regionType, RegionExtensionType regionExtensionType) { - selectCommand.baurahmenCommand(p, regionType, regionExtensionType); - } - - @Register(value = "color", description = "REGION_REGION_HELP_COLOR") - public void colorCommand(Player p, ColorMode color) { - colorCommand.genericColor(p, color); - } - @Register(value = "copypoint", description = "REGION_REGION_HELP_COPYPOINT") public void copyPointCommand(Player p) { Region region = Region.getRegion(p.getLocation()); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/ScriptVarsCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/ScriptVarsCommand.java deleted file mode 100644 index 9ce3403e..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/ScriptVarsCommand.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2021 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bausystem.features.script; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.features.script.variables.Context; -import de.steamwar.bausystem.features.script.variables.Value; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; -import de.steamwar.command.SWCommand; -import de.steamwar.command.SWCommandUtils; -import de.steamwar.command.TypeMapper; -import org.bukkit.entity.Player; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map; - -@Linked(LinkageType.COMMAND) -public class ScriptVarsCommand extends SWCommand { - - public ScriptVarsCommand() { - super("scriptvars"); - } - - @Register(description = "SCRIPT_COMMAND_VARS_HELP") - public void genericCommand(Player p) { - Context context = ScriptListener.getGlobalContext(p); - if (context.allVariables().isEmpty()) { - BauSystem.MESSAGE.send("SCRIPT_COMMAND_VARS_NO_VARS", p); - return; - } - int i = 0; - if (context.allVariables().size() == 1) { - BauSystem.MESSAGE.send("SCRIPT_COMMAND_VARS_ONE_VAR", p); - } else { - BauSystem.MESSAGE.send("SCRIPT_COMMAND_VARS_MANY_VARS", p, context.allVariables().size()); - } - for (Map.Entry var : context.entrySet()) { - if (i++ >= 40) break; - BauSystem.MESSAGE.sendPrefixless("SCRIPT_COMMAND_VARS_ELEMENT_WITH_DASH", p, var.getKey(), var.getValue().asString()); - } - } - - @Register(description = "SCRIPT_COMMAND_VARS_HELP_VAR") - public void getCommand(Player p, String varName) { - Context context = ScriptListener.getGlobalContext(p); - if (context.allVariables().isEmpty()) { - BauSystem.MESSAGE.send("SCRIPT_COMMAND_VARS_NO_VARS", p); - return; - } - if (!context.hasValue(varName)) { - BauSystem.MESSAGE.send("SCRIPT_COMMAND_VARS_UNKNOWN_VARS", p); - return; - } - BauSystem.MESSAGE.send("SCRIPT_COMMAND_VARS_ELEMENT", p, varName, context.getValue(varName).asString()); - } - - @Register(description = "SCRIPT_COMMAND_VARS_HELP_SET") - public void setValueCommand(Player p, String varName, int value) { - Context context = ScriptListener.getGlobalContext(p); - context.putValue(varName, new Value.LongValue(value)); - BauSystem.MESSAGE.send("SCRIPT_COMMAND_VARS_SET_VALUE", p, varName, value); - } - - @Register(description = "SCRIPT_COMMAND_VARS_HELP_SET") - public void setValueCommand(Player p, String varName, double value) { - Context context = ScriptListener.getGlobalContext(p); - context.putValue(varName, new Value.DoubleValue(value)); - BauSystem.MESSAGE.send("SCRIPT_COMMAND_VARS_SET_VALUE", p, varName, value); - } - - @Register - public void setValueCommand(Player p, String varName, boolean value) { - Context context = ScriptListener.getGlobalContext(p); - context.putValue(varName, new Value.BooleanValue(value)); - BauSystem.MESSAGE.send("SCRIPT_COMMAND_VARS_SET_VALUE", p, varName, value); - } - - @Register - public void setValueCommand(Player p, String varName, String... value) { - Context context = ScriptListener.getGlobalContext(p); - String s = String.join(" ", value); - context.putValue(varName, new Value.StringValue(s)); - BauSystem.MESSAGE.send("SCRIPT_COMMAND_VARS_SET_VALUE", p, varName, s); - } - - @Register(description = "SCRIPT_COMMAND_VARS_HELP_DELETE") - public void removeCommand(Player p, String varName, @Mapper(value = "Delete") String remove) { - Context context = ScriptListener.getGlobalContext(p); - if (context.allVariables().isEmpty()) { - BauSystem.MESSAGE.send("SCRIPT_COMMAND_VARS_NO_VARS", p); - return; - } - context.removeValue(varName); - BauSystem.MESSAGE.send("SCRIPT_COMMAND_VARS_REMOVE_VALUE", p, varName); - } - - @ClassMapper(value = String.class, local = true) - public TypeMapper stringTypeMapper() { - return SWCommandUtils.createMapper(s -> s, (commandSender, s) -> { - if (commandSender instanceof Player) { - Player player = (Player) commandSender; - return new ArrayList<>(ScriptListener.getGlobalContext(player).allVariables()); - } - return null; - }); - } - - @Mapper(value = "Delete", local = true) - public TypeMapper clearStringTypeMapper() { - List tabCompletes = Arrays.asList("delete", "clear", "remove"); - return SWCommandUtils.createMapper(s -> { - if (s.equalsIgnoreCase("delete") || s.equalsIgnoreCase("clear") || s.equalsIgnoreCase("remove")) { - return s; - } - return null; - }, s -> tabCompletes); - } - - @ClassMapper(value = boolean.class, local = true) - public TypeMapper integerTypeMapper() { - List tabCompletes = Arrays.asList("true", "false"); - return SWCommandUtils.createMapper(s -> { - if (s.equalsIgnoreCase("remove") || s.equalsIgnoreCase("clear") || s.equalsIgnoreCase("delete")) return null; - return s.equalsIgnoreCase("true"); - }, s -> tabCompletes); - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/TNTSimulator.java b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/TNTSimulator.java index b116983b..31f08799 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/TNTSimulator.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/TNTSimulator.java @@ -312,9 +312,9 @@ public class TNTSimulator { } private void updatePosition(Set tntSpawns, Consumer positionChanger) { - Set vectors = new HashSet<>(); + Map vectors = new IdentityHashMap<>(); for (TNTSpawn tntSpawn : tntSpawns) { - if (vectors.add(tntSpawn.position)) { + if (vectors.put(tntSpawn.position, true) == null) { positionChanger.accept(tntSpawn.position); } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/ProcessingTracesState.java b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/ProcessingTracesState.java index 5d95f7e9..5748907c 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/ProcessingTracesState.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/ProcessingTracesState.java @@ -63,7 +63,7 @@ public class ProcessingTracesState implements LaufbauState { } else { Vector movement = location.clone().subtract(previousLocation); cuboidList.add(new Cuboid(previousLocation.getX() - 0.49, Math.min(previousLocation.getY(), location.getY()), previousLocation.getZ() - 0.49, 0.98, Math.abs(movement.getY()) + 0.98, 0.98)); - if (Math.abs(movement.getX()) > Math.abs(movement.getZ())) { + if (Math.abs(tntPosition.getUpdateVelocity().getX()) >= Math.abs(tntPosition.getUpdateVelocity().getZ())) { cuboidList.add(new Cuboid(Math.min(previousLocation.getX(), location.getX()) - 0.49, location.getY(), previousLocation.getZ() - 0.49, Math.abs(movement.getX()) + 0.98, 0.98, 0.98)); cuboidList.add(new Cuboid(location.getX() - 0.49, location.getY(), Math.min(previousLocation.getZ(), location.getZ()) - 0.49, 0.98, 0.98, Math.abs(movement.getZ()) + 0.98)); } else { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/Panzern.java b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/Panzern.java index 81740e55..0c168cc4 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/Panzern.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/Panzern.java @@ -119,20 +119,20 @@ public class Panzern { return; case SLAB: currentBlock.setType(slabMaterial); - editSession.getChangeSet().add(new BlockChange(BukkitAdapter.asBlockVector(currentBlock.getLocation()), airType, slabType)); + editSession.setBlock(BukkitAdapter.asBlockVector(currentBlock.getLocation()), slabType); break; case BLOCK: case DEFAULT: currentBlock.setType(blockMaterial); - editSession.getChangeSet().add(new BlockChange(BukkitAdapter.asBlockVector(currentBlock.getLocation()), airType, blockType)); + editSession.setBlock(BukkitAdapter.asBlockVector(currentBlock.getLocation()), blockType); break; case UNMOVABLE: currentBlock.setType(Material.JUKEBOX); - editSession.getChangeSet().add(new BlockChange(BukkitAdapter.asBlockVector(currentBlock.getLocation()), airType, jukeboxType)); + editSession.setBlock(BukkitAdapter.asBlockVector(currentBlock.getLocation()), jukeboxType); break; case UNMOVABLE_SLAB: currentBlock.setType(Material.COBWEB); - editSession.getChangeSet().add(new BlockChange(BukkitAdapter.asBlockVector(currentBlock.getLocation()), airType, cobwebType)); + editSession.setBlock(BukkitAdapter.asBlockVector(currentBlock.getLocation()), cobwebType); break; default: emptyBlocks.add(currentBlock.getLocation().toVector()); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/testblock/blockcounter/BlockCounter.java b/BauSystem_Main/src/de/steamwar/bausystem/features/testblock/blockcounter/BlockCounter.java index 9cd0e5d4..cf34f6f1 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/testblock/blockcounter/BlockCounter.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/testblock/blockcounter/BlockCounter.java @@ -53,9 +53,9 @@ public class BlockCounter { double countPerTick = (double) count / Math.max((lastTick - tick), 1); if (isActive(player)) { if (countPerTick < 100) { - return BauSystem.MESSAGE.parsePrefixed("BLOCK_COUNTER_MESSAGE_SECOND", player, count, tntCount, (int) (countPerTNT * 10) / 10.0, (int) (countPerTick * 100) / 100.0 * 20); + return BauSystem.MESSAGE.parse("BLOCK_COUNTER_MESSAGE_SECOND", player, count, tntCount, (int) (countPerTNT * 10) / 10.0, (int) (countPerTick * 100) / 100.0 * 20); } else { - return BauSystem.MESSAGE.parsePrefixed("BLOCK_COUNTER_MESSAGE", player, count, tntCount, (int) (countPerTNT * 10) / 10.0, (int) (countPerTick * 100) / 100.0); + return BauSystem.MESSAGE.parse("BLOCK_COUNTER_MESSAGE", player, count, tntCount, (int) (countPerTNT * 10) / 10.0, (int) (countPerTick * 100) / 100.0); } } return null; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TNTPosition.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TNTPosition.java index 4aabdbbb..09b882ee 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TNTPosition.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TNTPosition.java @@ -22,25 +22,53 @@ package de.steamwar.bausystem.features.tracer; import de.steamwar.bausystem.features.tracer.show.Record; import de.steamwar.bausystem.shared.Position; import lombok.Getter; +import lombok.RequiredArgsConstructor; import org.bukkit.entity.TNTPrimed; import org.bukkit.util.Vector; +import java.util.function.Supplier; + @Getter public class TNTPosition extends Position { + @RequiredArgsConstructor + public static class CachingSupplier implements Supplier { + + private final Supplier supplier; + private boolean initialized; + private T value; + + @Override + public T get() { + if (!initialized) { + value = supplier.get(); + initialized = true; + } + return value; + } + } + private final Record.TNTRecord record; private final int fuseTicks; private final Vector previousLocation; + private final Vector velocity; + private final CachingSupplier updateVelocity; private final boolean exploded; - public TNTPosition(Record.TNTRecord record, TNTPrimed entity, Vector previousLocation, boolean exploded) { + public TNTPosition(Record.TNTRecord record, TNTPrimed entity, Vector previousLocation, Vector velocity, CachingSupplier updateVelocity, boolean exploded) { super(entity.getLocation().toVector()); this.record = record; this.fuseTicks = entity.getFuseTicks(); this.previousLocation = previousLocation; + this.velocity = velocity; + this.updateVelocity = updateVelocity; this.exploded = exploded; } + public Vector getUpdateVelocity() { + return updateVelocity.get(); + } + @Override public String toString() { return "Position{" + diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/Record.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/Record.java index c01ce31d..d76f4441 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/Record.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/Record.java @@ -24,6 +24,7 @@ import de.steamwar.bausystem.features.tracer.TNTPosition; import de.steamwar.bausystem.shared.ShowMode; import lombok.Getter; import org.bukkit.entity.TNTPrimed; +import org.bukkit.util.Vector; import java.util.ArrayList; import java.util.List; @@ -98,9 +99,21 @@ public class Record { private void add(TNTPrimed tntPrimed, boolean exploded) { TNTPosition position; if (positions.isEmpty()) { - position = new TNTPosition(this, tntPrimed, null, exploded); + position = new TNTPosition(this, tntPrimed, null, tntPrimed.getVelocity(), new TNTPosition.CachingSupplier<>(() -> null), exploded); } else { - position = new TNTPosition(this, tntPrimed, positions.get(positions.size() - 1).getLocation(), exploded); + int currentSize = positions.size() + 1; + TNTPosition.CachingSupplier velocitySupplier = new TNTPosition.CachingSupplier<>(() -> { + Vector current = null; + for (int i = currentSize - 1; i >= 0; i--) { + TNTPosition currentTNT = positions.get(i); + if ((currentTNT.getVelocity().getX() == 0 || currentTNT.getVelocity().getZ() == 0) && current != null) { + break; + } + current = currentTNT.getVelocity(); + } + return current; + }); + position = new TNTPosition(this, tntPrimed, positions.get(positions.size() - 1).getLocation(), tntPrimed.getVelocity(), velocitySupplier, exploded); } positions.add(position); TraceShowManager.show(position); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/mode/FactoredEntityShowMode.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/mode/FactoredEntityShowMode.java index 06288cb6..2a819e8c 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/mode/FactoredEntityShowMode.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/mode/FactoredEntityShowMode.java @@ -109,8 +109,7 @@ public abstract class FactoredEntityShowMode implements ShowMode { } if (showModeParameter.isInterpolate_XZ()) { - Vector movement = position.getLocation().clone().subtract(position.getPreviousLocation()); - Vector updatePointXZ = Math.abs(movement.getX()) > Math.abs(movement.getZ()) + Vector updatePointXZ = Math.abs(position.getUpdateVelocity().getX()) >= Math.abs(position.getUpdateVelocity().getZ()) ? position.getLocation().clone().setZ(position.getPreviousLocation().getZ()) : position.getLocation().clone().setX(position.getPreviousLocation().getX()); if (!position.getLocation().equals(updatePointXZ)) { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/other/ClearCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/ClearCommand.java similarity index 96% rename from BauSystem_Main/src/de/steamwar/bausystem/features/other/ClearCommand.java rename to BauSystem_Main/src/de/steamwar/bausystem/features/util/ClearCommand.java index 7e292237..24c1dd8e 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/other/ClearCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/ClearCommand.java @@ -1,7 +1,7 @@ /* * This file is a part of the SteamWar software. * - * Copyright (C) 2021 SteamWar.de-Serverteam + * Copyright (C) 2022 SteamWar.de-Serverteam * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -package de.steamwar.bausystem.features.other; +package de.steamwar.bausystem.features.util; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/other/DeclutterCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/DeclutterCommand.java similarity index 95% rename from BauSystem_Main/src/de/steamwar/bausystem/features/other/DeclutterCommand.java rename to BauSystem_Main/src/de/steamwar/bausystem/features/util/DeclutterCommand.java index 6f79b69c..a684bab9 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/other/DeclutterCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/DeclutterCommand.java @@ -1,7 +1,7 @@ /* * This file is a part of the SteamWar software. * - * Copyright (C) 2021 SteamWar.de-Serverteam + * Copyright (C) 2022 SteamWar.de-Serverteam * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -package de.steamwar.bausystem.features.other; +package de.steamwar.bausystem.features.util; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.linkage.LinkageType; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/other/GamemodeCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/GamemodeCommand.java similarity index 95% rename from BauSystem_Main/src/de/steamwar/bausystem/features/other/GamemodeCommand.java rename to BauSystem_Main/src/de/steamwar/bausystem/features/util/GamemodeCommand.java index f4d38198..2682d5f9 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/other/GamemodeCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/GamemodeCommand.java @@ -1,7 +1,7 @@ /* * This file is a part of the SteamWar software. * - * Copyright (C) 2021 SteamWar.de-Serverteam + * Copyright (C) 2022 SteamWar.de-Serverteam * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by @@ -16,7 +16,7 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -package de.steamwar.bausystem.features.other; +package de.steamwar.bausystem.features.util; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.linkage.LinkageType; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/other/KillAllCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/KillAllCommand.java similarity index 97% rename from BauSystem_Main/src/de/steamwar/bausystem/features/other/KillAllCommand.java rename to BauSystem_Main/src/de/steamwar/bausystem/features/util/KillAllCommand.java index 59153c28..736494be 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/other/KillAllCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/KillAllCommand.java @@ -1,7 +1,7 @@ /* * This file is a part of the SteamWar software. * - * Copyright (C) 2021 SteamWar.de-Serverteam + * Copyright (C) 2022 SteamWar.de-Serverteam * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -package de.steamwar.bausystem.features.other; +package de.steamwar.bausystem.features.util; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.SWUtils; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/other/NoClipCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/NoClipCommand.java similarity index 98% rename from BauSystem_Main/src/de/steamwar/bausystem/features/other/NoClipCommand.java rename to BauSystem_Main/src/de/steamwar/bausystem/features/util/NoClipCommand.java index d61df74e..f605f828 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/other/NoClipCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/NoClipCommand.java @@ -1,7 +1,7 @@ /* * This file is a part of the SteamWar software. * - * Copyright (C) 2021 SteamWar.de-Serverteam + * Copyright (C) 2022 SteamWar.de-Serverteam * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -package de.steamwar.bausystem.features.other; +package de.steamwar.bausystem.features.util; import com.comphenix.tinyprotocol.Reflection; import com.comphenix.tinyprotocol.TinyProtocol; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/other/SlotCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/SlotCommand.java similarity index 96% rename from BauSystem_Main/src/de/steamwar/bausystem/features/other/SlotCommand.java rename to BauSystem_Main/src/de/steamwar/bausystem/features/util/SlotCommand.java index 0c50d8ff..c6a3af49 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/other/SlotCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/SlotCommand.java @@ -1,7 +1,7 @@ /* * This file is a part of the SteamWar software. * - * Copyright (C) 2021 SteamWar.de-Serverteam + * Copyright (C) 2022 SteamWar.de-Serverteam * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -package de.steamwar.bausystem.features.other; +package de.steamwar.bausystem.features.util; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.SWUtils; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/other/TeleportCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/TeleportCommand.java similarity index 94% rename from BauSystem_Main/src/de/steamwar/bausystem/features/other/TeleportCommand.java rename to BauSystem_Main/src/de/steamwar/bausystem/features/util/TeleportCommand.java index 40fd9aa0..047a94e2 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/other/TeleportCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/TeleportCommand.java @@ -1,7 +1,7 @@ /* * This file is a part of the SteamWar software. * - * Copyright (C) 2021 SteamWar.de-Serverteam + * Copyright (C) 2022 SteamWar.de-Serverteam * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -package de.steamwar.bausystem.features.other; +package de.steamwar.bausystem.features.util; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.linkage.LinkageType; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/other/TimeCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/TimeCommand.java similarity index 97% rename from BauSystem_Main/src/de/steamwar/bausystem/features/other/TimeCommand.java rename to BauSystem_Main/src/de/steamwar/bausystem/features/util/TimeCommand.java index 66e916b5..58436511 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/other/TimeCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/TimeCommand.java @@ -1,7 +1,7 @@ /* * This file is a part of the SteamWar software. * - * Copyright (C) 2021 SteamWar.de-Serverteam + * Copyright (C) 2022 SteamWar.de-Serverteam * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -package de.steamwar.bausystem.features.other; +package de.steamwar.bausystem.features.util; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/other/TpsCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/TpsCommand.java similarity index 95% rename from BauSystem_Main/src/de/steamwar/bausystem/features/other/TpsCommand.java rename to BauSystem_Main/src/de/steamwar/bausystem/features/util/TpsCommand.java index a81ed03b..877c0da1 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/other/TpsCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/TpsCommand.java @@ -1,7 +1,7 @@ /* * This file is a part of the SteamWar software. * - * Copyright (C) 2021 SteamWar.de-Serverteam + * Copyright (C) 2022 SteamWar.de-Serverteam * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -package de.steamwar.bausystem.features.other; +package de.steamwar.bausystem.features.util; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.tpslimit.TPSWarpUtils; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/WaterVisionCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/WaterVisionCommand.java deleted file mode 100644 index bef8e245..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/WaterVisionCommand.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2021 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bausystem.features.util; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; -import de.steamwar.command.SWCommand; -import net.md_5.bungee.api.ChatMessageType; -import org.bukkit.entity.Player; -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; - -@Linked(LinkageType.COMMAND) -public class WaterVisionCommand extends SWCommand { - - public WaterVisionCommand() { - super("watervision", "wv"); - } - - @Register(description = "WATER_VISION_HELP") - public void genericCommand(Player p) { - if (p.hasPotionEffect(PotionEffectType.WATER_BREATHING)) { - p.removePotionEffect(PotionEffectType.WATER_BREATHING); - BauSystem.MESSAGE.sendPrefixless("WATER_VISION_DISABLE", p, ChatMessageType.ACTION_BAR); - return; - } - p.addPotionEffect(new PotionEffect(PotionEffectType.WATER_BREATHING, 1000000, 255, false, false)); - BauSystem.MESSAGE.sendPrefixless("WATER_VISION_ENABLE", p, ChatMessageType.ACTION_BAR); - } -} \ No newline at end of file diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/other/items/ClearBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/ClearBauGuiItem.java similarity index 94% rename from BauSystem_Main/src/de/steamwar/bausystem/features/other/items/ClearBauGuiItem.java rename to BauSystem_Main/src/de/steamwar/bausystem/features/util/items/ClearBauGuiItem.java index 3c9a56b0..ec39cb33 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/other/items/ClearBauGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/ClearBauGuiItem.java @@ -1,7 +1,7 @@ /* * This file is a part of the SteamWar software. * - * Copyright (C) 2021 SteamWar.de-Serverteam + * Copyright (C) 2022 SteamWar.de-Serverteam * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -package de.steamwar.bausystem.features.other.items; +package de.steamwar.bausystem.features.util.items; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/other/items/DeclutterBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/DeclutterBauGuiItem.java similarity index 92% rename from BauSystem_Main/src/de/steamwar/bausystem/features/other/items/DeclutterBauGuiItem.java rename to BauSystem_Main/src/de/steamwar/bausystem/features/util/items/DeclutterBauGuiItem.java index 09077542..70e7296d 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/other/items/DeclutterBauGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/DeclutterBauGuiItem.java @@ -1,7 +1,7 @@ /* * This file is a part of the SteamWar software. * - * Copyright (C) 2021 SteamWar.de-Serverteam + * Copyright (C) 2022 SteamWar.de-Serverteam * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by @@ -17,11 +17,11 @@ * along with this program. If not, see . */ -package de.steamwar.bausystem.features.other.items; +package de.steamwar.bausystem.features.util.items; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.features.other.DeclutterCommand; +import de.steamwar.bausystem.features.util.DeclutterCommand; import de.steamwar.bausystem.linkage.LinkageType; import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.linkage.LinkedInstance; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/other/items/GamemodeBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/GamemodeBauGuiItem.java similarity index 96% rename from BauSystem_Main/src/de/steamwar/bausystem/features/other/items/GamemodeBauGuiItem.java rename to BauSystem_Main/src/de/steamwar/bausystem/features/util/items/GamemodeBauGuiItem.java index cc4a6c1d..fb8bf022 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/other/items/GamemodeBauGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/GamemodeBauGuiItem.java @@ -1,7 +1,7 @@ /* * This file is a part of the SteamWar software. * - * Copyright (C) 2021 SteamWar.de-Serverteam + * Copyright (C) 2022 SteamWar.de-Serverteam * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -package de.steamwar.bausystem.features.other.items; +package de.steamwar.bausystem.features.util.items; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/other/items/KillAllBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/KillAllBauGuiItem.java similarity index 93% rename from BauSystem_Main/src/de/steamwar/bausystem/features/other/items/KillAllBauGuiItem.java rename to BauSystem_Main/src/de/steamwar/bausystem/features/util/items/KillAllBauGuiItem.java index 95b6567f..e31ea268 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/other/items/KillAllBauGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/KillAllBauGuiItem.java @@ -1,7 +1,7 @@ /* * This file is a part of the SteamWar software. * - * Copyright (C) 2021 SteamWar.de-Serverteam + * Copyright (C) 2022 SteamWar.de-Serverteam * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by @@ -17,11 +17,11 @@ * along with this program. If not, see . */ -package de.steamwar.bausystem.features.other.items; +package de.steamwar.bausystem.features.util.items; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.features.other.KillAllCommand; +import de.steamwar.bausystem.features.util.KillAllCommand; import de.steamwar.bausystem.linkage.LinkageType; import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.linkage.LinkedInstance; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/other/items/TeleportBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/TeleportBauGuiItem.java similarity index 95% rename from BauSystem_Main/src/de/steamwar/bausystem/features/other/items/TeleportBauGuiItem.java rename to BauSystem_Main/src/de/steamwar/bausystem/features/util/items/TeleportBauGuiItem.java index e0df2221..a190b0d6 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/other/items/TeleportBauGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/TeleportBauGuiItem.java @@ -1,7 +1,7 @@ /* * This file is a part of the SteamWar software. * - * Copyright (C) 2021 SteamWar.de-Serverteam + * Copyright (C) 2022 SteamWar.de-Serverteam * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -package de.steamwar.bausystem.features.other.items; +package de.steamwar.bausystem.features.util.items; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/WaterVisionBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/WaterVisionBauGuiItem.java deleted file mode 100644 index b6b6b290..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/WaterVisionBauGuiItem.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2021 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bausystem.features.util.items; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; -import de.steamwar.bausystem.linkage.specific.BauGuiItem; -import de.steamwar.inventory.SWItem; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.event.inventory.ClickType; -import org.bukkit.inventory.ItemStack; -import org.bukkit.potion.PotionEffectType; - -@Linked(LinkageType.BAU_GUI_ITEM) -public class WaterVisionBauGuiItem extends BauGuiItem { - - public WaterVisionBauGuiItem() { - super(18); - } - - @Override - public ItemStack getItem(Player player) { - if (player.hasPotionEffect(PotionEffectType.WATER_BREATHING)) { - return new SWItem(Material.WATER_BUCKET, BauSystem.MESSAGE.parse("WATER_VISION_ITEM_ENABLE", player)).getItemStack(); - } else { - return new SWItem(Material.BUCKET, BauSystem.MESSAGE.parse("WATER_VISION_ITEM_DISABLE", player)).getItemStack(); - } - } - - @Override - public boolean click(ClickType click, Player p) { - p.performCommand("wv"); - return true; - } - - @Override - public Permission permission() { - return Permission.MEMBER; - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/warp/Moon.java b/BauSystem_Main/src/de/steamwar/bausystem/features/warp/Moon.java deleted file mode 100644 index a70909c9..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/warp/Moon.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2021 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bausystem.features.warp; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.inventory.SWItem; -import lombok.experimental.UtilityClass; -import org.bukkit.Bukkit; -import org.bukkit.Material; -import org.bukkit.Particle; -import org.bukkit.entity.Player; -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; -import org.bukkit.util.Vector; - -import java.util.concurrent.atomic.AtomicInteger; - -@UtilityClass -public class Moon { - - public static void startMoon(Player player) { - player.getInventory().setHelmet(new SWItem(Material.GLASS, BauSystem.MESSAGE.parse("WARP_MOON_ITEM_NAME", player)).getItemStack()); - AtomicInteger countDown = new AtomicInteger(5); - Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), bukkitTask -> { - if (countDown.get() == 0) { - AtomicInteger iter = new AtomicInteger(1000); - Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), bukkitTask1 -> { - if (player.getLocation().getY() > 300 || iter.getAndDecrement() <= 0) { - player.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_FALLING, 60 * 5 * 20, 1, false, false)); - bukkitTask1.cancel(); - } else { - player.setVelocity(player.getVelocity().add(new Vector(0, 0.2, 0))); - player.getWorld().spawnParticle(Particle.FLAME, player.getLocation(), 5); - } - }, 0, 1); - bukkitTask.cancel(); - } else { - BauSystem.MESSAGE.sendPrefixless("WARP_MOON_COUNTDOOWN", player, countDown.getAndDecrement()); - } - }, 0, 20); - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/warp/Warp.java b/BauSystem_Main/src/de/steamwar/bausystem/features/warp/Warp.java index 2d8fface..6cbc6c10 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/warp/Warp.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/warp/Warp.java @@ -33,10 +33,21 @@ public class Warp { private static Map warpMap = new HashMap<>(); + static { + Warp worldSpawn = new Warp("WorldSpawn"); + worldSpawn.setLocation(Bukkit.getWorlds().get(0).getSpawnLocation()); + worldSpawn.setMat(Material.NETHER_STAR); + warpMap.put("WorldSpawn", worldSpawn); + } + private String name; private Location location; private Material mat; + private Warp(String name) { + this.name = name; + } + public Warp(String name, Player player) { this.name = name; this.location = player.getLocation(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/warp/WarpCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/warp/WarpCommand.java index 0234ea42..8dbcb6e5 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/warp/WarpCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/warp/WarpCommand.java @@ -56,11 +56,6 @@ public class WarpCommand extends SWCommand implements Disable, Enable { return SWCommandUtils.createMapper(Warp::getWarp, (commandSender, s) -> new ArrayList<>(Warp.getWarpNames())); } - @Register(value = "moon", noTabComplete = true) - public void tpMoon(Player p) { - Moon.startMoon(p); - } - @Register(value = "add", description = "WARP_HELP_ADD") @Register("create") public void addWarp(@Guard Player player, String name) { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/region/flags/Flag.java b/BauSystem_Main/src/de/steamwar/bausystem/region/flags/Flag.java index 4d3b9a2c..800c7a77 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/region/flags/Flag.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/region/flags/Flag.java @@ -34,7 +34,6 @@ public enum Flag implements EnumDisplay { COLOR("FLAG_COLOR", ColorMode.class, ColorMode.YELLOW, region -> false), TNT("FLAG_TNT", TNTMode.class, TNTMode.ONLY_TB, region -> true), FIRE("FLAG_FIRE", FireMode.class, FireMode.ALLOW, region -> true), - DAMAGE("FLAG_DAMAGE", DamageMode.class, DamageMode.ALLOW, region -> false), FREEZE("FLAG_FREEZE", FreezeMode.class, FreezeMode.INACTIVE, region -> true), PROTECT("FLAG_PROTECT", ProtectMode.class, ProtectMode.ACTIVE, region -> region.getFloorLevel() != 0); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/region/flags/flagvalues/DamageMode.java b/BauSystem_Main/src/de/steamwar/bausystem/region/flags/flagvalues/DamageMode.java deleted file mode 100644 index 071fd5fe..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/region/flags/flagvalues/DamageMode.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2021 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bausystem.region.flags.flagvalues; - -import de.steamwar.bausystem.region.flags.Flag; -import lombok.AllArgsConstructor; -import lombok.Getter; - -@Getter -@AllArgsConstructor -public enum DamageMode implements Flag.Value { - - ALLOW("FLAG_DAMAGE_ALLOW"), - DENY("FLAG_DAMAGE_DENY"); - - private static DamageMode[] values; - private final String chatValue; - - @Override - public DamageMode[] getValues() { - if (DamageMode.values == null) { - DamageMode.values = DamageMode.values(); //NOSONAR - } - return DamageMode.values; - } - - @Override - public DamageMode getValue() { - return this; - } - - @Override - public DamageMode getValueOf(final String name) { - try { - return DamageMode.valueOf(name.toUpperCase()); - } catch (IllegalArgumentException e) { - if (name.equalsIgnoreCase("false")) { - return DamageMode.DENY; - } - return DamageMode.ALLOW; - } - } -} \ No newline at end of file diff --git a/steamwarci.yml b/steamwarci.yml index 2488bfa6..d36f6f39 100644 --- a/steamwarci.yml +++ b/steamwarci.yml @@ -1,7 +1,6 @@ build: - "ln -s /home/gitea/lib" - "cp ~/gradle.properties ." - - "chmod u+x build.gradle" - "./gradlew buildProject" artifacts: