SteamWar/FightSystem
Archiviert
13
1

Embedded Schem + Arena relative replay

Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Lixfel 2021-08-24 08:16:57 +02:00
Ursprung 7d1c34d31e
Commit 0357a7a307
9 geänderte Dateien mit 246 neuen und 229 gelöschten Zeilen

Datei anzeigen

@ -63,7 +63,7 @@ public class Config {
private static final int BlueToRedX; private static final int BlueToRedX;
private static final int BlueToRedY; private static final int BlueToRedY;
public static final int BlueToRedZ; private static final int BlueToRedZ;
public static final int PreperationArea; public static final int PreperationArea;
public static final int WaterDepth; public static final int WaterDepth;
@ -390,4 +390,7 @@ public class Config {
public static boolean replayserver(){ public static boolean replayserver(){
return ReplayID == -1; return ReplayID == -1;
} }
public static boolean blueNegZ(){
return BlueToRedZ > 0;
}
} }

Datei anzeigen

@ -85,6 +85,11 @@ public class FightSchematic extends StateDependent {
} }
} }
public void setSchematic(int schemId, Clipboard clipboard) {
this.schematic = schemId;
this.clipboard = clipboard;
}
public void reset(){ public void reset(){
schematic = 0; schematic = 0;
clipboard = null; clipboard = null;

Datei anzeigen

@ -19,6 +19,7 @@
package de.steamwar.fightsystem.fight; package de.steamwar.fightsystem.fight;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import de.steamwar.comms.packets.TablistNamePacket; import de.steamwar.comms.packets.TablistNamePacket;
import de.steamwar.core.VersionedRunnable; import de.steamwar.core.VersionedRunnable;
import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.ArenaMode;
@ -299,7 +300,15 @@ public class FightTeam implements IFightTeam{
public void pasteSchem(Schematic schematic){ public void pasteSchem(Schematic schematic){
setSchem(schematic); setSchem(schematic);
testPasteAction();
}
public void pasteSchem(int schemId, Clipboard clipboard){
this.schematic.setSchematic(schemId, clipboard);
testPasteAction();
}
private void testPasteAction(){
if(Config.test()) if(Config.test())
this.schematic.enable(); this.schematic.enable();
else if(Fight.getOpposite(this).hasSchematic()){ else if(Fight.getOpposite(this).hasSchematic()){

Datei anzeigen

@ -46,13 +46,13 @@ public class FileSource extends PacketSource {
} }
public FileSource(File fightFile) throws IOException { public FileSource(File fightFile) throws IOException {
super(new DataInputStream(new GZIPInputStream(new FileInputStream(fightFile)))); super(new GZIPInputStream(new FileInputStream(fightFile)));
} }
@Override @Override
boolean isClosed() { boolean isClosed() {
try{ try{
return inputStream.available() == 0; return available() == 0;
}catch (IOException e){ }catch (IOException e){
return true; return true;
} }

Datei anzeigen

@ -21,7 +21,6 @@ package de.steamwar.fightsystem.record;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import java.io.DataInputStream;
import java.io.IOException; import java.io.IOException;
import java.net.Socket; import java.net.Socket;
import java.util.logging.Level; import java.util.logging.Level;
@ -30,7 +29,7 @@ public class LiveSource extends PacketSource {
private final Socket socket; private final Socket socket;
protected LiveSource(Socket socket) throws IOException { protected LiveSource(Socket socket) throws IOException {
super(new DataInputStream(socket.getInputStream())); super(socket.getInputStream());
this.socket = socket; this.socket = socket;
} }

Datei anzeigen

@ -19,6 +19,8 @@
package de.steamwar.fightsystem.record; package de.steamwar.fightsystem.record;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import de.steamwar.core.Core;
import de.steamwar.core.VersionedRunnable; import de.steamwar.core.VersionedRunnable;
import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.Config;
@ -55,6 +57,8 @@ public class PacketProcessor {
private static final World world = Bukkit.getWorlds().get(0); private static final World world = Bukkit.getWorlds().get(0);
private final PacketParser[] packetDecoder = new PacketParser[256];
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<>();
@ -62,10 +66,50 @@ public class PacketProcessor {
private final int obfuscateWith = TechHider.getObfuscateWith(); private final int obfuscateWith = TechHider.getObfuscateWith();
private final FreezeWorld freezer = new FreezeWorld(); private final FreezeWorld freezer = new FreezeWorld();
private boolean rotateZ = false;
private int arenaMinX = Config.ArenaRegion.getMinX();
private int arenaMinY = Config.BluePasteRegion.getMinY();
private int arenaMinZ = Config.ArenaRegion.getMinZ();
private boolean tickFinished = false;
public PacketProcessor(PacketSource source){ public PacketProcessor(PacketSource source){
this.source = source; this.source = source;
replaying = true; replaying = true;
packetDecoder[0x00] = this::playerJoins;
packetDecoder[0x01] = this::entityMoves;
packetDecoder[0x02] = this::entityDespawns;
packetDecoder[0x03] = this::entitySneak;
packetDecoder[0x04] = this::entityAnimation;
packetDecoder[0x05] = this::tntSpawn;
packetDecoder[0x06] = this::entityVelocity;
packetDecoder[0x07] = this::playerItem;
packetDecoder[0x08] = this::arrowSpawn;
packetDecoder[0x09] = this::fireballSpawn;
packetDecoder[0x0a] = this::bow;
packetDecoder[0x0b] = this::damage;
packetDecoder[0x0c] = this::fireTick;
packetDecoder[0x20] = this::arenaInfo;
packetDecoder[0x30] = this::block;
packetDecoder[0x31] = this::particle;
packetDecoder[0x32] = this::sound;
packetDecoder[0x33] = this::shortBlock;
packetDecoder[0x34] = this::soundAtPlayer;
packetDecoder[0x35] = this::shortRelativeBlock;
packetDecoder[0xa0] = () -> send(ChatMessageType.CHAT);
packetDecoder[0xa1] = () -> send(ChatMessageType.ACTION_BAR);
packetDecoder[0xa2] = () -> send(ChatMessageType.SYSTEM);
packetDecoder[0xb0] = () -> pasteSchem(Fight.getBlueTeam());
packetDecoder[0xb1] = () -> pasteSchem(Fight.getRedTeam());
packetDecoder[0xb2] = this::teams;
packetDecoder[0xb3] = () -> pasteEmbeddedSchem(Fight.getBlueTeam());
packetDecoder[0xb4] = () -> pasteEmbeddedSchem(Fight.getRedTeam());
packetDecoder[0xc0] = this::scoreboardTitle;
packetDecoder[0xc1] = this::scoreboardData;
packetDecoder[0xef] = source::readUTF;
packetDecoder[0xff] = this::tick;
if(source.async()) { if(source.async()) {
Bukkit.getScheduler().runTaskAsynchronously(FightSystem.getPlugin(), this::process); Bukkit.getScheduler().runTaskAsynchronously(FightSystem.getPlugin(), this::process);
task = Bukkit.getScheduler().runTaskTimer(FightSystem.getPlugin(), this::runSync, 1, 1); task = Bukkit.getScheduler().runTaskTimer(FightSystem.getPlugin(), this::runSync, 1, 1);
@ -98,56 +142,59 @@ public class PacketProcessor {
} }
private void playerJoins() throws IOException { private void playerJoins() throws IOException {
int entityId = source.rInt(); int entityId = source.readInt();
int userId = source.rInt(); int userId = source.readInt();
execSync(() -> new REntity(entityId, userId)); execSync(() -> new REntity(entityId, userId));
} }
private void entityMoves() throws IOException { private void entityMoves() throws IOException {
int entityId = source.rInt(); int entityId = source.readInt();
double locX = source.rDouble(); double locX = source.readDouble() - arenaMinX + Config.ArenaRegion.getMinX();
double locY = source.rDouble(); double locY = source.readDouble() - arenaMinY + Config.BluePasteRegion.getMinY();
double locZ = source.rDouble(); double z = source.readDouble() - arenaMinZ;
float pitch = source.rFloat(); if(rotateZ)
float yaw = source.rFloat(); z = Config.ArenaRegion.getSizeZ() - z;
byte headYaw = source.rByte(); double locZ = z + Config.ArenaRegion.getMinZ();
float pitch = source.readFloat();
float yaw = source.readFloat() + (rotateZ ? 360 : 0);
byte headYaw = (byte)((source.readByte() + (rotateZ ? 128 : 0)) % 256);
execSync(() -> REntity.getEntity(entityId).move(locX, locY, locZ, pitch, yaw, 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.readInt();
execSync(() -> REntity.getEntity(entityId).die()); execSync(() -> REntity.getEntity(entityId).die());
} }
private void entitySneak() throws IOException { private void entitySneak() throws IOException {
int entityId = source.rInt(); int entityId = source.readInt();
boolean sneaking = source.rBoolean(); boolean sneaking = source.readBoolean();
execSync(() -> REntity.getEntity(entityId).sneak(sneaking)); execSync(() -> REntity.getEntity(entityId).sneak(sneaking));
} }
private void entityAnimation() throws IOException { private void entityAnimation() throws IOException {
int entityId = source.rInt(); int entityId = source.readInt();
byte animation = source.rByte(); byte animation = source.readByte();
execSync(() -> REntity.getEntity(entityId).animation(animation)); execSync(() -> REntity.getEntity(entityId).animation(animation));
} }
private void tntSpawn() throws IOException { private void tntSpawn() throws IOException {
int entityId = source.rInt(); int entityId = source.readInt();
execSync(() -> new REntity(entityId, EntityType.PRIMED_TNT)); execSync(() -> new REntity(entityId, EntityType.PRIMED_TNT));
} }
private void entityVelocity() throws IOException { private void entityVelocity() throws IOException {
int entityId = source.rInt(); int entityId = source.readInt();
double dX = source.rDouble(); double dX = source.readDouble();
double dY = source.rDouble(); double dY = source.readDouble();
double dZ = source.rDouble(); double dZ = rotateZ ? -source.readDouble() : source.readDouble();
execSync(() -> { execSync(() -> {
REntity entity = REntity.getEntity(entityId); REntity entity = REntity.getEntity(entityId);
@ -157,49 +204,71 @@ public class PacketProcessor {
} }
private void playerItem() throws IOException { private void playerItem() throws IOException {
int entityId = source.rInt(); int entityId = source.readInt();
String item = source.rString(); String item = source.readUTF();
boolean enchanted = source.rBoolean(); boolean enchanted = source.readBoolean();
String slot = source.rString(); String slot = source.readUTF();
execSync(() -> 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.readInt();
execSync(() -> new REntity(entityId, EntityType.ARROW)); execSync(() -> new REntity(entityId, EntityType.ARROW));
} }
private void fireballSpawn() throws IOException { private void fireballSpawn() throws IOException {
int entityId = source.rInt(); int entityId = source.readInt();
execSync(() -> new REntity(entityId, EntityType.FIREBALL)); execSync(() -> new REntity(entityId, EntityType.FIREBALL));
} }
private void send(ChatMessageType type) throws IOException { private void send(ChatMessageType type) throws IOException {
String message = source.rString(); String message = source.readUTF();
BaseComponent[] text = TextComponent.fromLegacyText(message); BaseComponent[] text = TextComponent.fromLegacyText(message);
Bukkit.getOnlinePlayers().forEach(p -> p.spigot().sendMessage(type, text)); Bukkit.getOnlinePlayers().forEach(p -> p.spigot().sendMessage(type, text));
} }
private void arenaInfo() throws IOException {
rotateZ = source.readBoolean() != Config.blueNegZ();
arenaMinY = Byte.toUnsignedInt(source.readByte());
arenaMinX = source.readInt();
arenaMinZ = source.readInt();
}
private void shortBlock() throws IOException { private void shortBlock() throws IOException {
int x = Byte.toUnsignedInt(source.rByte()) + Config.ArenaRegion.getMinX(); int x = Byte.toUnsignedInt(source.readByte()) + Config.ArenaRegion.getMinX();
int y = Byte.toUnsignedInt(source.rByte()); int y = Byte.toUnsignedInt(source.readByte());
int z = Byte.toUnsignedInt(source.rByte()) + Config.ArenaRegion.getMinZ(); int z = Byte.toUnsignedInt(source.readByte()) + Config.ArenaRegion.getMinZ();
int blockState = source.rShort(); int blockState = source.readShort();
setBlock(x, y, z, blockState); setBlock(x, y, z, blockState);
} }
private void block() throws IOException { private void shortRelativeBlock() throws IOException {
int x = source.rInt(); int x = Byte.toUnsignedInt(source.readByte());
int y = Byte.toUnsignedInt(source.rByte()); int y = Byte.toUnsignedInt(source.readByte());
int z = source.rInt(); int z = Byte.toUnsignedInt(source.readByte());
int blockState = source.rInt(); int blockState = source.readShort();
setBlock(x, y, z, blockState); if(rotateZ)
z = Config.ArenaRegion.getSizeZ() - z;
setBlock(x + Config.ArenaRegion.getMinX(), y + Config.BluePasteRegion.getMinY(), z + Config.ArenaRegion.getMinZ(), blockState);
}
private void block() throws IOException {
int x = source.readInt() - arenaMinX;
int y = Byte.toUnsignedInt(source.readByte()) - arenaMinY;
int z = source.readInt() - arenaMinZ;
int blockState = source.readInt();
if(rotateZ)
z = Config.ArenaRegion.getSizeZ() - z;
setBlock(x + Config.ArenaRegion.getMinX(), y + Config.BluePasteRegion.getMinY(), z + Config.ArenaRegion.getMinZ(), blockState);
} }
private void setBlock(int x, int y, int z, int blockState){ private void setBlock(int x, int y, int z, int blockState){
@ -210,25 +279,25 @@ public class PacketProcessor {
} }
private void particle() throws IOException { private void particle() throws IOException {
double x = source.rDouble(); double x = source.readDouble();
double y = source.rDouble(); double y = source.readDouble();
double z = source.rDouble(); double z = source.readDouble();
String particleName = source.rString(); String particleName = source.readUTF();
execSync(() -> world.spawnParticle(Particle.valueOf(particleName), x, y, z, 1)); execSync(() -> world.spawnParticle(Particle.valueOf(particleName), x, y, z, 1));
} }
private void sound() throws IOException { private void sound() throws IOException {
int x = source.rInt(); int x = source.readInt();
int y = source.rInt(); int y = source.readInt();
int z = source.rInt(); int z = source.readInt();
String soundName = source.rString(); String soundName = source.readUTF();
String soundCategory = source.rString(); String soundCategory = source.readUTF();
float volume = source.rFloat(); float volume = source.readFloat();
float pitch = source.rFloat(); float pitch = source.readFloat();
Sound sound = Sound.valueOf(soundName); Sound sound = Sound.valueOf(soundName);
SoundCategory sCategory = SoundCategory.valueOf(soundCategory); SoundCategory sCategory = SoundCategory.valueOf(soundCategory);
@ -237,10 +306,10 @@ public class PacketProcessor {
} }
private void soundAtPlayer() throws IOException { private void soundAtPlayer() throws IOException {
String soundName = source.rString(); String soundName = source.readUTF();
float volume = source.rFloat(); float volume = source.readFloat();
float pitch = source.rFloat(); float pitch = source.readFloat();
Sound sound = Sound.valueOf(soundName); Sound sound = Sound.valueOf(soundName);
@ -252,14 +321,21 @@ public class PacketProcessor {
} }
private void pasteSchem(FightTeam team) throws IOException { private void pasteSchem(FightTeam team) throws IOException {
int schemId = source.rInt(); int schemId = source.readInt();
execSync(() -> team.pasteSchem(Schematic.getSchemFromDB(schemId))); execSync(() -> team.pasteSchem(Schematic.getSchemFromDB(schemId)));
} }
private void pasteEmbeddedSchem(FightTeam team) throws IOException {
int schemId = source.readInt();
Clipboard clipboard = Schematic.clipboardFromStream(source, Core.getVersion() > 12);
execSync(() -> team.pasteSchem(schemId, clipboard));
}
private void teams() throws IOException { private void teams() throws IOException {
int blueId = source.rInt(); int blueId = source.readInt();
int redId = source.rInt(); int redId = source.readInt();
execSync(() -> { execSync(() -> {
pasteForTeam(blueId, Fight.getBlueTeam()); pasteForTeam(blueId, Fight.getBlueTeam());
@ -274,14 +350,14 @@ public class PacketProcessor {
} }
private void scoreboardTitle() throws IOException { private void scoreboardTitle() throws IOException {
String title = source.rString(); String title = source.readUTF();
FightScoreboard.getScoreboard().setTitle(title); FightScoreboard.getScoreboard().setTitle(title);
} }
private void scoreboardData() throws IOException { private void scoreboardData() throws IOException {
String key = source.rString(); String key = source.readUTF();
int value = source.rInt(); int value = source.readInt();
FightScoreboard.getScoreboard().addScore(key, value); FightScoreboard.getScoreboard().addScore(key, value);
} }
@ -299,123 +375,43 @@ public class PacketProcessor {
} }
private void bow() throws IOException { private void bow() throws IOException {
int entityId = source.rInt(); int entityId = source.readInt();
boolean drawn = source.rBoolean(); boolean drawn = source.readBoolean();
boolean offHand = source.rBoolean(); boolean offHand = source.readBoolean();
execSync(() -> REntity.getEntity(entityId).setBowDrawn(drawn, offHand)); execSync(() -> REntity.getEntity(entityId).setBowDrawn(drawn, offHand));
} }
private void damage() throws IOException { private void damage() throws IOException {
int entityId = source.rInt(); int entityId = source.readInt();
execSync(() -> REntity.getEntity(entityId).damage()); execSync(() -> REntity.getEntity(entityId).damage());
} }
private void fireTick() throws IOException { private void fireTick() throws IOException {
int entityId = source.rInt(); int entityId = source.readInt();
boolean perma = source.rBoolean(); boolean perma = source.readBoolean();
execSync(() -> REntity.getEntity(entityId).setOnFire(perma)); execSync(() -> REntity.getEntity(entityId).setOnFire(perma));
} }
private void tick(){
execSync(REntity::tickFire);
if(!source.async())
tickFinished = true;
}
private void process(){ private void process(){
tickFinished = false;
try{ try{
boolean tickFinished = false;
while(!source.isClosed() && !tickFinished){ while(!source.isClosed() && !tickFinished){
byte packetType = source.rByte(); int packetType = Byte.toUnsignedInt(source.readByte());
switch(packetType){ PacketParser parser = packetDecoder[packetType];
case 0x00: if(parser != null){
playerJoins(); parser.process();
break; }else{
case 0x01: Bukkit.getLogger().log(Level.SEVERE, "Unknown packet " + packetType + " recieved, closing.");
entityMoves(); source.close();
break;
case 0x02:
entityDespawns();
break;
case 0x03:
entitySneak();
break;
case 0x04:
entityAnimation();
break;
case 0x05:
tntSpawn();
break;
case 0x06:
entityVelocity();
break;
case 0x07:
playerItem();
break;
case 0x08:
arrowSpawn();
break;
case 0x09:
fireballSpawn();
break;
case 0x0A:
bow();
break;
case 0x0B:
damage();
break;
case 0x0C:
fireTick();
break;
case 0x30:
block();
break;
case 0x31:
particle();
break;
case 0x32:
sound();
break;
case 0x33:
shortBlock();
break;
case 0x34:
soundAtPlayer();
break;
case (byte) 0xA0:
send(ChatMessageType.CHAT);
break;
case (byte) 0xA1:
send(ChatMessageType.ACTION_BAR);
break;
case (byte) 0xA2:
send(ChatMessageType.SYSTEM);
break;
case (byte) 0xB0:
pasteSchem(Fight.getBlueTeam());
break;
case (byte) 0xB1:
pasteSchem(Fight.getRedTeam());
break;
case (byte) 0xB2:
teams();
break;
case (byte) 0xC0:
scoreboardTitle();
break;
case (byte) 0xC1:
scoreboardData();
break;
case (byte) 0xEF:
// Comment
source.rString();
break;
case (byte) 0xFF:
//Tick
execSync(REntity::tickFire);
if(!source.async())
tickFinished = true;
break;
default:
Bukkit.getLogger().log(Level.SEVERE, "Unknown packet {} recieved, closing.", packetType);
source.close();
} }
} }
} catch (EOFException e) { } catch (EOFException e) {
@ -437,4 +433,8 @@ public class PacketProcessor {
new VersionedRunnable(() -> RecordSystem_14.setBlock(world, x, y, z, blockState), 14), new VersionedRunnable(() -> RecordSystem_14.setBlock(world, x, y, z, blockState), 14),
new VersionedRunnable(() -> RecordSystem_15.setBlock(world, x, y, z, blockState), 15)); new VersionedRunnable(() -> RecordSystem_15.setBlock(world, x, y, z, blockState), 15));
} }
private interface PacketParser{
void process() throws IOException;
}
} }

Datei anzeigen

@ -23,52 +23,20 @@ import org.bukkit.Bukkit;
import java.io.DataInputStream; import java.io.DataInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.util.logging.Level; import java.util.logging.Level;
public abstract class PacketSource { public abstract class PacketSource extends DataInputStream {
protected final DataInputStream inputStream; protected PacketSource(InputStream inputStream){
super(inputStream);
protected PacketSource(DataInputStream inputStream){
this.inputStream = inputStream;
new PacketProcessor(this); new PacketProcessor(this);
} }
public byte rByte() throws IOException { @Override
return inputStream.readByte();
}
public boolean rBoolean() throws IOException {
return inputStream.readBoolean();
}
public short rShort() throws IOException {
return inputStream.readShort();
}
public int rInt() throws IOException {
return inputStream.readInt();
}
public long rLong() throws IOException {
return inputStream.readLong();
}
public float rFloat() throws IOException {
return inputStream.readFloat();
}
public double rDouble() throws IOException {
return inputStream.readDouble();
}
public String rString() throws IOException {
return inputStream.readUTF();
}
public void close(){ public void close(){
try { try {
inputStream.close(); super.close();
} catch (IOException e) { } catch (IOException e) {
Bukkit.getLogger().log(Level.SEVERE, "IOException on disable", e); Bukkit.getLogger().log(Level.SEVERE, "IOException on disable", e);
} }

Datei anzeigen

@ -24,6 +24,7 @@ import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.fight.*; import de.steamwar.fightsystem.fight.*;
import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.FightState;
import de.steamwar.sql.Schematic;
import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.SteamwarUser;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
@ -35,6 +36,8 @@ import org.bukkit.util.Vector;
import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.logging.Level; import java.util.logging.Level;
public interface Recorder { public interface Recorder {
@ -47,6 +50,7 @@ public interface Recorder {
teamIds(Config.EventTeamBlueID, Config.EventTeamRedID); teamIds(Config.EventTeamBlueID, Config.EventTeamRedID);
} }
arenaInfo();
enableTeam(Fight.getBlueTeam()); enableTeam(Fight.getBlueTeam());
enableTeam(Fight.getRedTeam()); enableTeam(Fight.getRedTeam());
} }
@ -92,20 +96,26 @@ public interface Recorder {
* PlayerDamagePacket (0x0B) + int EntityId * PlayerDamagePacket (0x0B) + int EntityId
* SetOnFire (0x0C) + int EntityId + boolean perma * SetOnFire (0x0C) + int EntityId + boolean perma
* *
* ArenaInfo (0x20) + bool blueNegZ + byte arenaY + int arenaMinX + int arenaMinZ
* *
* BlockPacket (0x30) + pos int, byte, int + int BlockState * BlockPacket (0x30) + pos int, byte, int + int BlockState
* ParticlePacket (0x31) + double x, y, z + string particleType * ParticlePacket (0x31) + double x, y, z + string particleType
* SoundPacket (0x32) + int x, y, z + string soundType + string soundCategory + float volume, pitch * SoundPacket (0x32) + int x, y, z + string soundType + string soundCategory + float volume, pitch
* ShortBlockPacket (0x33) + pos relative to ArenaMinX,ArenaMinZ byte, byte, byte + short BlockState * ShortBlockPacket (0x33) + pos relative to ArenaMinX,ArenaMinZ byte, byte, byte + short BlockState
* SoundAtPlayerPacket (0x34) + string (soundType, soundCategory) + float volume, pitch * SoundAtPlayerPacket (0x34) + string (soundType, soundCategory) + float volume, pitch
* ShortBlockPacket (0x35) + pos relative to ArenaMinX,BluePasteY,ArenaMinZ byte, byte, byte + short BlockState
* *
* *
* ChatPacket (0xA0) + String message * ChatPacket (0xA0) + String message
* ActionBarPacket (0xA1) + String message * ActionBarPacket (0xA1) + String message
* SystemPacket (0xA2) + String message * SystemPacket (0xA2) + String message
*
* BlueSchemPacket (0xB0) + int blueSchemId * BlueSchemPacket (0xB0) + int blueSchemId
* RedSchemPacket (0xB1) + int redSchemId * RedSchemPacket (0xB1) + int redSchemId
* TeamIDPacket (0xB2) + int blueTeamId, redTeamId * TeamIDPacket (0xB2) + int blueTeamId, redTeamId
* BlueEmbeddedSchemPacket (0xB3) + int blueSchemId + gzipt NBT blob
* RedEmbeddedSchemPacket (0xB4) + int redSchemId + gzipt NBT blob
*
* ScoreboardTitlePacket (0xC0) + String scoreboardTitle * ScoreboardTitlePacket (0xC0) + String scoreboardTitle
* ScoreboardDataPacket (0xC1) + String key + int value * ScoreboardDataPacket (0xC1) + String key + int value
* *
@ -185,16 +195,22 @@ public interface Recorder {
write(0x0c, e.getEntityId(), perma); write(0x0c, e.getEntityId(), perma);
} }
default void arenaInfo(){
write(0x20, Config.blueNegZ(), (byte)Config.BluePasteRegion.getMinY(),
Config.ArenaRegion.getMinX(), Config.ArenaRegion.getMinZ());
}
default void blockChange(Block block){ default void blockChange(Block block){
int blockState = VersionedCallable.call(new VersionedCallable<>(() -> RecordSystem_8.blockToId(block), 8), int blockState = VersionedCallable.call(new VersionedCallable<>(() -> RecordSystem_8.blockToId(block), 8),
new VersionedCallable<>(() -> RecordSystem_14.blockToId(block), 14), new VersionedCallable<>(() -> RecordSystem_14.blockToId(block), 14),
new VersionedCallable<>(() -> RecordSystem_15.blockToId(block), 15)); new VersionedCallable<>(() -> RecordSystem_15.blockToId(block), 15));
int shortX = block.getX() - Config.ArenaRegion.getMinX(); int shortX = block.getX() - Config.ArenaRegion.getMinX();
int shortY = block.getY() - Config.BluePasteRegion.getMinY();
int shortZ = block.getZ() - Config.ArenaRegion.getMinZ(); int shortZ = block.getZ() - Config.ArenaRegion.getMinZ();
if((short)blockState == blockState && shortX > 0 && shortX < 256 && shortZ > 0 && shortZ < 256){ if((short)blockState == blockState && shortX >= 0 && shortX < 256 && shortY >= 0 && shortZ >= 0 && shortZ < 256){
//Short block packet //Short block packet
write(0x33, (byte)shortX, (byte)block.getY(), (byte)shortZ, (short)blockState); write(0x35, (byte)shortX, (byte)shortY, (byte)shortZ, (short)blockState);
}else{ }else{
//Block packet //Block packet
write(0x30, block.getX(), (byte)block.getY(), block.getZ(), blockState); write(0x30, block.getX(), (byte)block.getY(), block.getZ(), blockState);
@ -225,16 +241,26 @@ public interface Recorder {
write(0xa2, s); write(0xa2, s);
} }
default void teamIds(int blueTeamId, int redTeamId) {
write(0xb2, blueTeamId, redTeamId);
}
default void blueSchem(int schemId) { default void blueSchem(int schemId) {
write(0xb0, schemId); try {
write(0xb3, schemId, Schematic.getSchemFromDB(schemId).schemData());
} catch (IOException e) {
Bukkit.getLogger().log(Level.SEVERE, "Could not embed schematic", e);
write(0xb0, schemId);
}
} }
default void redSchem(int schemId) { default void redSchem(int schemId) {
write(0xb1, schemId); try {
} write(0xb4, schemId, Schematic.getSchemFromDB(schemId).schemData());
} catch (IOException e) {
default void teamIds(int blueTeamId, int redTeamId) { Bukkit.getLogger().log(Level.SEVERE, "Could not embed schematic", e);
write(0xb2, blueTeamId, redTeamId); write(0xb1, schemId);
}
} }
default void scoreboardTitle(String title){ default void scoreboardTitle(String title){
@ -252,28 +278,28 @@ public interface Recorder {
default void write(int id, Object... objects){ default void write(int id, Object... objects){
DataOutputStream stream = getStream(); DataOutputStream stream = getStream();
try { try {
synchronized (stream) { stream.writeByte(id);
stream.writeByte(id); for(Object o : objects){
for(Object o : objects){ if(o instanceof Boolean)
if(o instanceof Boolean) stream.writeBoolean((Boolean)o);
stream.writeBoolean((Boolean)o); else if(o instanceof Byte)
else if(o instanceof Byte) stream.writeByte((Byte)o);
stream.writeByte((Byte)o); else if(o instanceof Short)
else if(o instanceof Short) stream.writeShort((Short)o);
stream.writeShort((Short)o); else if(o instanceof Integer)
else if(o instanceof Integer) stream.writeInt((Integer)o);
stream.writeInt((Integer)o); else if(o instanceof Float)
else if(o instanceof Float) stream.writeFloat((Float)o);
stream.writeFloat((Float)o); else if(o instanceof Double)
else if(o instanceof Double) stream.writeDouble((Double)o);
stream.writeDouble((Double)o); else if(o instanceof String)
else if(o instanceof String) stream.writeUTF((String)o);
stream.writeUTF((String)o); else if(o instanceof InputStream)
else copy((InputStream) o, stream);
throw new SecurityException("Undefined write for: " + o.getClass().getName()); else
} throw new SecurityException("Undefined write for: " + o.getClass().getName());
stream.flush();
} }
stream.flush();
} catch (IOException e) { } catch (IOException e) {
Bukkit.getLogger().log(Level.SEVERE, "Could not write", e); Bukkit.getLogger().log(Level.SEVERE, "Could not write", e);
try { try {
@ -283,4 +309,11 @@ public interface Recorder {
} }
} }
} }
static void copy(InputStream var0, OutputStream var1) throws IOException {
int var5;
for(byte[] var4 = new byte[8192]; (var5 = var0.read(var4)) > 0;) {
var1.write(var4, 0, var5);
}
}
} }

Datei anzeigen

@ -52,7 +52,7 @@ public class WinconditionTimeTechKO extends Wincondition {
public WinconditionTimeTechKO(){ public WinconditionTimeTechKO(){
super("TechKO"); super("TechKO");
if(Config.BlueToRedZ > 0) { if(Config.blueNegZ()) {
smallerZteam = Fight.getBlueTeam(); smallerZteam = Fight.getBlueTeam();
biggerZteam = Fight.getRedTeam(); biggerZteam = Fight.getRedTeam();
}else{ }else{