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.EntityExplodeEvent;
import org.bukkit.event.entity.EntitySpawnEvent; import org.bukkit.event.entity.EntitySpawnEvent;
import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.entity.ProjectileLaunchEvent;
import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryType; import org.bukkit.event.inventory.InventoryType;
import org.bukkit.event.player.*; import org.bukkit.event.player.*;
@ -121,6 +122,14 @@ public class EventRecordListener extends BasicListener {
RecordSystem.item(player, disarmNull(e.getOffHandItem()), "OFFHAND"); 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) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onInventoryClick(InventoryClickEvent e){ public void onInventoryClick(InventoryClickEvent e){
Player player = (Player) e.getWhoClicked(); Player player = (Player) e.getWhoClicked();

Datei anzeigen

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