From 95e901115ade2c32f14510aa3f3294d4dc38bcc0 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sat, 23 Nov 2019 18:15:45 +0100 Subject: [PATCH] Full untested 1.14 without 1.14 Techhider --- FightSystem_12/pom.xml | 6 + .../fightsystem/fight/FightTeam_12.java | 14 +- .../fightsystem/utils/TechHider_12.java | 231 +++++++++++++++++ .../fightsystem/utils/WaterRemover_12.java | 11 + FightSystem_14/pom.xml | 6 + .../fightsystem/fight/FightTeam_14.java | 87 +++++++ .../fightsystem/utils/WaterRemover_14.java | 11 + FightSystem_8/pom.xml | 6 + .../fightsystem/fight/FightTeam_8.java | 16 +- .../src/de/steamwar/fightsystem/Config.java | 40 ++- .../fightsystem/utils/ITechHider.java | 26 +- FightSystem_Main/pom.xml | 6 + .../de/steamwar/fightsystem/fight/Fight.java | 4 +- .../steamwar/fightsystem/fight/FightTeam.java | 44 ++-- .../steamwar/fightsystem/utils/TechHider.java | 237 +----------------- .../fightsystem/utils/WaterRemover.java | 17 +- .../WinconditionWaterTechKO.java | 5 +- pom.xml | 6 - 18 files changed, 476 insertions(+), 297 deletions(-) create mode 100644 FightSystem_12/src/de/steamwar/fightsystem/utils/WaterRemover_12.java create mode 100644 FightSystem_14/src/de/steamwar/fightsystem/fight/FightTeam_14.java create mode 100644 FightSystem_14/src/de/steamwar/fightsystem/utils/WaterRemover_14.java diff --git a/FightSystem_12/pom.xml b/FightSystem_12/pom.xml index 09aae32..c4ab97a 100644 --- a/FightSystem_12/pom.xml +++ b/FightSystem_12/pom.xml @@ -43,6 +43,12 @@ 1.0 provided + + steamwar + WorldEdit + 1.0 + provided + steamwar Spigot diff --git a/FightSystem_12/src/de/steamwar/fightsystem/fight/FightTeam_12.java b/FightSystem_12/src/de/steamwar/fightsystem/fight/FightTeam_12.java index bfd47f0..71cd313 100644 --- a/FightSystem_12/src/de/steamwar/fightsystem/fight/FightTeam_12.java +++ b/FightSystem_12/src/de/steamwar/fightsystem/fight/FightTeam_12.java @@ -8,6 +8,7 @@ import com.sk89q.worldedit.bukkit.BukkitWorld; import com.sk89q.worldedit.math.transform.AffineTransform; import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.world.World; +import de.steamwar.fightsystem.Config; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.DyeColor; @@ -41,14 +42,17 @@ public class FightTeam_12 { @SuppressWarnings("deprecation") - static void replaceTeamColor(EditSession e, DyeColor c, CuboidRegion region){ - FightTeam_8.replaceTeamColor(e, c, region); + static void replaceTeamColor(EditSession e, DyeColor c, int cornerX, int cornerY, int cornerZ){ + FightTeam_8.replaceTeamColor(e, c, cornerX, cornerY, cornerZ); + Vector corner = new Vector(cornerX, cornerY, cornerZ); + CuboidRegion region = new CuboidRegion(corner, corner.add(Config.SchemsizeX, Config.SchemsizeY, Config.SchemsizeZ)); e.replaceBlocks(region, CONCRETE_SET, new BaseBlock(CONCRETE.getId(), c.getWoolData())); e.replaceBlocks(region, CONCRETE_POWDER_SET, new BaseBlock(CONCRETE_POWDER.getId(), c.getWoolData())); } - static EditSession pasteSchematic(File file, Vector paste, boolean rotate, boolean alignWater, int waterDepth){ + static EditSession pasteSchematic(File file, int pasteX, int pasteY, int pasteZ, boolean rotate){ com.boydti.fawe.object.schematic.Schematic schem; + Vector paste = new Vector(pasteX, pasteY, pasteZ); try { schem = FaweAPI.load(file); if(schem.getClipboard() == null) @@ -70,14 +74,14 @@ public class FightTeam_12 { v = paste.subtract(dimensions.getX()/2 - dimensions.getX()%2, 0, dimensions.getZ()/2 - dimensions.getZ()%2).subtract(offset); } - if(alignWater){ + if(Config.AlignWater){ Vector it = schem.getClipboard().getMinimumPoint(); int depth = 0; while(!schem.getClipboard().getBlock(it).isAir()){ depth++; it = it.setY(it.getY()+1); } - v = v.add(0, waterDepth - depth, 0); + v = v.add(0, Config.WaterDepth - depth, 0); } return schem.paste(w, v, false, true, aT); diff --git a/FightSystem_12/src/de/steamwar/fightsystem/utils/TechHider_12.java b/FightSystem_12/src/de/steamwar/fightsystem/utils/TechHider_12.java index ca07526..6beb2c5 100644 --- a/FightSystem_12/src/de/steamwar/fightsystem/utils/TechHider_12.java +++ b/FightSystem_12/src/de/steamwar/fightsystem/utils/TechHider_12.java @@ -1,15 +1,246 @@ package de.steamwar.fightsystem.utils; +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.ProtocolLibrary; +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.BlockPosition; +import com.comphenix.protocol.wrappers.ChunkCoordIntPair; +import com.comphenix.protocol.wrappers.MultiBlockChangeInfo; +import com.comphenix.protocol.wrappers.WrappedBlockData; +import com.comphenix.protocol.wrappers.nbt.NbtCompound; +import com.comphenix.protocol.wrappers.nbt.NbtFactory; +import de.steamwar.fightsystem.Config; +import de.steamwar.fightsystem.IFightSystem; +import de.steamwar.inventory.SWItem; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.UnpooledByteBufAllocator; import javafx.util.Pair; import net.minecraft.server.v1_12_R1.PacketPlayOutMapChunk; +import org.bukkit.Material; import org.bukkit.craftbukkit.v1_12_R1.CraftChunk; import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer; import org.bukkit.entity.Player; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import static de.steamwar.fightsystem.utils.ITechHider.bypass; + class TechHider_12 { private TechHider_12(){} + private static final short obfuscateShift4; + private static final Set hiddenBlocks; + + static{ + //noinspection deprecation + obfuscateShift4 = (short)(SWItem.getMaterial(Config.ObfuscateWith).getId() << 4); + + Set hBs = new HashSet<>(); + for(String mat : Config.HiddenBlocks){ + //noinspection deprecation + hBs.add(Material.getMaterial(mat).getId()); + } + hiddenBlocks = Collections.unmodifiableSet(hBs); + } + static void reloadChunk(Player p, Pair chunk){ ((CraftPlayer)p).getHandle().playerConnection.sendPacket(new PacketPlayOutMapChunk(((CraftChunk)p.getWorld().getChunkAt(chunk.getKey(), chunk.getValue())).getHandle(), 65535)); } + + static void start(){ + chunkHider(); + multiBlockHider(); + blockHider(); + blockActionHider(); + } + + private static void chunkHider(){ + ProtocolLibrary.getProtocolManager().getAsynchronousManager().registerAsyncHandler(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; + + PacketContainer cached = ITechHider.packetCache.get(packet); + if(cached != null){ + e.setPacket(cached); + return; + } + + cached = packet.deepClone(); + ITechHider.packetCache.put(packet, cached); + e.setPacket(cached); + StructureModifier list = cached.getSpecificModifier(List.class); + List nmsTags = list.read(0); + boolean changed = false; + for(int i = nmsTags.size() - 1; i >= 0; i--){ + NbtCompound nbt = NbtFactory.fromNMSCompound(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 = cached.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 < 4) + bitsPerBlock = 4; + else if(bitsPerBlock > 8){ + bitsPerBlock = 13; + buffer.writeByte(data[++i]); + } + + 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 actPalette = ITechHider.readVarInt(data, i); + int actPaletteLength = ITechHider.readVarIntLength(data, i); + + int blockId = actPalette >> 4; + if(hiddenBlocks.contains(blockId)){ + byte[] a = ITechHider.writeVarInt(obfuscateShift4); + buffer.writeBytes(a); + changed = true; + }else{ + buffer.writeBytes(data, i, actPaletteLength); + } + i += actPaletteLength; + } + 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{ + 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); + } + } + }).start(ITechHider.threadMultiplier * 4); + } + + private static void multiBlockHider(){ + ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(IFightSystem.getPlugin(), PacketType.Play.Server.MULTI_BLOCK_CHANGE) { + @Override + public void onPacketSending(PacketEvent e) { + PacketContainer packet = e.getPacket(); + + Player p = e.getPlayer(); + ChunkCoordIntPair pos = packet.getChunkCoordIntPairs().read(0); + if(bypass(p, pos.getChunkX(), pos.getChunkZ())) + return; + + PacketContainer cached = ITechHider.packetCache.get(packet); + if(cached != null){ + e.setPacket(cached); + return; + } + + cached = packet.shallowClone(); + ITechHider.packetCache.put(packet, cached); + e.setPacket(cached); + StructureModifier blockStructure = cached.getMultiBlockChangeInfoArrays(); + MultiBlockChangeInfo[] changes = blockStructure.read(0).clone(); + boolean changed = false; + for(MultiBlockChangeInfo mbci : changes){ + WrappedBlockData block = mbci.getData(); + //noinspection deprecation + if(hiddenBlocks.contains(block.getType().getId())){ + changed = true; + block.setType(ITechHider.obfuscateMaterial); + mbci.setData(block); + } + } + + if(changed){ + blockStructure.write(0, changes); + } + } + }); + } + + private static void blockHider(){ + ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(IFightSystem.getPlugin(), PacketType.Play.Server.BLOCK_CHANGE) { + @Override + public void onPacketSending(PacketEvent e) { + PacketContainer packet = e.getPacket(); + BlockPosition pos = packet.getBlockPositionModifier().read(0); + + Player p = e.getPlayer(); + if(bypass(p, ITechHider.posToChunk(pos.getX()), ITechHider.posToChunk(pos.getZ()))) + return; + + PacketContainer cached = ITechHider.packetCache.get(packet); + if(cached != null){ + e.setPacket(cached); + return; + } + + cached = packet.deepClone(); + ITechHider.packetCache.put(packet, cached); + e.setPacket(cached); + StructureModifier blockStructure = cached.getBlockData(); + WrappedBlockData block = blockStructure.read(0); + //noinspection deprecation + if(hiddenBlocks.contains(block.getType().getId())){ + block.setType(ITechHider.obfuscateMaterial); + blockStructure.write(0, block); + } + } + }); + } + + private static void blockActionHider(){ + ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(IFightSystem.getPlugin(), PacketType.Play.Server.BLOCK_ACTION) { + @Override + public void onPacketSending(PacketEvent e) { + PacketContainer packet = e.getPacket(); + BlockPosition pos = packet.getBlockPositionModifier().read(0); + + Player p = e.getPlayer(); + if(bypass(p, ITechHider.posToChunk(pos.getX()), ITechHider.posToChunk(pos.getZ()))) + return; + + e.setCancelled(true); + } + }); + } } diff --git a/FightSystem_12/src/de/steamwar/fightsystem/utils/WaterRemover_12.java b/FightSystem_12/src/de/steamwar/fightsystem/utils/WaterRemover_12.java new file mode 100644 index 0000000..06bbd21 --- /dev/null +++ b/FightSystem_12/src/de/steamwar/fightsystem/utils/WaterRemover_12.java @@ -0,0 +1,11 @@ +package de.steamwar.fightsystem.utils; + +import org.bukkit.Material; + +class WaterRemover_12 { + private WaterRemover_12(){} + + static boolean isWater(Material type){ + return type == Material.WATER || type == Material.STATIONARY_WATER; + } +} diff --git a/FightSystem_14/pom.xml b/FightSystem_14/pom.xml index 3019895..f6d65f0 100644 --- a/FightSystem_14/pom.xml +++ b/FightSystem_14/pom.xml @@ -38,5 +38,11 @@ FightSystem_API 1.0 + + steamwar + FAWE + 1.14 + provided + \ No newline at end of file diff --git a/FightSystem_14/src/de/steamwar/fightsystem/fight/FightTeam_14.java b/FightSystem_14/src/de/steamwar/fightsystem/fight/FightTeam_14.java new file mode 100644 index 0000000..0d06b54 --- /dev/null +++ b/FightSystem_14/src/de/steamwar/fightsystem/fight/FightTeam_14.java @@ -0,0 +1,87 @@ +package de.steamwar.fightsystem.fight; + +import com.boydti.fawe.FaweAPI; +import com.sk89q.worldedit.EditSession; +import com.sk89q.worldedit.bukkit.BukkitWorld; +import com.sk89q.worldedit.math.BlockVector3; +import com.sk89q.worldedit.math.transform.AffineTransform; +import com.sk89q.worldedit.regions.CuboidRegion; +import com.sk89q.worldedit.world.World; +import com.sk89q.worldedit.world.block.BaseBlock; +import com.sk89q.worldedit.world.block.BlockState; +import de.steamwar.fightsystem.Config; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.DyeColor; +import org.bukkit.scoreboard.Team; + +import java.io.File; +import java.io.IOException; +import java.util.Collections; +import java.util.Set; +import java.util.logging.Level; + +class FightTeam_14 { + private FightTeam_14(){} + + private static final Set WOOL_SET = Collections.singleton(new BaseBlock(BlockState.get("PINK_WOOL"))); + private static final Set CLAY_SET = Collections.singleton(new BaseBlock(BlockState.get("PINK_TERRACOTTA"))); + private static final Set GLASS_SET = Collections.singleton(new BaseBlock(BlockState.get("PINK_STAINED_GLASS"))); + private static final Set GLASS_PANE_SET = Collections.singleton(new BaseBlock(BlockState.get("PINK_STAINED_GLASS_PANE"))); + private static final Set CONCRETE_SET = Collections.singleton(new BaseBlock(BlockState.get("PINK_CONCRETE"))); + private static final Set CONCRETE_POWDER_SET = Collections.singleton(new BaseBlock(BlockState.get("PINK_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(EditSession e, DyeColor c, int cornerX, int cornerY, int cornerZ){ + BlockVector3 corner3 = BlockVector3.at(cornerX, cornerY, cornerZ); + BlockVector3 schemsize3 = BlockVector3.at(Config.SchemsizeX, Config.SchemsizeY, Config.SchemsizeZ); + CuboidRegion region = new CuboidRegion(corner3, corner3.add(schemsize3)); + e.replaceBlocks(region, WOOL_SET, new BaseBlock(BlockState.get(c.name() + "_WOOL"))); + e.replaceBlocks(region, CLAY_SET, new BaseBlock(BlockState.get(c.name() + "_TERRACOTTA"))); + e.replaceBlocks(region, GLASS_SET, new BaseBlock(BlockState.get(c.name() + "_STAINED_GLASS"))); + e.replaceBlocks(region, GLASS_PANE_SET, new BaseBlock(BlockState.get(c.name() + "_STAINED_GLASS_PANE"))); + e.replaceBlocks(region, CONCRETE_SET, new BaseBlock(BlockState.get(c.name() + "_CONCRETE"))); + e.replaceBlocks(region, CONCRETE_POWDER_SET, new BaseBlock(BlockState.get(c.name() + "_CONCRETE_POWDER"))); + } + + static EditSession pasteSchematic(File file, int pX, int pY, int pZ, boolean rotate){ + BlockVector3 paste = BlockVector3.at(pX, pY, pZ); + com.boydti.fawe.object.schematic.Schematic schem; + try { + schem = FaweAPI.load(file); + if(schem.getClipboard() == null) + throw new IOException(); + }catch(IOException e){ + Bukkit.getLogger().log(Level.SEVERE, "Failed loading Schematic", e); + return null; + } + + World w = new BukkitWorld(Bukkit.getWorlds().get(0)); + BlockVector3 dimensions = schem.getClipboard().getDimensions(); + BlockVector3 v; + BlockVector3 offset = schem.getClipboard().getRegion().getMinimumPoint().subtract(schem.getClipboard().getOrigin()); + AffineTransform aT = new AffineTransform(); + if(rotate){ + aT = aT.rotateY(180); + v = paste.add(dimensions.getX()/2 + dimensions.getX()%2, 0, dimensions.getZ()/2 + dimensions.getZ()%2).subtract(offset.multiply(-1, 1, -1)).subtract(1, 0, 1); + }else{ + v = paste.subtract(dimensions.getX()/2 - dimensions.getX()%2, 0, dimensions.getZ()/2 - dimensions.getZ()%2).subtract(offset); + } + + if(Config.AlignWater){ + BlockVector3 it = schem.getClipboard().getMinimumPoint(); + int depth = 0; + while(!schem.getClipboard().getBlock(it).getMaterial().isAir()){ + depth++; + it = it.add(0, 1, 0); + } + v = v.add(0, Config.WaterDepth - depth, 0); + } + + return schem.paste(w, v, false, true, aT); + } +} diff --git a/FightSystem_14/src/de/steamwar/fightsystem/utils/WaterRemover_14.java b/FightSystem_14/src/de/steamwar/fightsystem/utils/WaterRemover_14.java new file mode 100644 index 0000000..2e173bf --- /dev/null +++ b/FightSystem_14/src/de/steamwar/fightsystem/utils/WaterRemover_14.java @@ -0,0 +1,11 @@ +package de.steamwar.fightsystem.utils; + +import org.bukkit.Material; + +class WaterRemover_14 { + private WaterRemover_14(){} + + static boolean isWater(Material type){ + return type == Material.WATER; + } +} diff --git a/FightSystem_8/pom.xml b/FightSystem_8/pom.xml index 0354cb3..7e0b234 100644 --- a/FightSystem_8/pom.xml +++ b/FightSystem_8/pom.xml @@ -38,5 +38,11 @@ FightSystem_API 1.0 + + steamwar + WorldEdit + 1.0 + provided + \ No newline at end of file diff --git a/FightSystem_8/src/de/steamwar/fightsystem/fight/FightTeam_8.java b/FightSystem_8/src/de/steamwar/fightsystem/fight/FightTeam_8.java index ef10ebe..cce899a 100644 --- a/FightSystem_8/src/de/steamwar/fightsystem/fight/FightTeam_8.java +++ b/FightSystem_8/src/de/steamwar/fightsystem/fight/FightTeam_8.java @@ -7,6 +7,8 @@ import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.schematic.SchematicFormat; import com.sk89q.worldedit.world.DataException; import com.sk89q.worldedit.world.World; +import de.steamwar.fightsystem.Config; +import de.steamwar.fightsystem.IFightSystem; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.DyeColor; @@ -15,7 +17,6 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.HandlerList; import org.bukkit.event.Listener; import org.bukkit.event.block.BlockPhysicsEvent; -import org.bukkit.plugin.Plugin; import org.bukkit.scoreboard.NameTagVisibility; import org.bukkit.scoreboard.Team; @@ -51,7 +52,9 @@ class FightTeam_8 { } @SuppressWarnings("deprecation") - static void replaceTeamColor(EditSession e, DyeColor c, CuboidRegion region){ + static void replaceTeamColor(EditSession e, DyeColor c, int cornerX, int cornerY, int cornerZ){ + Vector corner = new Vector(cornerX, cornerY, cornerZ); + CuboidRegion region = new CuboidRegion(corner, corner.add(Config.SchemsizeX, Config.SchemsizeY, Config.SchemsizeZ)); try { e.replaceBlocks(region, WOOL_SET, new BaseBlock(WOOL.getId(), c.getWoolData())); e.replaceBlocks(region, CLAY_SET, new BaseBlock(CLAY.getId(), c.getWoolData())); @@ -62,7 +65,8 @@ class FightTeam_8 { } } - static EditSession pasteSchematic(File file, Vector paste, boolean rotate, boolean alignWater, int waterDepth, Plugin plugin){ + static EditSession pasteSchematic(File file, int pasteX, int pasteY, int pasteZ, boolean rotate){ + Vector paste = new Vector(pasteX, pasteY, pasteZ); CuboidClipboard clipboard; try { @@ -83,19 +87,19 @@ class FightTeam_8 { v = paste.subtract(dimensions.getX()/2 - dimensions.getX()%2, 0, dimensions.getZ()/2 - dimensions.getZ()%2).subtract(offset); } - if(alignWater){ + if(Config.AlignWater){ Vector it = Vector.ZERO; int depth = 0; while(!clipboard.getBlock(it).isAir()){ depth++; it = it.setY(it.getY()+1); } - v = v.add(0, waterDepth - depth, 0); + v = v.add(0, Config.WaterDepth - depth, 0); } EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(w, -1); FreezeWorld freezer = new FreezeWorld(); - Bukkit.getPluginManager().registerEvents(freezer, plugin); + Bukkit.getPluginManager().registerEvents(freezer, IFightSystem.getPlugin()); try { clipboard.paste(e, v, false, true); } catch (MaxChangedBlocksException ex) { diff --git a/FightSystem_API/src/de/steamwar/fightsystem/Config.java b/FightSystem_API/src/de/steamwar/fightsystem/Config.java index 55b4e2e..23cff16 100644 --- a/FightSystem_API/src/de/steamwar/fightsystem/Config.java +++ b/FightSystem_API/src/de/steamwar/fightsystem/Config.java @@ -1,6 +1,5 @@ package de.steamwar.fightsystem; -import com.sk89q.worldedit.Vector; import de.steamwar.sql.Event; import de.steamwar.sql.EventFight; import de.steamwar.sql.Team; @@ -30,19 +29,18 @@ public class Config { public static final int SchemsizeX; public static final int SchemsizeY; public static final int SchemsizeZ; - public static final Vector Schemsize; public static final int TeamBlueCornerX; public static final int TeamBlueCornerY; public static final int TeamBlueCornerZ; - public static final Vector TeamBlueCorner; + private static final int TeamBluePasteX; + private static final int TeamBluePasteZ; public static final Location TeamBlueSpawn; - public static final Vector TeamBluePaste; public static final int TeamRedCornerX; public static final int TeamRedCornerY; public static final int TeamRedCornerZ; - public static final Vector TeamRedCorner; + private static final int TeamRedPasteX; + private static final int TeamRedPasteZ; public static final Location TeamRedSpawn; - public static final Vector TeamRedPaste; private static final int TeamBluetoReddistanceX; private static final int TeamBluetoReddistanceY; public static final int TeamBluetoReddistanceZ; @@ -95,9 +93,9 @@ public class Config { public static final String LeaderDefault; //tech hider parameter - public static final List HiddenBlocks; + public static final List HiddenBlocks; public static final List HiddenBlockEntities; - public static final int ObfuscateWith; + public static final String ObfuscateWith; //event parameter private static final int EventKampfID; @@ -165,9 +163,9 @@ public class Config { MemberDefault = config.getString("Kits.MemberDefault"); LeaderDefault = config.getString("Kits.LeaderDefault"); - HiddenBlocks = Collections.unmodifiableList(config.getIntegerList("Techhider.HiddenBlocks")); + HiddenBlocks = Collections.unmodifiableList(config.getStringList("Techhider.HiddenBlocks")); HiddenBlockEntities = Collections.unmodifiableList(config.getStringList("Techhider.HiddenBlockEntities")); - ObfuscateWith = config.getInt("Techhider.ObfuscateWith"); + ObfuscateWith = config.getString("Techhider.ObfuscateWith"); if(schemsizeX < 0){ SchemsizeX = -schemsizeX; @@ -197,24 +195,18 @@ public class Config { TeamRedCornerY = TeamBluetoReddistanceY + TeamBlueCornerY; TeamRedCornerZ = TeamBluetoReddistanceZ + TeamBlueCornerZ; - int teamBluePasteX = TeamBlueCornerX + SchemsizeX / 2; - int teamBluePasteZ = TeamBlueCornerZ + SchemsizeZ / 2; - int teamRedPasteX = teamBluePasteX + TeamBluetoReddistanceX; - int teamRedPasteZ = teamBluePasteZ + TeamBluetoReddistanceZ; - - TeamBluePaste = new Vector(teamBluePasteX, TeamBlueCornerY, teamBluePasteZ); - TeamRedPaste = new Vector(teamRedPasteX, TeamRedCornerY, teamRedPasteZ); - Schemsize = new Vector(SchemsizeX, SchemsizeY, SchemsizeZ); - TeamBlueCorner = new Vector(TeamBlueCornerX, TeamBlueCornerY, TeamBlueCornerZ); - TeamRedCorner = new Vector(TeamRedCornerX, TeamRedCornerY, TeamRedCornerZ); + TeamBluePasteX = TeamBlueCornerX + SchemsizeX / 2; + TeamBluePasteZ = TeamBlueCornerZ + SchemsizeZ / 2; + TeamRedPasteX = TeamBluePasteX + TeamBluetoReddistanceX; + TeamRedPasteZ = TeamBluePasteZ + TeamBluetoReddistanceZ; World world = Bukkit.getWorlds().get(0); - TeamBlueSpawn = new Location(world, teamBluePasteX + 0.5, TeamBlueCornerY + (double)SchemsizeY, teamBluePasteZ + 0.5); - TeamRedSpawn = new Location(world, teamRedPasteX + 0.5, TeamRedCornerY + (double)SchemsizeY, teamRedPasteZ + 0.5); + TeamBlueSpawn = new Location(world, TeamBluePasteX + 0.5, TeamBlueCornerY + (double)SchemsizeY, TeamBluePasteZ + 0.5); + TeamRedSpawn = new Location(world, TeamRedPasteX + 0.5, TeamRedCornerY + (double)SchemsizeY, TeamRedPasteZ + 0.5); SpecSpawn = new Location(world, - teamBluePasteX + TeamBluetoReddistanceX/2.0, + TeamBluePasteX + TeamBluetoReddistanceX/2.0, TeamBlueCornerY + TeamBluetoReddistanceY/2.0 + SchemsizeY/2.0, - teamBluePasteZ + TeamBluetoReddistanceZ/2.0); + TeamBluePasteZ + TeamBluetoReddistanceZ/2.0); boolean teamRedRotate; boolean teamBlueRotate; diff --git a/FightSystem_API/src/de/steamwar/fightsystem/utils/ITechHider.java b/FightSystem_API/src/de/steamwar/fightsystem/utils/ITechHider.java index cea8016..5d2a58d 100644 --- a/FightSystem_API/src/de/steamwar/fightsystem/utils/ITechHider.java +++ b/FightSystem_API/src/de/steamwar/fightsystem/utils/ITechHider.java @@ -1,18 +1,32 @@ package de.steamwar.fightsystem.utils; +import com.comphenix.protocol.events.PacketContainer; 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.inventory.SWItem; +import org.bukkit.Bukkit; +import org.bukkit.Material; import org.bukkit.entity.Player; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; public class ITechHider { private ITechHider (){} + static final Map packetCache = new HashMap<>(); + static final Material obfuscateMaterial; + static final int threadMultiplier; + static final int arenaMinX; + static final int arenaMaxX; + static final int arenaMinZ; + static final int arenaMaxZ; + private static final int blueMinX; private static final int blueMaxX; private static final int blueMinZ; @@ -21,10 +35,6 @@ public class ITechHider { private static final int redMaxX; private static final int redMinZ; private static final int redMaxZ; - private static int arenaMinX; - private static int arenaMaxX; - private static int arenaMinZ; - private static int arenaMaxZ; static{ blueMinX = ITechHider.posToChunk(Config.TeamBlueCornerX); @@ -39,6 +49,14 @@ public class ITechHider { arenaMaxX = ITechHider.posToChunk(Config.ArenaMaxX) + 1; arenaMinZ = ITechHider.posToChunk(Config.ArenaMinZ); arenaMaxZ = ITechHider.posToChunk(Config.ArenaMaxZ) + 1; + + obfuscateMaterial = SWItem.getMaterial(Config.ObfuscateWith); + Bukkit.getScheduler().runTaskTimer(IFightSystem.getPlugin(), packetCache::clear, 1, 1); + + if(Config.event()) + threadMultiplier = 4; + else + threadMultiplier = 1; } static boolean bypass(Player p, int chunkX, int chunkZ){ diff --git a/FightSystem_Main/pom.xml b/FightSystem_Main/pom.xml index 41c7cb5..fd1557d 100644 --- a/FightSystem_Main/pom.xml +++ b/FightSystem_Main/pom.xml @@ -73,5 +73,11 @@ 1.0 compile + + steamwar + WorldEdit + 1.0 + provided + \ No newline at end of file diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/fight/Fight.java b/FightSystem_Main/src/de/steamwar/fightsystem/fight/Fight.java index e1fbc94..9fab60b 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/fight/Fight.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/fight/Fight.java @@ -8,8 +8,8 @@ import org.bukkit.entity.Player; public class Fight { private Fight(){} - public static final FightTeam redTeam = new FightTeam(Config.TeamRedName, Config.TeamRedPrefix, Config.TeamRedSpawn, Config.TeamRedPaste, Config.TeamRedCorner, Config.TeamRedRotate, false, Config.RedLeader); - public static final FightTeam blueTeam = new FightTeam(Config.TeamBlueName, Config.TeamBluePrefix, Config.TeamBlueSpawn, Config.TeamBluePaste, Config.TeamBlueCorner, Config.TeamBlueRotate, true, Config.BlueLeader); + public static final FightTeam redTeam = new FightTeam(Config.TeamRedName, Config.TeamRedPrefix, Config.TeamRedSpawn, Config.TeamRedCornerX, Config.TeamRedCornerY, Config.TeamRedCornerZ, Config.TeamRedRotate, false, Config.RedLeader); + public static final FightTeam blueTeam = new FightTeam(Config.TeamBlueName, Config.TeamBluePrefix, Config.TeamBlueSpawn, Config.TeamBlueCornerX, Config.TeamBlueCornerY, Config.TeamBlueCornerZ, Config.TeamBlueRotate, true, Config.BlueLeader); public static void init(){ IFight.init(redTeam, blueTeam); diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightTeam.java b/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightTeam.java index e9feb35..be15e27 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightTeam.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/fight/FightTeam.java @@ -1,8 +1,6 @@ package de.steamwar.fightsystem.fight; import com.sk89q.worldedit.EditSession; -import com.sk89q.worldedit.Vector; -import com.sk89q.worldedit.regions.CuboidRegion; import de.steamwar.core.Core; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.FightSystem; @@ -43,18 +41,26 @@ public class FightTeam implements IFightTeam{ private final boolean blue; private final Location spawn; - private final Vector paste; - private final Vector corner; + private final int pasteX; + private final int pasteY; + private final int pasteZ; + private final int cornerX; + private final int cornerY; + private final int cornerZ; private final boolean rotate; - public FightTeam(String name, String prefix, Location spawn, Vector paste, Vector corner, boolean rotate, boolean blue, UUID designatedLeader) { + public FightTeam(String name, String prefix, Location spawn, int cornerX, int cornerY, int cornerZ, boolean rotate, boolean blue, UUID designatedLeader) { this.spawn = spawn; - this.paste = paste; + this.pasteX = cornerX + Config.SchemsizeX/2; + this.pasteY = cornerY; + this.pasteZ = cornerZ + Config.SchemsizeZ/2; this.name = name; this.prefix = prefix; this.ready = false; this.rotate = rotate; - this.corner = corner; + this.cornerX = cornerX; + this.cornerY = cornerY; + this.cornerZ = cornerZ; this.blue = blue; this.designatedLeader = designatedLeader; color = ChatColor.getByChar(ChatColor.getLastColors(prefix).replace("§", "")); @@ -71,6 +77,9 @@ public class FightTeam implements IFightTeam{ case 8: FightTeam_8.setTeamColor(team, color); break; + case 14: + FightTeam_14.setTeamColor(team, color); + break; default: FightTeam_12.setTeamColor(team, color); } @@ -192,10 +201,10 @@ public class FightTeam implements IFightTeam{ inventory.setItem(1, new ItemBuilder(Material.AIR).build()); if(!Config.event()){ inventory.setItem(2, new ItemBuilder(Material.PAPER).removeAllAttributs().setDisplayName("§eSpieler einladen").build()); - inventory.setItem(3, new ItemBuilder(Material.getMaterial("FIREWORK_CHARGE")).removeAllAttributs().setDisplayName("§cSpieler rauswerfen").build()); - inventory.setItem(4, new ItemBuilder(Material.getMaterial("INK_SACK"), (short) 10).removeAllAttributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§cNicht bereit").build()); + inventory.setItem(3, new ItemBuilder(SWItem.getMaterial("FIREWORK_CHARGE")).removeAllAttributs().setDisplayName("§cSpieler rauswerfen").build()); + inventory.setItem(4, new ItemBuilder(SWItem.getDye(10), (short) 10).removeAllAttributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§cNicht bereit").build()); } - inventory.setItem(0, new ItemBuilder(Material.getMaterial("CAULDRON_ITEM")).removeAllAttributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§e" + Config.GameName + " wählen").build()); + inventory.setItem(0, new ItemBuilder(SWItem.getMaterial("CAULDRON_ITEM")).removeAllAttributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§e" + Config.GameName + " wählen").build()); } public Set getPlayers() { @@ -211,25 +220,30 @@ public class FightTeam implements IFightTeam{ EditSession e; switch(Core.getVersion()){ case 8: - e = FightTeam_8.pasteSchematic(file, paste, rotate, Config.AlignWater, Config.WaterDepth, FightSystem.getPlugin()); + e = FightTeam_8.pasteSchematic(file, pasteX, pasteY, pasteZ, rotate); + break; + case 14: + e = FightTeam_14.pasteSchematic(file, pasteX, pasteY, pasteZ, rotate); break; default: - e = FightTeam_12.pasteSchematic(file, paste, rotate, Config.AlignWater, Config.WaterDepth); + e = FightTeam_12.pasteSchematic(file, pasteX, pasteY, pasteZ, rotate); } replaceTeamColor(e); Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), this::teleportToSpawn,40); } private void replaceTeamColor(EditSession e){ - CuboidRegion region = new CuboidRegion(corner, corner.add(Config.Schemsize)); DyeColor c = ColorConverter.chat2dye(color); switch(Core.getVersion()){ case 8: - FightTeam_8.replaceTeamColor(e, c, region); + FightTeam_8.replaceTeamColor(e, c, cornerX, cornerY, cornerZ); + break; + case 14: + FightTeam_14.replaceTeamColor(e, c, cornerX, cornerY, cornerZ); break; default: - FightTeam_12.replaceTeamColor(e, c, region); + FightTeam_12.replaceTeamColor(e, c, cornerX, cornerY, cornerZ); } e.flushQueue(); diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/utils/TechHider.java b/FightSystem_Main/src/de/steamwar/fightsystem/utils/TechHider.java index 604174b..50cf397 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/utils/TechHider.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/utils/TechHider.java @@ -3,69 +3,38 @@ package de.steamwar.fightsystem.utils; import com.comphenix.protocol.PacketType; import com.comphenix.protocol.ProtocolLibrary; 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.BlockPosition; -import com.comphenix.protocol.wrappers.ChunkCoordIntPair; -import com.comphenix.protocol.wrappers.MultiBlockChangeInfo; -import com.comphenix.protocol.wrappers.WrappedBlockData; -import com.comphenix.protocol.wrappers.nbt.NbtCompound; -import com.comphenix.protocol.wrappers.nbt.NbtFactory; import de.steamwar.core.Core; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.FightSystem; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.UnpooledByteBufAllocator; import javafx.util.Pair; import org.bukkit.Bukkit; import org.bukkit.GameMode; -import org.bukkit.Material; import org.bukkit.entity.Player; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; import static de.steamwar.fightsystem.utils.ITechHider.bypass; public class TechHider { private TechHider(){} - private static Map packetCache = new HashMap<>(); - - private static int arenaMinX; - private static int arenaMaxX; - private static int arenaMinZ; - private static int arenaMaxZ; - private static short obfuscateShift4; - private static Material obfuscateMaterial; private static boolean running = false; - private static int threadMultiplier = 1; public static void init(){ if(disabled()) return; - arenaMinX = ITechHider.posToChunk(Config.ArenaMinX); - arenaMinZ = ITechHider.posToChunk(Config.ArenaMinZ); - arenaMaxX = ITechHider.posToChunk(Config.ArenaMaxX) + 1; - arenaMaxZ = ITechHider.posToChunk(Config.ArenaMaxZ) + 1; - - obfuscateShift4 = (short)(Config.ObfuscateWith << 4); - //noinspection deprecation - obfuscateMaterial = Material.getMaterial(Config.ObfuscateWith); - - if(Config.event()) - threadMultiplier = 4; - if(Core.getVersion() > 8){ ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Client.USE_ITEM) { @Override public void onPacketReceiving(PacketEvent e) { Player p = e.getPlayer(); - if(p.getGameMode() == GameMode.SPECTATOR){ + if(p.getGameMode() == GameMode.SPECTATOR) e.setCancelled(true); - } } }); } @@ -74,9 +43,8 @@ public class TechHider { public void onPacketReceiving(PacketEvent e) { Player p = e.getPlayer(); - if(p.getGameMode() == GameMode.SPECTATOR){ + if(p.getGameMode() == GameMode.SPECTATOR) e.setCancelled(true); - } } }); } @@ -89,209 +57,20 @@ public class TechHider { if(disabled()) return; - Bukkit.getScheduler().runTaskTimer(FightSystem.getPlugin(), packetCache::clear, 1, 1); - switch(Core.getVersion()){ case 8: break; default: - chunkHider(); - multiBlockHider(); - blockHider(); - blockActionHider(); + TechHider_12.start(); } } - private static void chunkHider(){ - ProtocolLibrary.getProtocolManager().getAsynchronousManager().registerAsyncHandler(new PacketAdapter(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; - - PacketContainer cached = packetCache.get(packet); - if(cached != null){ - e.setPacket(cached); - return; - } - - cached = packet.deepClone(); - packetCache.put(packet, cached); - e.setPacket(cached); - StructureModifier list = cached.getSpecificModifier(List.class); - List nmsTags = list.read(0); - boolean changed = false; - for(int i = nmsTags.size() - 1; i >= 0; i--){ - NbtCompound nbt = NbtFactory.fromNMSCompound(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 = cached.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 < 4) - bitsPerBlock = 4; - else if(bitsPerBlock > 8){ - bitsPerBlock = 13; - buffer.writeByte(data[++i]); - } - - 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 actPalette = ITechHider.readVarInt(data, i); - int actPaletteLength = ITechHider.readVarIntLength(data, i); - - int blockId = actPalette >> 4; - if(Config.HiddenBlocks.contains(blockId)){ - byte[] a = ITechHider.writeVarInt(obfuscateShift4); - buffer.writeBytes(a); - changed = true; - }else{ - buffer.writeBytes(data, i, actPaletteLength); - } - i += actPaletteLength; - } - 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{ - 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); - } - } - }).start(threadMultiplier * 4); - } - - private static void multiBlockHider(){ - ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Server.MULTI_BLOCK_CHANGE) { - @Override - public void onPacketSending(PacketEvent e) { - PacketContainer packet = e.getPacket(); - - Player p = e.getPlayer(); - ChunkCoordIntPair pos = packet.getChunkCoordIntPairs().read(0); - if(bypass(p, pos.getChunkX(), pos.getChunkZ())) - return; - - PacketContainer cached = packetCache.get(packet); - if(cached != null){ - e.setPacket(cached); - return; - } - - cached = packet.shallowClone(); - packetCache.put(packet, cached); - e.setPacket(cached); - StructureModifier blockStructure = cached.getMultiBlockChangeInfoArrays(); - MultiBlockChangeInfo[] changes = blockStructure.read(0).clone(); - boolean changed = false; - for(MultiBlockChangeInfo mbci : changes){ - WrappedBlockData block = mbci.getData(); - //noinspection deprecation - if(Config.HiddenBlocks.contains(block.getType().getId())){ - changed = true; - block.setType(obfuscateMaterial); - mbci.setData(block); - } - } - - if(changed){ - blockStructure.write(0, changes); - } - } - }); - } - - private static void blockHider(){ - ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Server.BLOCK_CHANGE) { - @Override - public void onPacketSending(PacketEvent e) { - PacketContainer packet = e.getPacket(); - BlockPosition pos = packet.getBlockPositionModifier().read(0); - - Player p = e.getPlayer(); - if(bypass(p, ITechHider.posToChunk(pos.getX()), ITechHider.posToChunk(pos.getZ()))) - return; - - PacketContainer cached = packetCache.get(packet); - if(cached != null){ - e.setPacket(cached); - return; - } - - cached = packet.deepClone(); - packetCache.put(packet, cached); - e.setPacket(cached); - StructureModifier blockStructure = cached.getBlockData(); - WrappedBlockData block = blockStructure.read(0); - //noinspection deprecation - if(Config.HiddenBlocks.contains(block.getType().getId())){ - block.setType(obfuscateMaterial); - blockStructure.write(0, block); - } - } - }); - } - - private static void blockActionHider(){ - ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Server.BLOCK_ACTION) { - @Override - public void onPacketSending(PacketEvent e) { - PacketContainer packet = e.getPacket(); - BlockPosition pos = packet.getBlockPositionModifier().read(0); - - Player p = e.getPlayer(); - if(bypass(p, ITechHider.posToChunk(pos.getX()), ITechHider.posToChunk(pos.getZ()))) - return; - - e.setCancelled(true); - } - }); - } - public static List> prepareChunkReload(Player p){ if(disabled()) return Collections.emptyList(); List> chunksToReload = new ArrayList<>(); - for(int x = arenaMinX; x <= arenaMaxX; x++) - for(int z = arenaMinZ; z <= arenaMaxZ; z++) + for(int x = ITechHider.arenaMinX; x <= ITechHider.arenaMaxX; x++) + for(int z = ITechHider.arenaMinZ; z <= ITechHider.arenaMaxZ; z++) if(!bypass(p, x, z)) chunksToReload.add(new Pair<>(x, z)); return chunksToReload; diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/utils/WaterRemover.java b/FightSystem_Main/src/de/steamwar/fightsystem/utils/WaterRemover.java index 02c09b9..6f20077 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/utils/WaterRemover.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/utils/WaterRemover.java @@ -1,5 +1,6 @@ package de.steamwar.fightsystem.utils; +import de.steamwar.core.Core; import de.steamwar.fightsystem.FightSystem; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -35,7 +36,7 @@ public class WaterRemover { while (it.hasNext()) { Map.Entry e = it.next(); Block b = e.getKey().getBlock(); - if (b.getType() == Material.STATIONARY_WATER || b.getType() == Material.WATER) + if (isWater(b.getType())) waterList.add(b); if(b.getType() != Material.AIR){ @@ -56,7 +57,7 @@ public class WaterRemover { while(it.hasNext()){ Block b = it.next(); blocksToRemove.addAll(getSourceBlocksOfWater(b)); - if (b.getType() != Material.STATIONARY_WATER && b.getType() != Material.WATER) + if (!isWater(b.getType())) it.remove(); } @@ -71,13 +72,13 @@ public class WaterRemover { private static void collectBlocks(Block anchor, Set collected, Set visitedBlocks) { if( - (anchor.getType() != Material.WATER && anchor.getType() != Material.STATIONARY_WATER) || + !isWater(anchor.getType()) || visitedBlocks.contains(anchor) ) return; visitedBlocks.add(anchor); - if (anchor.getType() == Material.STATIONARY_WATER) + if (isWater(anchor.getType())) collected.add(anchor); if(visitedBlocks.size() > 100) { @@ -91,4 +92,12 @@ public class WaterRemover { collectBlocks(anchor.getRelative(BlockFace.WEST), collected, visitedBlocks); } + public static boolean isWater(Material type){ + switch(Core.getVersion()){ + case 14: + return WaterRemover_14.isWater(type); + default: + return WaterRemover_12.isWater(type); + } + } } diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionWaterTechKO.java b/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionWaterTechKO.java index a7ba9ac..6273036 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionWaterTechKO.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/winconditions/WinconditionWaterTechKO.java @@ -1,10 +1,11 @@ package de.steamwar.fightsystem.winconditions; +import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.fight.Fight; import de.steamwar.fightsystem.fight.FightState; import de.steamwar.fightsystem.fight.FightTeam; -import de.steamwar.fightsystem.Config; +import de.steamwar.fightsystem.utils.WaterRemover; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; @@ -70,7 +71,7 @@ public class WinconditionWaterTechKO { for(int y = minY; y <= maxY; y++) { for (int z = minZ; z <= maxZ; z++) { Material type = WORLD.getBlockAt(x, y, z).getType(); - if (type == Material.STATIONARY_WATER || type == Material.WATER) + if (WaterRemover.isWater(type)) teamWater.add(new Location(WORLD, x, y, z)); } } diff --git a/pom.xml b/pom.xml index 0fb0790..2046376 100644 --- a/pom.xml +++ b/pom.xml @@ -50,12 +50,6 @@ 2.0 provided - - steamwar - WorldEdit - 1.0 - provided - steamwar ProtocolLib