From 3f1706f40f564d23eccb6f310ca0ebd38f64b22b Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Mon, 12 Apr 2021 16:07:16 +0200 Subject: [PATCH] Adding more Record Methods --- .../src/de/steamwar/fightsystem/Config.java | 4 ++-- .../fightsystem/listener/Recording.java | 22 ++++++++++++++---- .../fightsystem/record/RecordSystem.java | 23 +++++++++++++++++-- 3 files changed, 41 insertions(+), 8 deletions(-) diff --git a/FightSystem_API/src/de/steamwar/fightsystem/Config.java b/FightSystem_API/src/de/steamwar/fightsystem/Config.java index 1fcf4e8..3a03708 100644 --- a/FightSystem_API/src/de/steamwar/fightsystem/Config.java +++ b/FightSystem_API/src/de/steamwar/fightsystem/Config.java @@ -347,7 +347,7 @@ public class Config { EventTeamRedID = 0; BothTeamsPublic = true; MaximumTeamMembers = Integer.MAX_VALUE; - SpectateSystem = false; + SpectateSystem = true; } String blueLeader = System.getProperty("blueLeader", null); @@ -384,6 +384,6 @@ public class Config { return ArenaMode.Test.contains(mode); } public static boolean recording(){ - return mode == ArenaMode.EVENT; + return true;//mode == ArenaMode.EVENT; } } diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/Recording.java b/FightSystem_Main/src/de/steamwar/fightsystem/listener/Recording.java index fcefb2f..e483e5b 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/listener/Recording.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/listener/Recording.java @@ -36,10 +36,7 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; 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.entity.*; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryType; import org.bukkit.event.player.*; @@ -111,6 +108,21 @@ public class Recording implements Listener { RecordSystem.entityAnimation(e.getPlayer(), AIR); } + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onEntityDamage(EntityDamageEvent e) { + if(e.getEntityType() != EntityType.PLAYER) + return; + + Player p = (Player) e.getEntity(); + if(isNotSent(p)) + return; + + RecordSystem.damageAnimation(p); + + if(e.getCause() == EntityDamageEvent.DamageCause.FIRE_TICK) + RecordSystem.setOnFire(p); + } + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onTNTSpawn(EntitySpawnEvent e){ //TODO: Falling block @@ -228,4 +240,6 @@ public class Recording implements Listener { FightPlayer fp = Fight.getFightPlayer(p); return fp == null || !fp.isLiving() || FightState.getFightState() == FightState.SPECTATE; } + + } diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/record/RecordSystem.java b/FightSystem_Main/src/de/steamwar/fightsystem/record/RecordSystem.java index f0282ff..74912ff 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/record/RecordSystem.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/record/RecordSystem.java @@ -64,8 +64,9 @@ public class RecordSystem { * PlayerItemPacket (0x07) + int EntityId + String item + boolean enchanted + String slot * ArrowSpawnPacket (0x08) + int EntityId * FireballSpawnPacket (0x09) + int EntityId - * TODO Bow spanning - * + * BowSpanPacket (0x0A) + int EntityId + boolean hand + * PlayerDamagePacket (0x0B) + int EntityId + * SetOnFire (0x0C) + int EntityId * * * BlockPacket (0x30) + pos int, byte, int + int BlockState @@ -172,6 +173,24 @@ public class RecordSystem { spawnEntity(e); } + public static synchronized void bowSpan(Player p) { + Recorder.rByte(0x0A); + Recorder.rInt(p.getEntityId()); + Recorder.flush(); + } + + public static synchronized void damageAnimation(Player p) { + Recorder.rByte(0x0B); + Recorder.rInt(p.getEntityId()); + Recorder.flush(); + } + + public static synchronized void setOnFire(Player p) { + Recorder.rByte(0x0C); + Recorder.rInt(p.getEntityId()); + Recorder.flush(); + } + public static synchronized void blockChange(Block block){ int blockState = blockToId(block);