12
1

Merge branch '1_14-support'

Dieser Commit ist enthalten in:
Lixfel 2019-12-09 12:01:42 +01:00
Commit 2ed8959f5d
24 geänderte Dateien mit 649 neuen und 293 gelöschten Zeilen

1
.gitignore vendored
Datei anzeigen

@ -1,2 +1,3 @@
.idea
target
dependency-reduced-pom.xml

Datei anzeigen

@ -43,6 +43,12 @@
<version>1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>WorldEdit</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>Spigot</artifactId>

Datei anzeigen

@ -1,24 +1,20 @@
package de.steamwar.fightsystem.fight;
import com.boydti.fawe.FaweAPI;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.bukkit.BukkitWorld;
import com.sk89q.worldedit.math.transform.AffineTransform;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.world.World;
import org.bukkit.Bukkit;
import de.steamwar.fightsystem.Config;
import de.steamwar.sql.NoClipboardException;
import de.steamwar.sql.Schematic;
import org.bukkit.ChatColor;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.scoreboard.Team;
import java.io.File;
import java.io.IOException;
import java.util.Collections;
import java.util.Set;
import java.util.logging.Level;
public class FightTeam_12 {
private FightTeam_12(){}
@ -41,45 +37,15 @@ public class FightTeam_12 {
@SuppressWarnings("deprecation")
static void replaceTeamColor(EditSession e, DyeColor c, CuboidRegion region){
FightTeam_8.replaceTeamColor(e, c, region);
static void replaceTeamColor(EditSession e, DyeColor c, int cornerX, int cornerY, int cornerZ){
FightTeam_8.replaceTeamColor(e, c, cornerX, cornerY, cornerZ);
Vector corner = new Vector(cornerX, cornerY, cornerZ);
CuboidRegion region = new CuboidRegion(corner, corner.add(Config.SchemsizeX, Config.SchemsizeY, Config.SchemsizeZ));
e.replaceBlocks(region, CONCRETE_SET, new BaseBlock(CONCRETE.getId(), c.getWoolData()));
e.replaceBlocks(region, CONCRETE_POWDER_SET, new BaseBlock(CONCRETE_POWDER.getId(), c.getWoolData()));
}
static EditSession pasteSchematic(File file, Vector paste, boolean rotate, boolean alignWater, int waterDepth){
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));
Vector dimensions = schem.getClipboard().getDimensions();
Vector v;
Vector offset = new Vector(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(alignWater){
Vector it = schem.getClipboard().getMinimumPoint();
int depth = 0;
while(!schem.getClipboard().getBlock(it).isAir()){
depth++;
it = it.setY(it.getY()+1);
}
v = v.add(0, waterDepth - depth, 0);
}
return schem.paste(w, v, false, true, aT);
static EditSession pasteSchematic(Schematic schematic, int pasteX, int pasteY, int pasteZ, boolean rotate) throws Schematic.WrongVersionException, IOException, NoClipboardException {
return FightTeam_8.pasteSchematic(schematic, pasteX, pasteY, pasteZ, rotate);
}
}

Datei anzeigen

@ -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;
}
}

Datei anzeigen

@ -1,15 +1,134 @@
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_12_R1.PacketPlayOutMapChunk;
import org.bukkit.craftbukkit.v1_12_R1.CraftChunk;
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
import java.util.List;
import static de.steamwar.fightsystem.utils.ITechHider.bypass;
class TechHider_12 {
private TechHider_12(){}
private static final short obfuscateShift4 = (short)(Config.ObfuscateWith << 4);
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(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);
}
}

Datei anzeigen

@ -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
Datei anzeigen

@ -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>

Datei anzeigen

