From 5dfdb8e72224e2e1fd61f70fd6e82a09a3183d9a Mon Sep 17 00:00:00 2001 From: Lixfel <agga-games@gmx.de> Date: Wed, 24 Jan 2024 12:07:38 +0100 Subject: [PATCH] Code cleanup, Utilize Lombok Signed-off-by: Lixfel <agga-games@gmx.de> --- .../utils/CraftbukkitWrapper10.java | 2 +- .../utils/CraftbukkitWrapper12.java | 2 +- .../utils/CraftbukkitWrapper14.java | 2 +- .../utils/CraftbukkitWrapper15.java | 2 +- .../utils/CraftbukkitWrapper9.java | 2 +- .../de/steamwar/fightsystem/FightSystem.java | 14 ++---- .../fightsystem/commands/CommandInjector.java | 42 ------------------ .../fightsystem/commands/Commands.java | 11 ++++- .../fightsystem/commands/GamemodeCommand.java | 2 +- .../de/steamwar/fightsystem/fight/Fight.java | 11 ++--- .../fightsystem/fight/FightPlayer.java | 22 +++------- .../steamwar/fightsystem/fight/FightTeam.java | 17 ++++--- .../fightsystem/fight/FightWorld.java | 8 ++-- .../steamwar/fightsystem/fight/HotbarKit.java | 2 +- .../de/steamwar/fightsystem/fight/Kit.java | 35 ++++----------- .../fightsystem/listener/ArrowPickup.java | 32 -------------- .../fightsystem/record/FileRecorder.java | 6 +-- .../fightsystem/states/FightState.java | 7 ++- .../fightsystem/utils/FightStatistics.java | 6 +-- .../steamwar/fightsystem/utils/FightUI.java | 5 +-- .../fightsystem/utils/ItemBuilder.java | 44 ++++--------------- .../steamwar/fightsystem/utils/Message.java | 12 ++--- .../winconditions/Wincondition.java | 11 ++--- 23 files changed, 75 insertions(+), 222 deletions(-) delete mode 100644 FightSystem_Core/src/de/steamwar/fightsystem/commands/CommandInjector.java delete mode 100644 FightSystem_Core/src/de/steamwar/fightsystem/listener/ArrowPickup.java diff --git a/FightSystem_10/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper10.java b/FightSystem_10/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper10.java index e6b9dc8..78dd79a 100644 --- a/FightSystem_10/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper10.java +++ b/FightSystem_10/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper10.java @@ -39,7 +39,7 @@ public class CraftbukkitWrapper10 implements CraftbukkitWrapper { System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length); System.arraycopy(backupChunk.heightMap, 0, chunk.heightMap, 0, chunk.heightMap.length); w.tileEntityListTick.removeAll(chunk.tileEntities.values()); - if (!FightWorld.isPaper()) { + if (!FightWorld.isPAPER()) { w.tileEntityList.removeAll(chunk.tileEntities.values()); } chunk.tileEntities.clear(); diff --git a/FightSystem_12/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper12.java b/FightSystem_12/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper12.java index 36fd0ab..f8e843b 100644 --- a/FightSystem_12/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper12.java +++ b/FightSystem_12/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper12.java @@ -39,7 +39,7 @@ public class CraftbukkitWrapper12 implements CraftbukkitWrapper { System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length); System.arraycopy(backupChunk.heightMap, 0, chunk.heightMap, 0, chunk.heightMap.length); w.tileEntityListTick.removeAll(chunk.tileEntities.values()); - if (!FightWorld.isPaper()) { + if (!FightWorld.isPAPER()) { w.tileEntityList.removeAll(chunk.tileEntities.values()); } chunk.tileEntities.clear(); diff --git a/FightSystem_14/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper14.java b/FightSystem_14/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper14.java index 7528fcf..07c525d 100644 --- a/FightSystem_14/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper14.java +++ b/FightSystem_14/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper14.java @@ -38,7 +38,7 @@ public class CraftbukkitWrapper14 implements CraftbukkitWrapper { System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length); w.tileEntityListTick.removeAll(chunk.tileEntities.values()); - if (!FightWorld.isPaper()) { + if (!FightWorld.isPAPER()) { w.tileEntityList.removeAll(chunk.tileEntities.values()); } chunk.tileEntities.clear(); diff --git a/FightSystem_15/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper15.java b/FightSystem_15/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper15.java index f06902b..70d9e8c 100644 --- a/FightSystem_15/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper15.java +++ b/FightSystem_15/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper15.java @@ -38,7 +38,7 @@ public class CraftbukkitWrapper15 implements CraftbukkitWrapper { System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length); w.tileEntityListTick.removeAll(chunk.tileEntities.values()); - if (!FightWorld.isPaper()) { + if (!FightWorld.isPAPER()) { w.tileEntityList.removeAll(chunk.tileEntities.values()); } chunk.tileEntities.clear(); diff --git a/FightSystem_9/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper9.java b/FightSystem_9/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper9.java index a0ddcd9..54281ed 100644 --- a/FightSystem_9/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper9.java +++ b/FightSystem_9/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper9.java @@ -39,7 +39,7 @@ public class CraftbukkitWrapper9 implements CraftbukkitWrapper { System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length); System.arraycopy(backupChunk.heightMap, 0, chunk.heightMap, 0, chunk.heightMap.length); w.tileEntityListTick.removeAll(chunk.tileEntities.values()); - if (!FightWorld.isPaper()) { + if (!FightWorld.isPAPER()) { w.tileEntityList.removeAll(chunk.tileEntities.values()); } chunk.tileEntities.clear(); diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java b/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java index 0b17349..6e6b1c4 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java @@ -39,15 +39,18 @@ import de.steamwar.fightsystem.record.GlobalRecorder; import de.steamwar.fightsystem.record.LiveRecorder; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.OneShotStateDependent; +import de.steamwar.fightsystem.states.StateDependentListener; import de.steamwar.fightsystem.utils.*; import de.steamwar.fightsystem.winconditions.*; import de.steamwar.message.Message; import de.steamwar.sql.SchematicNode; +import lombok.Getter; import org.bukkit.Bukkit; import org.bukkit.plugin.java.JavaPlugin; public class FightSystem extends JavaPlugin { + @Getter private static FightSystem plugin; private Message message; @@ -97,7 +100,7 @@ public class FightSystem extends JavaPlugin { new RunningWorldInteraction(); new PersonalKitCreator(); new ArrowStopper(); - new ArrowPickup(); + new StateDependentListener(ArenaMode.All, FightState.All, BountifulWrapper.impl.newDenyArrowPickupListener()); new BlockFadeListener(); new LeaveableArena(); new ClickAnalyzer(); @@ -194,15 +197,6 @@ public class FightSystem extends JavaPlugin { FightState.setFightState(FightState.SPECTATE); } - public static FightSystem getPlugin() { - return plugin; - } - - public static void broadcast(String msg, Object... params) { - getMessage().broadcast(msg, params); - GlobalRecorder.getInstance().system(msg, params); - } - public static Message getMessage() { return plugin.message; } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/commands/CommandInjector.java b/FightSystem_Core/src/de/steamwar/fightsystem/commands/CommandInjector.java deleted file mode 100644 index 2c69fde..0000000 --- a/FightSystem_Core/src/de/steamwar/fightsystem/commands/CommandInjector.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - This file is a part of the SteamWar software. - - Copyright (C) 2020 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 <https://www.gnu.org/licenses/>. -*/ - -package de.steamwar.fightsystem.commands; - -import org.bukkit.Bukkit; -import org.bukkit.command.Command; -import org.bukkit.command.SimpleCommandMap; - -import java.lang.reflect.Field; - -public class CommandInjector { - - private CommandInjector(){} - - private static final String PACKAGE_NAME = Bukkit.getServer().getClass().getPackage().getName(); - private static final String VERSION = PACKAGE_NAME.substring(PACKAGE_NAME.lastIndexOf('.') + 1); - - public static void injectCommand(Command cmd) throws Exception { - Class serverClass = Class.forName("org.bukkit.craftbukkit." + VERSION + ".CraftServer"); - Field f1 = serverClass.getDeclaredField("commandMap"); - f1.setAccessible(true); - SimpleCommandMap commandMap = (SimpleCommandMap) f1.get(Bukkit.getServer()); - commandMap.register("BauSystem", cmd); - } -} diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/commands/Commands.java b/FightSystem_Core/src/de/steamwar/fightsystem/commands/Commands.java index 6102728..b880fa6 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/commands/Commands.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/commands/Commands.java @@ -19,6 +19,7 @@ package de.steamwar.fightsystem.commands; +import com.comphenix.tinyprotocol.Reflection; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.fight.Fight; @@ -28,12 +29,20 @@ import de.steamwar.fightsystem.fight.Kit; import de.steamwar.fightsystem.states.FightState; import de.steamwar.sql.PersonalKit; import de.steamwar.sql.SteamwarUser; +import lombok.experimental.UtilityClass; import net.md_5.bungee.api.ChatMessageType; import org.bukkit.Bukkit; +import org.bukkit.command.Command; +import org.bukkit.command.SimpleCommandMap; import org.bukkit.entity.Player; +@UtilityClass public class Commands { - private Commands(){} + + private static final Reflection.FieldAccessor<SimpleCommandMap> commandMap = Reflection.getField("{obc}.CraftServer", "commandMap", SimpleCommandMap.class); + public static void injectCommand(Command cmd) { + commandMap.get(Bukkit.getServer()).register("FightSystem", cmd); + } private static void errNoTeam(Player p){ FightSystem.getMessage().sendPrefixless("NO_TEAM", p, ChatMessageType.ACTION_BAR); diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/commands/GamemodeCommand.java b/FightSystem_Core/src/de/steamwar/fightsystem/commands/GamemodeCommand.java index 0cde5ac..5c56626 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/commands/GamemodeCommand.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/commands/GamemodeCommand.java @@ -47,10 +47,10 @@ public class GamemodeCommand extends BukkitCommand { try { CommandRemover.removeAll("gamemode"); - CommandInjector.injectCommand(this); } catch (Exception e) { FightSystem.getPlugin().getLogger().log(Level.SEVERE, "Failed to replace commands", e); } + Commands.injectCommand(this); } @Override diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/fight/Fight.java b/FightSystem_Core/src/de/steamwar/fightsystem/fight/Fight.java index 9d59a0b..cd7a232 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/fight/Fight.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/fight/Fight.java @@ -27,6 +27,7 @@ import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.record.GlobalRecorder; +import lombok.Getter; import org.bukkit.Bukkit; import org.bukkit.GameMode; import org.bukkit.Sound; @@ -39,7 +40,9 @@ import java.util.HashSet; public class Fight { private Fight(){} + @Getter private static final FightTeam redTeam = new FightTeam(Config.TeamRedName, Config.TeamRedColor, Config.TeamRedSpawn, Config.RedPasteRegion, Config.RedExtendRegion, Config.RedRotate, false, Config.RedLeader); + @Getter private static final FightTeam blueTeam = new FightTeam(Config.TeamBlueName, Config.TeamBlueColor, Config.TeamBlueSpawn, Config.BluePasteRegion, Config.BlueExtendRegion, Config.BlueRotate, true, Config.BlueLeader); private static final Collection<FightTeam> teams = new HashSet<>(); static { @@ -76,14 +79,6 @@ public class Fight { return getPlayerTeam(player) != null; } - public static FightTeam getRedTeam() { - return redTeam; - } - - public static FightTeam getBlueTeam() { - return blueTeam; - } - public static Collection<FightTeam> teams() { return teams; } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightPlayer.java b/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightPlayer.java index f28c039..763bd6f 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightPlayer.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightPlayer.java @@ -26,6 +26,8 @@ import de.steamwar.fightsystem.countdown.EnternCountdown; import de.steamwar.fightsystem.events.TeamDeathEvent; import de.steamwar.sql.PersonalKit; import de.steamwar.sql.SteamwarUser; +import lombok.Getter; +import lombok.Setter; import org.bukkit.Bukkit; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -36,9 +38,13 @@ public class FightPlayer { private final int id; private LivingEntity entity; + @Getter private final FightTeam team; private boolean isOut; + @Setter + @Getter private Kit kit; + @Getter private int kills; private EnternCountdown enternCountdown = null; @@ -113,22 +119,6 @@ public class FightPlayer { return leader != null && leader.getEntity() == entity; } - public Kit getKit() { - return kit; - } - - public void setKit(Kit kit) { - this.kit = kit; - } - - public FightTeam getTeam(){ - return team; - } - - public int getKills(){ - return kills; - } - public void addKill(){ kills++; } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightTeam.java b/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightTeam.java index a8dfbca..544be31 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightTeam.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightTeam.java @@ -44,7 +44,6 @@ import de.steamwar.techhider.ProtocolUtils; import lombok.Getter; import net.md_5.bungee.api.ChatMessageType; import org.bukkit.*; -import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.scoreboard.NameTagVisibility; @@ -58,7 +57,7 @@ public class FightTeam { private static void setKitButton(HotbarKit kit, boolean leader) { if (Kit.getAvailableKits(leader).size() > 1 || Config.PersonalKits) - kit.setItem(1, "CHOOSE_KIT", new ItemBuilder(Material.LEATHER_CHESTPLATE).removeAllAttributes().addEnchantment(Enchantment.DURABILITY, 1).build(), player -> GUI.kitSelection(player, "")); + kit.setItem(1, "CHOOSE_KIT", new ItemBuilder(Material.LEATHER_CHESTPLATE).enchant().build(), player -> GUI.kitSelection(player, "")); else kit.setItem(1, null, null, null); } @@ -66,30 +65,30 @@ public class FightTeam { private static final HotbarKit memberKit = new HotbarKit(); static { setKitButton(memberKit, false); - memberKit.setItem(7, "RESPAWN", new ItemBuilder(Material.BEACON).removeAllAttributes().build(), player -> player.teleport(Objects.requireNonNull(Fight.getPlayerTeam(player)).getSpawn())); + memberKit.setItem(7, "RESPAWN", new ItemBuilder(Material.BEACON).build(), player -> player.teleport(Objects.requireNonNull(Fight.getPlayerTeam(player)).getSpawn())); } private static final HotbarKit notReadyKit = new HotbarKit(memberKit); static { setKitButton(notReadyKit, true); if(!ArenaMode.RankedEvent.contains(Config.mode)){ - notReadyKit.setItem(2, "REQUESTS", new ItemBuilder(Material.PAPER).removeAllAttributes().build(), GUI::chooseJoinRequests); - notReadyKit.setItem(3, "REMOVE_PLAYERS", new ItemBuilder(SWItem.getMaterial("FIREWORK_CHARGE")).removeAllAttributes().build(), GUI::chooseRemove); + notReadyKit.setItem(2, "REQUESTS", new ItemBuilder(Material.PAPER).build(), GUI::chooseJoinRequests); + notReadyKit.setItem(3, "REMOVE_PLAYERS", new ItemBuilder(SWItem.getMaterial("FIREWORK_CHARGE")).build(), GUI::chooseRemove); } if(Config.test()) - notReadyKit.setItem(5, "CHOOSE_SCHEMATIC", new ItemBuilder(SWItem.getMaterial("CAULDRON_ITEM")).removeAllAttributes().addEnchantment(Enchantment.DURABILITY, 1).build(), GUI::preSchemDialog); + notReadyKit.setItem(5, "CHOOSE_SCHEMATIC", new ItemBuilder(SWItem.getMaterial("CAULDRON_ITEM")).enchant().build(), GUI::preSchemDialog); - notReadyKit.setItem(4, "TEAM_NOT_READY", new ItemBuilder(SWItem.getDye(10), (short) 10).removeAllAttributes().addEnchantment(Enchantment.DURABILITY, 1).build(), player -> Objects.requireNonNull(Fight.getPlayerTeam(player)).setReady(true)); + notReadyKit.setItem(4, "TEAM_NOT_READY", new ItemBuilder(SWItem.getDye(10), (short) 10).enchant().build(), player -> Objects.requireNonNull(Fight.getPlayerTeam(player)).setReady(true)); } private static final HotbarKit chooseSchemKit = new HotbarKit(notReadyKit); static { - chooseSchemKit.setItem(4, "CHOOSE_SCHEMATIC", new ItemBuilder(SWItem.getMaterial("CAULDRON_ITEM")).removeAllAttributes().addEnchantment(Enchantment.DURABILITY, 1).build(), GUI::preSchemDialog); + chooseSchemKit.setItem(4, "CHOOSE_SCHEMATIC", new ItemBuilder(SWItem.getMaterial("CAULDRON_ITEM")).enchant().build(), GUI::preSchemDialog); } private static final HotbarKit readyKit = new HotbarKit(memberKit); static { readyKit.setItem(1, null, null, null); - readyKit.setItem(4, "TEAM_READY", new ItemBuilder(SWItem.getDye(8), (short) 8).removeAllAttributes().addEnchantment(Enchantment.DURABILITY,1 ).build(), player -> Objects.requireNonNull(Fight.getPlayerTeam(player)).setReady(false)); + readyKit.setItem(4, "TEAM_READY", new ItemBuilder(SWItem.getDye(8), (short) 8).enchant().build(), player -> Objects.requireNonNull(Fight.getPlayerTeam(player)).setReady(false)); } @Getter diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightWorld.java b/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightWorld.java index 9e246da..6527e51 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightWorld.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightWorld.java @@ -26,6 +26,7 @@ import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependent; import de.steamwar.fightsystem.utils.CraftbukkitWrapper; import de.steamwar.fightsystem.utils.FlatteningWrapper; +import lombok.Getter; import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.WorldCreator; @@ -39,11 +40,8 @@ import java.util.Objects; public class FightWorld extends StateDependent { - private static final boolean paper = Bukkit.getVersion().contains("git-Paper"); - - public static boolean isPaper(){ - return paper; - } + @Getter + private static final boolean PAPER = Bukkit.getVersion().contains("git-Paper"); public FightWorld() { super(ArenaMode.Restartable.contains(Config.mode) || Config.replayserver(), FightState.Schem); diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/fight/HotbarKit.java b/FightSystem_Core/src/de/steamwar/fightsystem/fight/HotbarKit.java index 8310d2c..5bc1d84 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/fight/HotbarKit.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/fight/HotbarKit.java @@ -51,7 +51,7 @@ public class HotbarKit extends Kit { public static final HotbarKit SPECTATOR_KIT = new HotbarKit(); static { for(int i = 0; i < 9; i++) - SPECTATOR_KIT.setItem(i, "JOIN_REQUEST", new ItemBuilder(Material.PAPER).removeAllAttributes().build(), GUI::joinRequest); + SPECTATOR_KIT.setItem(i, "JOIN_REQUEST", new ItemBuilder(Material.PAPER).build(), GUI::joinRequest); } private static final int HOTBAR_SIZE = 9; diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/fight/Kit.java b/FightSystem_Core/src/de/steamwar/fightsystem/fight/Kit.java index 0ba4628..e382909 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/fight/Kit.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/fight/Kit.java @@ -30,6 +30,7 @@ import de.steamwar.inventory.SWInventory; import de.steamwar.inventory.SWItem; import de.steamwar.sql.PersonalKit; import de.steamwar.sql.SteamwarUser; +import lombok.Getter; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.configuration.ConfigurationSection; @@ -69,11 +70,19 @@ public class Kit { } } + @Getter private final String name; + @Getter private final ItemStack[] inventory; + @Getter private final ItemStack[] armor; + @Getter private final Collection<PotionEffect> effects; + /* In which stage is entern allowed? */ + @Getter private final int enterStage; + /* Is this kit allowed to set/handle tnt? */ + @Getter private final boolean tnt; private final boolean leaderAllowed; private final boolean memberAllowed; @@ -140,10 +149,6 @@ public class Kit { return kits; } - public String getName() { - return name; - } - public boolean canUseKit(boolean leader){ if (leader) { return leaderAllowed; @@ -156,10 +161,6 @@ public class Kit { return !memberAllowed; } - public ItemStack[] getInventory() { - return inventory; - } - public boolean contains(ItemStack stack) { for(ItemStack i : inventory) { if(similar(i, stack)) @@ -172,24 +173,6 @@ public class Kit { return false; } - public ItemStack[] getArmor() { - return armor; - } - - public Collection<PotionEffect> getEffects() { - return effects; - } - - /* Is this kit allowed to set/handle tnt? */ - public boolean isTnt(){ - return tnt; - } - - /* In which stage is entern allowed? */ - public int getEnterStage() { - return enterStage; - } - public void toPersonalKit(PersonalKit kit) { kit.setContainer(inventory, armor); } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/listener/ArrowPickup.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/ArrowPickup.java deleted file mode 100644 index 6839a3f..0000000 --- a/FightSystem_Core/src/de/steamwar/fightsystem/listener/ArrowPickup.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - This file is a part of the SteamWar software. - - Copyright (C) 2020 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 <https://www.gnu.org/licenses/>. -*/ - -package de.steamwar.fightsystem.listener; - -import de.steamwar.fightsystem.ArenaMode; -import de.steamwar.fightsystem.states.FightState; -import de.steamwar.fightsystem.states.StateDependentListener; -import de.steamwar.fightsystem.utils.BountifulWrapper; - -public class ArrowPickup { - - public ArrowPickup() { - new StateDependentListener(ArenaMode.All, FightState.All, BountifulWrapper.impl.newDenyArrowPickupListener()); - } -} diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/record/FileRecorder.java b/FightSystem_Core/src/de/steamwar/fightsystem/record/FileRecorder.java index 67d39bc..98933dd 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/record/FileRecorder.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/record/FileRecorder.java @@ -22,19 +22,17 @@ package de.steamwar.fightsystem.record; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependent; +import lombok.Getter; import java.io.*; import java.util.zip.GZIPOutputStream; public class FileRecorder extends StateDependent implements Recorder { + @Getter private static final File file = new File(Config.world.getWorldFolder(), "recording.recording"); private DataOutputStream outputStream; - public static File getFile() { - return file; - } - public FileRecorder(){ super(Config.ReplayID == 0, FightState.Recording); register(); diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/states/FightState.java b/FightSystem_Core/src/de/steamwar/fightsystem/states/FightState.java index 1a75d1a..1d5acf3 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/states/FightState.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/states/FightState.java @@ -19,6 +19,8 @@ package de.steamwar.fightsystem.states; +import lombok.Getter; + import java.util.*; public enum FightState { @@ -48,12 +50,9 @@ public enum FightState { public static final Set<FightState> AntiSpectate = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(SPECTATE))); private static final Map<IStateDependent, Boolean> stateDependentFeatures = new HashMap<>(); + @Getter private static FightState fightState = PRE_LEADER_SETUP; - public static FightState getFightState() { - return fightState; - } - public static void registerStateDependent(IStateDependent stateDependent){ if(stateDependent.enabled().isEmpty()) return; diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/utils/FightStatistics.java b/FightSystem_Core/src/de/steamwar/fightsystem/utils/FightStatistics.java index df12a82..1f46a3a 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/utils/FightStatistics.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/utils/FightStatistics.java @@ -35,6 +35,7 @@ import de.steamwar.network.packets.common.FightEndsPacket; import de.steamwar.sql.Replay; import de.steamwar.sql.SchematicNode; import de.steamwar.sql.SteamwarUser; +import lombok.Getter; import org.bukkit.Bukkit; import java.sql.Timestamp; @@ -46,6 +47,7 @@ import static de.steamwar.sql.Fight.create; public class FightStatistics { + @Getter private static boolean unranked = false; public static void unrank() { @@ -53,10 +55,6 @@ public class FightStatistics { FightUI.addSubtitle("UI_UNRANKED"); } - public static boolean isUnranked() { - return unranked; - } - private Timestamp starttime = Timestamp.from(Instant.now()); public FightStatistics() { diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/utils/FightUI.java b/FightSystem_Core/src/de/steamwar/fightsystem/utils/FightUI.java index da6df9c..122b690 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/utils/FightUI.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/utils/FightUI.java @@ -31,6 +31,7 @@ import de.steamwar.fightsystem.states.OneShotStateDependent; import de.steamwar.fightsystem.states.StateDependentCountdown; import de.steamwar.fightsystem.states.StateDependentTask; import de.steamwar.fightsystem.winconditions.Wincondition; +import lombok.Getter; import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -43,10 +44,8 @@ import java.util.stream.Collectors; public class FightUI { + @Getter private static FightUI instance; - public static FightUI getInstance() { - return instance; - } public FightUI() { new StateDependentTask(ArenaMode.AntiReplay, FightState.All, this::update, 20, 20); diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/utils/ItemBuilder.java b/FightSystem_Core/src/de/steamwar/fightsystem/utils/ItemBuilder.java index e7bac5d..728fb92 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/utils/ItemBuilder.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/utils/ItemBuilder.java @@ -25,51 +25,26 @@ import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; -import java.util.List; - public class ItemBuilder { private final ItemStack item; private final ItemMeta meta; - public ItemBuilder(Material matrial) { - item = new ItemStack(matrial); - meta = item.getItemMeta(); - } - - public ItemBuilder(Material matrial, int amount) { - item = new ItemStack(matrial, amount); + public ItemBuilder(Material material) { + item = new ItemStack(material); meta = item.getItemMeta(); + meta.addItemFlags(ItemFlag.values()); } @SuppressWarnings("deprecation") - public ItemBuilder(Material matrial, short subid) { - item = new ItemStack(matrial, 1, subid); + public ItemBuilder(Material material, short subid) { + item = new ItemStack(material, 1, subid); meta = item.getItemMeta(); + meta.addItemFlags(ItemFlag.values()); } - - public ItemBuilder removeAllAttributes() { - meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES); - meta.addItemFlags(ItemFlag.HIDE_DESTROYS); - meta.addItemFlags(ItemFlag.HIDE_UNBREAKABLE); - meta.addItemFlags(ItemFlag.HIDE_ENCHANTS); - meta.addItemFlags(ItemFlag.HIDE_PLACED_ON); - meta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS); - return this; - } - - public ItemBuilder setDisplayName(String name) { - meta.setDisplayName(name); - return this; - } - - public ItemBuilder addLore(List<String> lore) { - meta.setLore(lore); - return this; - } - - public ItemBuilder addEnchantment(Enchantment enchantment, int level) { - meta.addEnchant(enchantment, level, true); + + public ItemBuilder enchant() { + meta.addEnchant(Enchantment.DURABILITY, 1, true); return this; } @@ -77,5 +52,4 @@ public class ItemBuilder { item.setItemMeta(meta); return item; } - } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/utils/Message.java b/FightSystem_Core/src/de/steamwar/fightsystem/utils/Message.java index a142a7e..9484b64 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/utils/Message.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/utils/Message.java @@ -19,7 +19,11 @@ package de.steamwar.fightsystem.utils; +import lombok.Getter; + +@Getter public class Message { + private final String msg; private final Object[] params; @@ -27,12 +31,4 @@ public class Message { this.msg = msg; this.params = params; } - - public String getMsg() { - return msg; - } - - public Object[] getParams() { - return params; - } } diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/Wincondition.java b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/Wincondition.java index 3f0f58e..3b62aff 100644 --- a/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/Wincondition.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/Wincondition.java @@ -24,6 +24,7 @@ import de.steamwar.fightsystem.countdown.Countdown; import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.states.StateDependentCountdown; +import lombok.Getter; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; @@ -34,8 +35,10 @@ import java.util.stream.Collectors; public abstract class Wincondition { + @Getter protected static WinconditionPercent percentWincondition = null; protected static StateDependentCountdown timeOverCountdown = null; + @Getter protected static final List<PrintableWincondition> printableWinconditions = new ArrayList<>(); private final String windescription; @@ -61,14 +64,6 @@ public abstract class Wincondition { return Fight.getPlayerTeam((LivingEntity) player); } - public static List<PrintableWincondition> getPrintableWinconditions(){ - return printableWinconditions; - } - - public static WinconditionPercent getPercentWincondition() { - return percentWincondition; - } - protected void comparisonWin(ToDoubleFunction<FightTeam> evaluate, String winMessage, String tieMessage) { double max = Fight.teams().stream().mapToDouble(evaluate).max().orElseThrow(() -> new SecurityException("No teams present")); List<FightTeam> teams = Fight.teams().stream().filter(team -> evaluate.applyAsDouble(team) == max).collect(Collectors.toList()); -- 2.39.5