SteamWar/FightSystem
Archiviert
13
1

Omni-Replay #280

Manuell gemergt
Lixfel hat 15 Commits von spectate2.0 nach master 2021-08-27 22:12:03 +02:00 zusammengeführt
5 geänderte Dateien mit 403 neuen und 52 gelöschten Zeilen
Nur Änderungen aus Commit 26ccf98d44 werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -30,7 +30,7 @@ import org.bukkit.entity.Player;
public class RemoveCommand implements CommandExecutor { public class RemoveCommand implements CommandExecutor {
public RemoveCommand() { public RemoveCommand() {
new StateDependentCommand(ArenaMode.VariableTeams, FightState.Setup, "remove", this); new StateDependentCommand(ArenaMode.VariableTeams, FightState.Setup, "die", this);
} }
@Override @Override

Datei anzeigen

@ -19,36 +19,37 @@
package de.steamwar.fightsystem.record; package de.steamwar.fightsystem.record;
import com.sk89q.worldedit.EditSession;
import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.utils.ColorConverter; import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.sql.NoClipboardException; import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.utils.TechHider;
import de.steamwar.sql.Schematic; import de.steamwar.sql.Schematic;
import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.SteamwarUser;
import net.md_5.bungee.api.ChatMessageType; import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.BaseComponent; import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.*; import org.bukkit.*;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitTask; import org.bukkit.scheduler.BukkitTask;
import java.io.EOFException; import java.io.EOFException;
import java.io.IOException; import java.io.IOException;
import java.util.HashMap;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.Set;
import java.util.logging.Level; import java.util.logging.Level;
class PacketProcessor { class PacketProcessor {
private static final World world = Bukkit.getWorlds().get(0); private static final World world = Bukkit.getWorlds().get(0);
private final Map<Byte, Integer> packetCounter = new HashMap<>();
private final PacketSource source; private final PacketSource source;
private final BukkitTask task; private final BukkitTask task;
private final LinkedList<Runnable> syncList = new LinkedList<>(); private final LinkedList<Runnable> syncList = new LinkedList<>();
private final Set<Integer> hiddenBlockIds = TechHider.getHiddenBlockIds();
private final int obfuscateWith = TechHider.getObfuscateWith();
public PacketProcessor(PacketSource source){ public PacketProcessor(PacketSource source){
@ -103,13 +104,13 @@ class PacketProcessor {
float yaw = source.rFloat(); float yaw = source.rFloat();
byte headYaw = source.rByte(); byte headYaw = source.rByte();
execSync(() -> REntity.getEntity(entityId).move(locX, locY, locZ, yaw, pitch, headYaw)); execSync(() -> REntity.getEntity(entityId).move(locX, locY, locZ, pitch, yaw, headYaw));
} }
private void entityDespawns() throws IOException { private void entityDespawns() throws IOException {
int entityId = source.rInt(); int entityId = source.rInt();
execSync(() -> REntity.getEntity(entityId).remove()); execSync(() -> REntity.getEntity(entityId).die());
} }
private void entitySneak() throws IOException { private void entitySneak() throws IOException {
@ -129,7 +130,7 @@ class PacketProcessor {
private void tntSpawn() throws IOException { private void tntSpawn() throws IOException {
int entityId = source.rInt(); int entityId = source.rInt();
execSync(() -> new RTnT(entityId)); execSync(() -> new REntity(entityId, EntityType.PRIMED_TNT));
} }
private void entityVelocity() throws IOException { private void entityVelocity() throws IOException {
@ -142,7 +143,7 @@ class PacketProcessor {
execSync(() -> { execSync(() -> {
REntity entity = REntity.getEntity(entityId); REntity entity = REntity.getEntity(entityId);
if(entity != null) if(entity != null)
entity.setMotion(dX, dY, dZ); entity.setVelocity(dX, dY, dZ);
}); });
} }
@ -152,19 +153,19 @@ class PacketProcessor {
boolean enchanted = source.rBoolean(); boolean enchanted = source.rBoolean();
String slot = source.rString(); String slot = source.rString();
execSync(() -> ((RPlayer)REntity.getEntity(entityId)).setItem(item, enchanted, slot)); execSync(() -> REntity.getEntity(entityId).setItem(item, enchanted, slot));
} }
private void arrowSpawn() throws IOException { private void arrowSpawn() throws IOException {
int entityId = source.rInt(); int entityId = source.rInt();
execSync(() -> new RArrow(entityId)); execSync(() -> new REntity(entityId, EntityType.ARROW));
} }
private void fireballSpawn() throws IOException { private void fireballSpawn() throws IOException {
int entityId = source.rInt(); int entityId = source.rInt();
execSync(() -> new RFireball(entityId)); execSync(() -> new REntity(entityId, EntityType.FIREBALL));
} }
private void send(ChatMessageType type) throws IOException { private void send(ChatMessageType type) throws IOException {
@ -196,8 +197,8 @@ class PacketProcessor {
if(!Config.ArenaRegion.in2dRegion(x, z)) if(!Config.ArenaRegion.in2dRegion(x, z))
return; //Outside of the arena return; //Outside of the arena
if (!InspectCommand.inspecting && Config.TechhiderActive && Config.HiddenBlocks.contains(blockState)) { if (TechHider.ENABLED && hiddenBlockIds.contains(blockState)) {
blockState = Config.ObfuscateWith; blockState = obfuscateWith;
} }
IBlockData blockData = Objects.requireNonNull(Block.REGISTRY_ID.fromId(blockState)); IBlockData blockData = Objects.requireNonNull(Block.REGISTRY_ID.fromId(blockState));
execSync(() -> { execSync(() -> {
@ -251,19 +252,10 @@ class PacketProcessor {
}); });
} }
private void pasteSchem(int pasteX, int cornerY, int pasteZ, int cornerX, int cornerZ, boolean rotate, String prefix) throws IOException { private void pasteSchem(FightTeam team) throws IOException {
int schemId = source.rInt(); int schemId = source.rInt();
Schematic schem = Schematic.getSchemFromDB(schemId); execSync(() -> team.pasteSchem(Schematic.getSchemFromDB(schemId)));
DyeColor c = ColorConverter.chat2dye(ChatColor.getByChar(ChatColor.getLastColors(prefix).replace("§", "")));
execSync(() -> {
try {
EditSession e = Paster.pasteSchematic(schem, pasteX, cornerY, pasteZ, rotate);
Paster.replaceTeamColor(e, c, cornerX, cornerY, cornerZ);
} catch (NoClipboardException | IOException e) {
throw new SecurityException("Could not load Clipboard", e);
}
});
} }
private void teams() throws IOException { private void teams() throws IOException {
@ -287,18 +279,17 @@ class PacketProcessor {
} }
private void endSpectating(){ private void endSpectating(){
REntity.dieAll();
WorldLoader.reloadWorld(); WorldLoader.reloadWorld();
SpectateSystem.getScoreboard().setTitle("§eKein Kampf"); SpectateSystem.getScoreboard().setTitle("§eKein Kampf");
for(Map.Entry<Byte, Integer> entry : packetCounter.entrySet()){
System.out.println(Integer.toHexString(entry.getKey()) + " " + entry.getValue());
}
packetCounter.clear();
} }
private void bow() { private void bow() throws IOException {
//TODO implement Bow int entityId = source.rInt();
boolean drawn = source.rBoolean();
boolean offHand = source.rBoolean();
execSync(() -> REntity.getEntity(entityId).setBowDrawn(drawn, offHand));
} }
private void damage() throws IOException { private void damage() throws IOException {
@ -309,8 +300,9 @@ class PacketProcessor {
private void fireTick() throws IOException { private void fireTick() throws IOException {
int entityId = source.rInt(); int entityId = source.rInt();
boolean perma = source.rBoolean();
execSync(() -> REntity.getEntity(entityId).setOnFire()); execSync(() -> REntity.getEntity(entityId).setOnFire(perma));
} }
private void process(){ private void process(){
@ -319,7 +311,6 @@ class PacketProcessor {
boolean tickFinished = false; boolean tickFinished = false;
while(!source.isClosed() && !tickFinished){ while(!source.isClosed() && !tickFinished){
byte packetType = source.rByte(); byte packetType = source.rByte();
packetCounter.compute(packetType, (key, value) -> value != null ? value + 1 : 1);
switch(packetType){ switch(packetType){
case 0x00: case 0x00:
playerJoins(); playerJoins();
@ -352,10 +343,14 @@ class PacketProcessor {
fireballSpawn(); fireballSpawn();
break; break;
case 0x0A: case 0x0A:
bow();
break;
case 0x0B: case 0x0B:
damage(); damage();
break;
case 0x0C: case 0x0C:
fireTick(); fireTick();
break;
case 0x30: case 0x30:
block(); block();
break; break;
@ -381,10 +376,10 @@ class PacketProcessor {
send(ChatMessageType.SYSTEM); send(ChatMessageType.SYSTEM);
break; break;
case (byte) 0xB0: case (byte) 0xB0:
pasteSchem(Config.TeamBluePasteX, Config.TeamBlueCornerY, Config.TeamBluePasteZ, Config.TeamBlueCornerX, Config.TeamBlueCornerZ, Config.TeamBlueRotate, Config.TeamBluePrefix); pasteSchem(Fight.getBlueTeam());
break; break;
case (byte) 0xB1: case (byte) 0xB1:
pasteSchem(Config.TeamRedPasteX, Config.TeamRedCornerY, Config.TeamRedPasteZ, Config.TeamRedCornerX, Config.TeamRedCornerZ, Config.TeamRedRotate, Config.TeamRedPrefix); pasteSchem(Fight.getRedTeam());
break; break;
case (byte) 0xB2: case (byte) 0xB2:
teams(); teams();
@ -401,6 +396,7 @@ class PacketProcessor {
break; break;
case (byte) 0xFF: case (byte) 0xFF:
//Tick //Tick
execSync(REntity::tickFire);
if(!source.async()) if(!source.async())
tickFinished = true; tickFinished = true;
break; break;

Datei anzeigen

@ -0,0 +1,347 @@
package de.steamwar.fightsystem.record;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.reflect.StructureModifier;
import com.comphenix.protocol.wrappers.*;
import de.steamwar.core.Core;
import de.steamwar.sql.SteamwarUser;
import net.royawesome.jlibnoise.MathHelper;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.scoreboard.NameTagVisibility;
import org.bukkit.scoreboard.Team;
import java.util.*;
public class REntity {
private static final Map<Integer, REntity> entities = new HashMap<>();
public static REntity getEntity(int internalId){
return entities.get(internalId);
}
public static void tickFire() {
entities.forEach((integer, entity) -> {
if(entity.fireTick > 0) {
entity.fireTick--;
if(entity.fireTick == 0) {
//TODO
/*DataWatcher dataWatcher = new DataWatcher(null);
DataWatcherObject<Byte> dataWatcherObject = new DataWatcherObject<>(0, DataWatcherRegistry.a);
dataWatcher.register(dataWatcherObject, (byte) 0);
dataWatcher.markDirty(dataWatcherObject);
entity.sendDataWatcher(dataWatcher);*/
}
}
});
}
public static void playerJoins(Player player){
/*for(REntity entity : entities.values()){
entity.sendToPlayer(player);
entity.sendLocation(player);
if(entity.fireTick != 0) {
DataWatcher dataWatcher = new DataWatcher(null);
DataWatcherObject<Byte> dataWatcherObject = new DataWatcherObject<>(0, DataWatcherRegistry.a);
dataWatcher.register(dataWatcherObject, (byte) 1);
dataWatcher.markDirty(dataWatcherObject);
entity.sendDataWatcher(dataWatcher);
}
if(entity.sneaks) {
DataWatcher dataWatcher = new DataWatcher(null);
DataWatcherObject<EntityPose> dataWatcherObject = new DataWatcherObject<>(6, DataWatcherRegistry.s);
dataWatcher.register(dataWatcherObject, EntityPose.CROUCHING);
dataWatcher.markDirty(dataWatcherObject);
entity.sendDataWatcher(dataWatcher);
}
}*/
}
public static void dieAll(){
entities.forEach((id, entity) -> entity.broadcastDeath());
entities.clear();
}
private static final Team team;
static {
if(Bukkit.getScoreboardManager().getMainScoreboard().getTeam("Replay") == null)
team = Bukkit.getScoreboardManager().getMainScoreboard().registerNewTeam("Replay");
else
team = Bukkit.getScoreboardManager().getMainScoreboard().getTeam("Replay");
team.setNameTagVisibility(NameTagVisibility.NEVER);
}
private static int entityCount = Integer.MAX_VALUE;
private static final Random random = new Random();
private final int internalId, entityId;
private final UUID uuid;
private final EntityType entityType;
private final PlayerInfoData playerInfoData;
private final Map<String, ItemStack> itemSlots = new HashMap<>();
private double locX, locY, locZ;
private byte yaw, pitch, headYaw;
private int fireTick;
private boolean sneaks;
public REntity(int internalId, int userId){
this.internalId = internalId;
this.entityType = EntityType.PLAYER;
this.entityId = entityCount--;
SteamwarUser user = SteamwarUser.get(userId);
this.uuid = user.getUUID();
this.playerInfoData = new PlayerInfoData(WrappedGameProfile.fromOfflinePlayer(Bukkit.getOfflinePlayer(uuid)), 0, EnumWrappers.NativeGameMode.SURVIVAL, WrappedChatComponent.fromText(user.getUserName()));
entities.put(internalId, this);
//TODO: Spawn him!
}
public REntity(int internalId, EntityType entityType){
this.internalId = internalId;
this.entityType = entityType;
this.entityId = entityCount--;
this.playerInfoData = null;
this.uuid = new UUID(random.nextLong() & -61441L | 16384L, random.nextLong() & 4611686018427387903L | -9223372036854775808L);
entities.put(internalId, this);
ProtocolLibrary.getProtocolManager().broadcastServerPacket(getSpawnEntityPacket());
}
public void move(double locX, double locY, double locZ, float pitch, float yaw, byte headYaw){
this.locX = locX;
this.locY = locY;
this.locZ = locZ;
this.yaw = (byte)((int)(yaw * 256.0F / 360.0F));
this.pitch = (byte)((int)(pitch * 256.0F / 360.0F));
this.headYaw = headYaw;
ProtocolLibrary.getProtocolManager().broadcastServerPacket(getTeleportPacket());
ProtocolLibrary.getProtocolManager().broadcastServerPacket(getHeadRotationPacket());
}
public void animation(byte animation) {
PacketContainer animationPacket = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.ANIMATION);
StructureModifier<Integer> ints = animationPacket.getIntegers();
ints.write(0, entityId);
ints.write(1, (int) animation);
ProtocolLibrary.getProtocolManager().broadcastServerPacket(animationPacket);
}
public void setVelocity(double dX, double dY, double dZ) {
PacketContainer velocityPacket = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.ENTITY_VELOCITY);
StructureModifier<Integer> ints = velocityPacket.getIntegers();
ints.write(0, entityId);
ints.write(1, calcVelocity(dX));
ints.write(2, calcVelocity(dY));
ints.write(3, calcVelocity(dZ));
ProtocolLibrary.getProtocolManager().broadcastServerPacket(velocityPacket);
}
public void damage() {
PacketContainer statusPacket = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.ENTITY_STATUS);
statusPacket.getIntegers().write(0, entityId);
statusPacket.getBytes().write(0, (byte) 2);
ProtocolLibrary.getProtocolManager().broadcastServerPacket(statusPacket);
}
public void sneak(boolean sneaking) {
sneaks = sneaking;
/*
DataWatcher dataWatcher = new DataWatcher(null);
DataWatcherObject<EntityPose> dataWatcherObject = new DataWatcherObject<>(6, DataWatcherRegistry.s);
dataWatcher.register(dataWatcherObject, sneaking?EntityPose.CROUCHING:EntityPose.STANDING);
dataWatcher.markDirty(dataWatcherObject);
sendDataWatcher(dataWatcher);*/
}
public void setOnFire(boolean perma) {
if(!perma) {
fireTick = 21;
} else {
fireTick = -1;
}
/*DataWatcher dataWatcher = new DataWatcher(null);
DataWatcherObject<Byte> dataWatcherObject = new DataWatcherObject<>(0, DataWatcherRegistry.a);
dataWatcher.register(dataWatcherObject, (byte) 1);
dataWatcher.markDirty(dataWatcherObject);
sendDataWatcher(dataWatcher);*/
}
public void setBowDrawn(boolean drawn, boolean offHand) {
/*DataWatcher dataWatcher = new DataWatcher(null);
DataWatcherObject<Byte> dataWatcherObject = new DataWatcherObject<>(7, DataWatcherRegistry.a);
dataWatcher.register(dataWatcherObject, (byte) ((drawn ? 1 : 0) + (offHand ? 2 : 0)));
dataWatcher.markDirty(dataWatcherObject);
sendDataWatcher(dataWatcher);
private void sendDataWatcher(DataWatcher dataWatcher) {
PacketPlayOutEntityMetadata packet = new PacketPlayOutEntityMetadata(entity.getId(), dataWatcher, false);
for(Player player : Bukkit.getOnlinePlayers()){
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
}
}
*/
}
public void setItem(String item, boolean enchanted, String slot) {
ItemStack stack = new ItemStack(Material.valueOf(item.replace("minecraft:", "").toUpperCase()), 1);
if(enchanted)
stack.addEnchantment(Enchantment.DURABILITY, 1);
itemSlots.put(slot, stack);
ProtocolLibrary.getProtocolManager().broadcastServerPacket(getEquipmentPacket(slot, stack));
}
public void die(){
broadcastDeath();
entities.remove(internalId);
}
private void broadcastDeath(){
if(entityType == EntityType.PLAYER){
PacketContainer infoPacket = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.PLAYER_INFO);
infoPacket.getPlayerInfoAction().write(0, EnumWrappers.PlayerInfoAction.REMOVE_PLAYER);
infoPacket.getPlayerInfoDataLists().write(0, Collections.singletonList(new PlayerInfoData()));
ProtocolLibrary.getProtocolManager().broadcastServerPacket(infoPacket);
team.removeEntry(name);
}
PacketContainer destroyPacket = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.ENTITY_DESTROY);
destroyPacket.getIntegerArrays().write(0, new int[]{entityId});
ProtocolLibrary.getProtocolManager().broadcastServerPacket(destroyPacket);
}
private int entityTypeToId(){
//TODO
return 0;
}
private int calcVelocity(double value) {
return (int)(Math.max(-3.9, Math.min(value, 3.9)) * 8000);
}
private void fillPositioningPacket(PacketContainer packet, StructureModifier<Integer> ints){
ints.write(0, entityId);
if(Core.getVersion() > 8){
StructureModifier<Double> doubles = packet.getDoubles();
doubles.write(0, locX);
doubles.write(1, locY);
doubles.write(2, locZ);
}else{
ints.write(1, MathHelper.floor(locX * 32));
ints.write(2, MathHelper.floor(locY * 32));
ints.write(3, MathHelper.floor(locZ * 32));
}
}
private void fillByteRotation(PacketContainer packet){
StructureModifier<Byte> bytes = packet.getBytes();
bytes.write(0, yaw);
bytes.write(1, pitch);
}
private PacketContainer getTeleportPacket(){
PacketContainer teleportPacket = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.ENTITY_TELEPORT);
fillPositioningPacket(teleportPacket, teleportPacket.getIntegers());
fillByteRotation(teleportPacket);
return teleportPacket;
}
private PacketContainer getHeadRotationPacket(){
PacketContainer headRotation = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.ENTITY_HEAD_ROTATION);
headRotation.getIntegers().write(0, entityId);
headRotation.getBytes().write(1, headYaw);
return headRotation;
}
private PacketContainer getSpawnEntityPacket(){
PacketContainer spawnPacket = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.SPAWN_ENTITY);
StructureModifier<Integer> ints = spawnPacket.getIntegers();
fillPositioningPacket(spawnPacket, ints);
spawnPacket.getUUIDs().write(0, uuid);
if(Core.getVersion() > 8){
spawnPacket.getUUIDs().write(0, uuid);
ints.write(1, 0); // dX
ints.write(2, 0); // dY
ints.write(3, 0); // dZ
}
ints.write(4, (int)pitch);
ints.write(5, (int)yaw);
if(Core.getVersion() > 12){
spawnPacket.getEntityTypeModifier().write(0, entityType);
}else{
ints.write(6, entityTypeToId());
}
return spawnPacket;
}
private PacketContainer getEquipmentPacket(String slot, ItemStack stack){
PacketContainer equipmentPacket = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.ENTITY_EQUIPMENT);
StructureModifier<Integer> ints = equipmentPacket.getIntegers();
ints.write(0, entityId);
if(Core.getVersion() > 8){
switch(slot){
case "MAINHAND":
case "OFFHAND":
ints.write(1, 0);
break;
case "HEAD":
ints.write(1, 4);
break;
case "CHEST":
ints.write(1, 3);
break;
case "LEGS":
ints.write(1, 2);
break;
case "FEET":
default:
ints.write(1, 1);
}
}else{
equipmentPacket.getItemSlots().write(0, EnumWrappers.ItemSlot.valueOf(slot));
}
equipmentPacket.getItemModifier().write(0, stack);
return equipmentPacket;
}
private PacketContainer getPlayerInfoPacket(){
PacketContainer infoPacket = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.PLAYER_INFO);
infoPacket.getPlayerInfoAction().write(0, EnumWrappers.PlayerInfoAction.ADD_PLAYER);
infoPacket.getPlayerInfoDataLists().write(0, Collections.singletonList(playerInfoData));
return infoPacket;
}
private PacketContainer getNamedSpawnPacket(){
PacketContainer namedSpawnPacket = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.NAMED_ENTITY_SPAWN);
StructureModifier<Integer> ints = namedSpawnPacket.getIntegers();
fillPositioningPacket(namedSpawnPacket, ints);
namedSpawnPacket.getUUIDs().write(0, uuid);
fillByteRotation(namedSpawnPacket);
if(Core.getVersion() < 13){
namedSpawnPacket.getDataWatcherModifier().write(0, new WrappedDataWatcher());
}
return namedSpawnPacket;
}
}

Datei anzeigen

@ -157,7 +157,7 @@ public class RecordSystem {
public static synchronized void item(Player p, ItemStack item, String slot){ public static synchronized void item(Player p, ItemStack item, String slot){
Recorder.rByte(0x07); Recorder.rByte(0x07);
Recorder.rInt(p.getEntityId()); Recorder.rInt(p.getEntityId());
Recorder.rString(item.getType().getKey().toString()); Recorder.rString("minecraft:" + item.getType().name().toLowerCase());
Recorder.rBoolean(!item.getEnchantments().isEmpty()); Recorder.rBoolean(!item.getEnchantments().isEmpty());
Recorder.rString(slot); Recorder.rString(slot);
Recorder.flush(); Recorder.flush();

Datei anzeigen

@ -50,7 +50,7 @@ import static de.steamwar.fightsystem.utils.ITechHider.bypass;
public class TechHider extends StateDependent { public class TechHider extends StateDependent {
private static final boolean enabled = !Config.OnlyPublicSchematics && !Config.test() && Config.TechhiderActive; public static final boolean ENABLED = !Config.OnlyPublicSchematics && !Config.test() && Config.TechhiderActive;
private final ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager(); private final ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();
private final Map<PacketContainer, PacketContainer> packetCache = new HashMap<>(); private final Map<PacketContainer, PacketContainer> packetCache = new HashMap<>();
@ -59,16 +59,10 @@ public class TechHider extends StateDependent {
private final int threadMultiplier; private final int threadMultiplier;
public TechHider(){ public TechHider(){
super(enabled, FightState.Schem); super(ENABLED, FightState.Schem);
Set<Integer> hiddenBlockIds = VersionedCallable.call( Set<Integer> hiddenBlockIds = getHiddenBlockIds();
new VersionedCallable<>(TechHider_8::getHiddenBlockIds, 8), int obfuscateWith = getObfuscateWith();
new VersionedCallable<>(TechHider_14::getHiddenBlockIds, 14),
new VersionedCallable<>(TechHider_15::getHiddenBlockIds, 15));
int obfuscateWith = VersionedCallable.call(
new VersionedCallable<>(TechHider_8::getObfuscateWith, 8),
new VersionedCallable<>(TechHider_14::getObfuscateWith, 14),
new VersionedCallable<>(TechHider_15::getObfuscateWith, 15));
obfuscateMaterial = Material.getMaterial(Config.ObfuscateWith.toUpperCase()); obfuscateMaterial = Material.getMaterial(Config.ObfuscateWith.toUpperCase());
chunkHider = VersionedCallable.call(new VersionedCallable<>(() -> null, 8), chunkHider = VersionedCallable.call(new VersionedCallable<>(() -> null, 8),
@ -263,8 +257,22 @@ public class TechHider extends StateDependent {
} }
}; };
public static Set<Integer> getHiddenBlockIds(){
return VersionedCallable.call(
new VersionedCallable<>(TechHider_8::getHiddenBlockIds, 8),
new VersionedCallable<>(TechHider_14::getHiddenBlockIds, 14),
new VersionedCallable<>(TechHider_15::getHiddenBlockIds, 15));
}
public static int getObfuscateWith(){
return VersionedCallable.call(
new VersionedCallable<>(TechHider_8::getObfuscateWith, 8),
new VersionedCallable<>(TechHider_14::getObfuscateWith, 14),
new VersionedCallable<>(TechHider_15::getObfuscateWith, 15));
}
public static List<ChunkPos> prepareChunkReload(Player p, boolean hide){ public static List<ChunkPos> prepareChunkReload(Player p, boolean hide){
if(!enabled) if(!ENABLED)
return Collections.emptyList(); return Collections.emptyList();
List<ChunkPos> chunksToReload = new ArrayList<>(); List<ChunkPos> chunksToReload = new ArrayList<>();
Config.ArenaRegion.forEachChunk((x, z) -> { Config.ArenaRegion.forEachChunk((x, z) -> {
@ -275,7 +283,7 @@ public class TechHider extends StateDependent {
} }
public static void reloadChunks(Player p, List<ChunkPos> chunksToReload, boolean hide){ public static void reloadChunks(Player p, List<ChunkPos> chunksToReload, boolean hide){
if(!enabled) if(!ENABLED)
return; return;
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> { Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> {
for(ChunkPos chunk : chunksToReload){ for(ChunkPos chunk : chunksToReload){