@ -0,0 +1,91 @@
package de.steamwar.fightsystem.fight;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.bukkit.BukkitWorld;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.transform.AffineTransform;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.session.ClipboardHolder;
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 de.steamwar.sql.NoClipboardException;
import de.steamwar.sql.Schematic;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.DyeColor;
import org.bukkit.scoreboard.Team;
import java.io.IOException;
import java.util.Collections;
import java.util.Set;
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(Schematic schematic, int pX, int pY, int pZ, boolean rotate) throws Schematic.WrongVersionException, IOException, NoClipboardException {
BlockVector3 paste = BlockVector3.at(pX, pY, pZ);
Clipboard clipboard = schematic.load();
World w = new BukkitWorld(Bukkit.getWorlds().get(0));
BlockVector3 dimensions = clipboard.getDimensions();
BlockVector3 v;
BlockVector3 offset = clipboard.getRegion().getMinimumPoint().subtract(clipboard.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 = clipboard.getMinimumPoint();
int depth = 0;
while(!clipboard.getBlock(it).getMaterial().isAir()){
depth++;
it = it.add(0, 1, 0);
}
v = v.add(0, Config.WaterDepth - depth, 0);
}
EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(w, -1);
ClipboardHolder ch = new ClipboardHolder(clipboard);
ch.setTransform(aT);
try {
ch.createPaste(e).to(v).build();
} catch (MaxChangedBlocksException ex) {
throw new IOException(ex);
}
e.flushQueue();
return e;
}
}

Datei anzeigen

@ -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;
}
}

Datei anzeigen

@ -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);
}
}

Datei anzeigen

@ -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;
}
}

Datei anzeigen

@ -38,5 +38,11 @@
<artifactId>FightSystem_API</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>WorldEdit</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

Datei anzeigen

