WIP: Starting 1.14 support #58
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,2 +1,3 @@
|
|||||||
.idea
|
.idea
|
||||||
target
|
target
|
||||||
|
dependency-reduced-pom.xml
|
@ -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);
|
||||||
|
@ -0,0 +1,11 @@
|
|||||||
|
package de.steamwar.fightsystem.utils;
|
||||||
|
|
||||||
|
import org.bukkit.DyeColor;
|
||||||
|
|
||||||
|
class ColorConverter_12 {
|
||||||
|
private ColorConverter_12(){}
|
||||||
|
|
||||||
|
static DyeColor getSilver(){
|
||||||
|
return DyeColor.SILVER;
|
||||||
|
}
|
||||||
|
}
|
@ -1,15 +1,134 @@
|
|||||||
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.nbt.NbtCompound;
|
||||||
|
import com.comphenix.protocol.wrappers.nbt.NbtFactory;
|
||||||
|
import de.steamwar.fightsystem.Config;
|
||||||
|
import de.steamwar.fightsystem.IFightSystem;
|
||||||
|
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.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.List;
|
||||||
|
|
||||||
|
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 = (short)(Config.ObfuscateWith << 4);
|
||||||
|
|
||||||
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
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(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(ITechHider.threadMultiplier * 4);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
48
FightSystem_14/pom.xml
Normale Datei
48
FightSystem_14/pom.xml
Normale Datei
@ -0,0 +1,48 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>steamwar</groupId>
|
||||||
|
<artifactId>FightSystem</artifactId>
|
||||||
|
<version>1.0</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>FightSystem_14</artifactId>
|
||||||
|
<version>1.0</version>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<sourceDirectory>src</sourceDirectory>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<directory>src</directory>
|
||||||
|
<excludes>
|
||||||
|
<exclude>**/*.java</exclude>
|
||||||
|
<exclude>**/*.kt</exclude>
|
||||||
|
</excludes>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>steamwar</groupId>
|
||||||
|
<artifactId>Spigot</artifactId>
|
||||||
|
<version>1.14</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>steamwar</groupId>
|
||||||
|
<artifactId>FightSystem_API</artifactId>
|
||||||
|
<version>1.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>steamwar</groupId>
|
||||||
|
<artifactId>FAWE</artifactId>
|
||||||
|
<version>1.14</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</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.DyeColor;
|
||||||
|
|
||||||
|
class ColorConverter_14 {
|
||||||
|
private ColorConverter_14(){}
|
||||||
|
|
||||||
|
static DyeColor getSilver(){
|
||||||
|
return DyeColor.LIGHT_GRAY;
|
||||||
|
}
|
||||||
|
}
|
138
FightSystem_14/src/de/steamwar/fightsystem/utils/TechHider_14.java
Normale Datei
138
FightSystem_14/src/de/steamwar/fightsystem/utils/TechHider_14.java
Normale Datei
@ -0,0 +1,138 @@
|
|||||||
|
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.nbt.NbtCompound;
|
||||||
|
import com.comphenix.protocol.wrappers.nbt.NbtFactory;
|
||||||
|
import de.steamwar.fightsystem.Config;
|
||||||
|
import de.steamwar.fightsystem.IFightSystem;
|
||||||
|
import io.netty.buffer.ByteBuf;
|
||||||
|
import io.netty.buffer.UnpooledByteBufAllocator;
|
||||||
|
import javafx.util.Pair;
|
||||||
|
import net.minecraft.server.v1_14_R1.PacketPlayOutMapChunk;
|
||||||
|
import org.bukkit.craftbukkit.v1_14_R1.CraftChunk;
|
||||||
|
import org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static de.steamwar.fightsystem.utils.ITechHider.bypass;
|
||||||
|
|
||||||
|
public class TechHider_14 {
|
||||||
|
private TechHider_14(){}
|
||||||
|
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void start(){
|
||||||
|
chunkHider();
|
||||||
|
}
|
||||||
|
|
||||||
|
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(1);
|
||||||
|
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();
|
||||||
|
int primaryBitMask = ints.read(2);
|
||||||
|
int numChunkSections = 0;
|
||||||
|
while(primaryBitMask != 0){
|
||||||
|
numChunkSections += primaryBitMask & 1;
|
||||||
|
primaryBitMask >>= 1;
|
||||||
|
}
|
||||||
|
byte [] data = byteArray.read(0);
|
||||||
|
ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.directBuffer(data.length + 100);
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
while(numChunkSections > 0){
|
||||||
|
buffer.writeBytes(data, i, 2); // Block count
|
||||||
|
i += 2;
|
||||||
|
byte bitsPerBlock = data[i++];
|
||||||
|
buffer.writeByte(bitsPerBlock);
|
||||||
|
if(bitsPerBlock < 4)
|
||||||
|
bitsPerBlock = 4;
|
||||||
|
else if(bitsPerBlock > 8){
|
||||||
|
bitsPerBlock = 14;
|
||||||
|
buffer.writeByte(data[++i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(bitsPerBlock != 14){
|
||||||
|
int paletteLength = ITechHider.readVarInt(data, i);
|
||||||
|
int paletteLengthLength = ITechHider.readVarIntLength(data, i);
|
||||||
|
buffer.writeBytes(data, i, paletteLengthLength);
|
||||||
|
i += paletteLengthLength;
|
||||||
|
for(int actPaletteId = 0; actPaletteId < paletteLength; actPaletteId++){
|
||||||
|
int blockId = ITechHider.readVarInt(data, i);
|
||||||
|
int actPaletteLength = ITechHider.readVarIntLength(data, i);
|
||||||
|
|
||||||
|
if(Config.HiddenBlocks.contains(blockId)){
|
||||||
|
byte[] a = ITechHider.writeVarInt(Config.ObfuscateWith);
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
numChunkSections--;
|
||||||
|
}
|
||||||
|
buffer.writeBytes(data, i, data.length - i);
|
||||||
|
|
||||||
|
if(changed){
|
||||||
|
data = new byte[buffer.readableBytes()];
|
||||||
|
buffer.readBytes(data);
|
||||||
|
byteArray.write(0, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).start(ITechHider.threadMultiplier * 4);
|
||||||
|
}
|
||||||
|
}
|
@ -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;
|
||||||
@ -98,6 +96,7 @@ public class Config {
|
|||||||
public static final List<Integer> HiddenBlocks;
|
public static final List<Integer> HiddenBlocks;
|
||||||
public static final List<String> HiddenBlockEntities;
|
public static final List<String> HiddenBlockEntities;
|
||||||
public static final int ObfuscateWith;
|
public static final int ObfuscateWith;
|
||||||
|
public static final String ObfuscateWithTag;
|
||||||
|
|
||||||
//event parameter
|
//event parameter
|
||||||
private static final int EventKampfID;
|
private static final int EventKampfID;
|
||||||
@ -168,6 +167,7 @@ public class Config {
|
|||||||
HiddenBlocks = Collections.unmodifiableList(config.getIntegerList("Techhider.HiddenBlocks"));
|
HiddenBlocks = Collections.unmodifiableList(config.getIntegerList("Techhider.HiddenBlocks"));
|
||||||
HiddenBlockEntities = Collections.unmodifiableList(config.getStringList("Techhider.HiddenBlockEntities"));
|
HiddenBlockEntities = Collections.unmodifiableList(config.getStringList("Techhider.HiddenBlockEntities"));
|
||||||
ObfuscateWith = config.getInt("Techhider.ObfuscateWith");
|
ObfuscateWith = config.getInt("Techhider.ObfuscateWith");
|
||||||
|
ObfuscateWithTag = config.getString("Techhider.ObfuscateWithTag");
|
||||||
|
|
||||||
if(schemsizeX < 0){
|
if(schemsizeX < 0){
|
||||||
SchemsizeX = -schemsizeX;
|
SchemsizeX = -schemsizeX;
|
||||||
@ -197,24 +197,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,31 @@
|
|||||||
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 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 +34,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 +48,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 = Material.getMaterial(Config.ObfuscateWithTag);
|
||||||
|
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){
|
||||||
|
@ -26,29 +26,27 @@
|
|||||||
</resources>
|
</resources>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-assembly-plugin</artifactId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
|
<version>3.2.1</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<phase>package</phase>
|
<phase>package</phase>
|
||||||
<goals>
|
<goals>
|
||||||
<goal>single</goal>
|
<goal>shade</goal>
|
||||||
</goals>
|
</goals>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
<configuration>
|
|
||||||
<descriptorRefs>
|
|
||||||
<descriptorRef>jar-with-dependencies</descriptorRef>
|
|
||||||
</descriptorRefs>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
|
<finalName>FightSystem</finalName>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>steamwar</groupId>
|
<groupId>steamwar</groupId>
|
||||||
<artifactId>Spigot</artifactId>
|
<artifactId>Spigot</artifactId>
|
||||||
<version>1.8</version>
|
<version>1.14</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -63,11 +61,23 @@
|
|||||||
<version>1.0</version>
|
<version>1.0</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>steamwar</groupId>
|
||||||
|
<artifactId>FightSystem_14</artifactId>
|
||||||
|
<version>1.0</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>steamwar</groupId>
|
<groupId>steamwar</groupId>
|
||||||
<artifactId>FightSystem_API</artifactId>
|
<artifactId>FightSystem_API</artifactId>
|
||||||
<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>
|
@ -28,11 +28,11 @@ public class GUI {
|
|||||||
|
|
||||||
static void invitation(Player p, Player target){
|
static void invitation(Player p, Player target){
|
||||||
SWInventory inv = new SWInventory(target, 9, "Einladung von " + p.getName());
|
SWInventory inv = new SWInventory(target, 9, "Einladung von " + p.getName());
|
||||||
inv.setItem(0, Material.INK_SACK, (byte)10, "§aAnnehmen", (ClickType click) ->{
|
inv.setItem(0, SWItem.getDye(10), (byte)10, "§aAnnehmen", (ClickType click) ->{
|
||||||
Commands.acceptInvitation(target);
|
Commands.acceptInvitation(target);
|
||||||
target.closeInventory();
|
target.closeInventory();
|
||||||
});
|
});
|
||||||
inv.setItem(8, Material.INK_SACK, (byte)1, "§cAblehnen", (ClickType click) ->{
|
inv.setItem(8, SWItem.getDye(1), (byte)1, "§cAblehnen", (ClickType click) ->{
|
||||||
Commands.declineInvitation(target);
|
Commands.declineInvitation(target);
|
||||||
target.closeInventory();
|
target.closeInventory();
|
||||||
});
|
});
|
||||||
@ -94,11 +94,11 @@ public class GUI {
|
|||||||
SWInventory inv = new SWInventory(p, 9, Config.GameName + "-Auswahl");
|
SWInventory inv = new SWInventory(p, 9, Config.GameName + "-Auswahl");
|
||||||
inv.setItem(8, Material.REDSTONE, "§eÖffentliches " + Config.GameName, (ClickType click) -> schemDialog(p, true));
|
inv.setItem(8, Material.REDSTONE, "§eÖffentliches " + Config.GameName, (ClickType click) -> schemDialog(p, true));
|
||||||
if(Config.OnlyPublicSchematics){
|
if(Config.OnlyPublicSchematics){
|
||||||
inv.setItem(0, Material.INK_SACK, (byte)8, "§7Keine privaten Schematics erlaubt", (ClickType click)->{});
|
inv.setItem(0, SWItem.getDye(8), (byte)8, "§7Keine privaten Schematics erlaubt", (ClickType click)->{});
|
||||||
}else if(Schematic.getSchemsOfType(p.getUniqueId(), Config.SchematicType).isEmpty() && !Config.test()){
|
}else if(Schematic.getSchemsOfType(p.getUniqueId(), Config.SchematicType).isEmpty() && !Config.test()){
|
||||||
inv.setItem(0, Material.INK_SACK, (byte)8, "§7Kein privates " + Config.GameName + " vorhanden", (ClickType click)->{});
|
inv.setItem(0, SWItem.getDye(8), (byte)8, "§7Kein privates " + Config.GameName + " vorhanden", (ClickType click)->{});
|
||||||
}else{
|
}else{
|
||||||
inv.setItem(0, Material.CAULDRON_ITEM, "§ePrivates " + Config.GameName, (ClickType click) -> schemDialog(p, false));
|
inv.setItem(0, SWItem.getMaterial("CAULDRON_ITEM"), "§ePrivates " + Config.GameName, (ClickType click) -> schemDialog(p, false));
|
||||||
}
|
}
|
||||||
inv.setCallback(-999, (ClickType click) -> p.closeInventory());
|
inv.setCallback(-999, (ClickType click) -> p.closeInventory());
|
||||||
inv.open();
|
inv.open();
|
||||||
|
@ -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,13 +1,15 @@
|
|||||||
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;
|
||||||
import de.steamwar.fightsystem.kit.KitManager;
|
import de.steamwar.fightsystem.kit.KitManager;
|
||||||
import de.steamwar.fightsystem.utils.*;
|
import de.steamwar.fightsystem.utils.ColorConverter;
|
||||||
|
import de.steamwar.fightsystem.utils.FightScoreboard;
|
||||||
|
import de.steamwar.fightsystem.utils.ItemBuilder;
|
||||||
|
import de.steamwar.fightsystem.utils.TechHider;
|
||||||
|
import de.steamwar.inventory.SWItem;
|
||||||
import de.steamwar.sql.Schematic;
|
import de.steamwar.sql.Schematic;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import javafx.util.Pair;
|
import javafx.util.Pair;
|
||||||
@ -39,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("§", ""));
|
||||||
@ -67,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);
|
||||||
}
|
}
|
||||||
@ -188,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.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.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.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() {
|
||||||
@ -207,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();
|
||||||
@ -270,13 +288,13 @@ public class FightTeam implements IFightTeam{
|
|||||||
|
|
||||||
this.ready = ready;
|
this.ready = ready;
|
||||||
if(ready) {
|
if(ready) {
|
||||||
l.getInventory().setItem(4, new ItemBuilder(Material.INK_SACK, (short) 8).removeAllAttributs().addEnchantment(Enchantment.DURABILITY,1 ).setDisplayName("§aBereit").build());
|
l.getInventory().setItem(4, new ItemBuilder(SWItem.getDye(8), (short) 8).removeAllAttributs().addEnchantment(Enchantment.DURABILITY,1 ).setDisplayName("§aBereit").build());
|
||||||
broadcast(FightSystem.PREFIX + "§aEuer Team ist nun bereit!");
|
broadcast(FightSystem.PREFIX + "§aEuer Team ist nun bereit!");
|
||||||
if(Fight.getOpposite(this).isReady() || Config.test()) {
|
if(Fight.getOpposite(this).isReady() || Config.test()) {
|
||||||
FightSystem.setPreRunningState();
|
FightSystem.setPreRunningState();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
l.getInventory().setItem(4, new ItemBuilder(Material.INK_SACK, (short) 10).removeAllAttributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§cNicht bereit").build());
|
l.getInventory().setItem(4, new ItemBuilder(SWItem.getDye(10), (short) 10).removeAllAttributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§cNicht bereit").build());
|
||||||
broadcast(FightSystem.PREFIX + "§cEuer Team ist nicht mehr bereit!");
|
broadcast(FightSystem.PREFIX + "§cEuer Team ist nicht mehr bereit!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package de.steamwar.fightsystem.utils;
|
package de.steamwar.fightsystem.utils;
|
||||||
|
|
||||||
|
import de.steamwar.core.Core;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.DyeColor;
|
import org.bukkit.DyeColor;
|
||||||
|
|
||||||
@ -20,7 +21,6 @@ public class ColorConverter {
|
|||||||
chat2dye.put(ChatColor.GREEN, DyeColor.LIME);
|
chat2dye.put(ChatColor.GREEN, DyeColor.LIME);
|
||||||
chat2dye.put(ChatColor.RED, DyeColor.RED);
|
chat2dye.put(ChatColor.RED, DyeColor.RED);
|
||||||
chat2dye.put(ChatColor.DARK_GRAY, DyeColor.GRAY);
|
chat2dye.put(ChatColor.DARK_GRAY, DyeColor.GRAY);
|
||||||
chat2dye.put(ChatColor.GRAY, DyeColor.SILVER);
|
|
||||||
chat2dye.put(ChatColor.DARK_AQUA, DyeColor.CYAN);
|
chat2dye.put(ChatColor.DARK_AQUA, DyeColor.CYAN);
|
||||||
chat2dye.put(ChatColor.DARK_PURPLE, DyeColor.PURPLE);
|
chat2dye.put(ChatColor.DARK_PURPLE, DyeColor.PURPLE);
|
||||||
chat2dye.put(ChatColor.DARK_BLUE, DyeColor.BLUE);
|
chat2dye.put(ChatColor.DARK_BLUE, DyeColor.BLUE);
|
||||||
@ -28,8 +28,15 @@ public class ColorConverter {
|
|||||||
chat2dye.put(ChatColor.DARK_GREEN, DyeColor.GREEN);
|
chat2dye.put(ChatColor.DARK_GREEN, DyeColor.GREEN);
|
||||||
chat2dye.put(ChatColor.DARK_RED, DyeColor.RED);
|
chat2dye.put(ChatColor.DARK_RED, DyeColor.RED);
|
||||||
chat2dye.put(ChatColor.BLACK, DyeColor.BLACK);
|
chat2dye.put(ChatColor.BLACK, DyeColor.BLACK);
|
||||||
|
|
||||||
//Rosa 9pink, Braun 3brown
|
//Rosa 9pink, Braun 3brown
|
||||||
|
|
||||||
|
switch(Core.getVersion()){
|
||||||
|
case 14:
|
||||||
|
chat2dye.put(ChatColor.GRAY, ColorConverter_14.getSilver());
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
chat2dye.put(ChatColor.GRAY, ColorConverter_12.getSilver());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DyeColor chat2dye(ChatColor color){
|
public static DyeColor chat2dye(ChatColor color){
|
||||||
|
@ -10,62 +10,38 @@ import com.comphenix.protocol.wrappers.BlockPosition;
|
|||||||
import com.comphenix.protocol.wrappers.ChunkCoordIntPair;
|
import com.comphenix.protocol.wrappers.ChunkCoordIntPair;
|
||||||
import com.comphenix.protocol.wrappers.MultiBlockChangeInfo;
|
import com.comphenix.protocol.wrappers.MultiBlockChangeInfo;
|
||||||
import com.comphenix.protocol.wrappers.WrappedBlockData;
|
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 de.steamwar.fightsystem.IFightSystem;
|
||||||
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 +50,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,118 +64,22 @@ public class TechHider {
|
|||||||
if(disabled())
|
if(disabled())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Bukkit.getScheduler().runTaskTimer(FightSystem.getPlugin(), packetCache::clear, 1, 1);
|
blockActionHider();
|
||||||
|
blockHider();
|
||||||
|
multiBlockHider();
|
||||||
switch(Core.getVersion()){
|
switch(Core.getVersion()){
|
||||||
case 8:
|
case 8:
|
||||||
break;
|
break;
|
||||||
|
case 14:
|
||||||
|
TechHider_14.start();
|
||||||
|
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(){
|
private static void multiBlockHider(){
|
||||||
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Server.MULTI_BLOCK_CHANGE) {
|
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(IFightSystem.getPlugin(), PacketType.Play.Server.MULTI_BLOCK_CHANGE) {
|
||||||
@Override
|
@Override
|
||||||
public void onPacketSending(PacketEvent e) {
|
public void onPacketSending(PacketEvent e) {
|
||||||
PacketContainer packet = e.getPacket();
|
PacketContainer packet = e.getPacket();
|
||||||
@ -210,14 +89,14 @@ public class TechHider {
|
|||||||
if(bypass(p, pos.getChunkX(), pos.getChunkZ()))
|
if(bypass(p, pos.getChunkX(), pos.getChunkZ()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
PacketContainer cached = packetCache.get(packet);
|
PacketContainer cached = ITechHider.packetCache.get(packet);
|
||||||
if(cached != null){
|
if(cached != null){
|
||||||
e.setPacket(cached);
|
e.setPacket(cached);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
cached = packet.shallowClone();
|
cached = packet.shallowClone();
|
||||||
packetCache.put(packet, cached);
|
ITechHider.packetCache.put(packet, cached);
|
||||||
e.setPacket(cached);
|
e.setPacket(cached);
|
||||||
StructureModifier<MultiBlockChangeInfo[]> blockStructure = cached.getMultiBlockChangeInfoArrays();
|
StructureModifier<MultiBlockChangeInfo[]> blockStructure = cached.getMultiBlockChangeInfoArrays();
|
||||||
MultiBlockChangeInfo[] changes = blockStructure.read(0).clone();
|
MultiBlockChangeInfo[] changes = blockStructure.read(0).clone();
|
||||||
@ -227,7 +106,7 @@ public class TechHider {
|
|||||||
//noinspection deprecation
|
//noinspection deprecation
|
||||||
if(Config.HiddenBlocks.contains(block.getType().getId())){
|
if(Config.HiddenBlocks.contains(block.getType().getId())){
|
||||||
changed = true;
|
changed = true;
|
||||||
block.setType(obfuscateMaterial);
|
block.setType(ITechHider.obfuscateMaterial);
|
||||||
mbci.setData(block);
|
mbci.setData(block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -240,7 +119,7 @@ public class TechHider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void blockHider(){
|
private static void blockHider(){
|
||||||
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Server.BLOCK_CHANGE) {
|
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(IFightSystem.getPlugin(), PacketType.Play.Server.BLOCK_CHANGE) {
|
||||||
@Override
|
@Override
|
||||||
public void onPacketSending(PacketEvent e) {
|
public void onPacketSending(PacketEvent e) {
|
||||||
PacketContainer packet = e.getPacket();
|
PacketContainer packet = e.getPacket();
|
||||||
@ -250,20 +129,20 @@ public class TechHider {
|
|||||||
if(bypass(p, ITechHider.posToChunk(pos.getX()), ITechHider.posToChunk(pos.getZ())))
|
if(bypass(p, ITechHider.posToChunk(pos.getX()), ITechHider.posToChunk(pos.getZ())))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
PacketContainer cached = packetCache.get(packet);
|
PacketContainer cached = ITechHider.packetCache.get(packet);
|
||||||
if(cached != null){
|
if(cached != null){
|
||||||
e.setPacket(cached);
|
e.setPacket(cached);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
cached = packet.deepClone();
|
cached = packet.deepClone();
|
||||||
packetCache.put(packet, cached);
|
ITechHider.packetCache.put(packet, cached);
|
||||||
e.setPacket(cached);
|
e.setPacket(cached);
|
||||||
StructureModifier<WrappedBlockData> blockStructure = cached.getBlockData();
|
StructureModifier<WrappedBlockData> blockStructure = cached.getBlockData();
|
||||||
WrappedBlockData block = blockStructure.read(0);
|
WrappedBlockData block = blockStructure.read(0);
|
||||||
//noinspection deprecation
|
//noinspection deprecation
|
||||||
if(Config.HiddenBlocks.contains(block.getType().getId())){
|
if(Config.HiddenBlocks.contains(block.getType().getId())){
|
||||||
block.setType(obfuscateMaterial);
|
block.setType(ITechHider.obfuscateMaterial);
|
||||||
blockStructure.write(0, block);
|
blockStructure.write(0, block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -271,7 +150,7 @@ public class TechHider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void blockActionHider(){
|
private static void blockActionHider(){
|
||||||
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Server.BLOCK_ACTION) {
|
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(IFightSystem.getPlugin(), PacketType.Play.Server.BLOCK_ACTION) {
|
||||||
@Override
|
@Override
|
||||||
public void onPacketSending(PacketEvent e) {
|
public void onPacketSending(PacketEvent e) {
|
||||||
PacketContainer packet = e.getPacket();
|
PacketContainer packet = e.getPacket();
|
||||||
@ -290,8 +169,8 @@ public class TechHider {
|
|||||||
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;
|
||||||
@ -313,6 +192,9 @@ public class TechHider {
|
|||||||
case 8:
|
case 8:
|
||||||
TechHider_8.reloadChunk(p, chunk);
|
TechHider_8.reloadChunk(p, chunk);
|
||||||
break;
|
break;
|
||||||
|
case 14:
|
||||||
|
TechHider_14.reloadChunk(p, chunk);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
TechHider_12.reloadChunk(p, chunk);
|
TechHider_12.reloadChunk(p, chunk);
|
||||||
}
|
}
|
||||||
|
@ -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,16 +72,16 @@ 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() > 50) {
|
if(visitedBlocks.size() > 100) {
|
||||||
collected.clear();
|
collected.clear();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
7
pom.xml
7
pom.xml
@ -39,6 +39,7 @@
|
|||||||
<module>FightSystem_API</module>
|
<module>FightSystem_API</module>
|
||||||
<module>FightSystem_8</module>
|
<module>FightSystem_8</module>
|
||||||
<module>FightSystem_12</module>
|
<module>FightSystem_12</module>
|
||||||
|
<module>FightSystem_14</module>
|
||||||
<module>FightSystem_Main</module>
|
<module>FightSystem_Main</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
@ -49,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
Testkommentar