diff --git a/FightSystem_10/pom.xml b/FightSystem_10/pom.xml index 66633c1..3e87409 100644 --- a/FightSystem_10/pom.xml +++ b/FightSystem_10/pom.xml @@ -17,28 +17,10 @@ FightSystem_10 1.0 - - src - - - src - - **/*.java - **/*.kt - - - - - steamwar - FightSystem_9 - 1.0 - - - steamwar - FightSystem_API + FightSystem_Core 1.0 diff --git a/FightSystem_10/src/de/steamwar/fightsystem/listener/PersonalKitCreator_10.java b/FightSystem_10/src/de/steamwar/fightsystem/listener/PersonalKitCreator_10.java deleted file mode 100644 index d02d944..0000000 --- a/FightSystem_10/src/de/steamwar/fightsystem/listener/PersonalKitCreator_10.java +++ /dev/null @@ -1,36 +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 org.bukkit.craftbukkit.v1_10_R1.inventory.CraftItemStack; -import org.bukkit.inventory.ItemStack; - -import java.util.HashSet; -import java.util.Set; - -public class PersonalKitCreator_10 { - - public static boolean hasItems(ItemStack stack){ - Set keys = new HashSet<>(CraftItemStack.asNMSCopy(stack).getTag().c()); - keys.remove("Enchantments"); - keys.remove("Damage"); - return !keys.isEmpty(); - } -} diff --git a/FightSystem_10/src/de/steamwar/fightsystem/fight/FightWorld_10.java b/FightSystem_10/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper10.java similarity index 69% rename from FightSystem_10/src/de/steamwar/fightsystem/fight/FightWorld_10.java rename to FightSystem_10/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper10.java index 849b070..3e20fe9 100644 --- a/FightSystem_10/src/de/steamwar/fightsystem/fight/FightWorld_10.java +++ b/FightSystem_10/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper10.java @@ -1,7 +1,7 @@ /* This file is a part of the SteamWar software. - Copyright (C) 2020 SteamWar.de-Serverteam + Copyright (C) 2021 SteamWar.de-Serverteam This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by @@ -15,24 +15,29 @@ 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; +package de.steamwar.fightsystem.utils; import de.steamwar.core.events.ChunkListener; +import de.steamwar.fightsystem.fight.FightWorld; import net.minecraft.server.v1_10_R1.Chunk; import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.craftbukkit.v1_10_R1.CraftWorld; import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity; import org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer; +import org.bukkit.craftbukkit.v1_10_R1.inventory.CraftItemStack; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; -public class FightWorld_10 { - private FightWorld_10(){} +import java.util.HashSet; +import java.util.Set; - static void resetChunk(World world, World backup, int x, int z, boolean isPaper){ +public class CraftbukkitWrapper10 implements CraftbukkitWrapper.ICraftbukkitWrapper { + @Override + public void resetChunk(World world, World backup, int x, int z) { net.minecraft.server.v1_10_R1.World w = ((CraftWorld) world).getHandle(); Chunk chunk = w.getChunkAt(x, z); Chunk backupChunk = ((CraftWorld) backup).getHandle().getChunkAt(x, z); @@ -40,7 +45,7 @@ public class FightWorld_10 { 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 (!isPaper) { + if (!FightWorld.isPaper()) { w.tileEntityList.removeAll(chunk.tileEntities.values()); } chunk.tileEntities.clear(); @@ -50,11 +55,21 @@ public class FightWorld_10 { } } - public static void sendResourcePack(Player player, String pack, String sha1){ + @Override + public void sendResourcePack(Player player, String pack, String sha1) { ((CraftPlayer)player).getHandle().setResourcePack(pack, sha1); } - public static float headRotation(Entity e){ + @Override + public float headRotation(Entity e) { return ((CraftEntity)e).getHandle().getHeadRotation(); } + + @Override + public boolean hasItems(ItemStack stack) { + Set keys = new HashSet<>(CraftItemStack.asNMSCopy(stack).getTag().c()); + keys.remove("Enchantments"); + keys.remove("Damage"); + return !keys.isEmpty(); + } } diff --git a/FightSystem_12/pom.xml b/FightSystem_12/pom.xml index 0c0bcba..e5c8537 100644 --- a/FightSystem_12/pom.xml +++ b/FightSystem_12/pom.xml @@ -17,28 +17,15 @@ FightSystem_12 1.0 - - src - - - src - - **/*.java - **/*.kt - - - - - steamwar - FightSystem_10 + FightSystem_8 1.0 steamwar - FightSystem_API + FightSystem_Core 1.0 diff --git a/FightSystem_9/src/de/steamwar/fightsystem/fight/FightTeam_9.java b/FightSystem_12/src/de/steamwar/fightsystem/fight/FightTeam12.java similarity index 78% rename from FightSystem_9/src/de/steamwar/fightsystem/fight/FightTeam_9.java rename to FightSystem_12/src/de/steamwar/fightsystem/fight/FightTeam12.java index 51c04ce..7f24260 100644 --- a/FightSystem_9/src/de/steamwar/fightsystem/fight/FightTeam_9.java +++ b/FightSystem_12/src/de/steamwar/fightsystem/fight/FightTeam12.java @@ -22,11 +22,10 @@ package de.steamwar.fightsystem.fight; import org.bukkit.ChatColor; import org.bukkit.scoreboard.Team; -class FightTeam_9 { - private FightTeam_9(){} +public class FightTeam12 implements FightTeam.IFightTeam { - static void setTeamColor(Team team, ChatColor color){ - FightTeam_8.setTeamColor(team, color); - team.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.FOR_OWN_TEAM); + @Override + public void setTeamColor(Team team, ChatColor color){ + team.setColor(color); } } diff --git a/FightSystem_12/src/de/steamwar/fightsystem/listener/ArrowStopper12.java b/FightSystem_12/src/de/steamwar/fightsystem/listener/ArrowStopper12.java new file mode 100644 index 0000000..08b42cc --- /dev/null +++ b/FightSystem_12/src/de/steamwar/fightsystem/listener/ArrowStopper12.java @@ -0,0 +1,30 @@ +/* + This file is a part of the SteamWar software. + + Copyright (C) 2021 SteamWar.de-Serverteam + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ + +package de.steamwar.fightsystem.listener; + +import org.bukkit.entity.Arrow; + +public class ArrowStopper12 implements ArrowStopper.IArrowStopper { + + @Override + public boolean isInBlock(Arrow e) { + return e.isInBlock(); + } +} diff --git a/FightSystem_12/src/de/steamwar/fightsystem/listener/PersonalKitCreator_12.java b/FightSystem_12/src/de/steamwar/fightsystem/listener/PersonalKitCreator_12.java deleted file mode 100644 index a76bdc8..0000000 --- a/FightSystem_12/src/de/steamwar/fightsystem/listener/PersonalKitCreator_12.java +++ /dev/null @@ -1,36 +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 org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack; -import org.bukkit.inventory.ItemStack; - -import java.util.HashSet; -import java.util.Set; - -public class PersonalKitCreator_12 { - - public static boolean hasItems(ItemStack stack){ - Set keys = new HashSet<>(CraftItemStack.asNMSCopy(stack).getTag().c()); - keys.remove("Enchantments"); - keys.remove("Damage"); - return !keys.isEmpty(); - } -} \ No newline at end of file diff --git a/FightSystem_12/src/de/steamwar/fightsystem/fight/FightWorld_12.java b/FightSystem_12/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper12.java similarity index 69% rename from FightSystem_12/src/de/steamwar/fightsystem/fight/FightWorld_12.java rename to FightSystem_12/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper12.java index be3596e..1c03c20 100644 --- a/FightSystem_12/src/de/steamwar/fightsystem/fight/FightWorld_12.java +++ b/FightSystem_12/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper12.java @@ -1,7 +1,7 @@ /* This file is a part of the SteamWar software. - Copyright (C) 2020 SteamWar.de-Serverteam + Copyright (C) 2021 SteamWar.de-Serverteam This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by @@ -15,24 +15,29 @@ 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; +package de.steamwar.fightsystem.utils; import de.steamwar.core.events.ChunkListener; +import de.steamwar.fightsystem.fight.FightWorld; import net.minecraft.server.v1_12_R1.Chunk; import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.craftbukkit.v1_12_R1.CraftWorld; import org.bukkit.craftbukkit.v1_12_R1.entity.CraftEntity; import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer; +import org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; -public class FightWorld_12 { - private FightWorld_12(){} +import java.util.HashSet; +import java.util.Set; - static void resetChunk(World world, World backup, int x, int z, boolean isPaper){ +public class CraftbukkitWrapper12 implements CraftbukkitWrapper.ICraftbukkitWrapper { + @Override + public void resetChunk(World world, World backup, int x, int z) { net.minecraft.server.v1_12_R1.World w = ((CraftWorld) world).getHandle(); Chunk chunk = w.getChunkAt(x, z); Chunk backupChunk = ((CraftWorld) backup).getHandle().getChunkAt(x, z); @@ -40,7 +45,7 @@ public class FightWorld_12 { 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 (!isPaper) { + if (!FightWorld.isPaper()) { w.tileEntityList.removeAll(chunk.tileEntities.values()); } chunk.tileEntities.clear(); @@ -50,11 +55,21 @@ public class FightWorld_12 { } } - public static void sendResourcePack(Player player, String pack, String sha1){ + @Override + public void sendResourcePack(Player player, String pack, String sha1) { ((CraftPlayer)player).getHandle().setResourcePack(pack, sha1); } - public static float headRotation(Entity e){ + @Override + public float headRotation(Entity e) { return ((CraftEntity)e).getHandle().getHeadRotation(); } + + @Override + public boolean hasItems(ItemStack stack) { + Set keys = new HashSet<>(CraftItemStack.asNMSCopy(stack).getTag().c()); + keys.remove("Enchantments"); + keys.remove("Damage"); + return !keys.isEmpty(); + } } diff --git a/FightSystem_12/src/de/steamwar/fightsystem/utils/TechHider12.java b/FightSystem_12/src/de/steamwar/fightsystem/utils/TechHider12.java new file mode 100644 index 0000000..3f4ec39 --- /dev/null +++ b/FightSystem_12/src/de/steamwar/fightsystem/utils/TechHider12.java @@ -0,0 +1,124 @@ +/* + 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 com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketAdapter; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.events.PacketEvent; +import com.comphenix.protocol.reflect.StructureModifier; +import com.comphenix.protocol.wrappers.nbt.NbtBase; +import com.comphenix.protocol.wrappers.nbt.NbtCompound; +import de.steamwar.fightsystem.Config; +import de.steamwar.fightsystem.FightSystem; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; + +import java.util.List; +import java.util.Set; +import java.util.logging.Level; + +import static de.steamwar.fightsystem.utils.ITechHider.bypass; + +public class TechHider12 extends PacketAdapter { + + private final Set hiddenBlockIds = BlockIdWrapper.impl.getHiddenBlockIds(); + private final int obfuscateWith = BlockIdWrapper.impl.getObfuscateWith(); + + public TechHider12() { + super(FightSystem.getPlugin(), PacketType.Play.Server.MAP_CHUNK); + } + + @Override + public void onPacketSending(PacketEvent e) { + PacketContainer packet = e.getPacket(); + StructureModifier ints = packet.getIntegers(); + + int chunkX = ints.read(0); + int chunkZ = ints.read(1); + Player p = e.getPlayer(); + if(bypass(p, chunkX, chunkZ)) + return; + + packet = packet.shallowClone(); + e.setPacket(packet); + StructureModifier>> list = packet.getListNbtModifier(); + List> nmsTags = list.read(0); + boolean changed = false; + for(int i = nmsTags.size() - 1; i >= 0; i--){ + NbtCompound nbt = (NbtCompound)nmsTags.get(i); + if(Config.HiddenBlockEntities.contains(nbt.getString("id"))){ + nmsTags.remove(i); + changed = true; + } + } + if(changed) + list.write(0, nmsTags); + + changed = false; + StructureModifier byteArray = packet.getByteArrays(); + byte [] data = byteArray.read(0); + ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.directBuffer(data.length + 100); + int i = 0; + + while(i < data.length){ + byte bitsPerBlock = data[i++]; + buffer.writeByte(bitsPerBlock); + + if(bitsPerBlock != 13){ + int paletteLength = ITechHider.readVarInt(data, i); + int paletteLengthLength = ITechHider.readVarIntLength(data, i); + buffer.writeBytes(data, i, paletteLengthLength); + i += paletteLengthLength; + + for(int actPaletteId = 0; actPaletteId < paletteLength; actPaletteId++){ + int entry = ITechHider.readVarInt(data, i); + i += ITechHider.readVarIntLength(data, i); + + if(hiddenBlockIds.contains(entry)){ + entry = obfuscateWith; + changed = true; + } + buffer.writeBytes(ITechHider.writeVarInt(entry)); + } + }else{ + buffer.writeByte(data[++i]); //Empty palette + Bukkit.getLogger().log(Level.SEVERE, "Full chunk occured"); + } + + int dataArrayLength = ITechHider.readVarInt(data, i); + int dataArrayLengthLength = ITechHider.readVarIntLength(data, i); + buffer.writeBytes(data, i, dataArrayLength*8 + dataArrayLengthLength); + i += dataArrayLengthLength; + i += dataArrayLength * 8; + + buffer.writeBytes(data, i, 4096); + i += 4096; //Skylight (Not in Nether/End!!!) 2048 + Blocklight 2048 + } + + if(changed){ + data = new byte[buffer.readableBytes()]; + buffer.readBytes(data); + byteArray.write(0, data); + } + } +} diff --git a/FightSystem_12/src/de/steamwar/fightsystem/utils/TechHider_12.java b/FightSystem_12/src/de/steamwar/fightsystem/utils/TechHider_12.java deleted file mode 100644 index 4286cd5..0000000 --- a/FightSystem_12/src/de/steamwar/fightsystem/utils/TechHider_12.java +++ /dev/null @@ -1,122 +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 com.comphenix.protocol.PacketType; -import com.comphenix.protocol.events.PacketAdapter; -import com.comphenix.protocol.events.PacketContainer; -import com.comphenix.protocol.events.PacketEvent; -import com.comphenix.protocol.reflect.StructureModifier; -import com.comphenix.protocol.wrappers.nbt.NbtBase; -import com.comphenix.protocol.wrappers.nbt.NbtCompound; -import de.steamwar.fightsystem.Config; -import de.steamwar.fightsystem.IFightSystem; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.UnpooledByteBufAllocator; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; - -import java.util.List; -import java.util.Set; -import java.util.logging.Level; - -import static de.steamwar.fightsystem.utils.ITechHider.bypass; - -class TechHider_12 { - private TechHider_12(){} - - static PacketAdapter chunkHider(Set hiddenBlockIds, int obfuscateWith){ - return new PacketAdapter(IFightSystem.getPlugin(), PacketType.Play.Server.MAP_CHUNK) { - @Override - public void onPacketSending(PacketEvent e) { - PacketContainer packet = e.getPacket(); - StructureModifier ints = packet.getIntegers(); - - int chunkX = ints.read(0); - int chunkZ = ints.read(1); - Player p = e.getPlayer(); - if(bypass(p, chunkX, chunkZ)) - return; - - packet = packet.shallowClone(); - e.setPacket(packet); - StructureModifier>> list = packet.getListNbtModifier(); - List> nmsTags = list.read(0); - boolean changed = false; - for(int i = nmsTags.size() - 1; i >= 0; i--){ - NbtCompound nbt = (NbtCompound)nmsTags.get(i); - if(Config.HiddenBlockEntities.contains(nbt.getString("id"))){ - nmsTags.remove(i); - changed = true; - } - } - if(changed) - list.write(0, nmsTags); - - changed = false; - StructureModifier byteArray = packet.getByteArrays(); - byte [] data = byteArray.read(0); - ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.directBuffer(data.length + 100); - int i = 0; - - while(i < data.length){ - byte bitsPerBlock = data[i++]; - buffer.writeByte(bitsPerBlock); - - if(bitsPerBlock != 13){ - int paletteLength = ITechHider.readVarInt(data, i); - int paletteLengthLength = ITechHider.readVarIntLength(data, i); - buffer.writeBytes(data, i, paletteLengthLength); - i += paletteLengthLength; - - for(int actPaletteId = 0; actPaletteId < paletteLength; actPaletteId++){ - int entry = ITechHider.readVarInt(data, i); - i += ITechHider.readVarIntLength(data, i); - - if(hiddenBlockIds.contains(entry)){ - entry = obfuscateWith; - changed = true; - } - buffer.writeBytes(ITechHider.writeVarInt(entry)); - } - }else{ - buffer.writeByte(data[++i]); //Empty palette - Bukkit.getLogger().log(Level.SEVERE, "Full chunk 1.12 occured"); - } - - int dataArrayLength = ITechHider.readVarInt(data, i); - int dataArrayLengthLength = ITechHider.readVarIntLength(data, i); - buffer.writeBytes(data, i, dataArrayLength*8 + dataArrayLengthLength); - i += dataArrayLengthLength; - i += dataArrayLength * 8; - - buffer.writeBytes(data, i, 4096); - i += 4096; //Skylight (Not in Nether/End!!!) 2048 + Blocklight 2048 - } - - if(changed){ - data = new byte[buffer.readableBytes()]; - buffer.readBytes(data); - byteArray.write(0, data); - } - } - }; - } -} diff --git a/FightSystem_12/src/de/steamwar/fightsystem/fight/FightTeam_12.java b/FightSystem_12/src/de/steamwar/fightsystem/utils/WorldeditWrapper12.java similarity index 75% rename from FightSystem_12/src/de/steamwar/fightsystem/fight/FightTeam_12.java rename to FightSystem_12/src/de/steamwar/fightsystem/utils/WorldeditWrapper12.java index 0f3b5c6..25be503 100644 --- a/FightSystem_12/src/de/steamwar/fightsystem/fight/FightTeam_12.java +++ b/FightSystem_12/src/de/steamwar/fightsystem/utils/WorldeditWrapper12.java @@ -1,7 +1,7 @@ -/* +/* This file is a part of the SteamWar software. - - Copyright (C) 2020 SteamWar.de-Serverteam + + Copyright (C) 2021 SteamWar.de-Serverteam This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by @@ -15,24 +15,18 @@ 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; +package de.steamwar.fightsystem.utils; import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.extent.clipboard.Clipboard; -import org.bukkit.ChatColor; import org.bukkit.DyeColor; import org.bukkit.Material; -import org.bukkit.scoreboard.Team; -import java.util.Collections; -import java.util.Set; - -class FightTeam_12 { - private FightTeam_12(){} +public class WorldeditWrapper12 extends WorldeditWrapper8 { @SuppressWarnings("deprecation") private static final int COLOR_TO_REPLACE = DyeColor.PINK.getWoolData(); @@ -42,16 +36,10 @@ class FightTeam_12 { @SuppressWarnings("deprecation") private static final BaseBlock CONCRETE_POWDER = new BaseBlock(Material.CONCRETE_POWDER.getId(), COLOR_TO_REPLACE); - private static final Set CONCRETE_SET = Collections.singleton(CONCRETE); - private static final Set CONCRETE_POWDER_SET = Collections.singleton(CONCRETE_POWDER); - - static void setTeamColor(Team team, ChatColor color){ - team.setColor(color); - team.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.FOR_OWN_TEAM); - } - - static void replaceTeamColor(Clipboard clipboard, DyeColor c) throws WorldEditException { - FightTeam_8.replaceTeamColor(clipboard, c); + @SuppressWarnings("deprecation") + @Override + public void replaceTeamColor(Clipboard clipboard, DyeColor c) throws WorldEditException { + super.replaceTeamColor(clipboard, c); Vector minimum = clipboard.getRegion().getMinimumPoint(); BaseBlock concrete = new BaseBlock(CONCRETE.getId(), c.getWoolData()); diff --git a/FightSystem_14/pom.xml b/FightSystem_14/pom.xml index 3d7c934..ad025b7 100644 --- a/FightSystem_14/pom.xml +++ b/FightSystem_14/pom.xml @@ -17,19 +17,6 @@ FightSystem_14 1.0 - - src - - - src - - **/*.java - **/*.kt - - - - - steamwar @@ -47,12 +34,7 @@ steamwar - FightSystem_API - 1.0 - - - steamwar - FightSystem_12 + FightSystem_Core 1.0 diff --git a/FightSystem_14/src/de/steamwar/fightsystem/listener/PersonalKitCreator_14.java b/FightSystem_14/src/de/steamwar/fightsystem/listener/PersonalKitCreator_14.java deleted file mode 100644 index 74b3b44..0000000 --- a/FightSystem_14/src/de/steamwar/fightsystem/listener/PersonalKitCreator_14.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 . -*/ - -package de.steamwar.fightsystem.listener; - -import org.bukkit.craftbukkit.v1_14_R1.inventory.CraftItemStack; -import org.bukkit.inventory.ItemStack; - -import java.util.HashSet; -import java.util.Objects; -import java.util.Set; - -public class PersonalKitCreator_14 { - private PersonalKitCreator_14(){} - - public static boolean hasAttributeModifier(ItemStack stack){ - return stack.hasItemMeta() && Objects.requireNonNull(stack.getItemMeta()).hasAttributeModifiers(); - } - - public static boolean hasItems(ItemStack stack){ - Set keys = new HashSet<>(CraftItemStack.asNMSCopy(stack).getTag().getKeys()); - keys.remove("Enchantments"); - keys.remove("Damage"); - return !keys.isEmpty(); - } -} diff --git a/FightSystem_14/src/de/steamwar/fightsystem/listener/WaterRemover_14.java b/FightSystem_14/src/de/steamwar/fightsystem/listener/WaterRemover_14.java deleted file mode 100644 index 3b03787..0000000 --- a/FightSystem_14/src/de/steamwar/fightsystem/listener/WaterRemover_14.java +++ /dev/null @@ -1,59 +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 org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.block.data.BlockData; -import org.bukkit.block.data.Waterlogged; - -class WaterRemover_14 { - private WaterRemover_14(){} - - static boolean isWater(Block block){ - if(block.getType() == Material.WATER) - return true; - - BlockData data = block.getBlockData(); - if(!(data instanceof Waterlogged)) - return false; - - return ((Waterlogged) data).isWaterlogged(); - } - - static boolean removeWater(Block block){ - if(block.getType() == Material.WATER){ - block.setType(Material.AIR); - return true; - } - - BlockData data = block.getBlockData(); - if(!(data instanceof Waterlogged)) - return false; - - Waterlogged waterlogged = (Waterlogged) data; - if(waterlogged.isWaterlogged()){ - block.setType(Material.AIR); - return true; - } - - return false; - } -} diff --git a/FightSystem_14/src/de/steamwar/fightsystem/record/RecordSystem_14.java b/FightSystem_14/src/de/steamwar/fightsystem/utils/BlockIdWrapper14.java similarity index 50% rename from FightSystem_14/src/de/steamwar/fightsystem/record/RecordSystem_14.java rename to FightSystem_14/src/de/steamwar/fightsystem/utils/BlockIdWrapper14.java index 5e65cb4..78101c3 100644 --- a/FightSystem_14/src/de/steamwar/fightsystem/record/RecordSystem_14.java +++ b/FightSystem_14/src/de/steamwar/fightsystem/utils/BlockIdWrapper14.java @@ -1,7 +1,7 @@ /* This file is a part of the SteamWar software. - Copyright (C) 2020 SteamWar.de-Serverteam + Copyright (C) 2021 SteamWar.de-Serverteam This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by @@ -15,33 +15,29 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . -*/ + */ -package de.steamwar.fightsystem.record; +package de.steamwar.fightsystem.utils; -import net.minecraft.server.v1_14_R1.BlockPosition; -import net.minecraft.server.v1_14_R1.EntityPose; -import net.minecraft.server.v1_14_R1.IBlockData; -import net.minecraft.server.v1_14_R1.WorldServer; +import de.steamwar.fightsystem.Config; +import net.minecraft.server.v1_14_R1.*; import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.craftbukkit.v1_14_R1.CraftWorld; import org.bukkit.craftbukkit.v1_14_R1.block.CraftBlock; +import java.util.HashSet; import java.util.Objects; +import java.util.Set; -public class RecordSystem_14 { - private RecordSystem_14(){} - - static int blockToId(Block block){ +public class BlockIdWrapper14 implements BlockIdWrapper.IBlockIdWrapper { + @Override + public int blockToId(Block block) { return net.minecraft.server.v1_14_R1.Block.REGISTRY_ID.getId(((CraftBlock)block).getNMS()); } - static Object getPose(boolean sneaking){ - return sneaking ? EntityPose.SNEAKING : EntityPose.STANDING; - } - - static void setBlock(World world, int x, int y, int z, int blockState){ + @Override + public void setBlock(World world, int x, int y, int z, int blockState) { IBlockData blockData = Objects.requireNonNull(net.minecraft.server.v1_14_R1.Block.REGISTRY_ID.fromId(blockState)); WorldServer cworld = ((CraftWorld)world).getHandle(); BlockPosition pos = new BlockPosition(x, y, z); @@ -49,4 +45,35 @@ public class RecordSystem_14 { cworld.setTypeAndData(pos, blockData, 1042); cworld.getChunkProvider().flagDirty(pos); } + + @Override + public Set getHiddenBlockIds() { + Set hiddenBlockIds = new HashSet<>(); + for(String tag : Config.HiddenBlocks){ + for(IBlockData data : IRegistry.BLOCK.get(new MinecraftKey(tag)).getStates().a()){ + hiddenBlockIds.add(net.minecraft.server.v1_14_R1.Block.getCombinedId(data)); + } + } + + if(Config.HiddenBlocks.contains("water")){ + Fluid water = FluidTypes.WATER.a(false); + for(IBlockData data : net.minecraft.server.v1_14_R1.Block.REGISTRY_ID){ + if(data.p() == water){ + hiddenBlockIds.add(net.minecraft.server.v1_14_R1.Block.getCombinedId(data)); + } + } + } + + return hiddenBlockIds; + } + + @Override + public int getObfuscateWith() { + return net.minecraft.server.v1_14_R1.Block.getCombinedId(IRegistry.BLOCK.get(new MinecraftKey(Config.ObfuscateWith)).getBlockData()); + } + + @Override + public Object getPose(boolean sneaking) { + return sneaking ? EntityPose.SNEAKING : EntityPose.STANDING; + } } diff --git a/FightSystem_14/src/de/steamwar/fightsystem/fight/FightWorld_14.java b/FightSystem_14/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper14.java similarity index 69% rename from FightSystem_14/src/de/steamwar/fightsystem/fight/FightWorld_14.java rename to FightSystem_14/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper14.java index f2b9412..14c5989 100644 --- a/FightSystem_14/src/de/steamwar/fightsystem/fight/FightWorld_14.java +++ b/FightSystem_14/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper14.java @@ -1,7 +1,7 @@ /* This file is a part of the SteamWar software. - Copyright (C) 2020 SteamWar.de-Serverteam + Copyright (C) 2021 SteamWar.de-Serverteam This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by @@ -15,31 +15,36 @@ 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; +package de.steamwar.fightsystem.utils; import de.steamwar.core.events.ChunkListener; +import de.steamwar.fightsystem.fight.FightWorld; import net.minecraft.server.v1_14_R1.Chunk; import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.craftbukkit.v1_14_R1.CraftWorld; import org.bukkit.craftbukkit.v1_14_R1.entity.CraftEntity; import org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer; +import org.bukkit.craftbukkit.v1_14_R1.inventory.CraftItemStack; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; -public class FightWorld_14 { - private FightWorld_14(){} +import java.util.HashSet; +import java.util.Set; - static void resetChunk(World world, World backup, int x, int z, boolean isPaper){ +public class CraftbukkitWrapper14 implements CraftbukkitWrapper.ICraftbukkitWrapper { + @Override + public void resetChunk(World world, World backup, int x, int z) { net.minecraft.server.v1_14_R1.World w = ((CraftWorld) world).getHandle(); Chunk chunk = w.getChunkAt(x, z); Chunk backupChunk = ((CraftWorld) backup).getHandle().getChunkAt(x, z); System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length); w.tileEntityListTick.removeAll(chunk.tileEntities.values()); - if (!isPaper) { + if (!FightWorld.isPaper()) { w.tileEntityList.removeAll(chunk.tileEntities.values()); } chunk.tileEntities.clear(); @@ -51,11 +56,21 @@ public class FightWorld_14 { } } - public static void sendResourcePack(Player player, String pack, String sha1){ + @Override + public void sendResourcePack(Player player, String pack, String sha1) { ((CraftPlayer)player).getHandle().setResourcePack(pack, sha1); } - public static float headRotation(Entity e){ + @Override + public float headRotation(Entity e) { return ((CraftEntity)e).getHandle().getHeadRotation(); } + + @Override + public boolean hasItems(ItemStack stack) { + Set keys = new HashSet<>(CraftItemStack.asNMSCopy(stack).getTag().getKeys()); + keys.remove("Enchantments"); + keys.remove("Damage"); + return !keys.isEmpty(); + } } diff --git a/FightSystem_14/src/de/steamwar/fightsystem/utils/FlatteningWrapper14.java b/FightSystem_14/src/de/steamwar/fightsystem/utils/FlatteningWrapper14.java new file mode 100644 index 0000000..dc3ed90 --- /dev/null +++ b/FightSystem_14/src/de/steamwar/fightsystem/utils/FlatteningWrapper14.java @@ -0,0 +1,111 @@ +/* + This file is a part of the SteamWar software. + + Copyright (C) 2021 SteamWar.de-Serverteam + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ + +package de.steamwar.fightsystem.utils; + +import org.bukkit.DyeColor; +import org.bukkit.Material; +import org.bukkit.World; +import org.bukkit.block.Block; +import org.bukkit.block.data.BlockData; +import org.bukkit.block.data.Waterlogged; +import org.bukkit.event.block.BlockPhysicsEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.BlockDataMeta; +import org.bukkit.inventory.meta.ItemMeta; + +import java.util.Objects; + +public class FlatteningWrapper14 implements FlatteningWrapper.IFlatteningWrapper { + @Override + public DyeColor getSilver() { + return DyeColor.LIGHT_GRAY; + } + + @Override + public boolean isWater(Block block) { + if(block.getType() == Material.WATER) + return true; + + BlockData data = block.getBlockData(); + if(!(data instanceof Waterlogged)) + return false; + + return ((Waterlogged) data).isWaterlogged(); + } + + @Override + public boolean removeWater(Block block) { + if(block.getType() == Material.WATER){ + block.setType(Material.AIR); + return true; + } + + BlockData data = block.getBlockData(); + if(!(data instanceof Waterlogged)) + return false; + + Waterlogged waterlogged = (Waterlogged) data; + if(waterlogged.isWaterlogged()){ + block.setType(Material.AIR); + return true; + } + + return false; + } + + @Override + public boolean containsBlockMeta(ItemMeta meta) { + return meta instanceof BlockDataMeta && ((BlockDataMeta)meta).hasBlockData(); + } + + @Override + public boolean hasAttributeModifier(ItemStack stack) { + return stack.hasItemMeta() && Objects.requireNonNull(stack.getItemMeta()).hasAttributeModifiers(); + } + + @Override + public Material onBreak(Material type) { + switch(type){ + case REDSTONE_WIRE: + return Material.REDSTONE; + case PISTON_HEAD: + return Material.PISTON; + case ICE: + return Material.AIR; + default: + return type; + } + } + + @Override + public boolean doRecord(BlockPhysicsEvent e) { + return e.getBlock() == e.getSourceBlock() || e.getChangedType() == Material.AIR; + } + + @Override + public void forceLoadChunk(World world, int cX, int cZ) { + world.setChunkForceLoaded(cX, cZ, true); + } + + @Override + public boolean checkPistonMoving(Block block) { + return block.getType() == Material.MOVING_PISTON; + } +} diff --git a/FightSystem_14/src/de/steamwar/fightsystem/countdown/Countdown_14.java b/FightSystem_14/src/de/steamwar/fightsystem/utils/SWSound14.java similarity index 78% rename from FightSystem_14/src/de/steamwar/fightsystem/countdown/Countdown_14.java rename to FightSystem_14/src/de/steamwar/fightsystem/utils/SWSound14.java index 0195bdc..77fde1d 100644 --- a/FightSystem_14/src/de/steamwar/fightsystem/countdown/Countdown_14.java +++ b/FightSystem_14/src/de/steamwar/fightsystem/utils/SWSound14.java @@ -1,7 +1,7 @@ -/* +/* This file is a part of the SteamWar software. - - Copyright (C) 2020 SteamWar.de-Serverteam + + Copyright (C) 2021 SteamWar.de-Serverteam This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by @@ -15,16 +15,15 @@ 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; +package de.steamwar.fightsystem.utils; import org.bukkit.Sound; -class Countdown_14 { - private Countdown_14(){} - - static Sound getSound(SWSound sound){ +public class SWSound14 implements SWSound.ISWSound { + @Override + public Sound getSound(SWSound sound) { switch(sound){ case ENTITY_WITHER_DEATH: return Sound.ENTITY_WITHER_DEATH; @@ -32,6 +31,8 @@ class Countdown_14 { return Sound.BLOCK_NOTE_BLOCK_BASS; case BLOCK_NOTE_PLING: return Sound.BLOCK_NOTE_BLOCK_PLING; + case ENTITY_GENERIC_EXPLODE: + return Sound.ENTITY_GENERIC_EXPLODE; default: return null; } diff --git a/FightSystem_14/src/de/steamwar/fightsystem/utils/TechHider14.java b/FightSystem_14/src/de/steamwar/fightsystem/utils/TechHider14.java new file mode 100644 index 0000000..8f6cff3 --- /dev/null +++ b/FightSystem_14/src/de/steamwar/fightsystem/utils/TechHider14.java @@ -0,0 +1,199 @@ +/* + 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 com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketAdapter; +import com.comphenix.protocol.events.PacketContainer; +import com.comphenix.protocol.events.PacketEvent; +import com.comphenix.protocol.reflect.StructureModifier; +import com.comphenix.protocol.wrappers.nbt.NbtBase; +import com.comphenix.protocol.wrappers.nbt.NbtCompound; +import de.steamwar.fightsystem.Config; +import de.steamwar.fightsystem.FightSystem; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; +import org.bukkit.entity.Player; + +import java.nio.ByteBuffer; +import java.nio.LongBuffer; +import java.util.List; +import java.util.Set; + +import static de.steamwar.fightsystem.utils.ITechHider.bypass; + +public class TechHider14 extends PacketAdapter { + + private final Set hiddenBlockIds = BlockIdWrapper.impl.getHiddenBlockIds(); + private final int obfuscateWith = BlockIdWrapper.impl.getObfuscateWith(); + + public TechHider14(){ + super(FightSystem.getPlugin(), PacketType.Play.Server.MAP_CHUNK); + } + + @Override + public void onPacketSending(PacketEvent e) { + PacketContainer packet = e.getPacket(); + StructureModifier ints = packet.getIntegers(); + + int chunkX = ints.read(0); + int chunkZ = ints.read(1); + Player p = e.getPlayer(); + if(bypass(p, chunkX, chunkZ)) + return; + + packet = packet.shallowClone(); + e.setPacket(packet); + StructureModifier>> list = packet.getListNbtModifier(); + List> nmsTags = list.read(0); + boolean changed = false; + for(int i = nmsTags.size() - 1; i >= 0; i--){ + NbtBase nbtBase = nmsTags.get(i); + assert nbtBase instanceof NbtCompound; + NbtCompound nbt = (NbtCompound) nbtBase; + if(Config.HiddenBlockEntities.contains(nbt.getString("id"))){ + nmsTags.remove(i); + changed = true; + } + } + if(changed){ + list.write(0, nmsTags); + } + + changed = false; + StructureModifier byteArray = packet.getByteArrays(); + int primaryBitMask = ints.read(2); + byte[] data = byteArray.read(0); + ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.directBuffer(data.length + 100); + int i = 0; + + //int chunkY = 0; + while(primaryBitMask != 0){ + while((primaryBitMask & 1) == 0){ + primaryBitMask >>= 1; + //chunkY++; + } + + buffer.writeBytes(data, i, 2); // Block count + i += 2; + byte bitsPerBlock = data[i++]; + buffer.writeByte(bitsPerBlock); + + if(bitsPerBlock < 9){ + int paletteLength = ITechHider.readVarInt(data, i); + int paletteLengthLength = ITechHider.readVarIntLength(data, i); + buffer.writeBytes(data, i, paletteLengthLength); + i += paletteLengthLength; + for(int actPaletteId = 0; actPaletteId < paletteLength; actPaletteId++){ + int blockId = ITechHider.readVarInt(data, i); + int actPaletteLength = ITechHider.readVarIntLength(data, i); + + if(hiddenBlockIds.contains(blockId)){ + buffer.writeBytes(ITechHider.writeVarInt(obfuscateWith)); + changed = true; + }else{ + buffer.writeBytes(data, i, actPaletteLength); + } + i += actPaletteLength; + } + + //We modify only the chunk palette for performance reasons + int dataArrayLength = ITechHider.readVarInt(data, i); + int dataArrayLengthLength = ITechHider.readVarIntLength(data, i); + buffer.writeBytes(data, i, dataArrayLength * 8 + dataArrayLengthLength); + i += dataArrayLengthLength; + i += dataArrayLength * 8; + }else{ + //Full Chunk/no palette, so the chunk has to be crawled through + int dataArrayLength = ITechHider.readVarInt(data, i); + int dataArrayLengthLength = ITechHider.readVarIntLength(data, i); + buffer.writeBytes(data, i, dataArrayLengthLength); + i += dataArrayLengthLength; + + ByteBuffer source = ByteBuffer.wrap(data, i, dataArrayLength * 8); + VariableValueArray values = new VariableValueArray(bitsPerBlock, dataArrayLength, source.asLongBuffer()); + + for(int pos = 0; pos < 4096; pos++){ + if(hiddenBlockIds.contains(values.get(pos))){ + changed = true; + values.set(pos, obfuscateWith); + } + } + + for(long l : values.backing) + buffer.writeLong(l); + + i += dataArrayLength * 8; + } + + primaryBitMask >>= 1; + //chunkY++; + } + buffer.writeBytes(data, i, data.length - i); // MC appends a 0 byte at the end if there is a full chunk, idk why + + if(changed){ + data = new byte[buffer.readableBytes()]; + buffer.readBytes(data); + byteArray.write(0, data); + } + } + + private static final class VariableValueArray { + private final long[] backing; + private final int bitsPerValue; + private final long valueMask; + + public VariableValueArray(int bitsPerEntry, int dataArrayLength, LongBuffer buffer) { + this.bitsPerValue = bitsPerEntry; + this.backing = new long[dataArrayLength]; + buffer.get(backing); + this.valueMask = (1L << this.bitsPerValue) - 1; + } + + public int get(int index) { + index *= bitsPerValue; + int i0 = index >> 6; + int i1 = index & 0x3f; + + long value = backing[i0] >>> i1; + + // The value is divided over two long values + if (i1 + bitsPerValue > 64) { + value |= backing[++i0] << 64 - i1; + } + + return (int) (value & valueMask); + } + + public void set(int index, int value) { + index *= bitsPerValue; + int i0 = index >> 6; + int i1 = index & 0x3f; + + backing[i0] = this.backing[i0] & ~(this.valueMask << i1) | (value & valueMask) << i1; + int i2 = i1 + bitsPerValue; + // The value is divided over two long values + if (i2 > 64) { + i0++; + backing[i0] = backing[i0] & -(1L << i2 - 64) | value >> 64 - i1; + } + } + } +} diff --git a/FightSystem_14/src/de/steamwar/fightsystem/utils/TechHider_14.java b/FightSystem_14/src/de/steamwar/fightsystem/utils/TechHider_14.java deleted file mode 100644 index 39546ec..0000000 --- a/FightSystem_14/src/de/steamwar/fightsystem/utils/TechHider_14.java +++ /dev/null @@ -1,226 +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 com.comphenix.protocol.PacketType; -import com.comphenix.protocol.events.PacketAdapter; -import com.comphenix.protocol.events.PacketContainer; -import com.comphenix.protocol.events.PacketEvent; -import com.comphenix.protocol.reflect.StructureModifier; -import com.comphenix.protocol.wrappers.nbt.NbtBase; -import com.comphenix.protocol.wrappers.nbt.NbtCompound; -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.*; -import org.bukkit.entity.Player; - -import java.nio.ByteBuffer; -import java.nio.LongBuffer; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import static de.steamwar.fightsystem.utils.ITechHider.bypass; - -public class TechHider_14 { - private TechHider_14(){} - - static Set getHiddenBlockIds() { - Set hiddenBlockIds = new HashSet<>(); - for(String tag : Config.HiddenBlocks){ - for(IBlockData data : IRegistry.BLOCK.get(new MinecraftKey(tag)).getStates().a()){ - hiddenBlockIds.add(Block.getCombinedId(data)); - } - } - - if(Config.HiddenBlocks.contains("water")){ - Fluid water = FluidTypes.WATER.a(false); - for(IBlockData data : Block.REGISTRY_ID){ - if(data.p() == water){ - hiddenBlockIds.add(Block.getCombinedId(data)); - } - } - } - - return hiddenBlockIds; - } - - static int getObfuscateWith() { - return Block.getCombinedId(IRegistry.BLOCK.get(new MinecraftKey(Config.ObfuscateWith)).getBlockData()); - } - - static PacketAdapter chunkHider(Set hiddenBlockIds, int obfuscateWith){ - /* - * Bevor editing this function read and understand: https://wiki.vg/Chunk_Format - * */ - return new PacketAdapter(IFightSystem.getPlugin(), PacketType.Play.Server.MAP_CHUNK) { - @Override - public void onPacketSending(PacketEvent e) { - PacketContainer packet = e.getPacket(); - StructureModifier ints = packet.getIntegers(); - - int chunkX = ints.read(0); - int chunkZ = ints.read(1); - Player p = e.getPlayer(); - if(bypass(p, chunkX, chunkZ)) - return; - - packet = packet.shallowClone(); - e.setPacket(packet); - StructureModifier>> list = packet.getListNbtModifier(); - List> nmsTags = list.read(0); - boolean changed = false; - for(int i = nmsTags.size() - 1; i >= 0; i--){ - NbtBase nbtBase = nmsTags.get(i); - assert nbtBase instanceof NbtCompound; - NbtCompound nbt = (NbtCompound) nbtBase; - if(Config.HiddenBlockEntities.contains(nbt.getString("id"))){ - nmsTags.remove(i); - changed = true; - } - } - if(changed){ - list.write(0, nmsTags); - } - - changed = false; - StructureModifier byteArray = packet.getByteArrays(); - int primaryBitMask = ints.read(2); - byte[] data = byteArray.read(0); - ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.directBuffer(data.length + 100); - int i = 0; - - int chunkY = 0; - while(primaryBitMask != 0){ - while((primaryBitMask & 1) == 0){ - primaryBitMask >>= 1; - chunkY++; - } - - buffer.writeBytes(data, i, 2); // Block count - i += 2; - byte bitsPerBlock = data[i++]; - buffer.writeByte(bitsPerBlock); - - if(bitsPerBlock < 9){ - int paletteLength = ITechHider.readVarInt(data, i); - int paletteLengthLength = ITechHider.readVarIntLength(data, i); - buffer.writeBytes(data, i, paletteLengthLength); - i += paletteLengthLength; - for(int actPaletteId = 0; actPaletteId < paletteLength; actPaletteId++){ - int blockId = ITechHider.readVarInt(data, i); - int actPaletteLength = ITechHider.readVarIntLength(data, i); - - if(hiddenBlockIds.contains(blockId)){ - buffer.writeBytes(ITechHider.writeVarInt(obfuscateWith)); - changed = true; - }else{ - buffer.writeBytes(data, i, actPaletteLength); - } - i += actPaletteLength; - } - - //We modify only the chunk palette for performance reasons - int dataArrayLength = ITechHider.readVarInt(data, i); - int dataArrayLengthLength = ITechHider.readVarIntLength(data, i); - buffer.writeBytes(data, i, dataArrayLength * 8 + dataArrayLengthLength); - i += dataArrayLengthLength; - i += dataArrayLength * 8; - }else{ - //Full Chunk/no palette, so the chunk has to be crawled through - int dataArrayLength = ITechHider.readVarInt(data, i); - int dataArrayLengthLength = ITechHider.readVarIntLength(data, i); - buffer.writeBytes(data, i, dataArrayLengthLength); - i += dataArrayLengthLength; - - ByteBuffer source = ByteBuffer.wrap(data, i, dataArrayLength * 8); - VariableValueArray values = new VariableValueArray(bitsPerBlock, dataArrayLength, source.asLongBuffer()); - - for(int pos = 0; pos < 4096; pos++){ - if(hiddenBlockIds.contains(values.get(pos))){ - changed = true; - values.set(pos, obfuscateWith); - } - } - - for(long l : values.backing) - buffer.writeLong(l); - - i += dataArrayLength * 8; - } - - primaryBitMask >>= 1; - chunkY++; - } - buffer.writeBytes(data, i, data.length - i); // MC appends a 0 byte at the end if there is a full chunk, idk why - - if(changed){ - data = new byte[buffer.readableBytes()]; - buffer.readBytes(data); - byteArray.write(0, data); - } - } - }; - } - - private static final class VariableValueArray { - private final long[] backing; - private final int bitsPerValue; - private final long valueMask; - - public VariableValueArray(int bitsPerEntry, int dataArrayLength, LongBuffer buffer) { - this.bitsPerValue = bitsPerEntry; - this.backing = new long[dataArrayLength]; - buffer.get(backing); - this.valueMask = (1L << this.bitsPerValue) - 1; - } - - public int get(int index) { - index *= bitsPerValue; - int i0 = index >> 6; - int i1 = index & 0x3f; - - long value = backing[i0] >>> i1; - - // The value is divided over two long values - if (i1 + bitsPerValue > 64) { - value |= backing[++i0] << 64 - i1; - } - - return (int) (value & valueMask); - } - - public void set(int index, int value) { - index *= bitsPerValue; - int i0 = index >> 6; - int i1 = index & 0x3f; - - backing[i0] = this.backing[i0] & ~(this.valueMask << i1) | (value & valueMask) << i1; - int i2 = i1 + bitsPerValue; - // The value is divided over two long values - if (i2 > 64) { - i0++; - backing[i0] = backing[i0] & -(1L << i2 - 64) | value >> 64 - i1; - } - } - } -} diff --git a/FightSystem_14/src/de/steamwar/fightsystem/fight/FightTeam_14.java b/FightSystem_14/src/de/steamwar/fightsystem/utils/WorldeditWrapper14.java similarity index 88% rename from FightSystem_14/src/de/steamwar/fightsystem/fight/FightTeam_14.java rename to FightSystem_14/src/de/steamwar/fightsystem/utils/WorldeditWrapper14.java index 38b0170..aa19d25 100644 --- a/FightSystem_14/src/de/steamwar/fightsystem/fight/FightTeam_14.java +++ b/FightSystem_14/src/de/steamwar/fightsystem/utils/WorldeditWrapper14.java @@ -1,7 +1,7 @@ -/* +/* This file is a part of the SteamWar software. - - Copyright (C) 2020 SteamWar.de-Serverteam + + Copyright (C) 2021 SteamWar.de-Serverteam This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by @@ -15,9 +15,9 @@ 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; +package de.steamwar.fightsystem.utils; import com.sk89q.jnbt.NBTInputStream; import com.sk89q.worldedit.EditSession; @@ -39,21 +39,19 @@ import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockTypes; import de.steamwar.fightsystem.Config; -import de.steamwar.fightsystem.utils.Region; +import de.steamwar.fightsystem.FightSystem; import de.steamwar.sql.Schematic; import org.bukkit.Bukkit; -import org.bukkit.ChatColor; import org.bukkit.DyeColor; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.scoreboard.Team; import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; import java.io.IOException; import java.util.Objects; +import java.util.zip.GZIPInputStream; -public class FightTeam_14 { - private FightTeam_14(){} +public class WorldeditWrapper14 implements WorldeditWrapper.IWorldeditWrapper { private static final BaseBlock WOOL = Objects.requireNonNull(BlockTypes.PINK_WOOL).getDefaultState().toBaseBlock(); private static final BaseBlock CLAY = Objects.requireNonNull(BlockTypes.PINK_TERRACOTTA).getDefaultState().toBaseBlock(); @@ -63,12 +61,8 @@ public class FightTeam_14 { private static final BaseBlock CONCRETE_POWDER = Objects.requireNonNull(BlockTypes.PINK_CONCRETE_POWDER).getDefaultState().toBaseBlock(); private static final BaseBlock CARPET = Objects.requireNonNull(BlockTypes.PINK_CARPET).getDefaultState().toBaseBlock(); - static void setTeamColor(Team team, ChatColor color){ - team.setColor(color); - team.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.FOR_OWN_TEAM); - } - - static void replaceTeamColor(Clipboard clipboard, DyeColor c) throws WorldEditException { + @Override + public void replaceTeamColor(Clipboard clipboard, DyeColor c) throws WorldEditException { BlockVector3 minimum = clipboard.getRegion().getMinimumPoint(); BaseBlock wool = Objects.requireNonNull(BlockTypes.get(c.name().toLowerCase() + "_wool")).getDefaultState().toBaseBlock(); BaseBlock clay = Objects.requireNonNull(BlockTypes.get(c.name().toLowerCase() + "_terracotta")).getDefaultState().toBaseBlock(); @@ -103,7 +97,8 @@ public class FightTeam_14 { } } - static void pasteSchematic(Clipboard clipboard, Region region, boolean rotate) { + @Override + public void pasteSchematic(Clipboard clipboard, Region region, boolean rotate) { BlockVector3 paste = BlockVector3.at(region.centerX(), region.getMinY(), region.centerZ()); World w = new BukkitWorld(Bukkit.getWorlds().get(0)); @@ -135,7 +130,8 @@ public class FightTeam_14 { e.flushSession(); } - static void pasteChar(Clipboard character, int charOffset, int length, int x, int y, int z, AffineTransform aT){ + @Override + public void pasteChar(Clipboard character, int charOffset, int length, int x, int y, int z, AffineTransform aT) { BlockVector3 offset = character.getRegion().getMinimumPoint().subtract(character.getOrigin()); BlockVector3 v = BlockVector3.ZERO.subtract(- charOffset + length / 2, 0, 0).subtract(offset); v = aT.apply(v.toVector3()).toBlockPoint(); @@ -148,15 +144,13 @@ public class FightTeam_14 { e.flushSession(); } - static Clipboard loadSchem(NBTInputStream stream) throws IOException { - return new SpongeSchematicReader(stream).read(); + @Override + public Clipboard loadChar(String charName) throws IOException { + return new SpongeSchematicReader(new NBTInputStream(new GZIPInputStream(new FileInputStream(new File(FightSystem.getPlugin().getDataFolder(), "text/" + charName + ".schem"))))).read(); } - public static boolean checkPistonMoving(Block block){ - return block.getType() == Material.MOVING_PISTON; - } - - public static void saveSchem(Schematic schem, Region region, int minY) { + @Override + public void saveSchem(Schematic schem, Region region, int minY) { World w = new BukkitWorld(Bukkit.getWorlds().get(0)); BlockVector3 min = BlockVector3.at(region.getMinX(), minY, region.getMinZ()); CuboidRegion cuboidRegion = new CuboidRegion(w, min, BlockVector3.at(region.getMaxX(), region.getMaxY(), region.getMaxZ())); diff --git a/FightSystem_15/pom.xml b/FightSystem_15/pom.xml index 8858c54..7aa938d 100644 --- a/FightSystem_15/pom.xml +++ b/FightSystem_15/pom.xml @@ -17,19 +17,6 @@ FightSystem_15 1.0 - - src - - - src - - **/*.java - **/*.kt - - - - - steamwar @@ -47,12 +34,7 @@ steamwar - FightSystem_API - 1.0 - - - steamwar - FightSystem_14 + FightSystem_Core 1.0 diff --git a/FightSystem_15/src/de/steamwar/fightsystem/listener/PersonalKitCreator_15.java b/FightSystem_15/src/de/steamwar/fightsystem/listener/PersonalKitCreator_15.java deleted file mode 100644 index eec0197..0000000 --- a/FightSystem_15/src/de/steamwar/fightsystem/listener/PersonalKitCreator_15.java +++ /dev/null @@ -1,36 +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 org.bukkit.craftbukkit.v1_15_R1.inventory.CraftItemStack; -import org.bukkit.inventory.ItemStack; - -import java.util.HashSet; -import java.util.Set; - -public class PersonalKitCreator_15 { - - public static boolean hasItems(ItemStack stack){ - Set keys = new HashSet<>(CraftItemStack.asNMSCopy(stack).getTag().getKeys()); - keys.remove("Enchantments"); - keys.remove("Damage"); - return !keys.isEmpty(); - } -} diff --git a/FightSystem_15/src/de/steamwar/fightsystem/record/RecordSystem_15.java b/FightSystem_15/src/de/steamwar/fightsystem/utils/BlockIdWrapper15.java similarity index 50% rename from FightSystem_15/src/de/steamwar/fightsystem/record/RecordSystem_15.java rename to FightSystem_15/src/de/steamwar/fightsystem/utils/BlockIdWrapper15.java index db63363..c88034f 100644 --- a/FightSystem_15/src/de/steamwar/fightsystem/record/RecordSystem_15.java +++ b/FightSystem_15/src/de/steamwar/fightsystem/utils/BlockIdWrapper15.java @@ -1,7 +1,7 @@ /* This file is a part of the SteamWar software. - Copyright (C) 2020 SteamWar.de-Serverteam + Copyright (C) 2021 SteamWar.de-Serverteam This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by @@ -15,33 +15,29 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . -*/ + */ -package de.steamwar.fightsystem.record; +package de.steamwar.fightsystem.utils; -import net.minecraft.server.v1_15_R1.BlockPosition; -import net.minecraft.server.v1_15_R1.EntityPose; -import net.minecraft.server.v1_15_R1.IBlockData; -import net.minecraft.server.v1_15_R1.WorldServer; +import de.steamwar.fightsystem.Config; +import net.minecraft.server.v1_15_R1.*; import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.craftbukkit.v1_15_R1.CraftWorld; import org.bukkit.craftbukkit.v1_15_R1.block.CraftBlock; +import java.util.HashSet; import java.util.Objects; +import java.util.Set; -class RecordSystem_15 { - private RecordSystem_15(){} - - static int blockToId(Block block){ +public class BlockIdWrapper15 implements BlockIdWrapper.IBlockIdWrapper { + @Override + public int blockToId(Block block) { return net.minecraft.server.v1_15_R1.Block.REGISTRY_ID.getId(((CraftBlock)block).getNMS()); } - static Object getPose(boolean sneaking){ - return sneaking ? EntityPose.CROUCHING : EntityPose.STANDING; - } - - static void setBlock(World world, int x, int y, int z, int blockState){ + @Override + public void setBlock(World world, int x, int y, int z, int blockState) { IBlockData blockData = Objects.requireNonNull(net.minecraft.server.v1_15_R1.Block.REGISTRY_ID.fromId(blockState)); WorldServer cworld = ((CraftWorld)world).getHandle(); BlockPosition pos = new BlockPosition(x, y, z); @@ -49,4 +45,35 @@ class RecordSystem_15 { cworld.setTypeAndData(pos, blockData, 1042); cworld.getChunkProvider().flagDirty(pos); } + + @Override + public Set getHiddenBlockIds() { + Set hiddenBlockIds = new HashSet<>(); + for(String tag : Config.HiddenBlocks){ + for(IBlockData data : IRegistry.BLOCK.get(new MinecraftKey(tag)).getStates().a()){ + hiddenBlockIds.add(net.minecraft.server.v1_15_R1.Block.getCombinedId(data)); + } + } + + if(Config.HiddenBlocks.contains("water")){ + Fluid water = FluidTypes.WATER.a(false); + for(IBlockData data : net.minecraft.server.v1_15_R1.Block.REGISTRY_ID){ + if(data.getFluid() == water){ + hiddenBlockIds.add(net.minecraft.server.v1_15_R1.Block.getCombinedId(data)); + } + } + } + + return hiddenBlockIds; + } + + @Override + public int getObfuscateWith() { + return net.minecraft.server.v1_15_R1.Block.getCombinedId(IRegistry.BLOCK.get(new MinecraftKey(Config.ObfuscateWith)).getBlockData()); + } + + @Override + public Object getPose(boolean sneaking) { + return sneaking ? EntityPose.CROUCHING : EntityPose.STANDING; + } } diff --git a/FightSystem_15/src/de/steamwar/fightsystem/fight/FightWorld_15.java b/FightSystem_15/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper15.java similarity index 69% rename from FightSystem_15/src/de/steamwar/fightsystem/fight/FightWorld_15.java rename to FightSystem_15/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper15.java index b4c53b8..8d55c47 100644 --- a/FightSystem_15/src/de/steamwar/fightsystem/fight/FightWorld_15.java +++ b/FightSystem_15/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper15.java @@ -1,7 +1,7 @@ /* This file is a part of the SteamWar software. - Copyright (C) 2020 SteamWar.de-Serverteam + Copyright (C) 2021 SteamWar.de-Serverteam This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by @@ -15,31 +15,36 @@ 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; +package de.steamwar.fightsystem.utils; import de.steamwar.core.events.ChunkListener; +import de.steamwar.fightsystem.fight.FightWorld; import net.minecraft.server.v1_15_R1.Chunk; import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.craftbukkit.v1_15_R1.CraftWorld; import org.bukkit.craftbukkit.v1_15_R1.entity.CraftEntity; import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer; +import org.bukkit.craftbukkit.v1_15_R1.inventory.CraftItemStack; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; -public class FightWorld_15 { - private FightWorld_15(){} +import java.util.HashSet; +import java.util.Set; - static void resetChunk(World world, World backup, int x, int z, boolean isPaper){ +public class CraftbukkitWrapper15 implements CraftbukkitWrapper.ICraftbukkitWrapper { + @Override + public void resetChunk(World world, World backup, int x, int z) { net.minecraft.server.v1_15_R1.World w = ((CraftWorld) world).getHandle(); Chunk chunk = w.getChunkAt(x, z); Chunk backupChunk = ((CraftWorld) backup).getHandle().getChunkAt(x, z); System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length); w.tileEntityListTick.removeAll(chunk.tileEntities.values()); - if (!isPaper) { + if (!FightWorld.isPaper()) { w.tileEntityList.removeAll(chunk.tileEntities.values()); } chunk.tileEntities.clear(); @@ -51,11 +56,21 @@ public class FightWorld_15 { } } - public static void sendResourcePack(Player player, String pack, String sha1){ + @Override + public void sendResourcePack(Player player, String pack, String sha1) { ((CraftPlayer)player).getHandle().setResourcePack(pack, sha1); } - public static float headRotation(Entity e){ + @Override + public float headRotation(Entity e) { return ((CraftEntity)e).getHandle().getHeadRotation(); } + + @Override + public boolean hasItems(ItemStack stack) { + Set keys = new HashSet<>(CraftItemStack.asNMSCopy(stack).getTag().getKeys()); + keys.remove("Enchantments"); + keys.remove("Damage"); + return !keys.isEmpty(); + } } diff --git a/FightSystem_15/src/de/steamwar/fightsystem/utils/TechHider_15.java b/FightSystem_15/src/de/steamwar/fightsystem/utils/TechHider_15.java deleted file mode 100644 index e5d5e03..0000000 --- a/FightSystem_15/src/de/steamwar/fightsystem/utils/TechHider_15.java +++ /dev/null @@ -1,54 +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 de.steamwar.fightsystem.Config; -import net.minecraft.server.v1_15_R1.*; - -import java.util.HashSet; -import java.util.Set; - -class TechHider_15 { - private TechHider_15(){} - - static Set getHiddenBlockIds() { - Set hiddenBlockIds = new HashSet<>(); - for(String tag : Config.HiddenBlocks){ - for(IBlockData data : IRegistry.BLOCK.get(new MinecraftKey(tag)).getStates().a()){ - hiddenBlockIds.add(Block.getCombinedId(data)); - } - } - - if(Config.HiddenBlocks.contains("water")){ - Fluid water = FluidTypes.WATER.a(false); - for(IBlockData data : Block.REGISTRY_ID){ - if(data.getFluid() == water){ - hiddenBlockIds.add(Block.getCombinedId(data)); - } - } - } - - return hiddenBlockIds; - } - - static int getObfuscateWith() { - return Block.getCombinedId(IRegistry.BLOCK.get(new MinecraftKey(Config.ObfuscateWith)).getBlockData()); - } -} diff --git a/FightSystem_8/pom.xml b/FightSystem_8/pom.xml index 2fabd6f..3ec6b70 100644 --- a/FightSystem_8/pom.xml +++ b/FightSystem_8/pom.xml @@ -17,19 +17,6 @@ FightSystem_8 1.0 - - src - - - src - - **/*.java - **/*.kt - - - - - steamwar @@ -40,7 +27,7 @@ steamwar - FightSystem_API + FightSystem_Core 1.0 diff --git a/FightSystem_API/src/de/steamwar/fightsystem/fight/IFightTeam.java b/FightSystem_8/src/de/steamwar/fightsystem/fight/FightTeam8.java similarity index 76% rename from FightSystem_API/src/de/steamwar/fightsystem/fight/IFightTeam.java rename to FightSystem_8/src/de/steamwar/fightsystem/fight/FightTeam8.java index 919fa23..de213b8 100644 --- a/FightSystem_API/src/de/steamwar/fightsystem/fight/IFightTeam.java +++ b/FightSystem_8/src/de/steamwar/fightsystem/fight/FightTeam8.java @@ -19,11 +19,14 @@ package de.steamwar.fightsystem.fight; -import org.bukkit.entity.Player; +import org.bukkit.ChatColor; +import org.bukkit.scoreboard.Team; -public interface IFightTeam { +public class FightTeam8 implements FightTeam.IFightTeam { + + @Override + public void setTeamColor(Team team, ChatColor color){ + team.setPrefix("§" + color.getChar()); + } - boolean isBlue(); - boolean isPlayerInTeam(Player player); - boolean canPlayerEntern(Player player); } diff --git a/FightSystem_API/src/de/steamwar/fightsystem/countdown/SWSound.java b/FightSystem_8/src/de/steamwar/fightsystem/listener/ArrowPickup8.java similarity index 79% rename from FightSystem_API/src/de/steamwar/fightsystem/countdown/SWSound.java rename to FightSystem_8/src/de/steamwar/fightsystem/listener/ArrowPickup8.java index 46cd3f8..f5a9c7e 100644 --- a/FightSystem_API/src/de/steamwar/fightsystem/countdown/SWSound.java +++ b/FightSystem_8/src/de/steamwar/fightsystem/listener/ArrowPickup8.java @@ -1,7 +1,7 @@ -/* +/* This file is a part of the SteamWar software. - - Copyright (C) 2020 SteamWar.de-Serverteam + + Copyright (C) 2021 SteamWar.de-Serverteam This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by @@ -15,12 +15,11 @@ 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; +package de.steamwar.fightsystem.listener; -public enum SWSound { - ENTITY_WITHER_DEATH, - BLOCK_NOTE_PLING, - BLOCK_NOTE_BASS +import org.bukkit.event.Listener; + +public class ArrowPickup8 implements Listener { } diff --git a/FightSystem_14/src/de/steamwar/fightsystem/utils/ColorConverter_14.java b/FightSystem_8/src/de/steamwar/fightsystem/listener/ArrowStopper8.java similarity index 73% rename from FightSystem_14/src/de/steamwar/fightsystem/utils/ColorConverter_14.java rename to FightSystem_8/src/de/steamwar/fightsystem/listener/ArrowStopper8.java index af749e0..1c1c96c 100644 --- a/FightSystem_14/src/de/steamwar/fightsystem/utils/ColorConverter_14.java +++ b/FightSystem_8/src/de/steamwar/fightsystem/listener/ArrowStopper8.java @@ -1,7 +1,7 @@ -/* +/* This file is a part of the SteamWar software. - - Copyright (C) 2020 SteamWar.de-Serverteam + + Copyright (C) 2021 SteamWar.de-Serverteam This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by @@ -15,16 +15,15 @@ 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; +package de.steamwar.fightsystem.listener; -import org.bukkit.DyeColor; +import org.bukkit.entity.Arrow; -class ColorConverter_14 { - private ColorConverter_14(){} - - static DyeColor getSilver(){ - return DyeColor.LIGHT_GRAY; +public class ArrowStopper8 implements ArrowStopper.IArrowStopper { + @Override + public boolean isInBlock(Arrow e) { + return false; } } diff --git a/FightSystem_8/src/de/steamwar/fightsystem/utils/ColorConverter_8.java b/FightSystem_8/src/de/steamwar/fightsystem/listener/DenyWorldInteraction8.java similarity index 74% rename from FightSystem_8/src/de/steamwar/fightsystem/utils/ColorConverter_8.java rename to FightSystem_8/src/de/steamwar/fightsystem/listener/DenyWorldInteraction8.java index 3255431..db0b29c 100644 --- a/FightSystem_8/src/de/steamwar/fightsystem/utils/ColorConverter_8.java +++ b/FightSystem_8/src/de/steamwar/fightsystem/listener/DenyWorldInteraction8.java @@ -1,7 +1,7 @@ -/* +/* This file is a part of the SteamWar software. - - Copyright (C) 2020 SteamWar.de-Serverteam + + Copyright (C) 2021 SteamWar.de-Serverteam This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by @@ -15,16 +15,11 @@ 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; +package de.steamwar.fightsystem.listener; -import org.bukkit.DyeColor; +import org.bukkit.event.Listener; -class ColorConverter_8 { - private ColorConverter_8(){} - - static DyeColor getSilver(){ - return DyeColor.SILVER; - } +public class DenyWorldInteraction8 implements Listener { } diff --git a/FightSystem_8/src/de/steamwar/fightsystem/listener/WaterRemover_8.java b/FightSystem_8/src/de/steamwar/fightsystem/listener/WaterRemover_8.java deleted file mode 100644 index 4f7bab9..0000000 --- a/FightSystem_8/src/de/steamwar/fightsystem/listener/WaterRemover_8.java +++ /dev/null @@ -1,40 +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 org.bukkit.Material; -import org.bukkit.block.Block; - -public class WaterRemover_8 { - private WaterRemover_8(){} - - static boolean isWater(Block block){ - Material type = block.getType(); - return type == Material.WATER || type == Material.STATIONARY_WATER; - } - - static boolean removeWater(Block block){ - if(isWater(block)){ - block.setType(Material.AIR); - return true; - } - return false; - } -} diff --git a/FightSystem_8/src/de/steamwar/fightsystem/utils/TechHider_8.java b/FightSystem_8/src/de/steamwar/fightsystem/utils/BlockIdWrapper8.java similarity index 63% rename from FightSystem_8/src/de/steamwar/fightsystem/utils/TechHider_8.java rename to FightSystem_8/src/de/steamwar/fightsystem/utils/BlockIdWrapper8.java index ccf7943..723e2f0 100644 --- a/FightSystem_8/src/de/steamwar/fightsystem/utils/TechHider_8.java +++ b/FightSystem_8/src/de/steamwar/fightsystem/utils/BlockIdWrapper8.java @@ -1,7 +1,7 @@ /* This file is a part of the SteamWar software. - Copyright (C) 2020 SteamWar.de-Serverteam + Copyright (C) 2021 SteamWar.de-Serverteam This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by @@ -15,20 +15,31 @@ 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 de.steamwar.fightsystem.Config; import org.bukkit.Material; +import org.bukkit.World; +import org.bukkit.block.Block; import java.util.HashSet; import java.util.Set; -class TechHider_8 { - private TechHider_8(){} +public class BlockIdWrapper8 implements BlockIdWrapper.IBlockIdWrapper { + @Override + public int blockToId(Block block) { + return block.getTypeId() << 4 + block.getData(); + } - static Set getHiddenBlockIds() { + @Override + public void setBlock(World world, int x, int y, int z, int blockState) { + world.getBlockAt(x, y, z).setTypeIdAndData(blockState >> 4, (byte)(blockState & 0b1111), false); + } + + @Override + public Set getHiddenBlockIds() { Set hiddenBlockIds = new HashSet<>(); for(String tag : Config.HiddenBlocks){ hiddenBlockIds.add(Material.matchMaterial(tag).getId() << 4); @@ -36,7 +47,13 @@ class TechHider_8 { return hiddenBlockIds; } - static int getObfuscateWith() { + @Override + public int getObfuscateWith() { return Material.matchMaterial(Config.ObfuscateWith).getId() << 4; } + + @Override + public Object getPose(boolean sneaking) { + return null; + } } diff --git a/FightSystem_8/src/de/steamwar/fightsystem/utils/BountifulWrapper8.java b/FightSystem_8/src/de/steamwar/fightsystem/utils/BountifulWrapper8.java new file mode 100644 index 0000000..6d9c805 --- /dev/null +++ b/FightSystem_8/src/de/steamwar/fightsystem/utils/BountifulWrapper8.java @@ -0,0 +1,58 @@ +/* + This file is a part of the SteamWar software. + + Copyright (C) 2021 SteamWar.de-Serverteam + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ + +package de.steamwar.fightsystem.utils; + +import com.comphenix.protocol.wrappers.EnumWrappers; +import net.md_5.bungee.api.chat.BaseComponent; +import net.minecraft.server.v1_8_R3.ChatComponentText; +import net.minecraft.server.v1_8_R3.PacketPlayOutChat; +import org.bukkit.Material; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; +import org.bukkit.entity.Player; +import org.bukkit.scoreboard.Team; + +public class BountifulWrapper8 implements BountifulWrapper.IBountifulWrapper { + @Override + public boolean bowInHand(EnumWrappers.Hand hand, Player p) { + return p.getInventory().getItemInHand().getType() == Material.BOW; + } + + @Override + public void toActionbar(Player player, BaseComponent... components) { + PacketPlayOutChat packet = new PacketPlayOutChat(new ChatComponentText(BaseComponent.toLegacyText(components)), (byte)2); + ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet); + } + + @Override + public void toChat(Player player, BaseComponent... components) { + PacketPlayOutChat packet = new PacketPlayOutChat(new ChatComponentText(BaseComponent.toLegacyText(components)), (byte)0); + ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet); + } + + @Override + public void setAttackSpeed(Player player) { + // nothing to do + } + + @Override + public void setNametagVisibility(Team team) { + //nothing to do + } +} diff --git a/FightSystem_8/src/de/steamwar/fightsystem/fight/FightWorld_8.java b/FightSystem_8/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper8.java similarity index 70% rename from FightSystem_8/src/de/steamwar/fightsystem/fight/FightWorld_8.java rename to FightSystem_8/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper8.java index 9d25c29..89aedc7 100644 --- a/FightSystem_8/src/de/steamwar/fightsystem/fight/FightWorld_8.java +++ b/FightSystem_8/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper8.java @@ -1,7 +1,7 @@ /* This file is a part of the SteamWar software. - Copyright (C) 2020 SteamWar.de-Serverteam + Copyright (C) 2021 SteamWar.de-Serverteam This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by @@ -15,9 +15,9 @@ 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; +package de.steamwar.fightsystem.utils; import de.steamwar.core.events.ChunkListener; import net.minecraft.server.v1_8_R3.Chunk; @@ -26,13 +26,17 @@ import org.bukkit.World; import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; +import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; -public class FightWorld_8 { - private FightWorld_8(){} +import java.util.HashSet; +import java.util.Set; - static void resetChunk(World world, World backup, int x, int z, boolean isPaper){ +public class CraftbukkitWrapper8 implements CraftbukkitWrapper.ICraftbukkitWrapper { + @Override + public void resetChunk(World world, World backup, int x, int z) { net.minecraft.server.v1_8_R3.World w = ((CraftWorld) world).getHandle(); Chunk chunk = w.getChunkAt(x, z); Chunk backupChunk = ((CraftWorld) backup).getHandle().getChunkAt(x, z); @@ -47,11 +51,21 @@ public class FightWorld_8 { } } - public static void sendResourcePack(Player player, String pack, String sha1){ + @Override + public void sendResourcePack(Player player, String pack, String sha1) { ((CraftPlayer)player).getHandle().setResourcePack(pack, sha1); } - public static float headRotation(Entity e){ + @Override + public float headRotation(Entity e) { return ((CraftEntity)e).getHandle().getHeadRotation(); } + + @Override + public boolean hasItems(ItemStack stack) { + Set keys = new HashSet<>(CraftItemStack.asNMSCopy(stack).getTag().c()); + keys.remove("Enchantments"); + keys.remove("Damage"); + return !keys.isEmpty(); + } } diff --git a/FightSystem_8/src/de/steamwar/fightsystem/utils/FlatteningWrapper8.java b/FightSystem_8/src/de/steamwar/fightsystem/utils/FlatteningWrapper8.java new file mode 100644 index 0000000..5782625 --- /dev/null +++ b/FightSystem_8/src/de/steamwar/fightsystem/utils/FlatteningWrapper8.java @@ -0,0 +1,89 @@ +/* + This file is a part of the SteamWar software. + + Copyright (C) 2021 SteamWar.de-Serverteam + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ + +package de.steamwar.fightsystem.utils; + +import org.bukkit.DyeColor; +import org.bukkit.Material; +import org.bukkit.World; +import org.bukkit.block.Block; +import org.bukkit.event.block.BlockPhysicsEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +public class FlatteningWrapper8 implements FlatteningWrapper.IFlatteningWrapper { + @Override + public DyeColor getSilver() { + return DyeColor.SILVER; + } + + @Override + public boolean isWater(Block block) { + Material type = block.getType(); + return type == Material.WATER || type == Material.STATIONARY_WATER; + } + + @Override + public boolean removeWater(Block block) { + if(isWater(block)){ + block.setType(Material.AIR); + return true; + } + return false; + } + + @Override + public boolean containsBlockMeta(ItemMeta meta) { + return false; + } + + @Override + public boolean hasAttributeModifier(ItemStack stack) { + return false; + } + + @Override + public Material onBreak(Material type) { + switch(type){ + case REDSTONE_WIRE: + return Material.REDSTONE; + case PISTON_EXTENSION: + return Material.PISTON_BASE; + case ICE: + return Material.AIR; + default: + return type; + } + } + + @Override + public boolean doRecord(BlockPhysicsEvent e) { + return e.getChangedType() != e.getBlock().getType(); + } + + @Override + public void forceLoadChunk(World world, int cX, int cZ) { + // not possible in 1.8 + } + + @Override + public boolean checkPistonMoving(Block block) { + return block.getType() == Material.PISTON_MOVING_PIECE; + } +} diff --git a/FightSystem_8/src/de/steamwar/fightsystem/countdown/Countdown_8.java b/FightSystem_8/src/de/steamwar/fightsystem/utils/SWSound8.java similarity index 79% rename from FightSystem_8/src/de/steamwar/fightsystem/countdown/Countdown_8.java rename to FightSystem_8/src/de/steamwar/fightsystem/utils/SWSound8.java index 4224ecd..d4a6e21 100644 --- a/FightSystem_8/src/de/steamwar/fightsystem/countdown/Countdown_8.java +++ b/FightSystem_8/src/de/steamwar/fightsystem/utils/SWSound8.java @@ -1,7 +1,7 @@ -/* +/* This file is a part of the SteamWar software. - - Copyright (C) 2020 SteamWar.de-Serverteam + + Copyright (C) 2021 SteamWar.de-Serverteam This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by @@ -15,16 +15,15 @@ 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; +package de.steamwar.fightsystem.utils; import org.bukkit.Sound; -class Countdown_8 { - private Countdown_8(){} - - static Sound getSound(SWSound sound){ +public class SWSound8 implements SWSound.ISWSound { + @Override + public Sound getSound(SWSound sound) { switch(sound){ case ENTITY_WITHER_DEATH: return Sound.WITHER_DEATH; @@ -32,6 +31,8 @@ class Countdown_8 { return Sound.NOTE_BASS; case BLOCK_NOTE_PLING: return Sound.NOTE_PLING; + case ENTITY_GENERIC_EXPLODE: + return Sound.EXPLODE; default: return null; } diff --git a/FightSystem_8/src/de/steamwar/fightsystem/record/RecordSystem_8.java b/FightSystem_8/src/de/steamwar/fightsystem/utils/TechHider8.java similarity index 58% rename from FightSystem_8/src/de/steamwar/fightsystem/record/RecordSystem_8.java rename to FightSystem_8/src/de/steamwar/fightsystem/utils/TechHider8.java index 19dfa53..3a8e4f6 100644 --- a/FightSystem_8/src/de/steamwar/fightsystem/record/RecordSystem_8.java +++ b/FightSystem_8/src/de/steamwar/fightsystem/utils/TechHider8.java @@ -1,7 +1,7 @@ /* This file is a part of the SteamWar software. - Copyright (C) 2020 SteamWar.de-Serverteam + Copyright (C) 2021 SteamWar.de-Serverteam This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by @@ -15,22 +15,23 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . -*/ + */ -package de.steamwar.fightsystem.record; +package de.steamwar.fightsystem.utils; -import org.bukkit.World; -import org.bukkit.block.Block; +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.PacketAdapter; +import com.comphenix.protocol.events.PacketEvent; +import de.steamwar.fightsystem.FightSystem; -@SuppressWarnings("deprecation") -class RecordSystem_8 { - private RecordSystem_8(){} +public class TechHider8 extends PacketAdapter { - static int blockToId(Block block){ - return block.getTypeId() << 4 + block.getData(); + public TechHider8() { + super(FightSystem.getPlugin(), PacketType.Play.Server.MAP_CHUNK); } - static void setBlock(World world, int x, int y, int z, int blockState){ - world.getBlockAt(x, y, z).setTypeIdAndData(blockState >> 4, (byte)(blockState & 0b1111), false); + @Override + public void onPacketSending(PacketEvent e) { + // no implementation availible } } diff --git a/FightSystem_8/src/de/steamwar/fightsystem/fight/FightTeam_8.java b/FightSystem_8/src/de/steamwar/fightsystem/utils/WorldeditWrapper8.java similarity index 86% rename from FightSystem_8/src/de/steamwar/fightsystem/fight/FightTeam_8.java rename to FightSystem_8/src/de/steamwar/fightsystem/utils/WorldeditWrapper8.java index f62cb60..d12b387 100644 --- a/FightSystem_8/src/de/steamwar/fightsystem/fight/FightTeam_8.java +++ b/FightSystem_8/src/de/steamwar/fightsystem/utils/WorldeditWrapper8.java @@ -1,7 +1,7 @@ -/* +/* This file is a part of the SteamWar software. - - Copyright (C) 2020 SteamWar.de-Serverteam + + Copyright (C) 2021 SteamWar.de-Serverteam This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by @@ -15,9 +15,9 @@ 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; +package de.steamwar.fightsystem.utils; import com.sk89q.jnbt.NBTInputStream; import com.sk89q.worldedit.EditSession; @@ -38,20 +38,19 @@ import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.session.ClipboardHolder; import com.sk89q.worldedit.world.World; import de.steamwar.fightsystem.Config; -import de.steamwar.fightsystem.utils.Region; +import de.steamwar.fightsystem.FightSystem; import de.steamwar.sql.Schematic; import org.bukkit.Bukkit; -import org.bukkit.ChatColor; import org.bukkit.DyeColor; import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.scoreboard.Team; import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; import java.io.IOException; +import java.util.zip.GZIPInputStream; -public class FightTeam_8 { - private FightTeam_8(){} +public class WorldeditWrapper8 implements WorldeditWrapper.IWorldeditWrapper { @SuppressWarnings("deprecation") private static final int COLOR_TO_REPLACE = DyeColor.PINK.getWoolData(); @@ -67,11 +66,9 @@ public class FightTeam_8 { @SuppressWarnings("deprecation") private static final BaseBlock CARPET = new BaseBlock(Material.CARPET.getId(), COLOR_TO_REPLACE); - static void setTeamColor(Team team, ChatColor color){ - team.setPrefix("§" + color.getChar()); - } - - static void replaceTeamColor(Clipboard clipboard, DyeColor c) throws WorldEditException { + @SuppressWarnings("deprecation") + @Override + public void replaceTeamColor(Clipboard clipboard, DyeColor c) throws WorldEditException { Vector minimum = clipboard.getRegion().getMinimumPoint(); BaseBlock wool = new BaseBlock(WOOL.getId(), c.getWoolData()); BaseBlock clay = new BaseBlock(CLAY.getId(), c.getWoolData()); @@ -100,10 +97,11 @@ public class FightTeam_8 { } } - static void pasteSchematic(Clipboard clipboard, Region paste, boolean rotate) { + @Override + public void pasteSchematic(Clipboard clipboard, Region region, boolean rotate) { World w = new BukkitWorld(Bukkit.getWorlds().get(0)); Vector dimensions = clipboard.getDimensions(); - Vector v = new Vector(paste.centerX(), paste.getMinY(), paste.centerZ()); + Vector v = new Vector(region.centerX(), region.getMinY(), region.centerZ()); Vector offset = clipboard.getMinimumPoint().subtract(clipboard.getOrigin()); AffineTransform aT = new AffineTransform(); if(rotate){ @@ -130,7 +128,8 @@ public class FightTeam_8 { e.flushQueue(); } - static void pasteChar(Clipboard character, int charOffset, int length, int x, int y, int z, AffineTransform aT){ + @Override + public void pasteChar(Clipboard character, int charOffset, int length, int x, int y, int z, AffineTransform aT) { World w = new BukkitWorld(Bukkit.getWorlds().get(0)); Vector offset = character.getRegion().getMinimumPoint().subtract(character.getOrigin()); Vector v = Vector.ZERO.subtract(- charOffset + length / 2, 0, 0).subtract(offset); @@ -144,15 +143,13 @@ public class FightTeam_8 { e.flushQueue(); } - static Clipboard loadSchem(NBTInputStream stream) throws IOException { - return new SchematicReader(stream).read(new BukkitWorld(Bukkit.getWorlds().get(0)).getWorldData()); + @Override + public Clipboard loadChar(String charName) throws IOException { + return new SchematicReader(new NBTInputStream(new GZIPInputStream(new FileInputStream(new File(FightSystem.getPlugin().getDataFolder(), "text/" + charName + ".schematic"))))).read(new BukkitWorld(Bukkit.getWorlds().get(0)).getWorldData()); } - public static boolean checkPistonMoving(Block block){ - return block.getType() == Material.PISTON_MOVING_PIECE; - } - - public static void saveSchem(Schematic schem, Region region, int minY) { + @Override + public void saveSchem(Schematic schem, Region region, int minY) { World w = new BukkitWorld(Bukkit.getWorlds().get(0)); Vector min = new Vector(region.getMinX(), minY, region.getMinZ()); CuboidRegion cuboidRegion = new CuboidRegion(w, min, new Vector(region.getMaxX(), region.getMaxY(), region.getMaxZ())); diff --git a/FightSystem_9/pom.xml b/FightSystem_9/pom.xml index 769e6c2..8cf317c 100644 --- a/FightSystem_9/pom.xml +++ b/FightSystem_9/pom.xml @@ -17,28 +17,10 @@ FightSystem_9 1.0 - - src - - - src - - **/*.java - **/*.kt - - - - - steamwar - FightSystem_8 - 1.0 - - - steamwar - FightSystem_API + FightSystem_Core 1.0 diff --git a/FightSystem_9/src/de/steamwar/fightsystem/listener/PickupArrowListener_9.java b/FightSystem_9/src/de/steamwar/fightsystem/listener/ArrowPickup9.java similarity index 95% rename from FightSystem_9/src/de/steamwar/fightsystem/listener/PickupArrowListener_9.java rename to FightSystem_9/src/de/steamwar/fightsystem/listener/ArrowPickup9.java index 19a547a..28ce13b 100644 --- a/FightSystem_9/src/de/steamwar/fightsystem/listener/PickupArrowListener_9.java +++ b/FightSystem_9/src/de/steamwar/fightsystem/listener/ArrowPickup9.java @@ -23,7 +23,7 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerPickupArrowEvent; -class PickupArrowListener_9 implements Listener { +public class ArrowPickup9 implements Listener { @EventHandler public void onArrowPickup(PlayerPickupArrowEvent e){ diff --git a/FightSystem_10/src/de/steamwar/fightsystem/listener/DenyWorldInteraction_10.java b/FightSystem_9/src/de/steamwar/fightsystem/listener/DenyWorldInteraction9.java similarity index 90% rename from FightSystem_10/src/de/steamwar/fightsystem/listener/DenyWorldInteraction_10.java rename to FightSystem_9/src/de/steamwar/fightsystem/listener/DenyWorldInteraction9.java index 5a805c9..c5c6733 100644 --- a/FightSystem_10/src/de/steamwar/fightsystem/listener/DenyWorldInteraction_10.java +++ b/FightSystem_9/src/de/steamwar/fightsystem/listener/DenyWorldInteraction9.java @@ -1,7 +1,7 @@ /* This file is a part of the SteamWar software. - Copyright (C) 2020 SteamWar.de-Serverteam + Copyright (C) 2021 SteamWar.de-Serverteam This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by @@ -15,7 +15,7 @@ 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; @@ -23,7 +23,7 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerSwapHandItemsEvent; -public class DenyWorldInteraction_10 implements Listener { +public class DenyWorldInteraction9 implements Listener { @EventHandler public void onSwapItems(PlayerSwapHandItemsEvent event) { diff --git a/FightSystem_9/src/de/steamwar/fightsystem/listener/PersonalKitCreator_9.java b/FightSystem_9/src/de/steamwar/fightsystem/listener/PersonalKitCreator_9.java deleted file mode 100644 index 956e46a..0000000 --- a/FightSystem_9/src/de/steamwar/fightsystem/listener/PersonalKitCreator_9.java +++ /dev/null @@ -1,36 +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 org.bukkit.craftbukkit.v1_9_R2.inventory.CraftItemStack; -import org.bukkit.inventory.ItemStack; - -import java.util.HashSet; -import java.util.Set; - -public class PersonalKitCreator_9 { - - public static boolean hasItems(ItemStack stack){ - Set keys = new HashSet<>(CraftItemStack.asNMSCopy(stack).getTag().c()); - keys.remove("Enchantments"); - keys.remove("Damage"); - return !keys.isEmpty(); - } -} diff --git a/FightSystem_9/src/de/steamwar/fightsystem/listener/BasicListener_9.java b/FightSystem_9/src/de/steamwar/fightsystem/utils/BountifulWrapper9.java similarity index 55% rename from FightSystem_9/src/de/steamwar/fightsystem/listener/BasicListener_9.java rename to FightSystem_9/src/de/steamwar/fightsystem/utils/BountifulWrapper9.java index f90fa8a..ba721de 100644 --- a/FightSystem_9/src/de/steamwar/fightsystem/listener/BasicListener_9.java +++ b/FightSystem_9/src/de/steamwar/fightsystem/utils/BountifulWrapper9.java @@ -1,7 +1,7 @@ -/* +/* This file is a part of the SteamWar software. - - Copyright (C) 2020 SteamWar.de-Serverteam + + Copyright (C) 2021 SteamWar.de-Serverteam This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by @@ -15,29 +15,44 @@ 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; +package de.steamwar.fightsystem.utils; +import com.comphenix.protocol.wrappers.EnumWrappers; import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.chat.BaseComponent; +import org.bukkit.Material; import org.bukkit.attribute.Attribute; import org.bukkit.attribute.AttributeInstance; import org.bukkit.entity.Player; +import org.bukkit.scoreboard.Team; -class BasicListener_9 { - private BasicListener_9(){} +public class BountifulWrapper9 implements BountifulWrapper.IBountifulWrapper { + @Override + public boolean bowInHand(EnumWrappers.Hand hand, Player p) { + return (hand == EnumWrappers.Hand.MAIN_HAND && p.getInventory().getItemInMainHand().getType() == Material.BOW) || + (hand == EnumWrappers.Hand.OFF_HAND && p.getInventory().getItemInOffHand().getType() == Material.BOW); + } - static void toActionbar(Player player, BaseComponent... components){ + @Override + public void toActionbar(Player player, BaseComponent... components) { player.spigot().sendMessage(ChatMessageType.ACTION_BAR, components); } - static void toChat(Player player, BaseComponent... components){ + @Override + public void toChat(Player player, BaseComponent... components) { player.spigot().sendMessage(ChatMessageType.CHAT, components); } - static void setAttackSpeed(Player player){ + @Override + public void setAttackSpeed(Player player) { AttributeInstance attribute = player.getAttribute(Attribute.GENERIC_ATTACK_SPEED); attribute.setBaseValue(16); } + + @Override + public void setNametagVisibility(Team team) { + team.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.FOR_OWN_TEAM); + } } diff --git a/FightSystem_9/src/de/steamwar/fightsystem/fight/FightWorld_9.java b/FightSystem_9/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper9.java similarity index 69% rename from FightSystem_9/src/de/steamwar/fightsystem/fight/FightWorld_9.java rename to FightSystem_9/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper9.java index f35afb4..bb13e18 100644 --- a/FightSystem_9/src/de/steamwar/fightsystem/fight/FightWorld_9.java +++ b/FightSystem_9/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper9.java @@ -1,7 +1,7 @@ /* This file is a part of the SteamWar software. - Copyright (C) 2020 SteamWar.de-Serverteam + Copyright (C) 2021 SteamWar.de-Serverteam This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by @@ -15,24 +15,29 @@ 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; +package de.steamwar.fightsystem.utils; import de.steamwar.core.events.ChunkListener; +import de.steamwar.fightsystem.fight.FightWorld; import net.minecraft.server.v1_9_R2.Chunk; import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.craftbukkit.v1_9_R2.CraftWorld; import org.bukkit.craftbukkit.v1_9_R2.entity.CraftEntity; import org.bukkit.craftbukkit.v1_9_R2.entity.CraftPlayer; +import org.bukkit.craftbukkit.v1_9_R2.inventory.CraftItemStack; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; -public class FightWorld_9 { - private FightWorld_9(){} +import java.util.HashSet; +import java.util.Set; - static void resetChunk(World world, World backup, int x, int z, boolean isPaper){ +public class CraftbukkitWrapper9 implements CraftbukkitWrapper.ICraftbukkitWrapper { + @Override + public void resetChunk(World world, World backup, int x, int z) { net.minecraft.server.v1_9_R2.World w = ((CraftWorld) world).getHandle(); Chunk chunk = w.getChunkAt(x, z); Chunk backupChunk = ((CraftWorld) backup).getHandle().getChunkAt(x, z); @@ -40,7 +45,7 @@ public class FightWorld_9 { 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 (!isPaper) { + if (!FightWorld.isPaper()) { w.tileEntityList.removeAll(chunk.tileEntities.values()); } chunk.tileEntities.clear(); @@ -50,11 +55,21 @@ public class FightWorld_9 { } } - public static void sendResourcePack(Player player, String pack, String sha1){ + @Override + public void sendResourcePack(Player player, String pack, String sha1) { ((CraftPlayer)player).getHandle().setResourcePack(pack, sha1); } - public static float headRotation(Entity e){ + @Override + public float headRotation(Entity e) { return ((CraftEntity)e).getHandle().getHeadRotation(); } + + @Override + public boolean hasItems(ItemStack stack) { + Set keys = new HashSet<>(CraftItemStack.asNMSCopy(stack).getTag().c()); + keys.remove("Enchantments"); + keys.remove("Damage"); + return !keys.isEmpty(); + } } diff --git a/FightSystem_9/src/de/steamwar/fightsystem/countdown/Countdown_9.java b/FightSystem_9/src/de/steamwar/fightsystem/utils/SWSound9.java similarity index 78% rename from FightSystem_9/src/de/steamwar/fightsystem/countdown/Countdown_9.java rename to FightSystem_9/src/de/steamwar/fightsystem/utils/SWSound9.java index 71e345a..3589c09 100644 --- a/FightSystem_9/src/de/steamwar/fightsystem/countdown/Countdown_9.java +++ b/FightSystem_9/src/de/steamwar/fightsystem/utils/SWSound9.java @@ -1,7 +1,7 @@ -/* +/* This file is a part of the SteamWar software. - - Copyright (C) 2020 SteamWar.de-Serverteam + + Copyright (C) 2021 SteamWar.de-Serverteam This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by @@ -15,16 +15,15 @@ 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; +package de.steamwar.fightsystem.utils; import org.bukkit.Sound; -class Countdown_9 { - private Countdown_9(){} - - static Sound getSound(SWSound sound){ +public class SWSound9 implements SWSound.ISWSound { + @Override + public Sound getSound(SWSound sound){ switch(sound){ case ENTITY_WITHER_DEATH: return Sound.ENTITY_WITHER_DEATH; @@ -32,6 +31,8 @@ class Countdown_9 { return Sound.BLOCK_NOTE_BASS; case BLOCK_NOTE_PLING: return Sound.BLOCK_NOTE_PLING; + case ENTITY_GENERIC_EXPLODE: + return Sound.ENTITY_GENERIC_EXPLODE; default: return null; } diff --git a/FightSystem_API/src/de/steamwar/fightsystem/IFightSystem.java b/FightSystem_API/src/de/steamwar/fightsystem/IFightSystem.java deleted file mode 100644 index 5725381..0000000 --- a/FightSystem_API/src/de/steamwar/fightsystem/IFightSystem.java +++ /dev/null @@ -1,52 +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; - -import de.steamwar.sql.EventFight; -import org.bukkit.entity.Player; -import org.bukkit.plugin.Plugin; - -public class IFightSystem { - private IFightSystem(){} - - private static Plugin plugin; - private static EventFight eventFight; - private static Player eventLeiter; - - public static void init(Plugin plugin){ - IFightSystem.plugin = plugin; - } - static void setEventFight(EventFight ef){ - eventFight = ef; - } - static void setEventLeiter(Player el){ - eventLeiter = el; - } - - public static Plugin getPlugin(){ - return plugin; - } - public static EventFight getEventFight(){ - return eventFight; - } - public static Player getEventLeiter(){ - return eventLeiter; - } -} diff --git a/FightSystem_API/src/de/steamwar/fightsystem/fight/IFight.java b/FightSystem_API/src/de/steamwar/fightsystem/fight/IFight.java deleted file mode 100644 index 1c44e1a..0000000 --- a/FightSystem_API/src/de/steamwar/fightsystem/fight/IFight.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 . -*/ - -package de.steamwar.fightsystem.fight; - -import org.bukkit.entity.Player; - -public class IFight { - private IFight(){} - - private static IFightTeam redTeam; - private static IFightTeam blueTeam; - - public static void init(IFightTeam redTeam, IFightTeam blueTeam){ - IFight.redTeam = redTeam; - IFight.blueTeam = blueTeam; - } - - public static IFightTeam getPlayerTeam(Player player) { - if(redTeam.isPlayerInTeam(player)) - return redTeam; - if(blueTeam.isPlayerInTeam(player)) - return blueTeam; - return null; - } -} diff --git a/FightSystem_API/pom.xml b/FightSystem_Core/pom.xml similarity index 60% rename from FightSystem_API/pom.xml rename to FightSystem_Core/pom.xml index a2faacd..a9f81ed 100644 --- a/FightSystem_API/pom.xml +++ b/FightSystem_Core/pom.xml @@ -14,29 +14,23 @@ ${project.basedir}/.. - FightSystem_API + FightSystem_Core 1.0 - - src - - - src - - **/*.java - **/*.kt - - - - - steamwar Spigot - 1.12 + 1.15 system - ${main.basedir}/lib/Spigot-1.12.jar + ${main.basedir}/lib/Spigot-1.15.jar + + + steamwar + WorldEdit + 1.0 + system + ${main.basedir}/lib/WorldEdit-1.12.jar \ No newline at end of file diff --git a/FightSystem_Main/src/config.yml b/FightSystem_Core/src/config.yml similarity index 100% rename from FightSystem_Main/src/config.yml rename to FightSystem_Core/src/config.yml diff --git a/FightSystem_API/src/de/steamwar/fightsystem/ArenaMode.java b/FightSystem_Core/src/de/steamwar/fightsystem/ArenaMode.java similarity index 98% rename from FightSystem_API/src/de/steamwar/fightsystem/ArenaMode.java rename to FightSystem_Core/src/de/steamwar/fightsystem/ArenaMode.java index a3a5fee..bcfb258 100644 --- a/FightSystem_API/src/de/steamwar/fightsystem/ArenaMode.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/ArenaMode.java @@ -1,7 +1,7 @@ /* This file is a part of the SteamWar software. - Copyright (C) 2020 SteamWar.de-Serverteam + Copyright (C) 2021 SteamWar.de-Serverteam This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by @@ -15,7 +15,7 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . -*/ + */ package de.steamwar.fightsystem; diff --git a/FightSystem_API/src/de/steamwar/fightsystem/Config.java b/FightSystem_Core/src/de/steamwar/fightsystem/Config.java similarity index 97% rename from FightSystem_API/src/de/steamwar/fightsystem/Config.java rename to FightSystem_Core/src/de/steamwar/fightsystem/Config.java index 2837356..ac9b04d 100644 --- a/FightSystem_API/src/de/steamwar/fightsystem/Config.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/Config.java @@ -1,7 +1,7 @@ -/* +/* This file is a part of the SteamWar software. - - Copyright (C) 2020 SteamWar.de-Serverteam + + Copyright (C) 2021 SteamWar.de-Serverteam This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by @@ -15,7 +15,7 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . -*/ + */ package de.steamwar.fightsystem; @@ -132,12 +132,12 @@ public class Config { public static final int ReplayID; static{ - if(!new File(IFightSystem.getPlugin().getDataFolder(), System.getProperty("config", "config.yml")).exists()) { - IFightSystem.getPlugin().saveDefaultConfig(); + if(!new File(FightSystem.getPlugin().getDataFolder(), System.getProperty("config", "config.yml")).exists()) { + FightSystem.getPlugin().saveDefaultConfig(); Bukkit.getLogger().log(Level.SEVERE, "Arenaconfig fehlt!"); Bukkit.shutdown(); } - FileConfiguration config = YamlConfiguration.loadConfiguration(new File(IFightSystem.getPlugin().getDataFolder(), System.getProperty("config", "config.yml"))); + FileConfiguration config = YamlConfiguration.loadConfiguration(new File(FightSystem.getPlugin().getDataFolder(), System.getProperty("config", "config.yml"))); File worldConfigFile = new File(Bukkit.getWorlds().get(0).getWorldFolder(), config.getString("Arenaconfig", "config.yml")); if(!worldConfigFile.exists()) { @@ -326,7 +326,7 @@ public class Config { EventTeamRedID = team2.getTeamId(); BothTeamsPublic = EventTeamRedID == 0 && EventTeamBlueID == 0; - IFightSystem.setEventFight(eventFight); + FightSystem.setEventFight(eventFight); Event event = Event.get(eventFight.getEventID()); if(BothTeamsPublic) { diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/FightSystem.java b/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java similarity index 95% rename from FightSystem_Main/src/de/steamwar/fightsystem/FightSystem.java rename to FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java index 1d2b46d..2927bda 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/FightSystem.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.java @@ -20,14 +20,12 @@ package de.steamwar.fightsystem; import de.steamwar.core.CommandRemover; -import de.steamwar.core.Core; import de.steamwar.fightsystem.commands.*; import de.steamwar.fightsystem.countdown.*; import de.steamwar.fightsystem.event.HellsBells; import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.fight.FightWorld; -import de.steamwar.fightsystem.fight.IFight; import de.steamwar.fightsystem.listener.Shutdown; import de.steamwar.fightsystem.listener.*; import de.steamwar.fightsystem.record.*; @@ -49,17 +47,16 @@ public class FightSystem extends JavaPlugin { public static final String PREFIX = "§eArena§8» "; private static FightSystem plugin; + private static EventFight eventFight; + private static Player eventLeiter; @Override public void onLoad() { plugin = this; - IFightSystem.init(this); } @Override public void onEnable() { - IFight.init(Fight.getRedTeam(), Fight.getBlueTeam()); - new EntityDamage(); new WaterRemover(); new Permanent(); @@ -74,7 +71,7 @@ public class FightSystem extends JavaPlugin { new DenyWorldInteraction(); new EventJoin(); new Recording(); - // new ResourcePack(); + //new ResourcePack(); new Check(); new Shutdown(); new SetupQuit(); @@ -85,8 +82,7 @@ public class FightSystem extends JavaPlugin { new PersonalKitCreator(); new FightScoreboard(); new ArrowStopper(); - if(Core.getVersion() > 8) - new ArrowPickup(); + new ArrowPickup(); new EnterHandler(); new TechHider(); @@ -214,15 +210,19 @@ public class FightSystem extends JavaPlugin { } public static void setEventLeiter(Player el){ - IFightSystem.setEventLeiter(el); + eventLeiter = el; } public static Player getEventLeiter(){ - return IFightSystem.getEventLeiter(); + return eventLeiter; } public static EventFight getEventFight(){ - return IFightSystem.getEventFight(); + return eventFight; + } + + public static void setEventFight(EventFight ef){ + eventFight = ef; } public static FightSystem getPlugin() { diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/VersionDependent.java b/FightSystem_Core/src/de/steamwar/fightsystem/VersionDependent.java new file mode 100644 index 0000000..d44a1e6 --- /dev/null +++ b/FightSystem_Core/src/de/steamwar/fightsystem/VersionDependent.java @@ -0,0 +1,41 @@ +/* + This file is a part of the SteamWar software. + + Copyright (C) 2021 SteamWar.de-Serverteam + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ + +package de.steamwar.fightsystem; + +import de.steamwar.core.Core; + +import java.lang.reflect.InvocationTargetException; + +public class VersionDependent { + private VersionDependent() {} + + public static T getVersionImpl(String className){ + for(int version = Core.getVersion(); version >= 8; version--) { + try { + return (T) Class.forName(className + version).getDeclaredConstructor().newInstance(); + } catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { + throw new SecurityException("Could not load version dependent class", e); + } catch (ClassNotFoundException e) { + // try next version + } + } + throw new SecurityException("Unable to find version dependent implementation for " + className); + } +} diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/commands/AcceptCommand.java b/FightSystem_Core/src/de/steamwar/fightsystem/commands/AcceptCommand.java similarity index 100% rename from FightSystem_Main/src/de/steamwar/fightsystem/commands/AcceptCommand.java rename to FightSystem_Core/src/de/steamwar/fightsystem/commands/AcceptCommand.java diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/commands/AkCommand.java b/FightSystem_Core/src/de/steamwar/fightsystem/commands/AkCommand.java similarity index 100% rename from FightSystem_Main/src/de/steamwar/fightsystem/commands/AkCommand.java rename to FightSystem_Core/src/de/steamwar/fightsystem/commands/AkCommand.java diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/commands/CommandInjector.java b/FightSystem_Core/src/de/steamwar/fightsystem/commands/CommandInjector.java similarity index 100% rename from FightSystem_Main/src/de/steamwar/fightsystem/commands/CommandInjector.java rename to FightSystem_Core/src/de/steamwar/fightsystem/commands/CommandInjector.java diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/commands/Commands.java b/FightSystem_Core/src/de/steamwar/fightsystem/commands/Commands.java similarity index 100% rename from FightSystem_Main/src/de/steamwar/fightsystem/commands/Commands.java rename to FightSystem_Core/src/de/steamwar/fightsystem/commands/Commands.java diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/commands/DeclineCommand.java b/FightSystem_Core/src/de/steamwar/fightsystem/commands/DeclineCommand.java similarity index 100% rename from FightSystem_Main/src/de/steamwar/fightsystem/commands/DeclineCommand.java rename to FightSystem_Core/src/de/steamwar/fightsystem/commands/DeclineCommand.java diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/commands/GUI.java b/FightSystem_Core/src/de/steamwar/fightsystem/commands/GUI.java similarity index 100% rename from FightSystem_Main/src/de/steamwar/fightsystem/commands/GUI.java rename to FightSystem_Core/src/de/steamwar/fightsystem/commands/GUI.java diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/commands/GamemodeCommand.java b/FightSystem_Core/src/de/steamwar/fightsystem/commands/GamemodeCommand.java similarity index 100% rename from FightSystem_Main/src/de/steamwar/fightsystem/commands/GamemodeCommand.java rename to FightSystem_Core/src/de/steamwar/fightsystem/commands/GamemodeCommand.java diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/commands/InviteCommand.java b/FightSystem_Core/src/de/steamwar/fightsystem/commands/InviteCommand.java similarity index 100% rename from FightSystem_Main/src/de/steamwar/fightsystem/commands/InviteCommand.java rename to FightSystem_Core/src/de/steamwar/fightsystem/commands/InviteCommand.java diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/commands/KitCommand.java b/FightSystem_Core/src/de/steamwar/fightsystem/commands/KitCommand.java similarity index 100% rename from FightSystem_Main/src/de/steamwar/fightsystem/commands/KitCommand.java rename to FightSystem_Core/src/de/steamwar/fightsystem/commands/KitCommand.java diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/commands/LeaderCommand.java b/FightSystem_Core/src/de/steamwar/fightsystem/commands/LeaderCommand.java similarity index 100% rename from FightSystem_Main/src/de/steamwar/fightsystem/commands/LeaderCommand.java rename to FightSystem_Core/src/de/steamwar/fightsystem/commands/LeaderCommand.java diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/commands/LeaveCommand.java b/FightSystem_Core/src/de/steamwar/fightsystem/commands/LeaveCommand.java similarity index 100% rename from FightSystem_Main/src/de/steamwar/fightsystem/commands/LeaveCommand.java rename to FightSystem_Core/src/de/steamwar/fightsystem/commands/LeaveCommand.java diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/commands/LockschemCommand.java b/FightSystem_Core/src/de/steamwar/fightsystem/commands/LockschemCommand.java similarity index 100% rename from FightSystem_Main/src/de/steamwar/fightsystem/commands/LockschemCommand.java rename to FightSystem_Core/src/de/steamwar/fightsystem/commands/LockschemCommand.java diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/commands/ReadyCommand.java b/FightSystem_Core/src/de/steamwar/fightsystem/commands/ReadyCommand.java similarity index 100% rename from FightSystem_Main/src/de/steamwar/fightsystem/commands/ReadyCommand.java rename to FightSystem_Core/src/de/steamwar/fightsystem/commands/ReadyCommand.java diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/commands/RemoveCommand.java b/FightSystem_Core/src/de/steamwar/fightsystem/commands/RemoveCommand.java similarity index 100% rename from FightSystem_Main/src/de/steamwar/fightsystem/commands/RemoveCommand.java rename to FightSystem_Core/src/de/steamwar/fightsystem/commands/RemoveCommand.java diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/commands/ReplayCommand.java b/FightSystem_Core/src/de/steamwar/fightsystem/commands/ReplayCommand.java similarity index 100% rename from FightSystem_Main/src/de/steamwar/fightsystem/commands/ReplayCommand.java rename to FightSystem_Core/src/de/steamwar/fightsystem/commands/ReplayCommand.java diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/commands/SkipCommand.java b/FightSystem_Core/src/de/steamwar/fightsystem/commands/SkipCommand.java similarity index 100% rename from FightSystem_Main/src/de/steamwar/fightsystem/commands/SkipCommand.java rename to FightSystem_Core/src/de/steamwar/fightsystem/commands/SkipCommand.java diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/commands/StateCommand.java b/FightSystem_Core/src/de/steamwar/fightsystem/commands/StateCommand.java similarity index 100% rename from FightSystem_Main/src/de/steamwar/fightsystem/commands/StateCommand.java rename to FightSystem_Core/src/de/steamwar/fightsystem/commands/StateCommand.java diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/commands/WinCommand.java b/FightSystem_Core/src/de/steamwar/fightsystem/commands/WinCommand.java similarity index 100% rename from FightSystem_Main/src/de/steamwar/fightsystem/commands/WinCommand.java rename to FightSystem_Core/src/de/steamwar/fightsystem/commands/WinCommand.java diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/countdown/Countdown.java b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/Countdown.java similarity index 87% rename from FightSystem_Main/src/de/steamwar/fightsystem/countdown/Countdown.java rename to FightSystem_Core/src/de/steamwar/fightsystem/countdown/Countdown.java index 05c2a23..f847bb9 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/countdown/Countdown.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/Countdown.java @@ -19,11 +19,11 @@ package de.steamwar.fightsystem.countdown; -import de.steamwar.core.Core; import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.listener.BasicListener; import de.steamwar.fightsystem.record.GlobalRecorder; +import de.steamwar.fightsystem.utils.SWSound; import net.md_5.bungee.api.chat.BaseComponent; import net.md_5.bungee.api.chat.TextComponent; import org.bukkit.Bukkit; @@ -39,7 +39,7 @@ public abstract class Countdown { private static final List currentCountdowns = new ArrayList<>(); private final int totalTime; - private final Sound sound; + protected final Sound sound; private final boolean level; protected int time; @@ -48,31 +48,13 @@ public abstract class Countdown { public abstract String countdownCounting(); public abstract void countdownFinished(); - public Countdown(int time, SWSound sound, boolean level) { + protected Countdown(int time, SWSound sound, boolean level) { this.totalTime = time; this.time = time; - this.sound = getSound(sound); + this.sound = sound != null ? sound.getSound() : null; this.level = level; } - public static Sound getSound(SWSound sound){ - if(sound == null) - return null; - - switch (Core.getVersion()){ - 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_14.getSound(sound); - } - } - public void enable() { time = totalTime; task = Bukkit.getScheduler().runTaskTimer(FightSystem.getPlugin(), this::count, 20, 20); diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/countdown/EnternCountdown.java b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/EnternCountdown.java similarity index 89% rename from FightSystem_Main/src/de/steamwar/fightsystem/countdown/EnternCountdown.java rename to FightSystem_Core/src/de/steamwar/fightsystem/countdown/EnternCountdown.java index f08a8fe..ec78cc6 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/countdown/EnternCountdown.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/EnternCountdown.java @@ -23,6 +23,7 @@ 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.SWSound; import de.steamwar.fightsystem.utils.TechHider; import net.md_5.bungee.api.chat.TextComponent; import org.bukkit.entity.Player; @@ -59,19 +60,19 @@ public class EnternCountdown extends Countdown { BasicListener.toActionbar(player, TextComponent.fromLegacyText("§rNoch §a" + time / 60 + " §rMinuten " + countdownCounting())); break; case 60: case 30: case 20: case 15: case 10: case 5: case 4: case 3: case 2: - player.playSound(player.getLocation(), Countdown.getSound(SWSound.BLOCK_NOTE_PLING), 100.0F, 1.0F); + player.playSound(player.getLocation(), sound, 100.0F, 1.0F); BasicListener.toActionbar(player, TextComponent.fromLegacyText("§rNoch §a" + time + " §rSekunden " + countdownCounting())); break; case 1: - player.playSound(player.getLocation(), Countdown.getSound(SWSound.BLOCK_NOTE_PLING), 100.0F, 1.0F); + player.playSound(player.getLocation(), sound, 100.0F, 1.0F); BasicListener.toActionbar(player, TextComponent.fromLegacyText("§rNoch §a1 §rSekunde " + countdownCounting())); chunkPos = TechHider.prepareChunkReload(player, false); break; case 0: - player.playSound(player.getLocation(), Countdown.getSound(SWSound.BLOCK_NOTE_PLING), 100.0F, 2.0F); + player.playSound(player.getLocation(), sound, 100.0F, 2.0F); disable(); countdownFinished(); diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/countdown/EventSpectateCountdown.java b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/EventSpectateCountdown.java similarity index 97% rename from FightSystem_Main/src/de/steamwar/fightsystem/countdown/EventSpectateCountdown.java rename to FightSystem_Core/src/de/steamwar/fightsystem/countdown/EventSpectateCountdown.java index abaa890..a26a14d 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/countdown/EventSpectateCountdown.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/EventSpectateCountdown.java @@ -24,6 +24,7 @@ import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentCountdown; +import de.steamwar.fightsystem.utils.SWSound; public class EventSpectateCountdown extends Countdown { diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/countdown/NoPlayersOnlineCountdown.java b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/NoPlayersOnlineCountdown.java similarity index 100% rename from FightSystem_Main/src/de/steamwar/fightsystem/countdown/NoPlayersOnlineCountdown.java rename to FightSystem_Core/src/de/steamwar/fightsystem/countdown/NoPlayersOnlineCountdown.java diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/countdown/PostSchemCountdown.java b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/PostSchemCountdown.java similarity index 100% rename from FightSystem_Main/src/de/steamwar/fightsystem/countdown/PostSchemCountdown.java rename to FightSystem_Core/src/de/steamwar/fightsystem/countdown/PostSchemCountdown.java diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/countdown/PreRunningCountdown.java b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/PreRunningCountdown.java similarity index 97% rename from FightSystem_Main/src/de/steamwar/fightsystem/countdown/PreRunningCountdown.java rename to FightSystem_Core/src/de/steamwar/fightsystem/countdown/PreRunningCountdown.java index 36a6b79..9a5dac4 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/countdown/PreRunningCountdown.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/PreRunningCountdown.java @@ -24,6 +24,7 @@ import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentCountdown; +import de.steamwar.fightsystem.utils.SWSound; public class PreRunningCountdown extends Countdown { diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/countdown/PreSchemCountdown.java b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/PreSchemCountdown.java similarity index 97% rename from FightSystem_Main/src/de/steamwar/fightsystem/countdown/PreSchemCountdown.java rename to FightSystem_Core/src/de/steamwar/fightsystem/countdown/PreSchemCountdown.java index 6dbe901..f9c007a 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/countdown/PreSchemCountdown.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/PreSchemCountdown.java @@ -24,6 +24,7 @@ import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentCountdown; +import de.steamwar.fightsystem.utils.SWSound; public class PreSchemCountdown extends Countdown { diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/countdown/SpectateOverCountdown.java b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/SpectateOverCountdown.java similarity index 96% rename from FightSystem_Main/src/de/steamwar/fightsystem/countdown/SpectateOverCountdown.java rename to FightSystem_Core/src/de/steamwar/fightsystem/countdown/SpectateOverCountdown.java index 5946085..92ac120 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/countdown/SpectateOverCountdown.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/SpectateOverCountdown.java @@ -22,9 +22,9 @@ package de.steamwar.fightsystem.countdown; import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.FightSystem; -import de.steamwar.fightsystem.fight.FightWorld; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentCountdown; +import de.steamwar.fightsystem.utils.SWSound; public class SpectateOverCountdown extends Countdown { diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/countdown/TimeOverCountdown.java b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/TimeOverCountdown.java similarity index 96% rename from FightSystem_Main/src/de/steamwar/fightsystem/countdown/TimeOverCountdown.java rename to FightSystem_Core/src/de/steamwar/fightsystem/countdown/TimeOverCountdown.java index 96a6cab..a45e12c 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/countdown/TimeOverCountdown.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/countdown/TimeOverCountdown.java @@ -21,6 +21,7 @@ package de.steamwar.fightsystem.countdown; import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.Config; +import de.steamwar.fightsystem.utils.SWSound; import org.bukkit.Bukkit; public class TimeOverCountdown extends Countdown { diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/event/HellsBells.java b/FightSystem_Core/src/de/steamwar/fightsystem/event/HellsBells.java similarity index 99% rename from FightSystem_Main/src/de/steamwar/fightsystem/event/HellsBells.java rename to FightSystem_Core/src/de/steamwar/fightsystem/event/HellsBells.java index 1d3d87f..72a7b40 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/event/HellsBells.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/event/HellsBells.java @@ -22,7 +22,7 @@ package de.steamwar.fightsystem.event; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.countdown.Countdown; -import de.steamwar.fightsystem.countdown.SWSound; +import de.steamwar.fightsystem.utils.SWSound; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependent; import de.steamwar.fightsystem.winconditions.Winconditions; diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/fight/Fight.java b/FightSystem_Core/src/de/steamwar/fightsystem/fight/Fight.java similarity index 100% rename from FightSystem_Main/src/de/steamwar/fightsystem/fight/Fight.java rename to FightSystem_Core/src/de/steamwar/fightsystem/fight/Fight.java diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightPlayer.java b/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightPlayer.java similarity index 100% rename from FightSystem_Main/src/de/steamwar/fightsystem/fight/FightPlayer.java rename to FightSystem_Core/src/de/steamwar/fightsystem/fight/FightPlayer.java diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightSchematic.java b/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightSchematic.java similarity index 66% rename from FightSystem_Main/src/de/steamwar/fightsystem/fight/FightSchematic.java rename to FightSystem_Core/src/de/steamwar/fightsystem/fight/FightSchematic.java index af1d0b1..a9a1bcb 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightSchematic.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightSchematic.java @@ -19,12 +19,9 @@ package de.steamwar.fightsystem.fight; -import com.sk89q.jnbt.NBTInputStream; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.math.transform.AffineTransform; -import de.steamwar.core.VersionedCallable; -import de.steamwar.core.VersionedRunnable; import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.FightSystem; @@ -33,6 +30,7 @@ import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependent; import de.steamwar.fightsystem.utils.ColorConverter; import de.steamwar.fightsystem.utils.Region; +import de.steamwar.fightsystem.utils.WorldeditWrapper; import de.steamwar.sql.Schematic; import org.bukkit.Bukkit; import org.bukkit.DyeColor; @@ -41,14 +39,11 @@ import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.event.HandlerList; -import java.io.File; -import java.io.FileInputStream; import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Random; import java.util.logging.Level; -import java.util.zip.GZIPInputStream; public class FightSchematic extends StateDependent { @@ -122,29 +117,8 @@ public class FightSchematic extends StateDependent { Bukkit.getScheduler().runTask(FightSystem.getPlugin(), this::paste); } - private void replaceTeamColor(Clipboard clipboard){ - DyeColor c = ArenaMode.AntiPrepare.contains(Config.mode) ? ColorConverter.chat2dye(team.getColor()) : DyeColor.PINK; - VersionedRunnable.call(new VersionedRunnable(() -> { - try { - FightTeam_8.replaceTeamColor(clipboard, c); - } catch (WorldEditException ex) { - throw new SecurityException("Error recoloring schematic", ex); - } - }, 8), - new VersionedRunnable(() -> { - try { - FightTeam_12.replaceTeamColor(clipboard, c); - } catch (WorldEditException ex) { - throw new SecurityException("Error recoloring schematic", ex); - } - }, 12), - new VersionedRunnable(() -> { - try { - FightTeam_14.replaceTeamColor(clipboard, c); - } catch (WorldEditException ex) { - throw new SecurityException("Error recoloring schematic", ex); - } - }, 14)); + private void replaceTeamColor(Clipboard clipboard) throws WorldEditException { + WorldeditWrapper.impl.replaceTeamColor(clipboard, ArenaMode.AntiPrepare.contains(Config.mode) ? ColorConverter.chat2dye(team.getColor()) : DyeColor.PINK); } private void paste(){ @@ -152,35 +126,33 @@ public class FightSchematic extends StateDependent { try { replaceTeamColor(clipboard); - VersionedRunnable.call(new VersionedRunnable(() -> FightTeam_8.pasteSchematic(clipboard, region, rotate), 8), - new VersionedRunnable(() -> FightTeam_14.pasteSchematic(clipboard, region, rotate), 14)); - } catch (SecurityException securityException) { + WorldeditWrapper.impl.pasteSchematic(clipboard, region, rotate); + } catch (WorldEditException e) { Bukkit.broadcastMessage(FightSystem.PREFIX + "§cFehler beim Pasten der Schematic"); Bukkit.getScheduler().runTask(FightSystem.getPlugin(), FightSystem::setPreSchemState); - throw securityException; + throw new SecurityException("Could not paste schematic", e); } Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), freezer::disable, 3); Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), team::teleportToSpawn, 40); } - private Clipboard loadTextSchem(String schemName){ - return VersionedCallable.call(new VersionedCallable<>(() -> FightTeam_8.loadSchem(new NBTInputStream(new GZIPInputStream(new FileInputStream(new File(FightSystem.getPlugin().getDataFolder(), "text/" + schemName + ".schematic"))))), 8), - new VersionedCallable<>(() -> FightTeam_14.loadSchem(new NBTInputStream(new GZIPInputStream(new FileInputStream(new File(FightSystem.getPlugin().getDataFolder(), "text/" + schemName + ".schem"))))), 14)); + private Clipboard loadTextSchem(String schemName) throws IOException { + return WorldeditWrapper.impl.loadChar(schemName); } public void pasteTeamName(){ List characters = new ArrayList<>(); for(char c : team.getName().toCharArray()){ try { + characters.add(loadTextSchem(c == '/' ? "slash" : String.valueOf(c))); + } catch (IOException e) { + Bukkit.getLogger().log(Level.WARNING, "Could not display character {} due to missing file!", c); try { - characters.add(loadTextSchem(c == '/' ? "slash" : String.valueOf(c))); - } catch (RuntimeException e) { - Bukkit.getLogger().log(Level.WARNING, "Could not display character {} due to missing file!", c); characters.add(loadTextSchem("")); + }catch (IOException ex) { + throw new SecurityException("Could not load text", ex); } - }catch (RuntimeException e) { - throw new SecurityException("Could not load text", e); } } @@ -210,16 +182,15 @@ public class FightSchematic extends StateDependent { } for(int i = 0; i < characters.size(); i++){ - replaceTeamColor(characters.get(i)); - pasteChar(characters.get(i), offsets[i], length, team.getSchemRegion().centerX(), team.getExtendRegion().getMaxY(), z, aT); + try { + replaceTeamColor(characters.get(i)); + } catch (WorldEditException e) { + Bukkit.getLogger().log(Level.SEVERE, "Could not recolor team text", e); + } + WorldeditWrapper.impl.pasteChar(characters.get(i), offsets[i], length, team.getSchemRegion().centerX(), team.getExtendRegion().getMaxY(), z, aT); } } - private void pasteChar(Clipboard character, int charOffset, int length, int x, int y, int z, AffineTransform aT){ - VersionedRunnable.call(new VersionedRunnable(() -> FightTeam_8.pasteChar(character, charOffset, length, x, y, z, aT), 8), - new VersionedRunnable(() -> FightTeam_14.pasteChar(character, charOffset, length, x, y, z, aT), 14)); - } - @Override public void disable() { if(!Config.ReplaceObsidianBedrock) diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightTeam.java b/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightTeam.java similarity index 95% rename from FightSystem_Main/src/de/steamwar/fightsystem/fight/FightTeam.java rename to FightSystem_Core/src/de/steamwar/fightsystem/fight/FightTeam.java index 92ed1af..fab2aea 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightTeam.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightTeam.java @@ -21,17 +21,17 @@ package de.steamwar.fightsystem.fight; import com.sk89q.worldedit.extent.clipboard.Clipboard; import de.steamwar.comms.packets.TablistNamePacket; -import de.steamwar.core.VersionedRunnable; import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.FightSystem; +import de.steamwar.fightsystem.VersionDependent; import de.steamwar.fightsystem.countdown.Countdown; -import de.steamwar.fightsystem.listener.BasicListener; import de.steamwar.fightsystem.listener.FightScoreboard; import de.steamwar.fightsystem.listener.PersonalKitCreator; import de.steamwar.fightsystem.record.GlobalRecorder; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependent; +import de.steamwar.fightsystem.utils.BountifulWrapper; import de.steamwar.fightsystem.utils.ItemBuilder; import de.steamwar.fightsystem.utils.Region; import de.steamwar.fightsystem.utils.TechHider; @@ -48,7 +48,9 @@ import org.bukkit.scoreboard.Team; import java.util.*; -public class FightTeam implements IFightTeam{ +public class FightTeam { + + private static final IFightTeam impl = VersionDependent.getVersionImpl(FightTeam.class.getName()); private UUID designatedLeader; private FightPlayer leader; @@ -87,7 +89,8 @@ public class FightTeam implements IFightTeam{ else team = FightScoreboard.getBukkit().getTeam(name); assert team != null; - setTeamColor(team, color); + impl.setTeamColor(team, color); + BountifulWrapper.impl.setNametagVisibility(team); //noinspection deprecation team.setNameTagVisibility(NameTagVisibility.HIDE_FOR_OTHER_TEAMS); team.setAllowFriendlyFire(false); @@ -131,12 +134,10 @@ public class FightTeam implements IFightTeam{ return true; } - @Override public boolean isPlayerInTeam(Player player) { return players.containsKey(player); } - @Override public boolean canPlayerEntern(Player player) { return getFightPlayer(player).canEntern(); } @@ -196,7 +197,7 @@ public class FightTeam implements IFightTeam{ player.setHealth(20); player.setFoodLevel(20); player.getInventory().clear(); - BasicListener.setAttackSpeed(player); + BountifulWrapper.impl.setAttackSpeed(player); player.teleport(spawn); if(Kit.getAvailableKits(false).size() > 1 || Config.PersonalKits) player.getInventory().setItem(1, new ItemBuilder(Material.LEATHER_CHESTPLATE).removeAllAttributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§eKit wählen").build()); @@ -237,7 +238,6 @@ public class FightTeam implements IFightTeam{ return leader == null; } - @Override public boolean isBlue(){ return blue; } @@ -402,17 +402,14 @@ public class FightTeam implements IFightTeam{ return currentHearts / maximumHearts; } - private void setTeamColor(Team team, ChatColor color){ - VersionedRunnable.call(new VersionedRunnable(() -> FightTeam_8.setTeamColor(team, color), 8), - new VersionedRunnable(() -> FightTeam_9.setTeamColor(team, color), 9), - new VersionedRunnable(() -> FightTeam_12.setTeamColor(team, color), 12), - new VersionedRunnable(() -> FightTeam_14.setTeamColor(team, color), 14)); - } - public ChatColor getColor() { return color; } + public interface IFightTeam { + void setTeamColor(Team team, ChatColor color); + } + private class KitLoader extends StateDependent { private KitLoader() { super(ArenaMode.AntiReplay, FightState.Ingame); diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightWorld.java b/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightWorld.java similarity index 65% rename from FightSystem_Main/src/de/steamwar/fightsystem/fight/FightWorld.java rename to FightSystem_Core/src/de/steamwar/fightsystem/fight/FightWorld.java index 93e53bd..b3cacb5 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightWorld.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/fight/FightWorld.java @@ -19,12 +19,12 @@ package de.steamwar.fightsystem.fight; -import de.steamwar.core.Core; -import de.steamwar.core.VersionedRunnable; import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.Config; 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 org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.WorldCreator; @@ -33,13 +33,12 @@ import org.bukkit.entity.EntityType; public class FightWorld extends StateDependent { - private static final boolean paper; - - static{ - paper = Bukkit.getVersion().contains("git-Paper"); - } - private static final World world = Bukkit.getWorlds().get(0); + private static final boolean paper = Bukkit.getVersion().contains("git-Paper"); + + public static boolean isPaper(){ + return paper; + } public FightWorld() { super(ArenaMode.Restartable, FightState.Schem); @@ -51,10 +50,6 @@ public class FightWorld extends StateDependent { //unused } - public static boolean isPaper(){ - return paper; - } - @Override public void disable() { resetWorld(); @@ -63,8 +58,7 @@ public class FightWorld extends StateDependent { public static void forceLoad(){ Config.ArenaRegion.forEachChunk((cX, cZ) -> { world.loadChunk(cX, cZ); - if(Core.getVersion() > 12) - world.setChunkForceLoaded(cX, cZ, true); + FlatteningWrapper.impl.forceLoadChunk(world, cX, cZ); }); world.setKeepSpawnInMemory(true); } @@ -78,17 +72,7 @@ public class FightWorld extends StateDependent { World backup = new WorldCreator(world.getName() + "/backup").createWorld(); assert backup != null; - Config.ArenaRegion.forEachChunk((x, z) -> resetChunk(backup, x, z, FightWorld.isPaper())); + Config.ArenaRegion.forEachChunk((x, z) -> CraftbukkitWrapper.impl.resetChunk(world, backup, x, z)); Bukkit.unloadWorld(backup, false); } - - private static void resetChunk(World backup, int x, int z, boolean isPaper){ - VersionedRunnable.call( - new VersionedRunnable(() -> FightWorld_8.resetChunk(world, backup, x, z, isPaper), 8), - new VersionedRunnable(() -> FightWorld_9.resetChunk(world, backup, x, z, isPaper), 9), - new VersionedRunnable(() -> FightWorld_10.resetChunk(world, backup, x, z, isPaper), 10), - new VersionedRunnable(() -> FightWorld_12.resetChunk(world, backup, x, z, isPaper), 12), - new VersionedRunnable(() -> FightWorld_14.resetChunk(world, backup, x, z, isPaper), 14), - new VersionedRunnable(() -> FightWorld_15.resetChunk(world, backup, x, z, isPaper), 15)); - } -} +} \ No newline at end of file diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/fight/FreezeWorld.java b/FightSystem_Core/src/de/steamwar/fightsystem/fight/FreezeWorld.java similarity index 95% rename from FightSystem_Main/src/de/steamwar/fightsystem/fight/FreezeWorld.java rename to FightSystem_Core/src/de/steamwar/fightsystem/fight/FreezeWorld.java index d82cbbf..f3aa5d3 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/fight/FreezeWorld.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/fight/FreezeWorld.java @@ -19,7 +19,7 @@ package de.steamwar.fightsystem.fight; -import de.steamwar.fightsystem.IFightSystem; +import de.steamwar.fightsystem.FightSystem; import org.bukkit.Bukkit; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -32,7 +32,7 @@ import org.bukkit.event.player.PlayerSwapHandItemsEvent; public class FreezeWorld implements Listener { public FreezeWorld(){ - Bukkit.getPluginManager().registerEvents(this, IFightSystem.getPlugin()); + Bukkit.getPluginManager().registerEvents(this, FightSystem.getPlugin()); } public void disable(){ diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/fight/Kit.java b/FightSystem_Core/src/de/steamwar/fightsystem/fight/Kit.java similarity index 92% rename from FightSystem_Main/src/de/steamwar/fightsystem/fight/Kit.java rename to FightSystem_Core/src/de/steamwar/fightsystem/fight/Kit.java index e37b47f..84df9b5 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/fight/Kit.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/fight/Kit.java @@ -19,13 +19,13 @@ package de.steamwar.fightsystem.fight; -import de.steamwar.core.Core; -import de.steamwar.core.VersionedCallable; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.commands.Commands; import de.steamwar.fightsystem.commands.GUI; -import de.steamwar.fightsystem.listener.*; +import de.steamwar.fightsystem.listener.PersonalKitCreator; +import de.steamwar.fightsystem.utils.CraftbukkitWrapper; +import de.steamwar.fightsystem.utils.FlatteningWrapper; import de.steamwar.inventory.SWInventory; import de.steamwar.inventory.SWItem; import de.steamwar.sql.PersonalKit; @@ -38,7 +38,6 @@ import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.BlockDataMeta; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.potion.PotionEffect; @@ -188,21 +187,16 @@ public class Kit { return true; //Check for attribute modifiers - if(Core.getVersion() >= 14 && PersonalKitCreator_14.hasAttributeModifier(stack)){ + if(FlatteningWrapper.impl.hasAttributeModifier(stack)){ return true; } if(stack.hasItemMeta()){ ItemMeta meta = stack.getItemMeta(); - if(meta instanceof BlockDataMeta && ((BlockDataMeta)meta).hasBlockData()) + if(FlatteningWrapper.impl.containsBlockMeta(meta)) return true; //Blocks always upwards slabs etc. - if(VersionedCallable.call(new VersionedCallable<>(() -> PersonalKitCreator_8.hasItems(stack), 8), - new VersionedCallable<>(() -> PersonalKitCreator_9.hasItems(stack), 9), - new VersionedCallable<>(() -> PersonalKitCreator_10.hasItems(stack), 10), - new VersionedCallable<>(() -> PersonalKitCreator_12.hasItems(stack), 12), - new VersionedCallable<>(() -> PersonalKitCreator_14.hasItems(stack), 14), - new VersionedCallable<>(() -> PersonalKitCreator_15.hasItems(stack), 15))) + if(CraftbukkitWrapper.impl.hasItems(stack)) return true; //Blocks prefilled inventories } diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/ArenaBorder.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/ArenaBorder.java similarity index 100% rename from FightSystem_Main/src/de/steamwar/fightsystem/listener/ArenaBorder.java rename to FightSystem_Core/src/de/steamwar/fightsystem/listener/ArenaBorder.java diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/ArrowPickup.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/ArrowPickup.java similarity index 85% rename from FightSystem_Main/src/de/steamwar/fightsystem/listener/ArrowPickup.java rename to FightSystem_Core/src/de/steamwar/fightsystem/listener/ArrowPickup.java index b8d4693..ccf9acd 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/listener/ArrowPickup.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/ArrowPickup.java @@ -19,16 +19,14 @@ package de.steamwar.fightsystem.listener; -import de.steamwar.core.Core; import de.steamwar.fightsystem.ArenaMode; +import de.steamwar.fightsystem.VersionDependent; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentListener; public class ArrowPickup { public ArrowPickup() { - if(Core.getVersion() > 8){ - new StateDependentListener(ArenaMode.All, FightState.All, new PickupArrowListener_9()); - } + new StateDependentListener(ArenaMode.All, FightState.All, VersionDependent.getVersionImpl(ArrowPickup.class.getName())); } } diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/ArrowStopper.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/ArrowStopper.java similarity index 91% rename from FightSystem_Main/src/de/steamwar/fightsystem/listener/ArrowStopper.java rename to FightSystem_Core/src/de/steamwar/fightsystem/listener/ArrowStopper.java index 35d8af1..47fcecf 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/listener/ArrowStopper.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/ArrowStopper.java @@ -1,7 +1,7 @@ /* This file is a part of the SteamWar software. - Copyright (C) 2020 SteamWar.de-Serverteam + Copyright (C) 2021 SteamWar.de-Serverteam This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by @@ -15,11 +15,12 @@ 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.fightsystem.Config; +import de.steamwar.fightsystem.VersionDependent; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentTask; import org.bukkit.Bukkit; @@ -36,6 +37,8 @@ public class ArrowStopper { private static final Vector NULL_VECTOR = new Vector(0, 0, 0); private static final BlockFace[] BLOCK_FACES = {BlockFace.UP, BlockFace.DOWN, BlockFace.EAST, BlockFace.WEST, BlockFace.NORTH, BlockFace.SOUTH}; + private static final IArrowStopper impl = VersionDependent.getVersionImpl(ArrowStopper.class.getName()); + public ArrowStopper() { new StateDependentTask(Config.TechhiderActive, FightState.Running, this::run, 1, 1); } @@ -90,7 +93,11 @@ public class ArrowStopper { boolean overMid = entity.getLocation().getZ() > Config.SpecSpawn.getZ(); boolean otherSide = teamFrom == overMid; return otherSide || - entity.isInBlock() || + impl.isInBlock(entity) || entity.getVelocity().equals(NULL_VECTOR); } + + public interface IArrowStopper { + boolean isInBlock(Arrow e); + } } diff --git a/FightSystem_8/src/de/steamwar/fightsystem/listener/BasicListener_8.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/BasicListener.java similarity index 69% rename from FightSystem_8/src/de/steamwar/fightsystem/listener/BasicListener_8.java rename to FightSystem_Core/src/de/steamwar/fightsystem/listener/BasicListener.java index 5cd86f6..f63dc1c 100644 --- a/FightSystem_8/src/de/steamwar/fightsystem/listener/BasicListener_8.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/BasicListener.java @@ -19,17 +19,19 @@ package de.steamwar.fightsystem.listener; +import de.steamwar.fightsystem.fight.Fight; +import de.steamwar.fightsystem.utils.BountifulWrapper; import net.md_5.bungee.api.chat.BaseComponent; import org.bukkit.entity.Player; -class BasicListener_8 { - private BasicListener_8(){} +public class BasicListener { + private BasicListener(){} - static void toActionbar(Player player, BaseComponent... components){ - player.spigot().sendMessage(components); + public static boolean notFighting(Player p){ + return Fight.getFightPlayer(p) == null; } - static void toChat(Player player, BaseComponent... components){ - player.spigot().sendMessage(components); + public static void toActionbar(Player player, BaseComponent... components){ + BountifulWrapper.impl.toActionbar(player, components); } } diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/Chat.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/Chat.java similarity index 96% rename from FightSystem_Main/src/de/steamwar/fightsystem/listener/Chat.java rename to FightSystem_Core/src/de/steamwar/fightsystem/listener/Chat.java index 973a706..21fdd77 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/listener/Chat.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/Chat.java @@ -27,6 +27,7 @@ import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.record.GlobalRecorder; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentListener; +import de.steamwar.fightsystem.utils.BountifulWrapper; import net.md_5.bungee.api.chat.BaseComponent; import net.md_5.bungee.api.chat.TextComponent; import org.bukkit.Bukkit; @@ -67,6 +68,6 @@ public class Chat implements Listener { GlobalRecorder.getInstance().chat(message); BaseComponent[] msg = TextComponent.fromLegacyText(message); for(Player p : Bukkit.getOnlinePlayers()) - BasicListener.toChat(p, msg); + BountifulWrapper.impl.toChat(p, msg); } } diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/Check.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/Check.java similarity index 100% rename from FightSystem_Main/src/de/steamwar/fightsystem/listener/Check.java rename to FightSystem_Core/src/de/steamwar/fightsystem/listener/Check.java diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/DenyWorldInteraction.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/DenyWorldInteraction.java similarity index 91% rename from FightSystem_Main/src/de/steamwar/fightsystem/listener/DenyWorldInteraction.java rename to FightSystem_Core/src/de/steamwar/fightsystem/listener/DenyWorldInteraction.java index 78b5d50..998f8cb 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/listener/DenyWorldInteraction.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/DenyWorldInteraction.java @@ -19,8 +19,8 @@ package de.steamwar.fightsystem.listener; -import de.steamwar.core.Core; import de.steamwar.fightsystem.ArenaMode; +import de.steamwar.fightsystem.VersionDependent; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentListener; import net.md_5.bungee.api.chat.TextComponent; @@ -40,11 +40,10 @@ public class DenyWorldInteraction implements Listener { public DenyWorldInteraction() { new StateDependentListener(ArenaMode.Test, FightState.PreRunning, this); new StateDependentListener(ArenaMode.AntiTest, FightState.AntiRunning, this); - if(Core.getVersion() > 9){ - Listener listener = new DenyWorldInteraction_10(); - new StateDependentListener(ArenaMode.Test, FightState.PreRunning, listener); - new StateDependentListener(ArenaMode.AntiTest, FightState.AntiRunning, listener); - } + + Listener listener = VersionDependent.getVersionImpl(DenyWorldInteraction.class.getName()); + new StateDependentListener(ArenaMode.Test, FightState.PreRunning, listener); + new StateDependentListener(ArenaMode.AntiTest, FightState.AntiRunning, listener); } @EventHandler diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/EntityDamage.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/EntityDamage.java similarity index 100% rename from FightSystem_Main/src/de/steamwar/fightsystem/listener/EntityDamage.java rename to FightSystem_Core/src/de/steamwar/fightsystem/listener/EntityDamage.java diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/EventJoin.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/EventJoin.java similarity index 100% rename from FightSystem_Main/src/de/steamwar/fightsystem/listener/EventJoin.java rename to FightSystem_Core/src/de/steamwar/fightsystem/listener/EventJoin.java diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/FightScoreboard.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/FightScoreboard.java similarity index 100% rename from FightSystem_Main/src/de/steamwar/fightsystem/listener/FightScoreboard.java rename to FightSystem_Core/src/de/steamwar/fightsystem/listener/FightScoreboard.java diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/HotbarGUI.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/HotbarGUI.java similarity index 100% rename from FightSystem_Main/src/de/steamwar/fightsystem/listener/HotbarGUI.java rename to FightSystem_Core/src/de/steamwar/fightsystem/listener/HotbarGUI.java diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/InFightDamage.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/InFightDamage.java similarity index 100% rename from FightSystem_Main/src/de/steamwar/fightsystem/listener/InFightDamage.java rename to FightSystem_Core/src/de/steamwar/fightsystem/listener/InFightDamage.java diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/InFightInventory.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/InFightInventory.java similarity index 93% rename from FightSystem_Main/src/de/steamwar/fightsystem/listener/InFightInventory.java rename to FightSystem_Core/src/de/steamwar/fightsystem/listener/InFightInventory.java index d63cccf..70ae2ba 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/listener/InFightInventory.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/InFightInventory.java @@ -24,6 +24,7 @@ import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.FightPlayer; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentListener; +import de.steamwar.fightsystem.utils.FlatteningWrapper; import net.md_5.bungee.api.chat.TextComponent; import org.bukkit.Material; import org.bukkit.event.EventHandler; @@ -81,17 +82,7 @@ public class InFightInventory implements Listener { public void onBlockBreak(BlockBreakEvent event) { Inventory inventory = event.getPlayer().getInventory(); - Material type = event.getBlock().getType(); - switch(type){ - case REDSTONE_WIRE: - type = Material.REDSTONE; - break; - case PISTON_HEAD: - type = Material.PISTON; - break; - case ICE: - return; - } + Material type = FlatteningWrapper.impl.onBreak(event.getBlock().getType()); ItemStack itemStack; for (int i = 0; i <= 35; i++) { //35 is the last normal inventory slot diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/IngameDeath.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/IngameDeath.java similarity index 93% rename from FightSystem_Main/src/de/steamwar/fightsystem/listener/IngameDeath.java rename to FightSystem_Core/src/de/steamwar/fightsystem/listener/IngameDeath.java index 8c896c5..89b3b3c 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/listener/IngameDeath.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/IngameDeath.java @@ -21,8 +21,7 @@ package de.steamwar.fightsystem.listener; import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.FightSystem; -import de.steamwar.fightsystem.countdown.Countdown; -import de.steamwar.fightsystem.countdown.SWSound; +import de.steamwar.fightsystem.utils.SWSound; import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.FightPlayer; import de.steamwar.fightsystem.fight.FightTeam; @@ -54,7 +53,7 @@ public class IngameDeath implements Listener { return; Bukkit.broadcastMessage(FightSystem.PREFIX + "§cDer Spieler " + team.getPrefix() + player.getName() + " §cist gestorben!"); - Fight.playSound(Countdown.getSound(SWSound.ENTITY_WITHER_DEATH), 100.0F, 1.0F); + Fight.playSound(SWSound.ENTITY_WITHER_DEATH.getSound(), 100.0F, 1.0F); team.getFightPlayer(player).setOut(); } diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/NormalJoin.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/NormalJoin.java similarity index 100% rename from FightSystem_Main/src/de/steamwar/fightsystem/listener/NormalJoin.java rename to FightSystem_Core/src/de/steamwar/fightsystem/listener/NormalJoin.java diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/Permanent.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/Permanent.java similarity index 100% rename from FightSystem_Main/src/de/steamwar/fightsystem/listener/Permanent.java rename to FightSystem_Core/src/de/steamwar/fightsystem/listener/Permanent.java diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/PersonalKitCreator.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/PersonalKitCreator.java similarity index 100% rename from FightSystem_Main/src/de/steamwar/fightsystem/listener/PersonalKitCreator.java rename to FightSystem_Core/src/de/steamwar/fightsystem/listener/PersonalKitCreator.java diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/PistonListener.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/PistonListener.java similarity index 98% rename from FightSystem_Main/src/de/steamwar/fightsystem/listener/PistonListener.java rename to FightSystem_Core/src/de/steamwar/fightsystem/listener/PistonListener.java index 5be57c1..adb4195 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/listener/PistonListener.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/PistonListener.java @@ -23,7 +23,6 @@ import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentListener; import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.block.BlockPistonExtendEvent; diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/PrepareSchem.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/PrepareSchem.java similarity index 83% rename from FightSystem_Main/src/de/steamwar/fightsystem/listener/PrepareSchem.java rename to FightSystem_Core/src/de/steamwar/fightsystem/listener/PrepareSchem.java index a9c68e9..e1a39ad 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/listener/PrepareSchem.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/PrepareSchem.java @@ -19,18 +19,16 @@ package de.steamwar.fightsystem.listener; -import de.steamwar.core.VersionedCallable; -import de.steamwar.core.VersionedRunnable; import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.FightTeam; -import de.steamwar.fightsystem.fight.FightTeam_14; -import de.steamwar.fightsystem.fight.FightTeam_8; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentListener; +import de.steamwar.fightsystem.utils.FlatteningWrapper; import de.steamwar.fightsystem.utils.Region; +import de.steamwar.fightsystem.utils.WorldeditWrapper; import de.steamwar.sql.Schematic; import org.bukkit.Bukkit; import org.bukkit.World; @@ -60,9 +58,7 @@ public class PrepareSchem implements Listener { try{ region.forEach((x, y, z) -> { - if(VersionedCallable.call( - new VersionedCallable<>(() -> FightTeam_8.checkPistonMoving(world.getBlockAt(x, y, z)), 8), - new VersionedCallable<>(() -> FightTeam_14.checkPistonMoving(world.getBlockAt(x, y, z)), 14))){ + if(FlatteningWrapper.impl.checkPistonMoving(world.getBlockAt(x, y, z))){ FightSystem.shutdown(FightSystem.PREFIX + "§cIm Teambereich wurden sich noch bewegende Pistons gefunden, Einsenden wird abgebrochen."); throw new IllegalStateException(); } @@ -72,12 +68,10 @@ public class PrepareSchem implements Listener { } try{ - VersionedRunnable.call( - new VersionedRunnable(() -> FightTeam_8.saveSchem(schem, region, minY), 8), - new VersionedRunnable(() -> FightTeam_14.saveSchem(schem, region, minY), 14)); + WorldeditWrapper.impl.saveSchem(schem, region, minY); }catch(IllegalStateException e){ FightSystem.shutdown(FightSystem.PREFIX + "§cDie Schematic konnte nicht gespeichert werden, Einsenden wird abgebrochen."); - return; + throw new SecurityException("Could not save schem", e); } schem.setSchemType(Config.SchematicType.checkType()); diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/RankedJoin.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/RankedJoin.java similarity index 100% rename from FightSystem_Main/src/de/steamwar/fightsystem/listener/RankedJoin.java rename to FightSystem_Core/src/de/steamwar/fightsystem/listener/RankedJoin.java diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/Recording.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/Recording.java similarity index 90% rename from FightSystem_Main/src/de/steamwar/fightsystem/listener/Recording.java rename to FightSystem_Core/src/de/steamwar/fightsystem/listener/Recording.java index 0460e50..86d4377 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/listener/Recording.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/Recording.java @@ -25,7 +25,6 @@ import com.comphenix.protocol.events.PacketAdapter; import com.comphenix.protocol.events.PacketContainer; import com.comphenix.protocol.events.PacketEvent; import com.comphenix.protocol.wrappers.EnumWrappers; -import de.steamwar.core.Core; import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.fight.Fight; @@ -36,6 +35,9 @@ import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependent; import de.steamwar.fightsystem.states.StateDependentListener; import de.steamwar.fightsystem.states.StateDependentTask; +import de.steamwar.fightsystem.utils.BountifulWrapper; +import de.steamwar.fightsystem.utils.FlatteningWrapper; +import de.steamwar.fightsystem.utils.SWSound; import org.bukkit.*; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; @@ -65,8 +67,7 @@ public class Recording implements Listener { EnumWrappers.Hand hand = packet.getHands().read(0); Player p = event.getPlayer(); - if(!((hand == EnumWrappers.Hand.MAIN_HAND && p.getInventory().getItemInMainHand().getType() == Material.BOW) || - (hand == EnumWrappers.Hand.OFF_HAND && p.getInventory().getItemInOffHand().getType() == Material.BOW))) + if(!BountifulWrapper.impl.bowInHand(hand, p)) return; GlobalRecorder.getInstance().bowSpan(p, true, hand != EnumWrappers.Hand.MAIN_HAND); @@ -124,22 +125,6 @@ public class Recording implements Listener { GlobalRecorder.getInstance().entitySpeed(tnt); } }, 1, 1); - if(Core.getVersion() > 12){ - new StateDependentListener(ArenaMode.AntiReplay, FightState.All, new Listener() { - @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) - public void onBlockPhysics(BlockPhysicsEvent e){ - if(e.getBlock() == e.getSourceBlock() || e.getChangedType() == Material.AIR) - GlobalRecorder.getInstance().blockChange(e.getBlock()); - } - }); - }else{ - new StateDependentListener(ArenaMode.AntiReplay, FightState.All, new Listener() { - @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) - public void onBlockPhysics(BlockPhysicsEvent e){ - GlobalRecorder.getInstance().blockChange(e.getBlock()); - } - }); - } } @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @@ -163,6 +148,12 @@ public class Recording implements Listener { GlobalRecorder.getInstance().systemChat(e.getMessage()); } + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onBlockPhysics(BlockPhysicsEvent e){ + if(FlatteningWrapper.impl.doRecord(e)) + GlobalRecorder.getInstance().blockChange(e.getBlock()); + } + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onSneak(PlayerToggleSneakEvent e){ if(isNotSent(e.getPlayer())) @@ -223,7 +214,7 @@ public class Recording implements Listener { Location loc = e.getLocation(); GlobalRecorder.getInstance().entityDespawns(e.getEntity()); GlobalRecorder.getInstance().particle(loc.getX(), loc.getY(), loc.getZ(), Particle.EXPLOSION_HUGE.name()); - GlobalRecorder.getInstance().sound(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), Sound.ENTITY_GENERIC_EXPLODE.name(), SoundCategory.BLOCKS.name(), 4.0F, (1.0F + (random.nextFloat() - random.nextFloat()) * 0.2F) * 0.7F); + GlobalRecorder.getInstance().sound(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), SWSound.ENTITY_GENERIC_EXPLODE, EnumWrappers.SoundCategory.BLOCKS.name(), 4.0F, (1.0F + (random.nextFloat() - random.nextFloat()) * 0.2F) * 0.7F); } @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/ResourcePack.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/ResourcePack.java similarity index 60% rename from FightSystem_Main/src/de/steamwar/fightsystem/listener/ResourcePack.java rename to FightSystem_Core/src/de/steamwar/fightsystem/listener/ResourcePack.java index 019ff5e..dfe27c8 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/listener/ResourcePack.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/ResourcePack.java @@ -1,11 +1,10 @@ package de.steamwar.fightsystem.listener; -import de.steamwar.core.VersionedRunnable; import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.FightSystem; -import de.steamwar.fightsystem.fight.*; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentListener; +import de.steamwar.fightsystem.utils.CraftbukkitWrapper; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -21,7 +20,7 @@ public class ResourcePack implements Listener { @EventHandler public void handlePlayerJoin(PlayerJoinEvent event) { Player player = event.getPlayer(); - sendResourcePack(player, "https://steamwar.de/antixray.zip", "3e94f5abeb07cc95067b27705615ec14666abe7b"); + CraftbukkitWrapper.impl.sendResourcePack(player, "https://steamwar.de/antixray.zip", "3e94f5abeb07cc95067b27705615ec14666abe7b"); } @EventHandler @@ -34,14 +33,4 @@ public class ResourcePack implements Listener { player.sendMessage(FightSystem.PREFIX + "§cDa du abgelehnt hast, musst du nun in der Serverliste erst einmal wieder Ressourcenpakete von SteamWar aktivieren."); player.kickPlayer(null); } - - private void sendResourcePack(Player player, String pack, String sha1){ - VersionedRunnable.call( - new VersionedRunnable(() -> FightWorld_8.sendResourcePack(player, pack, sha1), 8), - new VersionedRunnable(() -> FightWorld_9.sendResourcePack(player, pack, sha1), 9), - new VersionedRunnable(() -> FightWorld_10.sendResourcePack(player, pack, sha1), 10), - new VersionedRunnable(() -> FightWorld_12.sendResourcePack(player, pack, sha1), 12), - new VersionedRunnable(() -> FightWorld_14.sendResourcePack(player, pack, sha1), 14), - new VersionedRunnable(() -> FightWorld_15.sendResourcePack(player, pack, sha1), 15)); - } } diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/SetupQuit.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/SetupQuit.java similarity index 100% rename from FightSystem_Main/src/de/steamwar/fightsystem/listener/SetupQuit.java rename to FightSystem_Core/src/de/steamwar/fightsystem/listener/SetupQuit.java diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/Shutdown.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/Shutdown.java similarity index 100% rename from FightSystem_Main/src/de/steamwar/fightsystem/listener/Shutdown.java rename to FightSystem_Core/src/de/steamwar/fightsystem/listener/Shutdown.java diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/TeamArea.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/TeamArea.java similarity index 100% rename from FightSystem_Main/src/de/steamwar/fightsystem/listener/TeamArea.java rename to FightSystem_Core/src/de/steamwar/fightsystem/listener/TeamArea.java diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/TestJoin.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/TestJoin.java similarity index 100% rename from FightSystem_Main/src/de/steamwar/fightsystem/listener/TestJoin.java rename to FightSystem_Core/src/de/steamwar/fightsystem/listener/TestJoin.java diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/WaterRemover.java b/FightSystem_Core/src/de/steamwar/fightsystem/listener/WaterRemover.java similarity index 82% rename from FightSystem_Main/src/de/steamwar/fightsystem/listener/WaterRemover.java rename to FightSystem_Core/src/de/steamwar/fightsystem/listener/WaterRemover.java index d33dc58..ae8059e 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/listener/WaterRemover.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/listener/WaterRemover.java @@ -19,11 +19,11 @@ package de.steamwar.fightsystem.listener; -import de.steamwar.core.VersionedCallable; import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentListener; +import de.steamwar.fightsystem.utils.FlatteningWrapper; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.event.EventHandler; @@ -55,9 +55,7 @@ public class WaterRemover implements Listener { private void checkBlock(Block b) { //checks for water and removes it, if present - if(!VersionedCallable.call( - new VersionedCallable<>(() -> WaterRemover_8.removeWater(b), 8), - new VersionedCallable<>(() -> WaterRemover_14.removeWater(b), 14))) + if(!FlatteningWrapper.impl.removeWater(b)) return; if(b.getY() < MIN_Y) @@ -69,10 +67,4 @@ public class WaterRemover implements Listener { checkBlock(b.getRelative(BlockFace.NORTH)); checkBlock(b.getRelative(BlockFace.SOUTH)); } - - public static boolean isWater(Block block){ - return VersionedCallable.call( - new VersionedCallable<>(() -> WaterRemover_8.isWater(block), 8), - new VersionedCallable<>(() -> WaterRemover_14.isWater(block), 14)); - } } diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/record/FileRecorder.java b/FightSystem_Core/src/de/steamwar/fightsystem/record/FileRecorder.java similarity index 100% rename from FightSystem_Main/src/de/steamwar/fightsystem/record/FileRecorder.java rename to FightSystem_Core/src/de/steamwar/fightsystem/record/FileRecorder.java diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/record/FileSource.java b/FightSystem_Core/src/de/steamwar/fightsystem/record/FileSource.java similarity index 100% rename from FightSystem_Main/src/de/steamwar/fightsystem/record/FileSource.java rename to FightSystem_Core/src/de/steamwar/fightsystem/record/FileSource.java diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/record/GlobalRecorder.java b/FightSystem_Core/src/de/steamwar/fightsystem/record/GlobalRecorder.java similarity index 100% rename from FightSystem_Main/src/de/steamwar/fightsystem/record/GlobalRecorder.java rename to FightSystem_Core/src/de/steamwar/fightsystem/record/GlobalRecorder.java diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/record/LiveRecorder.java b/FightSystem_Core/src/de/steamwar/fightsystem/record/LiveRecorder.java similarity index 100% rename from FightSystem_Main/src/de/steamwar/fightsystem/record/LiveRecorder.java rename to FightSystem_Core/src/de/steamwar/fightsystem/record/LiveRecorder.java diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/record/LiveServer.java b/FightSystem_Core/src/de/steamwar/fightsystem/record/LiveServer.java similarity index 100% rename from FightSystem_Main/src/de/steamwar/fightsystem/record/LiveServer.java rename to FightSystem_Core/src/de/steamwar/fightsystem/record/LiveServer.java diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/record/LiveSource.java b/FightSystem_Core/src/de/steamwar/fightsystem/record/LiveSource.java similarity index 100% rename from FightSystem_Main/src/de/steamwar/fightsystem/record/LiveSource.java rename to FightSystem_Core/src/de/steamwar/fightsystem/record/LiveSource.java diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/record/PacketProcessor.java b/FightSystem_Core/src/de/steamwar/fightsystem/record/PacketProcessor.java similarity index 93% rename from FightSystem_Main/src/de/steamwar/fightsystem/record/PacketProcessor.java rename to FightSystem_Core/src/de/steamwar/fightsystem/record/PacketProcessor.java index 57c53fd..1caa6c0 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/record/PacketProcessor.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/record/PacketProcessor.java @@ -29,7 +29,10 @@ import de.steamwar.fightsystem.countdown.EventSpectateCountdown; import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.fight.FreezeWorld; +import de.steamwar.fightsystem.listener.BasicListener; import de.steamwar.fightsystem.listener.FightScoreboard; +import de.steamwar.fightsystem.utils.BlockIdWrapper; +import de.steamwar.fightsystem.utils.BountifulWrapper; import de.steamwar.fightsystem.utils.TechHider; import de.steamwar.sql.Schematic; import de.steamwar.sql.Team; @@ -38,7 +41,6 @@ import net.md_5.bungee.api.chat.BaseComponent; import net.md_5.bungee.api.chat.TextComponent; import org.bukkit.*; import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitTask; import java.io.EOFException; @@ -62,8 +64,8 @@ public class PacketProcessor { private final PacketSource source; private final BukkitTask task; private final LinkedList syncList = new LinkedList<>(); - private final Set hiddenBlockIds = TechHider.getHiddenBlockIds(); - private final int obfuscateWith = TechHider.getObfuscateWith(); + private final Set hiddenBlockIds = BlockIdWrapper.impl.getHiddenBlockIds(); + private final int obfuscateWith = BlockIdWrapper.impl.getObfuscateWith(); private final FreezeWorld freezer = new FreezeWorld(); private boolean rotateZ = false; @@ -228,7 +230,19 @@ public class PacketProcessor { String message = source.readUTF(); BaseComponent[] text = TextComponent.fromLegacyText(message); - Bukkit.getOnlinePlayers().forEach(p -> p.spigot().sendMessage(type, text)); + Bukkit.getOnlinePlayers().forEach(p -> { + switch(type){ + case CHAT: + BountifulWrapper.impl.toChat(p, text); + break; + case SYSTEM: + p.spigot().sendMessage(text); + break; + case ACTION_BAR: + BasicListener.toActionbar(p, text); + break; + } + }); } private void arenaInfo() throws IOException { @@ -275,7 +289,7 @@ public class PacketProcessor { if(!Config.ArenaRegion.in2dRegion(x, z)) return; //Outside of the arena - execSync(() -> setBlockInternal(x, y, z, TechHider.ENABLED && hiddenBlockIds.contains(blockState) ? obfuscateWith : blockState)); + execSync(() -> BlockIdWrapper.impl.setBlock(world, x, y, z, TechHider.ENABLED && hiddenBlockIds.contains(blockState) ? obfuscateWith : blockState)); } private void particle() throws IOException { @@ -313,11 +327,7 @@ public class PacketProcessor { Sound sound = Sound.valueOf(soundName); - execSync(() -> { - for(Player player : Bukkit.getOnlinePlayers()){ - player.playSound(player.getLocation(), sound, volume, pitch); - } - }); + execSync(() -> Fight.playSound(sound, volume, pitch)); } private void pasteSchem(FightTeam team) throws IOException { @@ -428,12 +438,6 @@ public class PacketProcessor { } } - private static void setBlockInternal(int x, int y, int z, int blockState){ - VersionedRunnable.call(new VersionedRunnable(() -> RecordSystem_8.setBlock(world, x, y, z, blockState), 8), - new VersionedRunnable(() -> RecordSystem_14.setBlock(world, x, y, z, blockState), 14), - new VersionedRunnable(() -> RecordSystem_15.setBlock(world, x, y, z, blockState), 15)); - } - private interface PacketParser{ void process() throws IOException; } diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/record/PacketSource.java b/FightSystem_Core/src/de/steamwar/fightsystem/record/PacketSource.java similarity index 100% rename from FightSystem_Main/src/de/steamwar/fightsystem/record/PacketSource.java rename to FightSystem_Core/src/de/steamwar/fightsystem/record/PacketSource.java diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/record/REntity.java b/FightSystem_Core/src/de/steamwar/fightsystem/record/REntity.java similarity index 97% rename from FightSystem_Main/src/de/steamwar/fightsystem/record/REntity.java rename to FightSystem_Core/src/de/steamwar/fightsystem/record/REntity.java index 6e2d067..880b41d 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/record/REntity.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/record/REntity.java @@ -26,8 +26,8 @@ import com.comphenix.protocol.reflect.StructureModifier; import com.comphenix.protocol.wrappers.*; import com.mojang.authlib.GameProfile; import de.steamwar.core.Core; -import de.steamwar.core.VersionedCallable; import de.steamwar.fightsystem.listener.FightScoreboard; +import de.steamwar.fightsystem.utils.BlockIdWrapper; import de.steamwar.sql.SteamwarUser; import net.royawesome.jlibnoise.MathHelper; import org.bukkit.Bukkit; @@ -80,7 +80,7 @@ public class REntity { } if(entity.sneaks) { if(Core.getVersion() > 12){ - ProtocolLibrary.getProtocolManager().sendServerPacket(player, entity.getDataWatcherPacket(6, getPose(true))); + ProtocolLibrary.getProtocolManager().sendServerPacket(player, entity.getDataWatcherPacket(6, BlockIdWrapper.impl.getPose(true))); }else{ ProtocolLibrary.getProtocolManager().sendServerPacket(player, entity.getDataWatcherPacket(0, (byte) 2)); } @@ -192,7 +192,7 @@ public class REntity { sneaks = sneaking; if(Core.getVersion() > 12){ - ProtocolLibrary.getProtocolManager().broadcastServerPacket(getDataWatcherPacket(6, getPose(sneaking))); + ProtocolLibrary.getProtocolManager().broadcastServerPacket(getDataWatcherPacket(6, BlockIdWrapper.impl.getPose(sneaking))); }else{ ProtocolLibrary.getProtocolManager().broadcastServerPacket(getDataWatcherPacket(0, sneaking ? (byte) 2 : (byte) 0)); } @@ -370,9 +370,4 @@ public class REntity { } return namedSpawnPacket; } - - private static Object getPose(boolean sneaking){ - return VersionedCallable.call(new VersionedCallable<>(() -> RecordSystem_14.getPose(sneaking), 14), - new VersionedCallable<>(() -> RecordSystem_15.getPose(sneaking), 15)); - } } diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/record/Recorder.java b/FightSystem_Core/src/de/steamwar/fightsystem/record/Recorder.java similarity index 90% rename from FightSystem_Main/src/de/steamwar/fightsystem/record/Recorder.java rename to FightSystem_Core/src/de/steamwar/fightsystem/record/Recorder.java index d9f2f40..4e6525a 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/record/Recorder.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/record/Recorder.java @@ -19,11 +19,15 @@ package de.steamwar.fightsystem.record; -import de.steamwar.core.VersionedCallable; import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.Config; -import de.steamwar.fightsystem.fight.*; +import de.steamwar.fightsystem.fight.Fight; +import de.steamwar.fightsystem.fight.FightPlayer; +import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.states.FightState; +import de.steamwar.fightsystem.utils.BlockIdWrapper; +import de.steamwar.fightsystem.utils.CraftbukkitWrapper; +import de.steamwar.fightsystem.utils.SWSound; import de.steamwar.sql.Schematic; import de.steamwar.sql.SteamwarUser; import org.bukkit.Bukkit; @@ -132,14 +136,7 @@ public interface Recorder { default void entityMoves(Entity e){ Location location = e.getLocation(); - write(0x01, e.getEntityId(), location.getX(), location.getY(), location.getZ(), location.getPitch(), location.getYaw(), (byte)(VersionedCallable.call( - new VersionedCallable<>(() -> FightWorld_8.headRotation(e), 8), - new VersionedCallable<>(() -> FightWorld_9.headRotation(e), 9), - new VersionedCallable<>(() -> FightWorld_10.headRotation(e), 10), - new VersionedCallable<>(() -> FightWorld_12.headRotation(e), 12), - new VersionedCallable<>(() -> FightWorld_14.headRotation(e), 14), - new VersionedCallable<>(() -> FightWorld_15.headRotation(e), 15) - ) * 256 / 360)); + write(0x01, e.getEntityId(), location.getX(), location.getY(), location.getZ(), location.getPitch(), location.getYaw(), (byte) (CraftbukkitWrapper.impl.headRotation(e) * 256 / 360)); } default void entityDespawns(Entity e){ @@ -201,9 +198,7 @@ public interface Recorder { } default void blockChange(Block block){ - int blockState = VersionedCallable.call(new VersionedCallable<>(() -> RecordSystem_8.blockToId(block), 8), - new VersionedCallable<>(() -> RecordSystem_14.blockToId(block), 14), - new VersionedCallable<>(() -> RecordSystem_15.blockToId(block), 15)); + int blockState = BlockIdWrapper.impl.blockToId(block); int shortX = block.getX() - Config.ArenaRegion.getMinX(); int shortY = block.getY() - Config.BluePasteRegion.getMinY(); @@ -221,8 +216,8 @@ public interface Recorder { write(0x31, x, y, z, particleType); } - default void sound(int x, int y, int z, String soundType, String soundCategory, float volume, float pitch){ - write(0x32, x, y, z, soundType, soundCategory, volume, pitch); + default void sound(int x, int y, int z, SWSound soundType, String soundCategory, float volume, float pitch){ + write(0x32, x, y, z, soundType.getSound().name(), soundCategory, volume, pitch); } default void soundAtPlayer(String soundType, float volume, float pitch){ diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/states/FightState.java b/FightSystem_Core/src/de/steamwar/fightsystem/states/FightState.java similarity index 100% rename from FightSystem_Main/src/de/steamwar/fightsystem/states/FightState.java rename to FightSystem_Core/src/de/steamwar/fightsystem/states/FightState.java diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/states/IStateDependent.java b/FightSystem_Core/src/de/steamwar/fightsystem/states/IStateDependent.java similarity index 100% rename from FightSystem_Main/src/de/steamwar/fightsystem/states/IStateDependent.java rename to FightSystem_Core/src/de/steamwar/fightsystem/states/IStateDependent.java diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/states/OneShotStateDependent.java b/FightSystem_Core/src/de/steamwar/fightsystem/states/OneShotStateDependent.java similarity index 100% rename from FightSystem_Main/src/de/steamwar/fightsystem/states/OneShotStateDependent.java rename to FightSystem_Core/src/de/steamwar/fightsystem/states/OneShotStateDependent.java diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/states/StateDependent.java b/FightSystem_Core/src/de/steamwar/fightsystem/states/StateDependent.java similarity index 100% rename from FightSystem_Main/src/de/steamwar/fightsystem/states/StateDependent.java rename to FightSystem_Core/src/de/steamwar/fightsystem/states/StateDependent.java diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/states/StateDependentCommand.java b/FightSystem_Core/src/de/steamwar/fightsystem/states/StateDependentCommand.java similarity index 100% rename from FightSystem_Main/src/de/steamwar/fightsystem/states/StateDependentCommand.java rename to FightSystem_Core/src/de/steamwar/fightsystem/states/StateDependentCommand.java diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/states/StateDependentCountdown.java b/FightSystem_Core/src/de/steamwar/fightsystem/states/StateDependentCountdown.java similarity index 100% rename from FightSystem_Main/src/de/steamwar/fightsystem/states/StateDependentCountdown.java rename to FightSystem_Core/src/de/steamwar/fightsystem/states/StateDependentCountdown.java diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/states/StateDependentListener.java b/FightSystem_Core/src/de/steamwar/fightsystem/states/StateDependentListener.java similarity index 100% rename from FightSystem_Main/src/de/steamwar/fightsystem/states/StateDependentListener.java rename to FightSystem_Core/src/de/steamwar/fightsystem/states/StateDependentListener.java diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/states/StateDependentTask.java b/FightSystem_Core/src/de/steamwar/fightsystem/states/StateDependentTask.java similarity index 100% rename from FightSystem_Main/src/de/steamwar/fightsystem/states/StateDependentTask.java rename to FightSystem_Core/src/de/steamwar/fightsystem/states/StateDependentTask.java diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/utils/BlockIdWrapper.java b/FightSystem_Core/src/de/steamwar/fightsystem/utils/BlockIdWrapper.java new file mode 100644 index 0000000..d293875 --- /dev/null +++ b/FightSystem_Core/src/de/steamwar/fightsystem/utils/BlockIdWrapper.java @@ -0,0 +1,42 @@ +/* + This file is a part of the SteamWar software. + + Copyright (C) 2021 SteamWar.de-Serverteam + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ + +package de.steamwar.fightsystem.utils; + +import de.steamwar.fightsystem.VersionDependent; +import org.bukkit.World; +import org.bukkit.block.Block; + +import java.util.Set; + +public class BlockIdWrapper { + private BlockIdWrapper() {} + + public static final IBlockIdWrapper impl = VersionDependent.getVersionImpl(BlockIdWrapper.class.getName()); + + public interface IBlockIdWrapper { + int blockToId(Block block); + void setBlock(World world, int x, int y, int z, int blockState); + + Set getHiddenBlockIds(); + int getObfuscateWith(); + + Object getPose(boolean sneaking); + } +} diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/utils/BountifulWrapper.java b/FightSystem_Core/src/de/steamwar/fightsystem/utils/BountifulWrapper.java new file mode 100644 index 0000000..e6705b8 --- /dev/null +++ b/FightSystem_Core/src/de/steamwar/fightsystem/utils/BountifulWrapper.java @@ -0,0 +1,43 @@ +/* + This file is a part of the SteamWar software. + + Copyright (C) 2021 SteamWar.de-Serverteam + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ + +package de.steamwar.fightsystem.utils; + +import com.comphenix.protocol.wrappers.EnumWrappers; +import de.steamwar.fightsystem.VersionDependent; +import net.md_5.bungee.api.chat.BaseComponent; +import org.bukkit.entity.Player; +import org.bukkit.scoreboard.Team; + +public class BountifulWrapper { + private BountifulWrapper() {} + + public static final IBountifulWrapper impl = VersionDependent.getVersionImpl(BountifulWrapper.class.getName()); + + public interface IBountifulWrapper { + boolean bowInHand(EnumWrappers.Hand hand, Player p); + + void toActionbar(Player player, BaseComponent... components); + void toChat(Player player, BaseComponent... components); + + void setAttackSpeed(Player player); + + void setNametagVisibility(Team team); + } +} diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/utils/ColorConverter.java b/FightSystem_Core/src/de/steamwar/fightsystem/utils/ColorConverter.java similarity index 86% rename from FightSystem_Main/src/de/steamwar/fightsystem/utils/ColorConverter.java rename to FightSystem_Core/src/de/steamwar/fightsystem/utils/ColorConverter.java index faa10ac..32f4451 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/utils/ColorConverter.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/utils/ColorConverter.java @@ -19,7 +19,6 @@ package de.steamwar.fightsystem.utils; -import de.steamwar.core.VersionedRunnable; import org.bukkit.ChatColor; import org.bukkit.DyeColor; @@ -47,10 +46,7 @@ public class ColorConverter { chat2dye.put(ChatColor.DARK_GREEN, DyeColor.GREEN); chat2dye.put(ChatColor.DARK_RED, DyeColor.RED); chat2dye.put(ChatColor.BLACK, DyeColor.BLACK); - //Rosa 9pink, Braun 3brown - - VersionedRunnable.call(new VersionedRunnable(() -> chat2dye.put(ChatColor.GRAY, ColorConverter_8.getSilver()), 8), - new VersionedRunnable(() -> chat2dye.put(ChatColor.GRAY, ColorConverter_14.getSilver()), 14)); + chat2dye.put(ChatColor.GRAY, FlatteningWrapper.impl.getSilver()); } public static DyeColor chat2dye(ChatColor color){ diff --git a/FightSystem_8/src/de/steamwar/fightsystem/listener/PersonalKitCreator_8.java b/FightSystem_Core/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper.java similarity index 53% rename from FightSystem_8/src/de/steamwar/fightsystem/listener/PersonalKitCreator_8.java rename to FightSystem_Core/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper.java index aa34f31..a39b895 100644 --- a/FightSystem_8/src/de/steamwar/fightsystem/listener/PersonalKitCreator_8.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/utils/CraftbukkitWrapper.java @@ -1,7 +1,7 @@ /* This file is a part of the SteamWar software. - Copyright (C) 2020 SteamWar.de-Serverteam + Copyright (C) 2021 SteamWar.de-Serverteam This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by @@ -15,22 +15,25 @@ 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; +package de.steamwar.fightsystem.utils; -import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack; +import de.steamwar.fightsystem.VersionDependent; +import org.bukkit.World; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import java.util.HashSet; -import java.util.Set; +public class CraftbukkitWrapper { + private CraftbukkitWrapper() {} -public class PersonalKitCreator_8 { + public static final ICraftbukkitWrapper impl = VersionDependent.getVersionImpl(CraftbukkitWrapper.class.getName()); - public static boolean hasItems(ItemStack stack){ - Set keys = new HashSet<>(CraftItemStack.asNMSCopy(stack).getTag().c()); - keys.remove("Enchantments"); - keys.remove("Damage"); - return !keys.isEmpty(); + public interface ICraftbukkitWrapper { + void resetChunk(World world, World backup, int x, int z); + void sendResourcePack(Player player, String pack, String sha1); + float headRotation(Entity e); + boolean hasItems(ItemStack stack); } } diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/utils/EnterHandler.java b/FightSystem_Core/src/de/steamwar/fightsystem/utils/EnterHandler.java similarity index 100% rename from FightSystem_Main/src/de/steamwar/fightsystem/utils/EnterHandler.java rename to FightSystem_Core/src/de/steamwar/fightsystem/utils/EnterHandler.java diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/utils/FightStatistics.java b/FightSystem_Core/src/de/steamwar/fightsystem/utils/FightStatistics.java similarity index 100% rename from FightSystem_Main/src/de/steamwar/fightsystem/utils/FightStatistics.java rename to FightSystem_Core/src/de/steamwar/fightsystem/utils/FightStatistics.java diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/utils/FlatteningWrapper.java b/FightSystem_Core/src/de/steamwar/fightsystem/utils/FlatteningWrapper.java new file mode 100644 index 0000000..a3b09e2 --- /dev/null +++ b/FightSystem_Core/src/de/steamwar/fightsystem/utils/FlatteningWrapper.java @@ -0,0 +1,53 @@ +/* + This file is a part of the SteamWar software. + + Copyright (C) 2021 SteamWar.de-Serverteam + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ + +package de.steamwar.fightsystem.utils; + +import de.steamwar.fightsystem.VersionDependent; +import org.bukkit.DyeColor; +import org.bukkit.Material; +import org.bukkit.World; +import org.bukkit.block.Block; +import org.bukkit.event.block.BlockPhysicsEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + +public class FlatteningWrapper { + private FlatteningWrapper() {} + + public static final IFlatteningWrapper impl = VersionDependent.getVersionImpl(FlatteningWrapper.class.getName()); + + public interface IFlatteningWrapper { + DyeColor getSilver(); + + boolean isWater(Block block); + boolean removeWater(Block block); + + boolean containsBlockMeta(ItemMeta meta); + boolean hasAttributeModifier(ItemStack stack); + + Material onBreak(Material type); + + boolean doRecord(BlockPhysicsEvent e); + + void forceLoadChunk(World world, int cX, int cZ); + + boolean checkPistonMoving(Block block); + } +} diff --git a/FightSystem_API/src/de/steamwar/fightsystem/utils/ITechHider.java b/FightSystem_Core/src/de/steamwar/fightsystem/utils/ITechHider.java similarity index 90% rename from FightSystem_API/src/de/steamwar/fightsystem/utils/ITechHider.java rename to FightSystem_Core/src/de/steamwar/fightsystem/utils/ITechHider.java index ade4044..c772ec2 100644 --- a/FightSystem_API/src/de/steamwar/fightsystem/utils/ITechHider.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/utils/ITechHider.java @@ -1,7 +1,7 @@ -/* +/* This file is a part of the SteamWar software. - - Copyright (C) 2020 SteamWar.de-Serverteam + + Copyright (C) 2021 SteamWar.de-Serverteam This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by @@ -15,15 +15,15 @@ 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 com.google.common.primitives.Bytes; import de.steamwar.fightsystem.Config; -import de.steamwar.fightsystem.IFightSystem; -import de.steamwar.fightsystem.fight.IFight; -import de.steamwar.fightsystem.fight.IFightTeam; +import de.steamwar.fightsystem.FightSystem; +import de.steamwar.fightsystem.fight.Fight; +import de.steamwar.fightsystem.fight.FightTeam; import org.bukkit.entity.Player; import java.util.ArrayList; @@ -33,10 +33,10 @@ public class ITechHider { private ITechHider (){} static boolean bypass(Player p, int chunkX, int chunkZ){ - if(p == IFightSystem.getEventLeiter()) + if(p == FightSystem.getEventLeiter()) return true; - IFightTeam ft = IFight.getPlayerTeam(p); + FightTeam ft = Fight.getPlayerTeam(p); if(ft == null){ return Config.ArenaRegion.chunkOutside(chunkX, chunkZ); }else if(ft.isBlue()){ diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/utils/ItemBuilder.java b/FightSystem_Core/src/de/steamwar/fightsystem/utils/ItemBuilder.java similarity index 100% rename from FightSystem_Main/src/de/steamwar/fightsystem/utils/ItemBuilder.java rename to FightSystem_Core/src/de/steamwar/fightsystem/utils/ItemBuilder.java diff --git a/FightSystem_API/src/de/steamwar/fightsystem/utils/Region.java b/FightSystem_Core/src/de/steamwar/fightsystem/utils/Region.java similarity index 98% rename from FightSystem_API/src/de/steamwar/fightsystem/utils/Region.java rename to FightSystem_Core/src/de/steamwar/fightsystem/utils/Region.java index 4f38486..809b530 100644 --- a/FightSystem_API/src/de/steamwar/fightsystem/utils/Region.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/utils/Region.java @@ -1,7 +1,7 @@ /* This file is a part of the SteamWar software. - Copyright (C) 2020 SteamWar.de-Serverteam + Copyright (C) 2021 SteamWar.de-Serverteam This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by @@ -15,7 +15,7 @@ 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; diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/utils/SWSound.java b/FightSystem_Core/src/de/steamwar/fightsystem/utils/SWSound.java new file mode 100644 index 0000000..9d6ece4 --- /dev/null +++ b/FightSystem_Core/src/de/steamwar/fightsystem/utils/SWSound.java @@ -0,0 +1,40 @@ +/* + This file is a part of the SteamWar software. + + Copyright (C) 2021 SteamWar.de-Serverteam + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ + +package de.steamwar.fightsystem.utils; + +import de.steamwar.fightsystem.VersionDependent; +import org.bukkit.Sound; + +public enum SWSound { + ENTITY_WITHER_DEATH, + BLOCK_NOTE_PLING, + BLOCK_NOTE_BASS, + ENTITY_GENERIC_EXPLODE; + + private static final ISWSound impl = VersionDependent.getVersionImpl(SWSound.class.getName()); + + public Sound getSound() { + return impl.getSound(this); + } + + public interface ISWSound { + Sound getSound(SWSound sound); + } +} diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/utils/TechHider.java b/FightSystem_Core/src/de/steamwar/fightsystem/utils/TechHider.java similarity index 84% rename from FightSystem_Main/src/de/steamwar/fightsystem/utils/TechHider.java rename to FightSystem_Core/src/de/steamwar/fightsystem/utils/TechHider.java index 49e39e6..6414551 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/utils/TechHider.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/utils/TechHider.java @@ -31,12 +31,11 @@ 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.VersionedCallable; import de.steamwar.core.events.ChunkListener; import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.FightSystem; -import de.steamwar.fightsystem.IFightSystem; +import de.steamwar.fightsystem.VersionDependent; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependent; import org.bukkit.Bukkit; @@ -61,20 +60,15 @@ public class TechHider extends StateDependent { public TechHider(){ super(ENABLED, FightState.Schem); - Set hiddenBlockIds = getHiddenBlockIds(); - int obfuscateWith = getObfuscateWith(); - obfuscateMaterial = Material.getMaterial(Config.ObfuscateWith.toUpperCase()); - chunkHider = VersionedCallable.call(new VersionedCallable<>(() -> null, 8), - new VersionedCallable<>(() -> TechHider_12.chunkHider(hiddenBlockIds, obfuscateWith), 12), - new VersionedCallable<>(() -> TechHider_14.chunkHider(hiddenBlockIds, obfuscateWith), 14)); + chunkHider = VersionDependent.getVersionImpl(TechHider.class.getName()); if(Config.mode == ArenaMode.EVENT) threadMultiplier = 4; else threadMultiplier = 1; - Bukkit.getScheduler().runTaskTimer(IFightSystem.getPlugin(), packetCache::clear, 1, 1); + Bukkit.getScheduler().runTaskTimer(FightSystem.getPlugin(), packetCache::clear, 1, 1); if(Core.getVersion() > 8){ protocolManager.addPacketListener(new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Client.USE_ITEM) { @@ -104,15 +98,13 @@ public class TechHider extends StateDependent { protocolManager.addPacketListener(blockHider); protocolManager.addPacketListener(multiBlockHider); protocolManager.addPacketListener(blockActionHider); + protocolManager.getAsynchronousManager().registerAsyncHandler(chunkHider).start(threadMultiplier * 4); if(Core.getVersion() > 8) { protocolManager.addPacketListener(updateBlockEntity); } if(Core.getVersion() > 12) { protocolManager.addPacketListener(blockBreakHider); } - if(chunkHider != null) { - protocolManager.getAsynchronousManager().registerAsyncHandler(chunkHider).start(threadMultiplier * 4); - } } @Override @@ -120,18 +112,16 @@ public class TechHider extends StateDependent { protocolManager.removePacketListener(blockHider); protocolManager.removePacketListener(multiBlockHider); protocolManager.removePacketListener(blockActionHider); + protocolManager.getAsynchronousManager().unregisterAsyncHandler(chunkHider); if(Core.getVersion() > 8) { protocolManager.removePacketListener(updateBlockEntity); } if(Core.getVersion() > 12) { protocolManager.removePacketListener(blockBreakHider); } - if(chunkHider != null) { - protocolManager.getAsynchronousManager().unregisterAsyncHandler(chunkHider); - } } - private final PacketAdapter multiBlockHider = new PacketAdapter(IFightSystem.getPlugin(), PacketType.Play.Server.MULTI_BLOCK_CHANGE) { + private final PacketAdapter multiBlockHider = new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Server.MULTI_BLOCK_CHANGE) { @Override public void onPacketSending(PacketEvent e) { PacketContainer packet = e.getPacket(); @@ -168,7 +158,7 @@ public class TechHider extends StateDependent { } }; - private final PacketAdapter blockHider = new PacketAdapter(IFightSystem.getPlugin(), PacketType.Play.Server.BLOCK_CHANGE) { + private final PacketAdapter blockHider = new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Server.BLOCK_CHANGE) { @Override public void onPacketSending(PacketEvent e) { PacketContainer packet = e.getPacket(); @@ -196,7 +186,7 @@ public class TechHider extends StateDependent { } }; - private final PacketAdapter blockActionHider = new PacketAdapter(IFightSystem.getPlugin(), PacketType.Play.Server.BLOCK_ACTION) { + private final PacketAdapter blockActionHider = new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Server.BLOCK_ACTION) { @Override public void onPacketSending(PacketEvent e) { PacketContainer packet = e.getPacket(); @@ -210,7 +200,7 @@ public class TechHider extends StateDependent { } }; - private final PacketAdapter blockBreakHider = new PacketAdapter(IFightSystem.getPlugin(), PacketType.Play.Server.BLOCK_BREAK) { + private final PacketAdapter blockBreakHider = new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Server.BLOCK_BREAK) { @Override public void onPacketSending(PacketEvent e) { PacketContainer packet = e.getPacket(); @@ -257,20 +247,6 @@ public class TechHider extends StateDependent { } }; - public static Set getHiddenBlockIds(){ - return VersionedCallable.call( - new VersionedCallable<>(TechHider_8::getHiddenBlockIds, 8), - new VersionedCallable<>(TechHider_14::getHiddenBlockIds, 14), - new VersionedCallable<>(TechHider_15::getHiddenBlockIds, 15)); - } - - public static int getObfuscateWith(){ - return VersionedCallable.call( - new VersionedCallable<>(TechHider_8::getObfuscateWith, 8), - new VersionedCallable<>(TechHider_14::getObfuscateWith, 14), - new VersionedCallable<>(TechHider_15::getObfuscateWith, 15)); - } - public static List prepareChunkReload(Player p, boolean hide){ if(!ENABLED) return Collections.emptyList(); diff --git a/FightSystem_Core/src/de/steamwar/fightsystem/utils/WorldeditWrapper.java b/FightSystem_Core/src/de/steamwar/fightsystem/utils/WorldeditWrapper.java new file mode 100644 index 0000000..cc7ad07 --- /dev/null +++ b/FightSystem_Core/src/de/steamwar/fightsystem/utils/WorldeditWrapper.java @@ -0,0 +1,43 @@ +/* + This file is a part of the SteamWar software. + + Copyright (C) 2021 SteamWar.de-Serverteam + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ + +package de.steamwar.fightsystem.utils; + +import com.sk89q.worldedit.WorldEditException; +import com.sk89q.worldedit.extent.clipboard.Clipboard; +import com.sk89q.worldedit.math.transform.AffineTransform; +import de.steamwar.fightsystem.VersionDependent; +import de.steamwar.sql.Schematic; +import org.bukkit.DyeColor; + +import java.io.IOException; + +public class WorldeditWrapper { + private WorldeditWrapper() {} + + public static final IWorldeditWrapper impl = VersionDependent.getVersionImpl(WorldeditWrapper.class.getName()); + + public interface IWorldeditWrapper { + void replaceTeamColor(Clipboard clipboard, DyeColor c) throws WorldEditException; + void pasteSchematic(Clipboard clipboard, Region region, boolean rotate); + void pasteChar(Clipboard character, int charOffset, int length, int x, int y, int z, AffineTransform aT); + Clipboard loadChar(String charName) throws IOException; + void saveSchem(Schematic schem, Region region, int minY); + } +} diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/EventTeamOffWincondition.java b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/EventTeamOffWincondition.java similarity index 100% rename from FightSystem_Main/src/de/steamwar/fightsystem/winconditions/EventTeamOffWincondition.java rename to FightSystem_Core/src/de/steamwar/fightsystem/winconditions/EventTeamOffWincondition.java diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/PercentWincondition.java b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/PercentWincondition.java similarity index 100% rename from FightSystem_Main/src/de/steamwar/fightsystem/winconditions/PercentWincondition.java rename to FightSystem_Core/src/de/steamwar/fightsystem/winconditions/PercentWincondition.java diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/PrintableWincondition.java b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/PrintableWincondition.java similarity index 100% rename from FightSystem_Main/src/de/steamwar/fightsystem/winconditions/PrintableWincondition.java rename to FightSystem_Core/src/de/steamwar/fightsystem/winconditions/PrintableWincondition.java diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/RankedPlayerLeftWincondition.java b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/RankedPlayerLeftWincondition.java similarity index 100% rename from FightSystem_Main/src/de/steamwar/fightsystem/winconditions/RankedPlayerLeftWincondition.java rename to FightSystem_Core/src/de/steamwar/fightsystem/winconditions/RankedPlayerLeftWincondition.java diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/Wincondition.java b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/Wincondition.java similarity index 100% rename from FightSystem_Main/src/de/steamwar/fightsystem/winconditions/Wincondition.java rename to FightSystem_Core/src/de/steamwar/fightsystem/winconditions/Wincondition.java diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionAllDead.java b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionAllDead.java similarity index 100% rename from FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionAllDead.java rename to FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionAllDead.java diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionCaptainDead.java b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionCaptainDead.java similarity index 100% rename from FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionCaptainDead.java rename to FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionCaptainDead.java diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionHeartRatioTimeout.java b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionHeartRatioTimeout.java similarity index 100% rename from FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionHeartRatioTimeout.java rename to FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionHeartRatioTimeout.java diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionPercentSystem.java b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPercentSystem.java similarity index 100% rename from FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionPercentSystem.java rename to FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPercentSystem.java diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionPercentTimeout.java b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPercentTimeout.java similarity index 100% rename from FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionPercentTimeout.java rename to FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPercentTimeout.java diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionPoints.java b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPoints.java similarity index 100% rename from FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionPoints.java rename to FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPoints.java diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionPumpkinTechKO.java b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPumpkinTechKO.java similarity index 100% rename from FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionPumpkinTechKO.java rename to FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionPumpkinTechKO.java diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionRelativePercent.java b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionRelativePercent.java similarity index 100% rename from FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionRelativePercent.java rename to FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionRelativePercent.java diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionTimeTechKO.java b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionTimeTechKO.java similarity index 98% rename from FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionTimeTechKO.java rename to FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionTimeTechKO.java index dfc9f6d..659e3a4 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionTimeTechKO.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionTimeTechKO.java @@ -22,7 +22,7 @@ package de.steamwar.fightsystem.winconditions; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.countdown.Countdown; -import de.steamwar.fightsystem.countdown.SWSound; +import de.steamwar.fightsystem.utils.SWSound; import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.FightTeam; import de.steamwar.fightsystem.states.FightState; diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionTimeout.java b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionTimeout.java similarity index 100% rename from FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionTimeout.java rename to FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionTimeout.java diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionWaterTechKO.java b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionWaterTechKO.java similarity index 95% rename from FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionWaterTechKO.java rename to FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionWaterTechKO.java index d548f8c..2510815 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionWaterTechKO.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/WinconditionWaterTechKO.java @@ -23,9 +23,9 @@ import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.FightTeam; -import de.steamwar.fightsystem.listener.WaterRemover; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentTask; +import de.steamwar.fightsystem.utils.FlatteningWrapper; import org.bukkit.Bukkit; import org.bukkit.World; @@ -69,7 +69,7 @@ public class WinconditionWaterTechKO extends Wincondition implements PrintableWi private void check() { water = 0; team.getExtendRegion().forEach((x, y, z) -> { - if (WaterRemover.isWater(WORLD.getBlockAt(x, y, z))) + if (FlatteningWrapper.impl.isWater(WORLD.getBlockAt(x, y, z))) water++; }); diff --git a/FightSystem_API/src/de/steamwar/fightsystem/winconditions/Winconditions.java b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/Winconditions.java similarity index 95% rename from FightSystem_API/src/de/steamwar/fightsystem/winconditions/Winconditions.java rename to FightSystem_Core/src/de/steamwar/fightsystem/winconditions/Winconditions.java index 604cc99..eb52f04 100644 --- a/FightSystem_API/src/de/steamwar/fightsystem/winconditions/Winconditions.java +++ b/FightSystem_Core/src/de/steamwar/fightsystem/winconditions/Winconditions.java @@ -1,7 +1,7 @@ /* This file is a part of the SteamWar software. - Copyright (C) 2020 SteamWar.de-Serverteam + Copyright (C) 2021 SteamWar.de-Serverteam This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by @@ -15,7 +15,7 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . -*/ + */ package de.steamwar.fightsystem.winconditions; diff --git a/FightSystem_Main/src/plugin.yml b/FightSystem_Core/src/plugin.yml similarity index 100% rename from FightSystem_Main/src/plugin.yml rename to FightSystem_Core/src/plugin.yml diff --git a/FightSystem_Main/pom.xml b/FightSystem_Main/pom.xml index 3083862..2cd94da 100644 --- a/FightSystem_Main/pom.xml +++ b/FightSystem_Main/pom.xml @@ -1,4 +1,23 @@ + + @@ -18,16 +37,6 @@ 1.0 - src - - - src - - **/*.java - **/*.kt - - - org.apache.maven.plugins @@ -47,20 +56,6 @@ - - steamwar - Spigot - 1.15 - system - ${main.basedir}/lib/Spigot-1.15.jar - - - steamwar - WorldEdit - 1.0 - system - ${main.basedir}/lib/WorldEdit-1.12.jar - steamwar FightSystem_8 @@ -99,7 +94,7 @@ steamwar - FightSystem_API + FightSystem_Core 1.0 compile diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/BasicListener.java b/FightSystem_Main/src/de/steamwar/fightsystem/listener/BasicListener.java deleted file mode 100644 index c572101..0000000 --- a/FightSystem_Main/src/de/steamwar/fightsystem/listener/BasicListener.java +++ /dev/null @@ -1,47 +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 de.steamwar.core.VersionedRunnable; -import de.steamwar.fightsystem.fight.Fight; -import net.md_5.bungee.api.chat.BaseComponent; -import org.bukkit.entity.Player; - -public class BasicListener { - private BasicListener(){} - - public static boolean notFighting(Player p){ - return Fight.getFightPlayer(p) == null; - } - - public static void toActionbar(Player player, BaseComponent... components){ - VersionedRunnable.call(new VersionedRunnable(() -> BasicListener_8.toActionbar(player, components), 8), - new VersionedRunnable(() -> BasicListener_9.toActionbar(player, components), 9)); - } - - public static void toChat(Player player, BaseComponent... components){ - VersionedRunnable.call(new VersionedRunnable(() -> BasicListener_8.toChat(player, components), 8), - new VersionedRunnable(() -> BasicListener_9.toChat(player, components), 9)); - } - - public static void setAttackSpeed(Player player){ - VersionedRunnable.call(new VersionedRunnable(() -> BasicListener_9.setAttackSpeed(player), 9)); - } -} diff --git a/pom.xml b/pom.xml index 455d1b6..da93e94 100644 --- a/pom.xml +++ b/pom.xml @@ -26,17 +26,37 @@ 1.8 + + org.apache.maven.plugins + maven-jar-plugin + 3.2.0 + + + false + + + + src + + + src + + **/*.java + **/*.kt + + + - FightSystem_API FightSystem_8 FightSystem_9 FightSystem_10 FightSystem_12 FightSystem_14 FightSystem_15 + FightSystem_Core FightSystem_Main