@ -3,10 +3,15 @@ package de.steamwar.fightsystem.fight;
import com.sk89q.worldedit.*;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.bukkit.BukkitWorld;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.math.transform.AffineTransform;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.schematic.SchematicFormat;
import com.sk89q.worldedit.world.DataException;
import com.sk89q.worldedit.session.ClipboardHolder;
import com.sk89q.worldedit.world.World;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.IFightSystem;
import de.steamwar.sql.NoClipboardException;
import de.steamwar.sql.Schematic;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.DyeColor;
@ -15,15 +20,12 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockPhysicsEvent;
import org.bukkit.plugin.Plugin;
import org.bukkit.scoreboard.NameTagVisibility;
import org.bukkit.scoreboard.Team;
import java.io.File;
import java.io.IOException;
import java.util.Collections;
import java.util.Set;
import java.util.logging.Level;
class FightTeam_8 {
private FightTeam_8(){}
@ -51,7 +53,9 @@ class FightTeam_8 {
}
@SuppressWarnings("deprecation")
static void replaceTeamColor(EditSession e, DyeColor c, CuboidRegion region){
static void replaceTeamColor(EditSession e, DyeColor c, int cornerX, int cornerY, int cornerZ){
Vector corner = new Vector(cornerX, cornerY, cornerZ);
CuboidRegion region = new CuboidRegion(corner, corner.add(Config.SchemsizeX, Config.SchemsizeY, Config.SchemsizeZ));
try {
e.replaceBlocks(region, WOOL_SET, new BaseBlock(WOOL.getId(), c.getWoolData()));
e.replaceBlocks(region, CLAY_SET, new BaseBlock(CLAY.getId(), c.getWoolData()));
@ -62,45 +66,38 @@ class FightTeam_8 {
}
}
static EditSession pasteSchematic(File file, Vector paste, boolean rotate, boolean alignWater, int waterDepth, Plugin plugin){
CuboidClipboard clipboard;
try {
clipboard = SchematicFormat.getFormat(file).load(file);
}catch(IOException | DataException e){
Bukkit.getLogger().log(Level.SEVERE, "Failed loading Schematic", e);
return null;
}
static EditSession pasteSchematic(Schematic schematic, int pasteX, int pasteY, int pasteZ, boolean rotate) throws Schematic.WrongVersionException, IOException, NoClipboardException {
Vector paste = new Vector(pasteX, pasteY, pasteZ);
Clipboard clipboard = schematic.load();
World w = new BukkitWorld(Bukkit.getWorlds().get(0));
Vector dimensions = clipboard.getSize();
Vector dimensions = clipboard.getDimensions();
Vector v;
Vector offset = new Vector(clipboard.getOffset());
Vector offset = new Vector(clipboard.getOrigin());
AffineTransform aT = new AffineTransform();
if(rotate){
clipboard.rotate2D(180);
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(alignWater){
if(Config.AlignWater){
Vector it = Vector.ZERO;
int depth = 0;
while(!clipboard.getBlock(it).isAir()){
depth++;
it = it.setY(it.getY()+1);
}
v = v.add(0, waterDepth - depth, 0);
v = v.add(0, Config.WaterDepth - depth, 0);
}
EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(w, -1);
FreezeWorld freezer = new FreezeWorld();
Bukkit.getPluginManager().registerEvents(freezer, plugin);
try {
clipboard.paste(e, v, false, true);
} catch (MaxChangedBlocksException ex) {
//ignore
}
Bukkit.getPluginManager().registerEvents(freezer, IFightSystem.getPlugin());
ClipboardHolder ch = new ClipboardHolder(clipboard, w.getWorldData());
ch.setTransform(aT);
ch.createPaste(e, w.getWorldData()).to(v).build();
e.flushQueue();
HandlerList.unregisterAll(freezer);
return e;

Datei anzeigen

@ -1,6 +1,5 @@
package de.steamwar.fightsystem;
import com.sk89q.worldedit.Vector;
import de.steamwar.sql.Event;
import de.steamwar.sql.EventFight;
import de.steamwar.sql.Team;
@ -30,19 +29,18 @@ public class Config {
public static final int SchemsizeX;
public static final int SchemsizeY;
public static final int SchemsizeZ;
public static final Vector Schemsize;
public static final int TeamBlueCornerX;
public static final int TeamBlueCornerY;
public static final int TeamBlueCornerZ;
public static final Vector TeamBlueCorner;
private static final int TeamBluePasteX;
private static final int TeamBluePasteZ;
public static final Location TeamBlueSpawn;
public static final Vector TeamBluePaste;
public static final int TeamRedCornerX;
public static final int TeamRedCornerY;
public static final int TeamRedCornerZ;
public static final Vector TeamRedCorner;
private static final int TeamRedPasteX;
private static final int TeamRedPasteZ;
public static final Location TeamRedSpawn;
public static final Vector TeamRedPaste;
private static final int TeamBluetoReddistanceX;
private static final int TeamBluetoReddistanceY;
public static final int TeamBluetoReddistanceZ;
@ -98,6 +96,7 @@ public class Config {
public static final List<Integer> HiddenBlocks;
public static final List<String> HiddenBlockEntities;
public static final int ObfuscateWith;
public static final String ObfuscateWithTag;
//event parameter
private static final int EventKampfID;
@ -168,6 +167,7 @@ public class Config {
HiddenBlocks = Collections.unmodifiableList(config.getIntegerList("Techhider.HiddenBlocks"));
HiddenBlockEntities = Collections.unmodifiableList(config.getStringList("Techhider.HiddenBlockEntities"));
ObfuscateWith = config.getInt("Techhider.ObfuscateWith");
ObfuscateWithTag = config.getString("Techhider.ObfuscateWithTag");
if(schemsizeX < 0){
SchemsizeX = -schemsizeX;
@ -197,24 +197,18 @@ public class Config {
TeamRedCornerY = TeamBluetoReddistanceY + TeamBlueCornerY;
TeamRedCornerZ = TeamBluetoReddistanceZ + TeamBlueCornerZ;
int teamBluePasteX = TeamBlueCornerX + SchemsizeX / 2;
int teamBluePasteZ = TeamBlueCornerZ + SchemsizeZ / 2;
int teamRedPasteX = teamBluePasteX + TeamBluetoReddistanceX;
int teamRedPasteZ = teamBluePasteZ + TeamBluetoReddistanceZ;
TeamBluePaste = new Vector(teamBluePasteX, TeamBlueCornerY, teamBluePasteZ);
TeamRedPaste = new Vector(teamRedPasteX, TeamRedCornerY, teamRedPasteZ);
Schemsize = new Vector(SchemsizeX, SchemsizeY, SchemsizeZ);
TeamBlueCorner = new Vector(TeamBlueCornerX, TeamBlueCornerY, TeamBlueCornerZ);
TeamRedCorner = new Vector(TeamRedCornerX, TeamRedCornerY, TeamRedCornerZ);
TeamBluePasteX = TeamBlueCornerX + SchemsizeX / 2;
TeamBluePasteZ = TeamBlueCornerZ + SchemsizeZ / 2;
TeamRedPasteX = TeamBluePasteX + TeamBluetoReddistanceX;
TeamRedPasteZ = TeamBluePasteZ + TeamBluetoReddistanceZ;
World world = Bukkit.getWorlds().get(0);
TeamBlueSpawn = new Location(world, teamBluePasteX + 0.5, TeamBlueCornerY + (double)SchemsizeY, teamBluePasteZ + 0.5);
TeamRedSpawn = new Location(world, teamRedPasteX + 0.5, TeamRedCornerY + (double)SchemsizeY, teamRedPasteZ + 0.5);
TeamBlueSpawn = new Location(world, TeamBluePasteX + 0.5, TeamBlueCornerY + (double)SchemsizeY, TeamBluePasteZ + 0.5);
TeamRedSpawn = new Location(world, TeamRedPasteX + 0.5, TeamRedCornerY + (double)SchemsizeY, TeamRedPasteZ + 0.5);
SpecSpawn = new Location(world,
teamBluePasteX + TeamBluetoReddistanceX/2.0,
TeamBluePasteX + TeamBluetoReddistanceX/2.0,
TeamBlueCornerY + TeamBluetoReddistanceY/2.0 + SchemsizeY/2.0,
teamBluePasteZ + TeamBluetoReddistanceZ/2.0);
TeamBluePasteZ + TeamBluetoReddistanceZ/2.0);
boolean teamRedRotate;
boolean teamBlueRotate;

Datei anzeigen

@ -1,18 +1,31 @@
package de.steamwar.fightsystem.utils;
import com.comphenix.protocol.events.PacketContainer;
import com.google.common.primitives.Bytes;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.IFightSystem;
import de.steamwar.fightsystem.fight.IFight;
import de.steamwar.fightsystem.fight.IFightTeam;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class ITechHider {
private ITechHider (){}
static final Map<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 blueMaxX;
private static final int blueMinZ;
@ -21,10 +34,6 @@ public class ITechHider {
private static final int redMaxX;
private static final int redMinZ;
private static final int redMaxZ;
private static int arenaMinX;
private static int arenaMaxX;
private static int arenaMinZ;
private static int arenaMaxZ;
static{
blueMinX = ITechHider.posToChunk(Config.TeamBlueCornerX);
@ -39,6 +48,14 @@ public class ITechHider {
arenaMaxX = ITechHider.posToChunk(Config.ArenaMaxX) + 1;
arenaMinZ = ITechHider.posToChunk(Config.ArenaMinZ);
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){

Datei anzeigen

@ -26,29 +26,27 @@
</resources>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
<goal>shade</goal>
</goals>
</execution>
</executions>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
<finalName>FightSystem</finalName>
</build>
<dependencies>
<dependency>
<groupId>steamwar</groupId>
<artifactId>Spigot</artifactId>
<version>1.8</version>
<version>1.14</version>
<scope>provided</scope>
</dependency>
<dependency>
@ -63,11 +61,23 @@
<version>1.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>FightSystem_14</artifactId>
<version>1.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>FightSystem_API</artifactId>
<version>1.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>WorldEdit</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

Datei anzeigen

@ -28,11 +28,11 @@ public class GUI {
static void invitation(Player p, Player target){
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);
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);
target.closeInventory();
});
@ -94,11 +94,11 @@ public class GUI {
SWInventory inv = new SWInventory(p, 9, Config.GameName + "-Auswahl");
inv.setItem(8, Material.REDSTONE, "§eÖffentliches " + Config.GameName, (ClickType click) -> schemDialog(p, true));
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()){
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{
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.open();

Datei anzeigen

@ -8,8 +8,8 @@ import org.bukkit.entity.Player;
public class Fight {
private Fight(){}
public static final FightTeam redTeam = new FightTeam(Config.TeamRedName, Config.TeamRedPrefix, Config.TeamRedSpawn, Config.TeamRedPaste, Config.TeamRedCorner, Config.TeamRedRotate, false, Config.RedLeader);
public static final FightTeam blueTeam = new FightTeam(Config.TeamBlueName, Config.TeamBluePrefix, Config.TeamBlueSpawn, Config.TeamBluePaste, Config.TeamBlueCorner, Config.TeamBlueRotate, true, Config.BlueLeader);
public static final FightTeam redTeam = new FightTeam(Config.TeamRedName, Config.TeamRedPrefix, Config.TeamRedSpawn, Config.TeamRedCornerX, Config.TeamRedCornerY, Config.TeamRedCornerZ, Config.TeamRedRotate, false, Config.RedLeader);
public static final FightTeam blueTeam = new FightTeam(Config.TeamBlueName, Config.TeamBluePrefix, Config.TeamBlueSpawn, Config.TeamBlueCornerX, Config.TeamBlueCornerY, Config.TeamBlueCornerZ, Config.TeamBlueRotate, true, Config.BlueLeader);
public static void init(){
IFight.init(redTeam, blueTeam);

Datei anzeigen

@ -1,15 +1,17 @@
package de.steamwar.fightsystem.fight;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.regions.CuboidRegion;
import de.steamwar.core.Core;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
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.NoClipboardException;
import de.steamwar.sql.Schematic;
import de.steamwar.sql.SteamwarUser;
import javafx.util.Pair;
import org.bukkit.*;
import org.bukkit.enchantments.Enchantment;
@ -17,7 +19,7 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.scoreboard.Team;
import java.io.File;
import java.io.IOException;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@ -39,18 +41,26 @@ public class FightTeam implements IFightTeam{
private final boolean blue;
private final Location spawn;
private final Vector paste;
private final Vector corner;
private final int pasteX;
private final int pasteY;
private final int pasteZ;
private final int cornerX;
private final int cornerY;
private final int cornerZ;
private final boolean rotate;
public FightTeam(String name, String prefix, Location spawn, Vector paste, Vector corner, boolean rotate, boolean blue, UUID designatedLeader) {
public FightTeam(String name, String prefix, Location spawn, int cornerX, int cornerY, int cornerZ, boolean rotate, boolean blue, UUID designatedLeader) {
this.spawn = spawn;
this.paste = paste;
this.pasteX = cornerX + Config.SchemsizeX/2;
this.pasteY = cornerY;
this.pasteZ = cornerZ + Config.SchemsizeZ/2;
this.name = name;
this.prefix = prefix;
this.ready = false;
this.rotate = rotate;
this.corner = corner;
this.cornerX = cornerX;
this.cornerY = cornerY;
this.cornerZ = cornerZ;
this.blue = blue;
this.designatedLeader = designatedLeader;
color = ChatColor.getByChar(ChatColor.getLastColors(prefix).replace("§", ""));
@ -67,6 +77,9 @@ public class FightTeam implements IFightTeam{
case 8:
FightTeam_8.setTeamColor(team, color);
break;
case 14:
FightTeam_14.setTeamColor(team, color);
break;
default:
FightTeam_12.setTeamColor(team, color);
}
@ -188,10 +201,10 @@ public class FightTeam implements IFightTeam{
inventory.setItem(1, new ItemBuilder(Material.AIR).build());
if(!Config.event()){
inventory.setItem(2, new ItemBuilder(Material.PAPER).removeAllAttributs().setDisplayName("§eSpieler einladen").build());
inventory.setItem(3, new ItemBuilder(Material.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(3, new ItemBuilder(SWItem.getMaterial("FIREWORK_CHARGE")).removeAllAttributs().setDisplayName("§cSpieler rauswerfen").build());
inventory.setItem(4, new ItemBuilder(SWItem.getDye(10), (short) 10).removeAllAttributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§cNicht bereit").build());
}
inventory.setItem(0, new ItemBuilder(Material.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() {
@ -203,29 +216,41 @@ public class FightTeam implements IFightTeam{
}
private void pasteSchematic(){
File file = new File(Config.SchematicDirectory + SteamwarUser.get(schematic.getSchemOwner()).getUUID().toString(), schematic.getSchemName() + ".schematic");
EditSession e;
switch(Core.getVersion()){
case 8:
e = FightTeam_8.pasteSchematic(file, paste, rotate, Config.AlignWater, Config.WaterDepth, FightSystem.getPlugin());
break;
default:
e = FightTeam_12.pasteSchematic(file, paste, rotate, Config.AlignWater, Config.WaterDepth);
try {
switch(Core.getVersion()){
case 8:
e = FightTeam_8.pasteSchematic(schematic, pasteX, pasteY, pasteZ, rotate);
break;
case 14:
e = FightTeam_14.pasteSchematic(schematic, pasteX, pasteY, pasteZ, rotate);
break;
default:
e = FightTeam_12.pasteSchematic(schematic, pasteX, pasteY, pasteZ, rotate);
}
} catch (Schematic.WrongVersionException ex) {
broadcast(FightSystem.PREFIX + "§cDie gewählte Schematic kann nicht in dieser Version geladen werden");
return;
} catch (IOException | NoClipboardException ex) {
broadcast(FightSystem.PREFIX + "§cFehler beim Pasten der Schematic");
throw new SecurityException("Error pasting arena in schematic", ex);
}
replaceTeamColor(e);
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), this::teleportToSpawn,40);
}
private void replaceTeamColor(EditSession e){
CuboidRegion region = new CuboidRegion(corner, corner.add(Config.Schemsize));
DyeColor c = ColorConverter.chat2dye(color);
switch(Core.getVersion()){
case 8:
FightTeam_8.replaceTeamColor(e, c, region);
FightTeam_8.replaceTeamColor(e, c, cornerX, cornerY, cornerZ);
break;
case 14:
FightTeam_14.replaceTeamColor(e, c, cornerX, cornerY, cornerZ);
break;
default:
FightTeam_12.replaceTeamColor(e, c, region);
FightTeam_12.replaceTeamColor(e, c, cornerX, cornerY, cornerZ);
}
e.flushQueue();
@ -270,13 +295,13 @@ public class FightTeam implements IFightTeam{
this.ready = 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!");
if(Fight.getOpposite(this).isReady() || Config.test()) {
FightSystem.setPreRunningState();
}
} 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!");
}
}

Datei anzeigen

@ -1,5 +1,6 @@
package de.steamwar.fightsystem.utils;
import de.steamwar.core.Core;
import org.bukkit.ChatColor;
import org.bukkit.DyeColor;
@ -20,7 +21,6 @@ public class ColorConverter {
chat2dye.put(ChatColor.GREEN, DyeColor.LIME);
chat2dye.put(ChatColor.RED, DyeColor.RED);
chat2dye.put(ChatColor.DARK_GRAY, DyeColor.GRAY);
chat2dye.put(ChatColor.GRAY, DyeColor.SILVER);
chat2dye.put(ChatColor.DARK_AQUA, DyeColor.CYAN);
chat2dye.put(ChatColor.DARK_PURPLE, DyeColor.PURPLE);
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_RED, DyeColor.RED);
chat2dye.put(ChatColor.BLACK, DyeColor.BLACK);
//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){

Datei anzeigen

@ -10,62 +10,38 @@ import com.comphenix.protocol.wrappers.BlockPosition;
import com.comphenix.protocol.wrappers.ChunkCoordIntPair;
import com.comphenix.protocol.wrappers.MultiBlockChangeInfo;
import com.comphenix.protocol.wrappers.WrappedBlockData;
import com.comphenix.protocol.wrappers.nbt.NbtCompound;
import com.comphenix.protocol.wrappers.nbt.NbtFactory;
import de.steamwar.core.Core;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.UnpooledByteBufAllocator;
import de.steamwar.fightsystem.IFightSystem;
import javafx.util.Pair;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import static de.steamwar.fightsystem.utils.ITechHider.bypass;
public class TechHider {
private TechHider(){}
private static Map<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 int threadMultiplier = 1;
public static void init(){
if(disabled())
return;
arenaMinX = ITechHider.posToChunk(Config.ArenaMinX);
arenaMinZ = ITechHider.posToChunk(Config.ArenaMinZ);
arenaMaxX = ITechHider.posToChunk(Config.ArenaMaxX) + 1;
arenaMaxZ = ITechHider.posToChunk(Config.ArenaMaxZ) + 1;
obfuscateShift4 = (short)(Config.ObfuscateWith << 4);
//noinspection deprecation
obfuscateMaterial = Material.getMaterial(Config.ObfuscateWith);
if(Config.event())
threadMultiplier = 4;
if(Core.getVersion() > 8){
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Client.USE_ITEM) {
@Override
public void onPacketReceiving(PacketEvent e) {
Player p = e.getPlayer();
if(p.getGameMode() == GameMode.SPECTATOR){
if(p.getGameMode() == GameMode.SPECTATOR)
e.setCancelled(true);
}
}
});
}
@ -74,9 +50,8 @@ public class TechHider {
public void onPacketReceiving(PacketEvent e) {
Player p = e.getPlayer();
if(p.getGameMode() == GameMode.SPECTATOR){
if(p.getGameMode() == GameMode.SPECTATOR)
e.setCancelled(true);
}
}
});
}
@ -89,118 +64,22 @@ public class TechHider {
if(disabled())
return;
Bukkit.getScheduler().runTaskTimer(FightSystem.getPlugin(), packetCache::clear, 1, 1);
blockActionHider();
blockHider();
multiBlockHider();
switch(Core.getVersion()){
case 8:
break;
case 14:
TechHider_14.start();
break;
default:
chunkHider();
multiBlockHider();
blockHider();
blockActionHider();
TechHider_12.start();
}
}
private static void chunkHider(){
ProtocolLibrary.getProtocolManager().getAsynchronousManager().registerAsyncHandler(new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Server.MAP_CHUNK) {
@Override
public void onPacketSending(PacketEvent e) {
PacketContainer packet = e.getPacket();
StructureModifier<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) {
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(IFightSystem.getPlugin(), PacketType.Play.Server.MULTI_BLOCK_CHANGE) {
@Override
public void onPacketSending(PacketEvent e) {
PacketContainer packet = e.getPacket();
@ -210,14 +89,14 @@ public class TechHider {
if(bypass(p, pos.getChunkX(), pos.getChunkZ()))
return;
PacketContainer cached = packetCache.get(packet);
PacketContainer cached = ITechHider.packetCache.get(packet);
if(cached != null){
e.setPacket(cached);
return;
}
cached = packet.shallowClone();
packetCache.put(packet, cached);
ITechHider.packetCache.put(packet, cached);
e.setPacket(cached);
StructureModifier<MultiBlockChangeInfo[]> blockStructure = cached.getMultiBlockChangeInfoArrays();
MultiBlockChangeInfo[] changes = blockStructure.read(0).clone();
@ -227,7 +106,7 @@ public class TechHider {
//noinspection deprecation
if(Config.HiddenBlocks.contains(block.getType().getId())){
changed = true;
block.setType(obfuscateMaterial);
block.setType(ITechHider.obfuscateMaterial);
mbci.setData(block);
}
}
@ -240,7 +119,7 @@ public class TechHider {
}
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
public void onPacketSending(PacketEvent e) {
PacketContainer packet = e.getPacket();
@ -250,20 +129,20 @@ public class TechHider {
if(bypass(p, ITechHider.posToChunk(pos.getX()), ITechHider.posToChunk(pos.getZ())))
return;
PacketContainer cached = packetCache.get(packet);
PacketContainer cached = ITechHider.packetCache.get(packet);
if(cached != null){
e.setPacket(cached);
return;
}
cached = packet.deepClone();
packetCache.put(packet, cached);
ITechHider.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);
block.setType(ITechHider.obfuscateMaterial);
blockStructure.write(0, block);
}
}
@ -271,7 +150,7 @@ public class TechHider {
}
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
public void onPacketSending(PacketEvent e) {
PacketContainer packet = e.getPacket();
@ -290,8 +169,8 @@ public class TechHider {
if(disabled())
return Collections.emptyList();
List<Pair<Integer, Integer>> chunksToReload = new ArrayList<>();
for(int x = arenaMinX; x <= arenaMaxX; x++)
for(int z = arenaMinZ; z <= arenaMaxZ; z++)
for(int x = ITechHider.arenaMinX; x <= ITechHider.arenaMaxX; x++)
for(int z = ITechHider.arenaMinZ; z <= ITechHider.arenaMaxZ; z++)
if(!bypass(p, x, z))
chunksToReload.add(new Pair<>(x, z));
return chunksToReload;
@ -313,6 +192,9 @@ public class TechHider {
case 8:
TechHider_8.reloadChunk(p, chunk);
break;
case 14:
TechHider_14.reloadChunk(p, chunk);
break;
default:
TechHider_12.reloadChunk(p, chunk);
}

Datei anzeigen

@ -1,5 +1,6 @@
package de.steamwar.fightsystem.utils;
import de.steamwar.core.Core;
import de.steamwar.fightsystem.FightSystem;
import org.bukkit.Bukkit;
import org.bukkit.Location;
@ -35,7 +36,7 @@ public class WaterRemover {
while (it.hasNext()) {
Map.Entry<Location, Integer> e = it.next();
Block b = e.getKey().getBlock();
if (b.getType() == Material.STATIONARY_WATER || b.getType() == Material.WATER)
if (isWater(b.getType()))
waterList.add(b);
if(b.getType() != Material.AIR){
@ -56,7 +57,7 @@ public class WaterRemover {
while(it.hasNext()){
Block b = it.next();
blocksToRemove.addAll(getSourceBlocksOfWater(b));
if (b.getType() != Material.STATIONARY_WATER && b.getType() != Material.WATER)
if (!isWater(b.getType()))
it.remove();
}
@ -71,16 +72,16 @@ public class WaterRemover {
private static void collectBlocks(Block anchor, Set<Block> collected, Set<Block> visitedBlocks) {
if(
(anchor.getType() != Material.WATER && anchor.getType() != Material.STATIONARY_WATER) ||
!isWater(anchor.getType()) ||
visitedBlocks.contains(anchor)
)
return;
visitedBlocks.add(anchor);
if (anchor.getType() == Material.STATIONARY_WATER)
if (isWater(anchor.getType()))
collected.add(anchor);
if(visitedBlocks.size() > 50) {
if(visitedBlocks.size() > 100) {
collected.clear();
return;
}
@ -91,4 +92,12 @@ public class WaterRemover {
collectBlocks(anchor.getRelative(BlockFace.WEST), collected, visitedBlocks);
}
public static boolean isWater(Material type){
switch(Core.getVersion()){
case 14:
return WaterRemover_14.isWater(type);
default:
return WaterRemover_12.isWater(type);
}
}
}

Datei anzeigen

@ -1,10 +1,11 @@
package de.steamwar.fightsystem.winconditions;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightState;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.utils.WaterRemover;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
@ -70,7 +71,7 @@ public class WinconditionWaterTechKO {
for(int y = minY; y <= maxY; y++) {
for (int z = minZ; z <= maxZ; z++) {
Material type = WORLD.getBlockAt(x, y, z).getType();
if (type == Material.STATIONARY_WATER || type == Material.WATER)
if (WaterRemover.isWater(type))
teamWater.add(new Location(WORLD, x, y, z));
}
}

Datei anzeigen

@ -39,6 +39,7 @@
<module>FightSystem_API</module>
<module>FightSystem_8</module>
<module>FightSystem_12</module>
<module>FightSystem_14</module>
<module>FightSystem_Main</module>
</modules>
@ -49,12 +50,6 @@
<version>2.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>WorldEdit</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>ProtocolLib</artifactId>