From cd1185c46484cc35347efffb4ebee2bd8affecd9 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Tue, 8 Sep 2020 09:52:25 +0200 Subject: [PATCH 1/2] Simplify multiversioning with removing fall-through code Signed-off-by: Lixfel --- FightSystem_10/pom.xml | 2 +- .../fightsystem/countdown/Countdown_10.java | 30 ---------- .../fightsystem/fight/FightTeam_10.java | 45 --------------- .../listener/BasicListener_10.java | 39 ------------- .../fightsystem/utils/ColorConverter_10.java | 30 ---------- .../fightsystem/utils/TechHider_10.java | 33 ----------- .../fightsystem/utils/WaterRemover_10.java | 30 ---------- FightSystem_12/pom.xml | 2 +- .../fightsystem/countdown/Countdown_12.java | 30 ---------- .../fightsystem/fight/FightTeam_12.java | 7 --- .../listener/BasicListener_12.java | 39 ------------- .../fightsystem/utils/ColorConverter_12.java | 30 ---------- .../fightsystem/utils/TechHider_12.java | 7 --- .../fightsystem/utils/WaterRemover_12.java | 30 ---------- FightSystem_14/pom.xml | 2 +- .../listener/BasicListener_14.java | 39 ------------- .../fightsystem/utils/TechHider_14.java | 7 --- FightSystem_15/pom.xml | 2 +- .../fightsystem/countdown/Countdown_15.java | 30 ---------- .../fightsystem/fight/FightTeam_15.java | 45 --------------- .../listener/BasicListener_15.java | 39 ------------- .../fightsystem/utils/ColorConverter_15.java | 30 ---------- .../fightsystem/utils/TechHider_15.java | 7 --- .../fightsystem/utils/WaterRemover_15.java | 30 ---------- FightSystem_8/pom.xml | 2 +- .../fightsystem/utils/TechHider_8.java | 33 ----------- FightSystem_9/pom.xml | 2 +- .../fightsystem/fight/FightTeam_9.java | 16 ------ .../fightsystem/utils/ColorConverter_9.java | 30 ---------- .../fightsystem/utils/TechHider_9.java | 33 ----------- .../fightsystem/utils/WaterRemover_9.java | 31 ---------- FightSystem_API/pom.xml | 2 +- .../de/steamwar/fightsystem/IFightSystem.java | 8 +-- .../fightsystem/utils/ITechHider.java | 18 ------ FightSystem_Main/pom.xml | 2 +- .../de/steamwar/fightsystem/FightSystem.java | 2 +- .../fightsystem/countdown/Countdown.java | 16 +++--- .../countdown/EnternCountdown.java | 3 +- .../steamwar/fightsystem/fight/FightTeam.java | 55 +++++++----------- .../fightsystem/listener/BasicListener.java | 57 ++++++------------- .../fightsystem/utils/ColorConverter.java | 20 +++---- .../steamwar/fightsystem/utils/TechHider.java | 53 ++++++++--------- .../fightsystem/utils/WaterRemover.java | 15 ++--- 43 files changed, 97 insertions(+), 886 deletions(-) delete mode 100644 FightSystem_10/src/de/steamwar/fightsystem/countdown/Countdown_10.java delete mode 100644 FightSystem_10/src/de/steamwar/fightsystem/fight/FightTeam_10.java delete mode 100644 FightSystem_10/src/de/steamwar/fightsystem/listener/BasicListener_10.java delete mode 100644 FightSystem_10/src/de/steamwar/fightsystem/utils/ColorConverter_10.java delete mode 100644 FightSystem_10/src/de/steamwar/fightsystem/utils/TechHider_10.java delete mode 100644 FightSystem_10/src/de/steamwar/fightsystem/utils/WaterRemover_10.java delete mode 100644 FightSystem_12/src/de/steamwar/fightsystem/countdown/Countdown_12.java delete mode 100644 FightSystem_12/src/de/steamwar/fightsystem/listener/BasicListener_12.java delete mode 100644 FightSystem_12/src/de/steamwar/fightsystem/utils/ColorConverter_12.java delete mode 100644 FightSystem_12/src/de/steamwar/fightsystem/utils/WaterRemover_12.java delete mode 100644 FightSystem_14/src/de/steamwar/fightsystem/listener/BasicListener_14.java delete mode 100644 FightSystem_15/src/de/steamwar/fightsystem/countdown/Countdown_15.java delete mode 100644 FightSystem_15/src/de/steamwar/fightsystem/fight/FightTeam_15.java delete mode 100644 FightSystem_15/src/de/steamwar/fightsystem/listener/BasicListener_15.java delete mode 100644 FightSystem_15/src/de/steamwar/fightsystem/utils/ColorConverter_15.java delete mode 100644 FightSystem_15/src/de/steamwar/fightsystem/utils/WaterRemover_15.java delete mode 100644 FightSystem_8/src/de/steamwar/fightsystem/utils/TechHider_8.java delete mode 100644 FightSystem_9/src/de/steamwar/fightsystem/utils/ColorConverter_9.java delete mode 100644 FightSystem_9/src/de/steamwar/fightsystem/utils/TechHider_9.java delete mode 100644 FightSystem_9/src/de/steamwar/fightsystem/utils/WaterRemover_9.java diff --git a/FightSystem_10/pom.xml b/FightSystem_10/pom.xml index f286ddd..66633c1 100644 --- a/FightSystem_10/pom.xml +++ b/FightSystem_10/pom.xml @@ -51,7 +51,7 @@ steamwar Spigot - 1.0 + 1.10 system ${main.basedir}/lib/Spigot-1.10.jar diff --git a/FightSystem_10/src/de/steamwar/fightsystem/countdown/Countdown_10.java b/FightSystem_10/src/de/steamwar/fightsystem/countdown/Countdown_10.java deleted file mode 100644 index 9eb6e07..0000000 --- a/FightSystem_10/src/de/steamwar/fightsystem/countdown/Countdown_10.java +++ /dev/null @@ -1,30 +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 . -*/ - -package de.steamwar.fightsystem.countdown; - -import org.bukkit.Sound; - -class Countdown_10 { - private Countdown_10(){} - - static Sound getSound(SWSound sound){ - return Countdown_9.getSound(sound); - } -} diff --git a/FightSystem_10/src/de/steamwar/fightsystem/fight/FightTeam_10.java b/FightSystem_10/src/de/steamwar/fightsystem/fight/FightTeam_10.java deleted file mode 100644 index d837087..0000000 --- a/FightSystem_10/src/de/steamwar/fightsystem/fight/FightTeam_10.java +++ /dev/null @@ -1,45 +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 . -*/ - -package de.steamwar.fightsystem.fight; - -import com.sk89q.worldedit.EditSession; -import de.steamwar.sql.NoClipboardException; -import de.steamwar.sql.Schematic; -import org.bukkit.ChatColor; -import org.bukkit.DyeColor; -import org.bukkit.scoreboard.Team; - -import java.io.IOException; - -class FightTeam_10 { - private FightTeam_10(){} - - static void setTeamColor(Team team, ChatColor color) { - FightTeam_9.setTeamColor(team, color); - } - - static void replaceTeamColor(EditSession e, DyeColor c, int cornerX, int cornerY, int cornerZ){ - FightTeam_8.replaceTeamColor(e, c, cornerX, cornerY, cornerZ); - } - - static EditSession pasteSchematic(Schematic schematic, int pasteX, int pasteY, int pasteZ, boolean rotate) throws Schematic.WrongVersionException, IOException, NoClipboardException { - return FightTeam_8.pasteSchematic(schematic, pasteX, pasteY, pasteZ, rotate); - } -} diff --git a/FightSystem_10/src/de/steamwar/fightsystem/listener/BasicListener_10.java b/FightSystem_10/src/de/steamwar/fightsystem/listener/BasicListener_10.java deleted file mode 100644 index 9ffe265..0000000 --- a/FightSystem_10/src/de/steamwar/fightsystem/listener/BasicListener_10.java +++ /dev/null @@ -1,39 +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 . -*/ - -package de.steamwar.fightsystem.listener; - -import net.md_5.bungee.api.chat.BaseComponent; -import org.bukkit.entity.Player; - -class BasicListener_10 { - private BasicListener_10(){} - - static void toActionbar(Player player, BaseComponent... components){ - BasicListener_9.toActionbar(player, components); - } - - static void toChat(Player player, BaseComponent... components){ - BasicListener_9.toChat(player, components); - } - - static void setAttackSpeed(Player player){ - BasicListener_9.setAttackSpeed(player); - } -} diff --git a/FightSystem_10/src/de/steamwar/fightsystem/utils/ColorConverter_10.java b/FightSystem_10/src/de/steamwar/fightsystem/utils/ColorConverter_10.java deleted file mode 100644 index d159eba..0000000 --- a/FightSystem_10/src/de/steamwar/fightsystem/utils/ColorConverter_10.java +++ /dev/null @@ -1,30 +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 . -*/ - -package de.steamwar.fightsystem.utils; - -import org.bukkit.DyeColor; - -class ColorConverter_10 { - private ColorConverter_10(){} - - static DyeColor getSilver(){ - return ColorConverter_8.getSilver(); - } -} diff --git a/FightSystem_10/src/de/steamwar/fightsystem/utils/TechHider_10.java b/FightSystem_10/src/de/steamwar/fightsystem/utils/TechHider_10.java deleted file mode 100644 index bc2530a..0000000 --- a/FightSystem_10/src/de/steamwar/fightsystem/utils/TechHider_10.java +++ /dev/null @@ -1,33 +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 . -*/ - -package de.steamwar.fightsystem.utils; - -import net.minecraft.server.v1_10_R1.PacketPlayOutMapChunk; -import org.bukkit.craftbukkit.v1_10_R1.CraftChunk; -import org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer; -import org.bukkit.entity.Player; - -class TechHider_10 { - private TechHider_10(){} - - static void reloadChunk(Player p, ITechHider.ChunkPos chunk){ - ((CraftPlayer)p).getHandle().playerConnection.sendPacket(new PacketPlayOutMapChunk(((CraftChunk)p.getWorld().getChunkAt(chunk.x(), chunk.z())).getHandle(), 65535)); - } -} diff --git a/FightSystem_10/src/de/steamwar/fightsystem/utils/WaterRemover_10.java b/FightSystem_10/src/de/steamwar/fightsystem/utils/WaterRemover_10.java deleted file mode 100644 index 01f9b70..0000000 --- a/FightSystem_10/src/de/steamwar/fightsystem/utils/WaterRemover_10.java +++ /dev/null @@ -1,30 +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 . -*/ - -package de.steamwar.fightsystem.utils; - -import org.bukkit.block.Block; - -class WaterRemover_10 { - private WaterRemover_10(){} - - static boolean isWater(Block block){ - return WaterRemover_8.isWater(block); - } -} diff --git a/FightSystem_12/pom.xml b/FightSystem_12/pom.xml index 04f32b5..0c0bcba 100644 --- a/FightSystem_12/pom.xml +++ b/FightSystem_12/pom.xml @@ -51,7 +51,7 @@ steamwar Spigot - 1.0 + 1.12 system ${main.basedir}/lib/Spigot-1.12.jar diff --git a/FightSystem_12/src/de/steamwar/fightsystem/countdown/Countdown_12.java b/FightSystem_12/src/de/steamwar/fightsystem/countdown/Countdown_12.java deleted file mode 100644 index 235cd11..0000000 --- a/FightSystem_12/src/de/steamwar/fightsystem/countdown/Countdown_12.java +++ /dev/null @@ -1,30 +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 . -*/ - -package de.steamwar.fightsystem.countdown; - -import org.bukkit.Sound; - -class Countdown_12 { - private Countdown_12(){} - - static Sound getSound(SWSound sound){ - return Countdown_9.getSound(sound); - } -} diff --git a/FightSystem_12/src/de/steamwar/fightsystem/fight/FightTeam_12.java b/FightSystem_12/src/de/steamwar/fightsystem/fight/FightTeam_12.java index 3fcb335..c6138b0 100644 --- a/FightSystem_12/src/de/steamwar/fightsystem/fight/FightTeam_12.java +++ b/FightSystem_12/src/de/steamwar/fightsystem/fight/FightTeam_12.java @@ -25,14 +25,11 @@ import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.regions.CuboidRegion; import de.steamwar.fightsystem.Config; -import de.steamwar.sql.NoClipboardException; -import de.steamwar.sql.Schematic; import org.bukkit.ChatColor; import org.bukkit.DyeColor; import org.bukkit.Material; import org.bukkit.scoreboard.Team; -import java.io.IOException; import java.util.Collections; import java.util.Set; @@ -69,8 +66,4 @@ class FightTeam_12 { } e.flushQueue(); } - - static EditSession pasteSchematic(Schematic schematic, int pasteX, int pasteY, int pasteZ, boolean rotate) throws Schematic.WrongVersionException, IOException, NoClipboardException { - return FightTeam_8.pasteSchematic(schematic, pasteX, pasteY, pasteZ, rotate); - } } diff --git a/FightSystem_12/src/de/steamwar/fightsystem/listener/BasicListener_12.java b/FightSystem_12/src/de/steamwar/fightsystem/listener/BasicListener_12.java deleted file mode 100644 index 37d0afb..0000000 --- a/FightSystem_12/src/de/steamwar/fightsystem/listener/BasicListener_12.java +++ /dev/null @@ -1,39 +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 . -*/ - -package de.steamwar.fightsystem.listener; - -import net.md_5.bungee.api.chat.BaseComponent; -import org.bukkit.entity.Player; - -class BasicListener_12 { - private BasicListener_12(){} - - static void toActionbar(Player player, BaseComponent... components){ - BasicListener_9.toActionbar(player, components); - } - - static void toChat(Player player, BaseComponent... components){ - BasicListener_9.toChat(player, components); - } - - static void setAttackSpeed(Player player){ - BasicListener_9.setAttackSpeed(player); - } -} diff --git a/FightSystem_12/src/de/steamwar/fightsystem/utils/ColorConverter_12.java b/FightSystem_12/src/de/steamwar/fightsystem/utils/ColorConverter_12.java deleted file mode 100644 index adaa4fe..0000000 --- a/FightSystem_12/src/de/steamwar/fightsystem/utils/ColorConverter_12.java +++ /dev/null @@ -1,30 +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 . -*/ - -package de.steamwar.fightsystem.utils; - -import org.bukkit.DyeColor; - -class ColorConverter_12 { - private ColorConverter_12(){} - - static DyeColor getSilver(){ - return ColorConverter_8.getSilver(); - } -} diff --git a/FightSystem_12/src/de/steamwar/fightsystem/utils/TechHider_12.java b/FightSystem_12/src/de/steamwar/fightsystem/utils/TechHider_12.java index 6cff34a..29c9621 100644 --- a/FightSystem_12/src/de/steamwar/fightsystem/utils/TechHider_12.java +++ b/FightSystem_12/src/de/steamwar/fightsystem/utils/TechHider_12.java @@ -31,10 +31,7 @@ import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.IFightSystem; import io.netty.buffer.ByteBuf; import io.netty.buffer.UnpooledByteBufAllocator; -import net.minecraft.server.v1_12_R1.PacketPlayOutMapChunk; import org.bukkit.Bukkit; -import org.bukkit.craftbukkit.v1_12_R1.CraftChunk; -import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer; import org.bukkit.entity.Player; import java.util.List; @@ -47,10 +44,6 @@ class TechHider_12 { private static final short obfuscateShift4 = (short)(Config.ObfuscateWith << 4); - static void reloadChunk(Player p, ITechHider.ChunkPos chunk){ - ((CraftPlayer)p).getHandle().playerConnection.sendPacket(new PacketPlayOutMapChunk(((CraftChunk)p.getWorld().getChunkAt(chunk.x(), chunk.z())).getHandle(), 65535)); - } - static void start(){ chunkHider(); } diff --git a/FightSystem_12/src/de/steamwar/fightsystem/utils/WaterRemover_12.java b/FightSystem_12/src/de/steamwar/fightsystem/utils/WaterRemover_12.java deleted file mode 100644 index 787dfe7..0000000 --- a/FightSystem_12/src/de/steamwar/fightsystem/utils/WaterRemover_12.java +++ /dev/null @@ -1,30 +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 . -*/ - -package de.steamwar.fightsystem.utils; - -import org.bukkit.block.Block; - -class WaterRemover_12 { - private WaterRemover_12(){} - - static boolean isWater(Block block){ - return WaterRemover_8.isWater(block); - } -} diff --git a/FightSystem_14/pom.xml b/FightSystem_14/pom.xml index 3da1829..3d7c934 100644 --- a/FightSystem_14/pom.xml +++ b/FightSystem_14/pom.xml @@ -34,7 +34,7 @@ steamwar Spigot - 1.0 + 1.14 system ${main.basedir}/lib/Spigot-1.14.jar diff --git a/FightSystem_14/src/de/steamwar/fightsystem/listener/BasicListener_14.java b/FightSystem_14/src/de/steamwar/fightsystem/listener/BasicListener_14.java deleted file mode 100644 index d4233be..0000000 --- a/FightSystem_14/src/de/steamwar/fightsystem/listener/BasicListener_14.java +++ /dev/null @@ -1,39 +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 . -*/ - -package de.steamwar.fightsystem.listener; - -import net.md_5.bungee.api.chat.BaseComponent; -import org.bukkit.entity.Player; - -class BasicListener_14 { - private BasicListener_14(){} - - static void toActionbar(Player player, BaseComponent... components){ - BasicListener_9.toActionbar(player, components); - } - - static void toChat(Player player, BaseComponent... components){ - BasicListener_9.toChat(player, components); - } - - static void setAttackSpeed(Player player){ - BasicListener_9.setAttackSpeed(player); - } -} diff --git a/FightSystem_14/src/de/steamwar/fightsystem/utils/TechHider_14.java b/FightSystem_14/src/de/steamwar/fightsystem/utils/TechHider_14.java index ce3107a..aa6af7e 100644 --- a/FightSystem_14/src/de/steamwar/fightsystem/utils/TechHider_14.java +++ b/FightSystem_14/src/de/steamwar/fightsystem/utils/TechHider_14.java @@ -31,9 +31,6 @@ import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.IFightSystem; import io.netty.buffer.ByteBuf; import io.netty.buffer.UnpooledByteBufAllocator; -import net.minecraft.server.v1_14_R1.PacketPlayOutMapChunk; -import org.bukkit.craftbukkit.v1_14_R1.CraftChunk; -import org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer; import org.bukkit.entity.Player; import java.util.List; @@ -43,10 +40,6 @@ import static de.steamwar.fightsystem.utils.ITechHider.bypass; public class TechHider_14 { private TechHider_14(){} - static void reloadChunk(Player p, ITechHider.ChunkPos chunk){ - ((CraftPlayer)p).getHandle().playerConnection.sendPacket(new PacketPlayOutMapChunk(((CraftChunk)p.getWorld().getChunkAt(chunk.x(), chunk.z())).getHandle(), 65535)); - } - static void start(){ chunkHider(); } diff --git a/FightSystem_15/pom.xml b/FightSystem_15/pom.xml index 20b8ba4..8858c54 100644 --- a/FightSystem_15/pom.xml +++ b/FightSystem_15/pom.xml @@ -34,7 +34,7 @@ steamwar Spigot - 1.0 + 1.15 system ${main.basedir}/lib/Spigot-1.15.jar diff --git a/FightSystem_15/src/de/steamwar/fightsystem/countdown/Countdown_15.java b/FightSystem_15/src/de/steamwar/fightsystem/countdown/Countdown_15.java deleted file mode 100644 index 3e16bc8..0000000 --- a/FightSystem_15/src/de/steamwar/fightsystem/countdown/Countdown_15.java +++ /dev/null @@ -1,30 +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 . -*/ - -package de.steamwar.fightsystem.countdown; - -import org.bukkit.Sound; - -class Countdown_15 { - private Countdown_15(){} - - static Sound getSound(SWSound sound){ - return Countdown_14.getSound(sound); - } -} diff --git a/FightSystem_15/src/de/steamwar/fightsystem/fight/FightTeam_15.java b/FightSystem_15/src/de/steamwar/fightsystem/fight/FightTeam_15.java deleted file mode 100644 index a48a5c1..0000000 --- a/FightSystem_15/src/de/steamwar/fightsystem/fight/FightTeam_15.java +++ /dev/null @@ -1,45 +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 . -*/ - -package de.steamwar.fightsystem.fight; - -import com.sk89q.worldedit.EditSession; -import de.steamwar.sql.NoClipboardException; -import de.steamwar.sql.Schematic; -import org.bukkit.ChatColor; -import org.bukkit.DyeColor; -import org.bukkit.scoreboard.Team; - -import java.io.IOException; - -class FightTeam_15 { - private FightTeam_15(){} - - static void setTeamColor(Team team, ChatColor color){ - FightTeam_14.setTeamColor(team, color); - } - - static void replaceTeamColor(EditSession e, DyeColor c, int cornerX, int cornerY, int cornerZ){ - FightTeam_14.replaceTeamColor(e, c, cornerX, cornerY, cornerZ); - } - - static EditSession pasteSchematic(Schematic schematic, int pX, int pY, int pZ, boolean rotate) throws Schematic.WrongVersionException, IOException, NoClipboardException { - return FightTeam_14.pasteSchematic(schematic, pX, pY, pZ, rotate); - } -} diff --git a/FightSystem_15/src/de/steamwar/fightsystem/listener/BasicListener_15.java b/FightSystem_15/src/de/steamwar/fightsystem/listener/BasicListener_15.java deleted file mode 100644 index 616b45c..0000000 --- a/FightSystem_15/src/de/steamwar/fightsystem/listener/BasicListener_15.java +++ /dev/null @@ -1,39 +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 . -*/ - -package de.steamwar.fightsystem.listener; - -import net.md_5.bungee.api.chat.BaseComponent; -import org.bukkit.entity.Player; - -class BasicListener_15 { - private BasicListener_15(){} - - static void toActionbar(Player player, BaseComponent... components){ - BasicListener_9.toActionbar(player, components); - } - - static void toChat(Player player, BaseComponent... components){ - BasicListener_9.toChat(player, components); - } - - static void setAttackSpeed(Player player){ - BasicListener_9.setAttackSpeed(player); - } -} diff --git a/FightSystem_15/src/de/steamwar/fightsystem/utils/ColorConverter_15.java b/FightSystem_15/src/de/steamwar/fightsystem/utils/ColorConverter_15.java deleted file mode 100644 index e087ce1..0000000 --- a/FightSystem_15/src/de/steamwar/fightsystem/utils/ColorConverter_15.java +++ /dev/null @@ -1,30 +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 . -*/ - -package de.steamwar.fightsystem.utils; - -import org.bukkit.DyeColor; - -class ColorConverter_15 { - private ColorConverter_15(){} - - static DyeColor getSilver(){ - return ColorConverter_14.getSilver(); - } -} diff --git a/FightSystem_15/src/de/steamwar/fightsystem/utils/TechHider_15.java b/FightSystem_15/src/de/steamwar/fightsystem/utils/TechHider_15.java index 1e2d231..d8f4e30 100644 --- a/FightSystem_15/src/de/steamwar/fightsystem/utils/TechHider_15.java +++ b/FightSystem_15/src/de/steamwar/fightsystem/utils/TechHider_15.java @@ -36,12 +36,9 @@ import io.netty.buffer.ByteBuf; import io.netty.buffer.UnpooledByteBufAllocator; import net.minecraft.server.v1_15_R1.Block; import net.minecraft.server.v1_15_R1.ChunkSection; -import net.minecraft.server.v1_15_R1.PacketPlayOutMapChunk; import org.bukkit.Bukkit; import org.bukkit.World; -import org.bukkit.craftbukkit.v1_15_R1.CraftChunk; import org.bukkit.craftbukkit.v1_15_R1.CraftWorld; -import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer; import org.bukkit.entity.Player; import java.lang.reflect.InvocationTargetException; @@ -56,10 +53,6 @@ public class TechHider_15 { private static final World WORLD = Bukkit.getWorlds().get(0); private static final WrappedBlockData WRAPPED_BLOCK_DATA = WrappedBlockData.createData(ITechHider.obfuscateMaterial); - static void reloadChunk(Player p, ITechHider.ChunkPos chunk){ - ((CraftPlayer)p).getHandle().playerConnection.sendPacket(new PacketPlayOutMapChunk(((CraftChunk)p.getWorld().getChunkAt(chunk.x(), chunk.z())).getHandle(), 65535)); - } - static void start(){ chunkHider(); } diff --git a/FightSystem_15/src/de/steamwar/fightsystem/utils/WaterRemover_15.java b/FightSystem_15/src/de/steamwar/fightsystem/utils/WaterRemover_15.java deleted file mode 100644 index c876a6a..0000000 --- a/FightSystem_15/src/de/steamwar/fightsystem/utils/WaterRemover_15.java +++ /dev/null @@ -1,30 +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 . -*/ - -package de.steamwar.fightsystem.utils; - -import org.bukkit.block.Block; - -class WaterRemover_15 { - private WaterRemover_15(){} - - static boolean isWater(Block block){ - return WaterRemover_14.isWater(block); - } -} diff --git a/FightSystem_8/pom.xml b/FightSystem_8/pom.xml index 8b1974c..2fabd6f 100644 --- a/FightSystem_8/pom.xml +++ b/FightSystem_8/pom.xml @@ -34,7 +34,7 @@ steamwar Spigot - 1.0 + 1.8 system ${main.basedir}/lib/Spigot-1.8.jar diff --git a/FightSystem_8/src/de/steamwar/fightsystem/utils/TechHider_8.java b/FightSystem_8/src/de/steamwar/fightsystem/utils/TechHider_8.java deleted file mode 100644 index ad86f5b..0000000 --- a/FightSystem_8/src/de/steamwar/fightsystem/utils/TechHider_8.java +++ /dev/null @@ -1,33 +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 . -*/ - -package de.steamwar.fightsystem.utils; - -import net.minecraft.server.v1_8_R3.PacketPlayOutMapChunk; -import org.bukkit.craftbukkit.v1_8_R3.CraftChunk; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; -import org.bukkit.entity.Player; - -class TechHider_8 { - private TechHider_8(){} - - static void reloadChunk(Player p, ITechHider.ChunkPos chunk){ - ((CraftPlayer)p).getHandle().playerConnection.sendPacket(new PacketPlayOutMapChunk(((CraftChunk)p.getWorld().getChunkAt(chunk.x(), chunk.z())).getHandle(), true, 65535)); - } -} diff --git a/FightSystem_9/pom.xml b/FightSystem_9/pom.xml index b57e7a0..769e6c2 100644 --- a/FightSystem_9/pom.xml +++ b/FightSystem_9/pom.xml @@ -51,7 +51,7 @@ steamwar Spigot - 1.0 + 1.9 system ${main.basedir}/lib/Spigot-1.9.jar diff --git a/FightSystem_9/src/de/steamwar/fightsystem/fight/FightTeam_9.java b/FightSystem_9/src/de/steamwar/fightsystem/fight/FightTeam_9.java index 3471dbc..51c04ce 100644 --- a/FightSystem_9/src/de/steamwar/fightsystem/fight/FightTeam_9.java +++ b/FightSystem_9/src/de/steamwar/fightsystem/fight/FightTeam_9.java @@ -19,15 +19,9 @@ package de.steamwar.fightsystem.fight; -import com.sk89q.worldedit.EditSession; -import de.steamwar.sql.NoClipboardException; -import de.steamwar.sql.Schematic; import org.bukkit.ChatColor; -import org.bukkit.DyeColor; import org.bukkit.scoreboard.Team; -import java.io.IOException; - class FightTeam_9 { private FightTeam_9(){} @@ -35,14 +29,4 @@ class FightTeam_9 { FightTeam_8.setTeamColor(team, color); team.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.FOR_OWN_TEAM); } - - static void replaceTeamColor(EditSession e, DyeColor c, int cornerX, int cornerY, int cornerZ){ - FightTeam_8.replaceTeamColor(e, c, cornerX, cornerY, cornerZ); - } - - static EditSession pasteSchematic(Schematic schematic, int pasteX, int pasteY, int pasteZ, boolean rotate) throws Schematic.WrongVersionException, IOException, NoClipboardException { - return FightTeam_8.pasteSchematic(schematic, pasteX, pasteY, pasteZ, rotate); - } - - } diff --git a/FightSystem_9/src/de/steamwar/fightsystem/utils/ColorConverter_9.java b/FightSystem_9/src/de/steamwar/fightsystem/utils/ColorConverter_9.java deleted file mode 100644 index 108999a..0000000 --- a/FightSystem_9/src/de/steamwar/fightsystem/utils/ColorConverter_9.java +++ /dev/null @@ -1,30 +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 . -*/ - -package de.steamwar.fightsystem.utils; - -import org.bukkit.DyeColor; - -class ColorConverter_9 { - private ColorConverter_9(){} - - static DyeColor getSilver(){ - return ColorConverter_8.getSilver(); - } -} diff --git a/FightSystem_9/src/de/steamwar/fightsystem/utils/TechHider_9.java b/FightSystem_9/src/de/steamwar/fightsystem/utils/TechHider_9.java deleted file mode 100644 index 1f49508..0000000 --- a/FightSystem_9/src/de/steamwar/fightsystem/utils/TechHider_9.java +++ /dev/null @@ -1,33 +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 . -*/ - -package de.steamwar.fightsystem.utils; - -import net.minecraft.server.v1_9_R2.PacketPlayOutMapChunk; -import org.bukkit.craftbukkit.v1_9_R2.CraftChunk; -import org.bukkit.craftbukkit.v1_9_R2.entity.CraftPlayer; -import org.bukkit.entity.Player; - -class TechHider_9 { - private TechHider_9(){} - - static void reloadChunk(Player p, ITechHider.ChunkPos chunk){ - ((CraftPlayer)p).getHandle().playerConnection.sendPacket(new PacketPlayOutMapChunk(((CraftChunk)p.getWorld().getChunkAt(chunk.x(), chunk.z())).getHandle(), 65535)); - } -} diff --git a/FightSystem_9/src/de/steamwar/fightsystem/utils/WaterRemover_9.java b/FightSystem_9/src/de/steamwar/fightsystem/utils/WaterRemover_9.java deleted file mode 100644 index 5854183..0000000 --- a/FightSystem_9/src/de/steamwar/fightsystem/utils/WaterRemover_9.java +++ /dev/null @@ -1,31 +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 . -*/ - -package de.steamwar.fightsystem.utils; - -import org.bukkit.Material; -import org.bukkit.block.Block; - -class WaterRemover_9 { - private WaterRemover_9(){} - - static boolean isWater(Block block){ - return WaterRemover_8.isWater(block); - } -} diff --git a/FightSystem_API/pom.xml b/FightSystem_API/pom.xml index 2e7cfd0..a2faacd 100644 --- a/FightSystem_API/pom.xml +++ b/FightSystem_API/pom.xml @@ -34,7 +34,7 @@ steamwar Spigot - 1.0 + 1.12 system ${main.basedir}/lib/Spigot-1.12.jar diff --git a/FightSystem_API/src/de/steamwar/fightsystem/IFightSystem.java b/FightSystem_API/src/de/steamwar/fightsystem/IFightSystem.java index 73a6383..be18926 100644 --- a/FightSystem_API/src/de/steamwar/fightsystem/IFightSystem.java +++ b/FightSystem_API/src/de/steamwar/fightsystem/IFightSystem.java @@ -28,13 +28,11 @@ public class IFightSystem { private IFightSystem(){} private static Plugin plugin; - private static String prefix; private static EventFight eventFight; private static Player eventLeiter; - public static void init(Plugin plugin, String prefix){ + public static void init(Plugin plugin){ IFightSystem.plugin = plugin; - IFightSystem.prefix = prefix; } static void setEventFight(EventFight ef){ eventFight = ef; @@ -46,15 +44,13 @@ public class IFightSystem { public static Plugin getPlugin(){ return plugin; } - public static String getPrefix(){ - return prefix; - } public static EventFight getEventFight(){ return eventFight; } public static Player getEventLeiter(){ return eventLeiter; } + public static void shutdown(String reason){ if(reason != null) Bukkit.broadcastMessage(reason); diff --git a/FightSystem_API/src/de/steamwar/fightsystem/utils/ITechHider.java b/FightSystem_API/src/de/steamwar/fightsystem/utils/ITechHider.java index 382b9ec..4b0d28d 100644 --- a/FightSystem_API/src/de/steamwar/fightsystem/utils/ITechHider.java +++ b/FightSystem_API/src/de/steamwar/fightsystem/utils/ITechHider.java @@ -155,22 +155,4 @@ public class ITechHider { } while (value != 0); return Bytes.toArray(buffer); } - - public static class ChunkPos{ - final int x; - final int z; - - ChunkPos(int x, int z){ - this.x = x; - this.z = z; - } - - final int x(){ - return x; - } - - final int z(){ - return z; - } - } } diff --git a/FightSystem_Main/pom.xml b/FightSystem_Main/pom.xml index 22b8c69..3083862 100644 --- a/FightSystem_Main/pom.xml +++ b/FightSystem_Main/pom.xml @@ -50,7 +50,7 @@ steamwar Spigot - 1.0 + 1.15 system ${main.basedir}/lib/Spigot-1.15.jar diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/FightSystem.java b/FightSystem_Main/src/de/steamwar/fightsystem/FightSystem.java index d27331a..b468442 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/FightSystem.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/FightSystem.java @@ -57,7 +57,7 @@ public class FightSystem extends JavaPlugin { @Override public void onLoad() { setPlugin(this); - IFightSystem.init(this, PREFIX); + IFightSystem.init(this); } @Override diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/countdown/Countdown.java b/FightSystem_Main/src/de/steamwar/fightsystem/countdown/Countdown.java index e217cdf..7b1c2fe 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/countdown/Countdown.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/countdown/Countdown.java @@ -53,18 +53,16 @@ public abstract class Countdown { return null; switch (Core.getVersion()){ - case 15: - return Countdown_15.getSound(sound); - case 14: - return Countdown_14.getSound(sound); - case 10: - return Countdown_10.getSound(sound); - case 9: - return Countdown_9.getSound(sound); case 8: return Countdown_8.getSound(sound); + case 9: + case 10: + case 12: + return Countdown_9.getSound(sound); + case 14: + case 15: default: - return Countdown_12.getSound(sound); + return Countdown_14.getSound(sound); } } diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/countdown/EnternCountdown.java b/FightSystem_Main/src/de/steamwar/fightsystem/countdown/EnternCountdown.java index b8131e1..ca54a2b 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/countdown/EnternCountdown.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/countdown/EnternCountdown.java @@ -23,7 +23,6 @@ import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.fight.FightPlayer; import de.steamwar.fightsystem.listener.BasicListener; -import de.steamwar.fightsystem.utils.ITechHider; import de.steamwar.fightsystem.utils.TechHider; import net.md_5.bungee.api.chat.TextComponent; import org.bukkit.entity.Player; @@ -33,7 +32,7 @@ import java.util.List; public class EnternCountdown extends Countdown { private final FightPlayer fightPlayer; - private List chunkPos; + private List chunkPos; public EnternCountdown(FightPlayer fp) { super(fp.getKit().getEnterStage(), SWSound.BLOCK_NOTE_PLING, false); diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightTeam.java b/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightTeam.java index 415e0a7..6bd4a93 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightTeam.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightTeam.java @@ -166,7 +166,7 @@ public class FightTeam implements IFightTeam{ } public FightPlayer addMember(Player player) { - final List chunksToReload = TechHider.prepareChunkReload(player); + final List chunksToReload = TechHider.prepareChunkReload(player); FightPlayer fightPlayer = new FightPlayer(player, this); players.add(fightPlayer); invited.remove(player); @@ -184,7 +184,7 @@ public class FightTeam implements IFightTeam{ public void removePlayer(Player player) { FightPlayer fightPlayer = getFightPlayer(player); - final List chunksToReload = TechHider.prepareChunkReload(player); + final List chunksToReload = TechHider.prepareChunkReload(player); players.remove(fightPlayer); team.removeEntry(player.getName()); fightPlayer.getPlayer().getInventory().clear(); @@ -269,29 +269,21 @@ public class FightTeam implements IFightTeam{ try { switch(Core.getVersion()){ - case 15: - e = FightTeam_15.pasteSchematic(schem, pasteX, pasteY, pasteZ, rotate); - FightTeam_15.replaceTeamColor(e, c, cornerX, cornerY, cornerZ); - break; - case 14: - e = FightTeam_14.pasteSchematic(schem, pasteX, pasteY, pasteZ, rotate); - FightTeam_14.replaceTeamColor(e, c, cornerX, cornerY, cornerZ); - break; - case 10: - e = FightTeam_10.pasteSchematic(schem, pasteX, pasteY, pasteZ, rotate); - FightTeam_10.replaceTeamColor(e, c, cornerX, cornerY, cornerZ); - break; - case 9: - e = FightTeam_9.pasteSchematic(schem, pasteX, pasteY, pasteZ, rotate); - FightTeam_9.replaceTeamColor(e, c, cornerX, cornerY, cornerZ); - break; case 8: + case 9: + case 10: e = FightTeam_8.pasteSchematic(schem, pasteX, pasteY, pasteZ, rotate); FightTeam_8.replaceTeamColor(e, c, cornerX, cornerY, cornerZ); break; - default: - e = FightTeam_12.pasteSchematic(schem, pasteX, pasteY, pasteZ, rotate); + case 12: + e = FightTeam_8.pasteSchematic(schem, pasteX, pasteY, pasteZ, rotate); FightTeam_12.replaceTeamColor(e, c, cornerX, cornerY, cornerZ); + break; + case 14: + case 15: + default: + e = FightTeam_14.pasteSchematic(schem, pasteX, pasteY, pasteZ, rotate); + FightTeam_14.replaceTeamColor(e, c, cornerX, cornerY, cornerZ); } } catch (Schematic.WrongVersionException ex) { broadcast(FightSystem.PREFIX + "§cDie gewählte Schematic kann nicht in dieser Version geladen werden"); @@ -441,23 +433,20 @@ public class FightTeam implements IFightTeam{ private void setTeamColor(Team team, ChatColor color){ switch(Core.getVersion()){ - case 15: - FightTeam_15.setTeamColor(team, color); - break; - case 14: - FightTeam_14.setTeamColor(team, color); - break; - case 10: - FightTeam_10.setTeamColor(team, color); - break; - case 9: - FightTeam_9.setTeamColor(team, color); - break; case 8: FightTeam_8.setTeamColor(team, color); break; - default: + case 9: + case 10: + FightTeam_9.setTeamColor(team, color); + break; + case 12: FightTeam_12.setTeamColor(team, color); + break; + case 14: + case 15: + default: + FightTeam_14.setTeamColor(team, color); } } diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/BasicListener.java b/FightSystem_Main/src/de/steamwar/fightsystem/listener/BasicListener.java index 9699f4c..4f1484f 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/listener/BasicListener.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/listener/BasicListener.java @@ -47,66 +47,45 @@ public abstract class BasicListener implements Listener, StateDependent { public static void toActionbar(Player player, BaseComponent... components){ switch(Core.getVersion()){ - case 15: - BasicListener_15.toActionbar(player, components); - break; - case 14: - BasicListener_14.toActionbar(player, components); - break; - case 10: - BasicListener_10.toActionbar(player, components); - break; - case 9: - BasicListener_9.toActionbar(player, components); - break; case 8: BasicListener_8.toActionbar(player, components); break; + case 9: + case 10: + case 12: + case 14: + case 15: default: - BasicListener_12.toActionbar(player, components); + BasicListener_9.toActionbar(player, components); } } public static void toChat(Player player, BaseComponent... components){ switch(Core.getVersion()){ - case 15: - BasicListener_15.toChat(player, components); - break; - case 14: - BasicListener_14.toChat(player, components); - break; - case 10: - BasicListener_10.toChat(player, components); - break; - case 9: - BasicListener_9.toChat(player, components); - break; case 8: BasicListener_8.toChat(player, components); break; + case 9: + case 10: + case 12: + case 14: + case 15: default: - BasicListener_12.toChat(player, components); + BasicListener_9.toChat(player, components); } } void setAttackSpeed(Player player){ switch(Core.getVersion()){ - case 15: - BasicListener_15.setAttackSpeed(player); - break; - case 14: - BasicListener_14.setAttackSpeed(player); - break; - case 10: - BasicListener_10.setAttackSpeed(player); - break; - case 9: - BasicListener_9.setAttackSpeed(player); - break; case 8: break; + case 9: + case 10: + case 12: + case 14: + case 15: default: - BasicListener_12.setAttackSpeed(player); + BasicListener_9.setAttackSpeed(player); } } diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/utils/ColorConverter.java b/FightSystem_Main/src/de/steamwar/fightsystem/utils/ColorConverter.java index b57363a..80c1d9d 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/utils/ColorConverter.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/utils/ColorConverter.java @@ -50,23 +50,17 @@ public class ColorConverter { //Rosa 9pink, Braun 3brown switch(Core.getVersion()){ - case 15: - chat2dye.put(ChatColor.GRAY, ColorConverter_15.getSilver()); - break; - case 14: - chat2dye.put(ChatColor.GRAY, ColorConverter_14.getSilver()); - break; - case 10: - chat2dye.put(ChatColor.GRAY, ColorConverter_10.getSilver()); - break; - case 9: - chat2dye.put(ChatColor.GRAY, ColorConverter_9.getSilver()); - break; case 8: + case 9: + case 10: + case 12: chat2dye.put(ChatColor.GRAY, ColorConverter_8.getSilver()); break; + case 14: + case 15: default: - chat2dye.put(ChatColor.GRAY, ColorConverter_12.getSilver()); + chat2dye.put(ChatColor.GRAY, ColorConverter_14.getSilver()); + break; } } diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/utils/TechHider.java b/FightSystem_Main/src/de/steamwar/fightsystem/utils/TechHider.java index e74c3b2..354482b 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/utils/TechHider.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/utils/TechHider.java @@ -30,6 +30,7 @@ import com.comphenix.protocol.wrappers.ChunkCoordIntPair; import com.comphenix.protocol.wrappers.MultiBlockChangeInfo; import com.comphenix.protocol.wrappers.WrappedBlockData; import de.steamwar.core.Core; +import de.steamwar.core.events.ChunkListener; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.IFightSystem; @@ -210,51 +211,47 @@ public class TechHider { }); } - public static List prepareChunkReload(Player p){ + public static List prepareChunkReload(Player p){ if(disabled()) return Collections.emptyList(); - List chunksToReload = new ArrayList<>(); + List chunksToReload = new ArrayList<>(); for(int x = ITechHider.arenaMinX; x <= ITechHider.arenaMaxX; x++) for(int z = ITechHider.arenaMinZ; z <= ITechHider.arenaMaxZ; z++) if(!bypass(p, x, z)) - chunksToReload.add(new ITechHider.ChunkPos(x, z)); + chunksToReload.add(new ChunkPos(x, z)); return chunksToReload; } - public static void reloadChunks(Player p, List chunksToReload){ + public static void reloadChunks(Player p, List chunksToReload){ if(disabled()) return; Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> { - for(ITechHider.ChunkPos chunk : chunksToReload){ + for(ChunkPos chunk : chunksToReload){ if(bypass(p, chunk.x(), chunk.z())) - reloadChunk(p, chunk); + ChunkListener.sendChunk(p, chunk.x(), chunk.z()); } }, 40); } - private static void reloadChunk(Player p, ITechHider.ChunkPos chunk){ - switch(Core.getVersion()){ - case 15: - TechHider_15.reloadChunk(p, chunk); - break; - case 14: - TechHider_14.reloadChunk(p, chunk); - break; - case 10: - TechHider_10.reloadChunk(p, chunk); - break; - case 9: - TechHider_9.reloadChunk(p, chunk); - break; - case 8: - TechHider_8.reloadChunk(p, chunk); - break; - default: - TechHider_12.reloadChunk(p, chunk); - } - } - private static boolean disabled(){ return Config.OnlyPublicSchematics || Config.test() || !Config.TechhiderActive; } + + public static class ChunkPos{ + final int x; + final int z; + + ChunkPos(int x, int z){ + this.x = x; + this.z = z; + } + + final int x(){ + return x; + } + + final int z(){ + return z; + } + } } diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/utils/WaterRemover.java b/FightSystem_Main/src/de/steamwar/fightsystem/utils/WaterRemover.java index 2cfb603..8506394 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/utils/WaterRemover.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/utils/WaterRemover.java @@ -73,18 +73,15 @@ public class WaterRemover { public static boolean isWater(Block block){ switch(Core.getVersion()){ - case 15: - return WaterRemover_15.isWater(block); - case 14: - return WaterRemover_14.isWater(block); - case 10: - return WaterRemover_10.isWater(block); - case 9: - return WaterRemover_9.isWater(block); case 8: + case 9: + case 10: + case 12: return WaterRemover_8.isWater(block); + case 14: + case 15: default: - return WaterRemover_12.isWater(block); + return WaterRemover_14.isWater(block); } } } From 46151ba73f868f3c3a2318eb1d8dc9f4ca7da1b4 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Tue, 8 Sep 2020 15:58:56 +0200 Subject: [PATCH 2/2] Improving multiversion capability Signed-off-by: Lixfel --- .../listener/PersonalKitCreator_14.java | 32 ++++++++++++ .../listener/PickupArrowListener_9.java | 24 ++++----- .../de/steamwar/fightsystem/FightSystem.java | 4 +- ...oryListener.java => GameplayListener.java} | 12 ++--- .../listener/PersonalKitCreator.java | 3 +- .../listener/VersionDependentListener.java | 52 +++++++++++++++++++ 6 files changed, 101 insertions(+), 26 deletions(-) create mode 100644 FightSystem_14/src/de/steamwar/fightsystem/listener/PersonalKitCreator_14.java rename FightSystem_Main/src/de/steamwar/fightsystem/listener/SleepListener.java => FightSystem_9/src/de/steamwar/fightsystem/listener/PickupArrowListener_9.java (71%) rename FightSystem_Main/src/de/steamwar/fightsystem/listener/{ExtendedInventoryListener.java => GameplayListener.java} (80%) create mode 100644 FightSystem_Main/src/de/steamwar/fightsystem/listener/VersionDependentListener.java diff --git a/FightSystem_14/src/de/steamwar/fightsystem/listener/PersonalKitCreator_14.java b/FightSystem_14/src/de/steamwar/fightsystem/listener/PersonalKitCreator_14.java new file mode 100644 index 0000000..f635870 --- /dev/null +++ b/FightSystem_14/src/de/steamwar/fightsystem/listener/PersonalKitCreator_14.java @@ -0,0 +1,32 @@ +/* + 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 . +*/ + +package de.steamwar.fightsystem.listener; + +import org.bukkit.inventory.ItemStack; + +import java.util.Objects; + +class PersonalKitCreator_14 { + private PersonalKitCreator_14(){} + + static boolean hasAttributeModifier(ItemStack stack){ + return stack.hasItemMeta() && Objects.requireNonNull(stack.getItemMeta()).hasAttributeModifiers(); + } +} diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/SleepListener.java b/FightSystem_9/src/de/steamwar/fightsystem/listener/PickupArrowListener_9.java similarity index 71% rename from FightSystem_Main/src/de/steamwar/fightsystem/listener/SleepListener.java rename to FightSystem_9/src/de/steamwar/fightsystem/listener/PickupArrowListener_9.java index 7fd7b9c..19a547a 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/listener/SleepListener.java +++ b/FightSystem_9/src/de/steamwar/fightsystem/listener/PickupArrowListener_9.java @@ -1,6 +1,6 @@ -/* +/* 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 @@ -19,20 +19,14 @@ package de.steamwar.fightsystem.listener; -import de.steamwar.fightsystem.states.FightState; import org.bukkit.event.EventHandler; -import org.bukkit.event.player.PlayerBedEnterEvent; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerPickupArrowEvent; -import java.util.EnumSet; +class PickupArrowListener_9 implements Listener { -public class SleepListener extends BasicListener{ - - public SleepListener() { - super(EnumSet.allOf(FightState.class)); - } - - @EventHandler - public void onSleep(PlayerBedEnterEvent e) { - e.setCancelled(true); - } + @EventHandler + public void onArrowPickup(PlayerPickupArrowEvent e){ + e.setCancelled(true); + } } diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/FightSystem.java b/FightSystem_Main/src/de/steamwar/fightsystem/FightSystem.java index b468442..57e904f 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/FightSystem.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/FightSystem.java @@ -93,10 +93,10 @@ public class FightSystem extends JavaPlugin { new TestListener(); new NormalJoinListener(); new RankedJoinListener(); - new SleepListener(); + new GameplayListener(); new PersonalKitCreator(); if(Core.getVersion() > 8) - new ExtendedInventoryListener(); + new VersionDependentListener(); new EnterHandler(); diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/ExtendedInventoryListener.java b/FightSystem_Main/src/de/steamwar/fightsystem/listener/GameplayListener.java similarity index 80% rename from FightSystem_Main/src/de/steamwar/fightsystem/listener/ExtendedInventoryListener.java rename to FightSystem_Main/src/de/steamwar/fightsystem/listener/GameplayListener.java index c25c867..0b6ef8d 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/listener/ExtendedInventoryListener.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/listener/GameplayListener.java @@ -20,23 +20,21 @@ package de.steamwar.fightsystem.listener; import de.steamwar.fightsystem.states.FightState; -import org.bukkit.Material; import org.bukkit.event.EventHandler; import org.bukkit.event.inventory.CraftItemEvent; import org.bukkit.event.inventory.FurnaceSmeltEvent; -import org.bukkit.event.player.PlayerPickupArrowEvent; -import org.bukkit.inventory.ItemStack; +import org.bukkit.event.player.PlayerBedEnterEvent; import java.util.EnumSet; -public class ExtendedInventoryListener extends BasicListener { +public class GameplayListener extends BasicListener{ - public ExtendedInventoryListener() { + public GameplayListener() { super(EnumSet.allOf(FightState.class)); } @EventHandler - public void onArrowPickup(PlayerPickupArrowEvent e){ + public void onSleep(PlayerBedEnterEvent e) { e.setCancelled(true); } @@ -47,6 +45,6 @@ public class ExtendedInventoryListener extends BasicListener { @EventHandler public void onFurnace(FurnaceSmeltEvent e){ - e.setResult(new ItemStack(Material.AIR)); + e.setCancelled(true); } } diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/PersonalKitCreator.java b/FightSystem_Main/src/de/steamwar/fightsystem/listener/PersonalKitCreator.java index 803c661..c593dae 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/listener/PersonalKitCreator.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/listener/PersonalKitCreator.java @@ -46,7 +46,6 @@ import org.bukkit.inventory.PlayerInventory; import java.util.EnumSet; import java.util.HashMap; import java.util.Map; -import java.util.Objects; import java.util.logging.Level; public class PersonalKitCreator extends BasicListener { @@ -156,7 +155,7 @@ public class PersonalKitCreator extends BasicListener { return true; //Check for attribute modifiers - if(Core.getVersion() >= 14 && stack.hasItemMeta() && Objects.requireNonNull(stack.getItemMeta()).hasAttributeModifiers()){ + if(Core.getVersion() >= 14 && PersonalKitCreator_14.hasAttributeModifier(stack)){ Bukkit.getLogger().log(Level.SEVERE, "Spieler " + player.getName() + " hat versucht ein Item mit einem Attribute-Modifier zu bekommen."); return true; } diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/VersionDependentListener.java b/FightSystem_Main/src/de/steamwar/fightsystem/listener/VersionDependentListener.java new file mode 100644 index 0000000..55cd3d0 --- /dev/null +++ b/FightSystem_Main/src/de/steamwar/fightsystem/listener/VersionDependentListener.java @@ -0,0 +1,52 @@ +/* + 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 . +*/ + +package de.steamwar.fightsystem.listener; + +import de.steamwar.core.Core; +import de.steamwar.fightsystem.FightSystem; +import de.steamwar.fightsystem.states.FightState; +import org.bukkit.Bukkit; +import org.bukkit.event.HandlerList; +import org.bukkit.event.Listener; + +import java.util.*; + +public class VersionDependentListener extends BasicListener { + + private final List listeners = new ArrayList<>(); + + public VersionDependentListener() { + super(EnumSet.allOf(FightState.class)); + if(Core.getVersion() > 8) + listeners.add(new PickupArrowListener_9()); + } + + @Override + public void enable() { + for(Listener listener : listeners) + Bukkit.getPluginManager().registerEvents(listener, FightSystem.getPlugin()); + } + + @Override + public void disable() { + for(Listener listener : listeners) + HandlerList.unregisterAll(listener); + } +}