SteamWar/FightSystem
Archiviert
13
1

Additional work

Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Lixfel 2020-09-05 21:43:14 +02:00
Ursprung 6ed7ae0180
Commit 80416f3cdb
2 geänderte Dateien mit 50 neuen und 10 gelöschten Zeilen

Datei anzeigen

@ -16,6 +16,7 @@ import org.bukkit.event.block.BlockPhysicsEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.EntitySpawnEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.entity.ProjectileLaunchEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.event.player.*;
@ -121,6 +122,14 @@ public class EventRecordListener extends BasicListener {
RecordSystem.item(player, disarmNull(e.getOffHandItem()), "OFFHAND");
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onProjectileSpawn(ProjectileLaunchEvent e){
if(e.getEntityType() == EntityType.FIREBALL)
RecordSystem.fireballSpawn(e.getEntity());
else if(e.getEntityType() == EntityType.ARROW)
RecordSystem.arrowSpawn(e.getEntity());
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onInventoryClick(InventoryClickEvent e){
Player player = (Player) e.getWhoClicked();

Datei anzeigen

@ -39,6 +39,8 @@ public class RecordSystem {
* TNTSpawnPacket (0x05) + int EntityId
* EntitySpeedPacket (0x06) + int EntityId + double dx, dy, dz
* PlayerItemPacket (0x07) + int EntityId + String item + boolean enchanted + String slot
* ArrowSpawnPacket (0x08) + int EntityId
* FireballSpawnPacket (0x09) + int EntityId
* TODO Bow spanning
*
*
@ -46,6 +48,7 @@ public class RecordSystem {
* BlockPacket (0x30) + pos int, byte, int + int BlockState
* ParticlePacket (0x31) + double x, y, z + string particleType
* SoundPacket (0x32) + int x, y, z + string soundType + string soundType + float volume, pitch
* ShortBlockPacket (0x33) + pos relative to ArenaMinX,ArenaMinZ byte, byte, byte + short BlockState
*
*
* ChatPacket (0xA0) + String message
@ -104,9 +107,7 @@ public class RecordSystem {
public static synchronized void tntSpawn(Entity e){
Recorder.rByte(0x05);
Recorder.rInt(e.getEntityId());
entityMoves(e);
entitySpeed(e);
spawnEntity(e);
}
public static synchronized void entitySpeed(Entity e){
@ -120,20 +121,44 @@ public class RecordSystem {
}
public static synchronized void item(Player p, ItemStack item, String slot){
Recorder.rByte(p.getEntityId());
Recorder.rByte(0x07);
Recorder.rInt(p.getEntityId());
Recorder.rString(item.getType().getKey().toString());
Recorder.rBoolean(!item.getEnchantments().isEmpty());
Recorder.rString(slot);
Recorder.flush();
}
public static synchronized void arrowSpawn(Entity e){
Recorder.rByte(0x08);
spawnEntity(e);
}
public static synchronized void fireballSpawn(Entity e){
Recorder.rByte(0x09);
spawnEntity(e);
}
public static synchronized void blockChange(BlockPosition pos, int blockState){
Recorder.rByte(0x30);
Recorder.rInt(pos.getX());
Recorder.rByte(pos.getY());
Recorder.rInt(pos.getZ());
Recorder.rInt(blockState);
Recorder.flush();
int shortX = pos.getX() - Config.ArenaMinX;
int shortZ = pos.getZ() - Config.ArenaMinZ;
if((short)blockState == blockState && shortX > 0 && shortX < 256 && shortZ > 0 && shortZ < 256){
//Short block packet
Recorder.rByte(0x33);
Recorder.rByte(pos.getX());
Recorder.rByte(pos.getY());
Recorder.rByte(pos.getZ());
Recorder.rShort((short)blockState);
Recorder.flush();
}else{
//Block packet
Recorder.rByte(0x30);
Recorder.rInt(pos.getX());
Recorder.rByte(pos.getY());
Recorder.rInt(pos.getZ());
Recorder.rInt(blockState);
Recorder.flush();
}
}
public static synchronized void particle(double x, double y, double z, String particleType){
@ -216,4 +241,10 @@ public class RecordSystem {
entitySpeed(tnt);
}
}
private static void spawnEntity(Entity e){
Recorder.rInt(e.getEntityId());
entityMoves(e);
entitySpeed(e);
}
}