Full untested 1.14 without 1.14 Techhider
Dieser Commit ist enthalten in:
Ursprung
39e4ab421e
Commit
95e901115a
@ -43,6 +43,12 @@
|
|||||||
<version>1.0</version>
|
<version>1.0</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>steamwar</groupId>
|
||||||
|
<artifactId>WorldEdit</artifactId>
|
||||||
|
<version>1.0</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>steamwar</groupId>
|
<groupId>steamwar</groupId>
|
||||||
<artifactId>Spigot</artifactId>
|
<artifactId>Spigot</artifactId>
|
||||||
|
@ -8,6 +8,7 @@ import com.sk89q.worldedit.bukkit.BukkitWorld;
|
|||||||
import com.sk89q.worldedit.math.transform.AffineTransform;
|
import com.sk89q.worldedit.math.transform.AffineTransform;
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
|
import de.steamwar.fightsystem.Config;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.DyeColor;
|
import org.bukkit.DyeColor;
|
||||||
@ -41,14 +42,17 @@ public class FightTeam_12 {
|
|||||||
|
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
static void replaceTeamColor(EditSession e, DyeColor c, CuboidRegion region){
|
static void replaceTeamColor(EditSession e, DyeColor c, int cornerX, int cornerY, int cornerZ){
|
||||||
FightTeam_8.replaceTeamColor(e, c, region);
|
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_SET, new BaseBlock(CONCRETE.getId(), c.getWoolData()));
|
||||||
e.replaceBlocks(region, CONCRETE_POWDER_SET, new BaseBlock(CONCRETE_POWDER.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;
|
com.boydti.fawe.object.schematic.Schematic schem;
|
||||||
|
Vector paste = new Vector(pasteX, pasteY, pasteZ);
|
||||||
try {
|
try {
|
||||||
schem = FaweAPI.load(file);
|
schem = FaweAPI.load(file);
|
||||||
if(schem.getClipboard() == null)
|
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);
|
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();
|
Vector it = schem.getClipboard().getMinimumPoint();
|
||||||
int depth = 0;
|
int depth = 0;
|
||||||
while(!schem.getClipboard().getBlock(it).isAir()){
|
while(!schem.getClipboard().getBlock(it).isAir()){
|
||||||
depth++;
|
depth++;
|
||||||
it = it.setY(it.getY()+1);
|
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);
|
return schem.paste(w, v, false, true, aT);
|
||||||
|
@ -1,15 +1,246 @@
|
|||||||
package de.steamwar.fightsystem.utils;
|
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 javafx.util.Pair;
|
||||||
import net.minecraft.server.v1_12_R1.PacketPlayOutMapChunk;
|
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.CraftChunk;
|
||||||
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer;
|
||||||
import org.bukkit.entity.Player;
|
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 {
|
class TechHider_12 {
|
||||||
private TechHider_12(){}
|
private TechHider_12(){}
|
||||||
|
|
||||||
|
private static final short obfuscateShift4;
|
||||||
|
private static final Set<Integer> hiddenBlocks;
|
||||||
|
|
||||||
|
static{
|
||||||
|
//noinspection deprecation
|
||||||
|
obfuscateShift4 = (short)(SWItem.getMaterial(Config.ObfuscateWith).getId() << 4);
|
||||||
|
|
||||||
|
Set<Integer> 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<Integer, Integer> chunk){
|
static void reloadChunk(Player p, Pair<Integer, Integer> chunk){
|
||||||
((CraftPlayer)p).getHandle().playerConnection.sendPacket(new PacketPlayOutMapChunk(((CraftChunk)p.getWorld().getChunkAt(chunk.getKey(), chunk.getValue())).getHandle(), 65535));
|
((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<Integer> 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> 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<byte[]> 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<MultiBlockChangeInfo[]> 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<WrappedBlockData> 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);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
@ -38,5 +38,11 @@
|
|||||||
<artifactId>FightSystem_API</artifactId>
|
<artifactId>FightSystem_API</artifactId>
|
||||||
<version>1.0</version>
|
<version>1.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>steamwar</groupId>
|
||||||
|
<artifactId>FAWE</artifactId>
|
||||||
|
<version>1.14</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
87
FightSystem_14/src/de/steamwar/fightsystem/fight/FightTeam_14.java
Normale Datei
87
FightSystem_14/src/de/steamwar/fightsystem/fight/FightTeam_14.java
Normale Datei
@ -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<BaseBlock> WOOL_SET = Collections.singleton(new BaseBlock(BlockState.get("PINK_WOOL")));
|
||||||
|
private static final Set<BaseBlock> CLAY_SET = Collections.singleton(new BaseBlock(BlockState.get("PINK_TERRACOTTA")));
|
||||||
|
private static final Set<BaseBlock> GLASS_SET = Collections.singleton(new BaseBlock(BlockState.get("PINK_STAINED_GLASS")));
|
||||||
|
private static final Set<BaseBlock> GLASS_PANE_SET = Collections.singleton(new BaseBlock(BlockState.get("PINK_STAINED_GLASS_PANE")));
|
||||||
|
private static final Set<BaseBlock> CONCRETE_SET = Collections.singleton(new BaseBlock(BlockState.get("PINK_CONCRETE")));
|
||||||
|
private static final Set<BaseBlock> 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);
|
||||||
|
}
|
||||||
|
}
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
@ -38,5 +38,11 @@
|
|||||||
<artifactId>FightSystem_API</artifactId>
|
<artifactId>FightSystem_API</artifactId>
|
||||||
<version>1.0</version>
|
<version>1.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>steamwar</groupId>
|
||||||
|
<artifactId>WorldEdit</artifactId>
|
||||||
|
<version>1.0</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
@ -7,6 +7,8 @@ import com.sk89q.worldedit.regions.CuboidRegion;
|
|||||||
import com.sk89q.worldedit.schematic.SchematicFormat;
|
import com.sk89q.worldedit.schematic.SchematicFormat;
|
||||||
import com.sk89q.worldedit.world.DataException;
|
import com.sk89q.worldedit.world.DataException;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
|
import de.steamwar.fightsystem.Config;
|
||||||
|
import de.steamwar.fightsystem.IFightSystem;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.DyeColor;
|
import org.bukkit.DyeColor;
|
||||||
@ -15,7 +17,6 @@ import org.bukkit.event.EventHandler;
|
|||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.block.BlockPhysicsEvent;
|
import org.bukkit.event.block.BlockPhysicsEvent;
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
import org.bukkit.scoreboard.NameTagVisibility;
|
import org.bukkit.scoreboard.NameTagVisibility;
|
||||||
import org.bukkit.scoreboard.Team;
|
import org.bukkit.scoreboard.Team;
|
||||||
|
|
||||||
@ -51,7 +52,9 @@ class FightTeam_8 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@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 {
|
try {
|
||||||
e.replaceBlocks(region, WOOL_SET, new BaseBlock(WOOL.getId(), c.getWoolData()));
|
e.replaceBlocks(region, WOOL_SET, new BaseBlock(WOOL.getId(), c.getWoolData()));
|
||||||
e.replaceBlocks(region, CLAY_SET, new BaseBlock(CLAY.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;
|
CuboidClipboard clipboard;
|
||||||
|
|
||||||
try {
|
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);
|
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;
|
Vector it = Vector.ZERO;
|
||||||
int depth = 0;
|
int depth = 0;
|
||||||
while(!clipboard.getBlock(it).isAir()){
|
while(!clipboard.getBlock(it).isAir()){
|
||||||
depth++;
|
depth++;
|
||||||
it = it.setY(it.getY()+1);
|
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);
|
EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(w, -1);
|
||||||
FreezeWorld freezer = new FreezeWorld();
|
FreezeWorld freezer = new FreezeWorld();
|
||||||
Bukkit.getPluginManager().registerEvents(freezer, plugin);
|
Bukkit.getPluginManager().registerEvents(freezer, IFightSystem.getPlugin());
|
||||||
try {
|
try {
|
||||||
clipboard.paste(e, v, false, true);
|
clipboard.paste(e, v, false, true);
|
||||||
} catch (MaxChangedBlocksException ex) {
|
} catch (MaxChangedBlocksException ex) {
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package de.steamwar.fightsystem;
|
package de.steamwar.fightsystem;
|
||||||
|
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import de.steamwar.sql.Event;
|
import de.steamwar.sql.Event;
|
||||||
import de.steamwar.sql.EventFight;
|
import de.steamwar.sql.EventFight;
|
||||||
import de.steamwar.sql.Team;
|
import de.steamwar.sql.Team;
|
||||||
@ -30,19 +29,18 @@ public class Config {
|
|||||||
public static final int SchemsizeX;
|
public static final int SchemsizeX;
|
||||||
public static final int SchemsizeY;
|
public static final int SchemsizeY;
|
||||||
public static final int SchemsizeZ;
|
public static final int SchemsizeZ;
|
||||||
public static final Vector Schemsize;
|
|
||||||
public static final int TeamBlueCornerX;
|
public static final int TeamBlueCornerX;
|
||||||
public static final int TeamBlueCornerY;
|
public static final int TeamBlueCornerY;
|
||||||
public static final int TeamBlueCornerZ;
|
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 Location TeamBlueSpawn;
|
||||||
public static final Vector TeamBluePaste;
|
|
||||||
public static final int TeamRedCornerX;
|
public static final int TeamRedCornerX;
|
||||||
public static final int TeamRedCornerY;
|
public static final int TeamRedCornerY;
|
||||||
public static final int TeamRedCornerZ;
|
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 Location TeamRedSpawn;
|
||||||
public static final Vector TeamRedPaste;
|
|
||||||
private static final int TeamBluetoReddistanceX;
|
private static final int TeamBluetoReddistanceX;
|
||||||
private static final int TeamBluetoReddistanceY;
|
private static final int TeamBluetoReddistanceY;
|
||||||
public static final int TeamBluetoReddistanceZ;
|
public static final int TeamBluetoReddistanceZ;
|
||||||
@ -95,9 +93,9 @@ public class Config {
|
|||||||
public static final String LeaderDefault;
|
public static final String LeaderDefault;
|
||||||
|
|
||||||
//tech hider parameter
|
//tech hider parameter
|
||||||
public static final List<Integer> HiddenBlocks;
|
public static final List<String> HiddenBlocks;
|
||||||
public static final List<String> HiddenBlockEntities;
|
public static final List<String> HiddenBlockEntities;
|
||||||
public static final int ObfuscateWith;
|
public static final String ObfuscateWith;
|
||||||
|
|
||||||
//event parameter
|
//event parameter
|
||||||
private static final int EventKampfID;
|
private static final int EventKampfID;
|
||||||
@ -165,9 +163,9 @@ public class Config {
|
|||||||
MemberDefault = config.getString("Kits.MemberDefault");
|
MemberDefault = config.getString("Kits.MemberDefault");
|
||||||
LeaderDefault = config.getString("Kits.LeaderDefault");
|
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"));
|
HiddenBlockEntities = Collections.unmodifiableList(config.getStringList("Techhider.HiddenBlockEntities"));
|
||||||
ObfuscateWith = config.getInt("Techhider.ObfuscateWith");
|
ObfuscateWith = config.getString("Techhider.ObfuscateWith");
|
||||||
|
|
||||||
if(schemsizeX < 0){
|
if(schemsizeX < 0){
|
||||||
SchemsizeX = -schemsizeX;
|
SchemsizeX = -schemsizeX;
|
||||||
@ -197,24 +195,18 @@ public class Config {
|
|||||||
TeamRedCornerY = TeamBluetoReddistanceY + TeamBlueCornerY;
|
TeamRedCornerY = TeamBluetoReddistanceY + TeamBlueCornerY;
|
||||||
TeamRedCornerZ = TeamBluetoReddistanceZ + TeamBlueCornerZ;
|
TeamRedCornerZ = TeamBluetoReddistanceZ + TeamBlueCornerZ;
|
||||||
|
|
||||||
int teamBluePasteX = TeamBlueCornerX + SchemsizeX / 2;
|
TeamBluePasteX = TeamBlueCornerX + SchemsizeX / 2;
|
||||||
int teamBluePasteZ = TeamBlueCornerZ + SchemsizeZ / 2;
|
TeamBluePasteZ = TeamBlueCornerZ + SchemsizeZ / 2;
|
||||||
int teamRedPasteX = teamBluePasteX + TeamBluetoReddistanceX;
|
TeamRedPasteX = TeamBluePasteX + TeamBluetoReddistanceX;
|
||||||
int teamRedPasteZ = teamBluePasteZ + TeamBluetoReddistanceZ;
|
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);
|
|
||||||
|
|
||||||
World world = Bukkit.getWorlds().get(0);
|
World world = Bukkit.getWorlds().get(0);
|
||||||
TeamBlueSpawn = new Location(world, teamBluePasteX + 0.5, TeamBlueCornerY + (double)SchemsizeY, teamBluePasteZ + 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);
|
TeamRedSpawn = new Location(world, TeamRedPasteX + 0.5, TeamRedCornerY + (double)SchemsizeY, TeamRedPasteZ + 0.5);
|
||||||
SpecSpawn = new Location(world,
|
SpecSpawn = new Location(world,
|
||||||
teamBluePasteX + TeamBluetoReddistanceX/2.0,
|
TeamBluePasteX + TeamBluetoReddistanceX/2.0,
|
||||||
TeamBlueCornerY + TeamBluetoReddistanceY/2.0 + SchemsizeY/2.0,
|
TeamBlueCornerY + TeamBluetoReddistanceY/2.0 + SchemsizeY/2.0,
|
||||||
teamBluePasteZ + TeamBluetoReddistanceZ/2.0);
|
TeamBluePasteZ + TeamBluetoReddistanceZ/2.0);
|
||||||
|
|
||||||
boolean teamRedRotate;
|
boolean teamRedRotate;
|
||||||
boolean teamBlueRotate;
|
boolean teamBlueRotate;
|
||||||
|
@ -1,18 +1,32 @@
|
|||||||
package de.steamwar.fightsystem.utils;
|
package de.steamwar.fightsystem.utils;
|
||||||
|
|
||||||
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
import com.google.common.primitives.Bytes;
|
import com.google.common.primitives.Bytes;
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.IFightSystem;
|
import de.steamwar.fightsystem.IFightSystem;
|
||||||
import de.steamwar.fightsystem.fight.IFight;
|
import de.steamwar.fightsystem.fight.IFight;
|
||||||
import de.steamwar.fightsystem.fight.IFightTeam;
|
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 org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class ITechHider {
|
public class ITechHider {
|
||||||
private ITechHider (){}
|
private ITechHider (){}
|
||||||
|
|
||||||
|
static final Map<PacketContainer, PacketContainer> 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 blueMinX;
|
||||||
private static final int blueMaxX;
|
private static final int blueMaxX;
|
||||||
private static final int blueMinZ;
|
private static final int blueMinZ;
|
||||||
@ -21,10 +35,6 @@ public class ITechHider {
|
|||||||
private static final int redMaxX;
|
private static final int redMaxX;
|
||||||
private static final int redMinZ;
|
private static final int redMinZ;
|
||||||
private static final int redMaxZ;
|
private static final int redMaxZ;
|
||||||
private static int arenaMinX;
|
|
||||||
private static int arenaMaxX;
|
|
||||||
private static int arenaMinZ;
|
|
||||||
private static int arenaMaxZ;
|
|
||||||
|
|
||||||
static{
|
static{
|
||||||
blueMinX = ITechHider.posToChunk(Config.TeamBlueCornerX);
|
blueMinX = ITechHider.posToChunk(Config.TeamBlueCornerX);
|
||||||
@ -39,6 +49,14 @@ public class ITechHider {
|
|||||||
arenaMaxX = ITechHider.posToChunk(Config.ArenaMaxX) + 1;
|
arenaMaxX = ITechHider.posToChunk(Config.ArenaMaxX) + 1;
|
||||||
arenaMinZ = ITechHider.posToChunk(Config.ArenaMinZ);
|
arenaMinZ = ITechHider.posToChunk(Config.ArenaMinZ);
|
||||||
arenaMaxZ = ITechHider.posToChunk(Config.ArenaMaxZ) + 1;
|
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){
|
static boolean bypass(Player p, int chunkX, int chunkZ){
|
||||||
|
@ -73,5 +73,11 @@
|
|||||||
<version>1.0</version>
|
<version>1.0</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>steamwar</groupId>
|
||||||
|
<artifactId>WorldEdit</artifactId>
|
||||||
|
<version>1.0</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
@ -8,8 +8,8 @@ import org.bukkit.entity.Player;
|
|||||||
public class Fight {
|
public class Fight {
|
||||||
private 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 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.TeamBluePaste, Config.TeamBlueCorner, Config.TeamBlueRotate, true, Config.BlueLeader);
|
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(){
|
public static void init(){
|
||||||
IFight.init(redTeam, blueTeam);
|
IFight.init(redTeam, blueTeam);
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
package de.steamwar.fightsystem.fight;
|
package de.steamwar.fightsystem.fight;
|
||||||
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
|
||||||
import de.steamwar.core.Core;
|
import de.steamwar.core.Core;
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
@ -43,18 +41,26 @@ public class FightTeam implements IFightTeam{
|
|||||||
private final boolean blue;
|
private final boolean blue;
|
||||||
|
|
||||||
private final Location spawn;
|
private final Location spawn;
|
||||||
private final Vector paste;
|
private final int pasteX;
|
||||||
private final Vector corner;
|
private final int pasteY;
|
||||||
|
private final int pasteZ;
|
||||||
|
private final int cornerX;
|
||||||
|
private final int cornerY;
|
||||||
|
private final int cornerZ;
|
||||||
private final boolean rotate;
|
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.spawn = spawn;
|
||||||
this.paste = paste;
|
this.pasteX = cornerX + Config.SchemsizeX/2;
|
||||||
|
this.pasteY = cornerY;
|
||||||
|
this.pasteZ = cornerZ + Config.SchemsizeZ/2;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.prefix = prefix;
|
this.prefix = prefix;
|
||||||
this.ready = false;
|
this.ready = false;
|
||||||
this.rotate = rotate;
|
this.rotate = rotate;
|
||||||
this.corner = corner;
|
this.cornerX = cornerX;
|
||||||
|
this.cornerY = cornerY;
|
||||||
|
this.cornerZ = cornerZ;
|
||||||
this.blue = blue;
|
this.blue = blue;
|
||||||
this.designatedLeader = designatedLeader;
|
this.designatedLeader = designatedLeader;
|
||||||
color = ChatColor.getByChar(ChatColor.getLastColors(prefix).replace("§", ""));
|
color = ChatColor.getByChar(ChatColor.getLastColors(prefix).replace("§", ""));
|
||||||
@ -71,6 +77,9 @@ public class FightTeam implements IFightTeam{
|
|||||||
case 8:
|
case 8:
|
||||||
FightTeam_8.setTeamColor(team, color);
|
FightTeam_8.setTeamColor(team, color);
|
||||||
break;
|
break;
|
||||||
|
case 14:
|
||||||
|
FightTeam_14.setTeamColor(team, color);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
FightTeam_12.setTeamColor(team, color);
|
FightTeam_12.setTeamColor(team, color);
|
||||||
}
|
}
|
||||||
@ -192,10 +201,10 @@ public class FightTeam implements IFightTeam{
|
|||||||
inventory.setItem(1, new ItemBuilder(Material.AIR).build());
|
inventory.setItem(1, new ItemBuilder(Material.AIR).build());
|
||||||
if(!Config.event()){
|
if(!Config.event()){
|
||||||
inventory.setItem(2, new ItemBuilder(Material.PAPER).removeAllAttributs().setDisplayName("§eSpieler einladen").build());
|
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(3, new ItemBuilder(SWItem.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(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<FightPlayer> getPlayers() {
|
public Set<FightPlayer> getPlayers() {
|
||||||
@ -211,25 +220,30 @@ public class FightTeam implements IFightTeam{
|
|||||||
EditSession e;
|
EditSession e;
|
||||||
switch(Core.getVersion()){
|
switch(Core.getVersion()){
|
||||||
case 8:
|
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;
|
break;
|
||||||
default:
|
default:
|
||||||
e = FightTeam_12.pasteSchematic(file, paste, rotate, Config.AlignWater, Config.WaterDepth);
|
e = FightTeam_12.pasteSchematic(file, pasteX, pasteY, pasteZ, rotate);
|
||||||
}
|
}
|
||||||
replaceTeamColor(e);
|
replaceTeamColor(e);
|
||||||
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), this::teleportToSpawn,40);
|
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), this::teleportToSpawn,40);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void replaceTeamColor(EditSession e){
|
private void replaceTeamColor(EditSession e){
|
||||||
CuboidRegion region = new CuboidRegion(corner, corner.add(Config.Schemsize));
|
|
||||||
DyeColor c = ColorConverter.chat2dye(color);
|
DyeColor c = ColorConverter.chat2dye(color);
|
||||||
|
|
||||||
switch(Core.getVersion()){
|
switch(Core.getVersion()){
|
||||||
case 8:
|
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;
|
break;
|
||||||
default:
|
default:
|
||||||
FightTeam_12.replaceTeamColor(e, c, region);
|
FightTeam_12.replaceTeamColor(e, c, cornerX, cornerY, cornerZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
e.flushQueue();
|
e.flushQueue();
|
||||||
|
@ -3,69 +3,38 @@ package de.steamwar.fightsystem.utils;
|
|||||||
import com.comphenix.protocol.PacketType;
|
import com.comphenix.protocol.PacketType;
|
||||||
import com.comphenix.protocol.ProtocolLibrary;
|
import com.comphenix.protocol.ProtocolLibrary;
|
||||||
import com.comphenix.protocol.events.PacketAdapter;
|
import com.comphenix.protocol.events.PacketAdapter;
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
|
||||||
import com.comphenix.protocol.events.PacketEvent;
|
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.core.Core;
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
import io.netty.buffer.ByteBuf;
|
|
||||||
import io.netty.buffer.UnpooledByteBufAllocator;
|
|
||||||
import javafx.util.Pair;
|
import javafx.util.Pair;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.entity.Player;
|
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;
|
import static de.steamwar.fightsystem.utils.ITechHider.bypass;
|
||||||
|
|
||||||
public class TechHider {
|
public class TechHider {
|
||||||
private TechHider(){}
|
private TechHider(){}
|
||||||
|
|
||||||
private static Map<PacketContainer, PacketContainer> 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 boolean running = false;
|
||||||
private static int threadMultiplier = 1;
|
|
||||||
|
|
||||||
public static void init(){
|
public static void init(){
|
||||||
if(disabled())
|
if(disabled())
|
||||||
return;
|
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){
|
if(Core.getVersion() > 8){
|
||||||
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Client.USE_ITEM) {
|
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Client.USE_ITEM) {
|
||||||
@Override
|
@Override
|
||||||
public void onPacketReceiving(PacketEvent e) {
|
public void onPacketReceiving(PacketEvent e) {
|
||||||
Player p = e.getPlayer();
|
Player p = e.getPlayer();
|
||||||
|
|
||||||
if(p.getGameMode() == GameMode.SPECTATOR){
|
if(p.getGameMode() == GameMode.SPECTATOR)
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -74,9 +43,8 @@ public class TechHider {
|
|||||||
public void onPacketReceiving(PacketEvent e) {
|
public void onPacketReceiving(PacketEvent e) {
|
||||||
Player p = e.getPlayer();
|
Player p = e.getPlayer();
|
||||||
|
|
||||||
if(p.getGameMode() == GameMode.SPECTATOR){
|
if(p.getGameMode() == GameMode.SPECTATOR)
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -89,209 +57,20 @@ public class TechHider {
|
|||||||
if(disabled())
|
if(disabled())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Bukkit.getScheduler().runTaskTimer(FightSystem.getPlugin(), packetCache::clear, 1, 1);
|
|
||||||
|
|
||||||
switch(Core.getVersion()){
|
switch(Core.getVersion()){
|
||||||
case 8:
|
case 8:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
chunkHider();
|
TechHider_12.start();
|
||||||
multiBlockHider();
|
|
||||||
blockHider();
|
|
||||||
blockActionHider();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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<Integer> 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> 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<byte[]> 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<MultiBlockChangeInfo[]> 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<WrappedBlockData> 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<Pair<Integer, Integer>> prepareChunkReload(Player p){
|
public static List<Pair<Integer, Integer>> prepareChunkReload(Player p){
|
||||||
if(disabled())
|
if(disabled())
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
List<Pair<Integer, Integer>> chunksToReload = new ArrayList<>();
|
List<Pair<Integer, Integer>> chunksToReload = new ArrayList<>();
|
||||||
for(int x = arenaMinX; x <= arenaMaxX; x++)
|
for(int x = ITechHider.arenaMinX; x <= ITechHider.arenaMaxX; x++)
|
||||||
for(int z = arenaMinZ; z <= arenaMaxZ; z++)
|
for(int z = ITechHider.arenaMinZ; z <= ITechHider.arenaMaxZ; z++)
|
||||||
if(!bypass(p, x, z))
|
if(!bypass(p, x, z))
|
||||||
chunksToReload.add(new Pair<>(x, z));
|
chunksToReload.add(new Pair<>(x, z));
|
||||||
return chunksToReload;
|
return chunksToReload;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package de.steamwar.fightsystem.utils;
|
package de.steamwar.fightsystem.utils;
|
||||||
|
|
||||||
|
import de.steamwar.core.Core;
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -35,7 +36,7 @@ public class WaterRemover {
|
|||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
Map.Entry<Location, Integer> e = it.next();
|
Map.Entry<Location, Integer> e = it.next();
|
||||||
Block b = e.getKey().getBlock();
|
Block b = e.getKey().getBlock();
|
||||||
if (b.getType() == Material.STATIONARY_WATER || b.getType() == Material.WATER)
|
if (isWater(b.getType()))
|
||||||
waterList.add(b);
|
waterList.add(b);
|
||||||
|
|
||||||
if(b.getType() != Material.AIR){
|
if(b.getType() != Material.AIR){
|
||||||
@ -56,7 +57,7 @@ public class WaterRemover {
|
|||||||
while(it.hasNext()){
|
while(it.hasNext()){
|
||||||
Block b = it.next();
|
Block b = it.next();
|
||||||
blocksToRemove.addAll(getSourceBlocksOfWater(b));
|
blocksToRemove.addAll(getSourceBlocksOfWater(b));
|
||||||
if (b.getType() != Material.STATIONARY_WATER && b.getType() != Material.WATER)
|
if (!isWater(b.getType()))
|
||||||
it.remove();
|
it.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,13 +72,13 @@ public class WaterRemover {
|
|||||||
|
|
||||||
private static void collectBlocks(Block anchor, Set<Block> collected, Set<Block> visitedBlocks) {
|
private static void collectBlocks(Block anchor, Set<Block> collected, Set<Block> visitedBlocks) {
|
||||||
if(
|
if(
|
||||||
(anchor.getType() != Material.WATER && anchor.getType() != Material.STATIONARY_WATER) ||
|
!isWater(anchor.getType()) ||
|
||||||
visitedBlocks.contains(anchor)
|
visitedBlocks.contains(anchor)
|
||||||
)
|
)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
visitedBlocks.add(anchor);
|
visitedBlocks.add(anchor);
|
||||||
if (anchor.getType() == Material.STATIONARY_WATER)
|
if (isWater(anchor.getType()))
|
||||||
collected.add(anchor);
|
collected.add(anchor);
|
||||||
|
|
||||||
if(visitedBlocks.size() > 100) {
|
if(visitedBlocks.size() > 100) {
|
||||||
@ -91,4 +92,12 @@ public class WaterRemover {
|
|||||||
collectBlocks(anchor.getRelative(BlockFace.WEST), collected, visitedBlocks);
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
package de.steamwar.fightsystem.winconditions;
|
package de.steamwar.fightsystem.winconditions;
|
||||||
|
|
||||||
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
import de.steamwar.fightsystem.fight.Fight;
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
import de.steamwar.fightsystem.fight.FightState;
|
import de.steamwar.fightsystem.fight.FightState;
|
||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.utils.WaterRemover;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -70,7 +71,7 @@ public class WinconditionWaterTechKO {
|
|||||||
for(int y = minY; y <= maxY; y++) {
|
for(int y = minY; y <= maxY; y++) {
|
||||||
for (int z = minZ; z <= maxZ; z++) {
|
for (int z = minZ; z <= maxZ; z++) {
|
||||||
Material type = WORLD.getBlockAt(x, y, z).getType();
|
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));
|
teamWater.add(new Location(WORLD, x, y, z));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
6
pom.xml
6
pom.xml
@ -50,12 +50,6 @@
|
|||||||
<version>2.0</version>
|
<version>2.0</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>steamwar</groupId>
|
|
||||||
<artifactId>WorldEdit</artifactId>
|
|
||||||
<version>1.0</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>steamwar</groupId>
|
<groupId>steamwar</groupId>
|
||||||
<artifactId>ProtocolLib</artifactId>
|
<artifactId>ProtocolLib</artifactId>
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren