diff --git a/FightSystem_10/src/de/steamwar/fightsystem/fight/FightWorld_10.java b/FightSystem_10/src/de/steamwar/fightsystem/fight/FightWorld_10.java index 3b81471..fe5c04e 100644 --- a/FightSystem_10/src/de/steamwar/fightsystem/fight/FightWorld_10.java +++ b/FightSystem_10/src/de/steamwar/fightsystem/fight/FightWorld_10.java @@ -24,9 +24,12 @@ import net.minecraft.server.v1_10_R1.Chunk; import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.craftbukkit.v1_10_R1.CraftWorld; +import org.bukkit.craftbukkit.v1_10_R1.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer; +import org.bukkit.entity.Entity; import org.bukkit.entity.Player; -class FightWorld_10 { +public class FightWorld_10 { private FightWorld_10(){} static void resetChunk(World world, World backup, int x, int z){ @@ -44,4 +47,12 @@ class FightWorld_10 { ChunkListener.sendChunk(p, x, z); } } + + public static void sendResourcePack(Player player, String pack, String sha1){ + ((CraftPlayer)player).getHandle().setResourcePack(pack, sha1); + } + + public static float headRotation(Entity e){ + return ((CraftEntity)e).getHandle().getHeadRotation(); + } } diff --git a/FightSystem_12/src/de/steamwar/fightsystem/fight/FightWorld_12.java b/FightSystem_12/src/de/steamwar/fightsystem/fight/FightWorld_12.java index f4a7d6c..6ea877c 100644 --- a/FightSystem_12/src/de/steamwar/fightsystem/fight/FightWorld_12.java +++ b/FightSystem_12/src/de/steamwar/fightsystem/fight/FightWorld_12.java @@ -24,9 +24,12 @@ import net.minecraft.server.v1_12_R1.Chunk; import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.craftbukkit.v1_12_R1.CraftWorld; +import org.bukkit.craftbukkit.v1_12_R1.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer; +import org.bukkit.entity.Entity; import org.bukkit.entity.Player; -class FightWorld_12 { +public class FightWorld_12 { private FightWorld_12(){} static void resetChunk(World world, World backup, int x, int z){ @@ -44,4 +47,12 @@ class FightWorld_12 { ChunkListener.sendChunk(p, x, z); } } + + public static void sendResourcePack(Player player, String pack, String sha1){ + ((CraftPlayer)player).getHandle().setResourcePack(pack, sha1); + } + + public static float headRotation(Entity e){ + return ((CraftEntity)e).getHandle().getHeadRotation(); + } } diff --git a/FightSystem_14/src/de/steamwar/fightsystem/fight/FightWorld_14.java b/FightSystem_14/src/de/steamwar/fightsystem/fight/FightWorld_14.java index 0cff188..81ea1f9 100644 --- a/FightSystem_14/src/de/steamwar/fightsystem/fight/FightWorld_14.java +++ b/FightSystem_14/src/de/steamwar/fightsystem/fight/FightWorld_14.java @@ -24,9 +24,12 @@ import net.minecraft.server.v1_14_R1.Chunk; import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.craftbukkit.v1_14_R1.CraftWorld; +import org.bukkit.craftbukkit.v1_14_R1.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer; +import org.bukkit.entity.Entity; import org.bukkit.entity.Player; -class FightWorld_14 { +public class FightWorld_14 { private FightWorld_14(){} static void resetChunk(World world, World backup, int x, int z){ @@ -45,4 +48,12 @@ class FightWorld_14 { ChunkListener.sendChunk(p, x, z); } } + + public static void sendResourcePack(Player player, String pack, String sha1){ + ((CraftPlayer)player).getHandle().setResourcePack(pack, sha1); + } + + public static float headRotation(Entity e){ + return ((CraftEntity)e).getHandle().getHeadRotation(); + } } diff --git a/FightSystem_15/src/de/steamwar/fightsystem/fight/FightWorld_15.java b/FightSystem_15/src/de/steamwar/fightsystem/fight/FightWorld_15.java index cac3956..ae6de0d 100644 --- a/FightSystem_15/src/de/steamwar/fightsystem/fight/FightWorld_15.java +++ b/FightSystem_15/src/de/steamwar/fightsystem/fight/FightWorld_15.java @@ -24,9 +24,12 @@ import net.minecraft.server.v1_15_R1.Chunk; import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.craftbukkit.v1_15_R1.CraftWorld; +import org.bukkit.craftbukkit.v1_15_R1.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer; +import org.bukkit.entity.Entity; import org.bukkit.entity.Player; -class FightWorld_15 { +public class FightWorld_15 { private FightWorld_15(){} static void resetChunk(World world, World backup, int x, int z){ @@ -45,4 +48,12 @@ class FightWorld_15 { ChunkListener.sendChunk(p, x, z); } } + + public static void sendResourcePack(Player player, String pack, String sha1){ + ((CraftPlayer)player).getHandle().setResourcePack(pack, sha1); + } + + public static float headRotation(Entity e){ + return ((CraftEntity)e).getHandle().getHeadRotation(); + } } diff --git a/FightSystem_15/src/de/steamwar/fightsystem/record/RecordSystem_15.java b/FightSystem_15/src/de/steamwar/fightsystem/record/RecordSystem_15.java index 3618085..6d1a1e3 100644 --- a/FightSystem_15/src/de/steamwar/fightsystem/record/RecordSystem_15.java +++ b/FightSystem_15/src/de/steamwar/fightsystem/record/RecordSystem_15.java @@ -21,8 +21,6 @@ package de.steamwar.fightsystem.record; import org.bukkit.block.Block; import org.bukkit.craftbukkit.v1_15_R1.block.CraftBlock; -import org.bukkit.craftbukkit.v1_15_R1.entity.CraftEntity; -import org.bukkit.entity.Entity; class RecordSystem_15 { private RecordSystem_15(){} @@ -30,8 +28,4 @@ class RecordSystem_15 { static int blockToId(Block block){ return net.minecraft.server.v1_15_R1.Block.REGISTRY_ID.getId(((CraftBlock)block).getNMS()); } - - static int headRotation(Entity e){ - return (int)(((CraftEntity)e).getHandle().getHeadRotation() * 256 / 360); - } } diff --git a/FightSystem_8/src/de/steamwar/fightsystem/fight/FightWorld_8.java b/FightSystem_8/src/de/steamwar/fightsystem/fight/FightWorld_8.java index d2c4bd6..5c6b6f2 100644 --- a/FightSystem_8/src/de/steamwar/fightsystem/fight/FightWorld_8.java +++ b/FightSystem_8/src/de/steamwar/fightsystem/fight/FightWorld_8.java @@ -24,9 +24,12 @@ import net.minecraft.server.v1_8_R3.Chunk; import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.craftbukkit.v1_8_R3.CraftWorld; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; +import org.bukkit.entity.Entity; import org.bukkit.entity.Player; -class FightWorld_8 { +public class FightWorld_8 { private FightWorld_8(){} static void resetChunk(World world, World backup, int x, int z){ @@ -43,4 +46,12 @@ class FightWorld_8 { ChunkListener.sendChunk(p, x, z); } } + + public static void sendResourcePack(Player player, String pack, String sha1){ + ((CraftPlayer)player).getHandle().setResourcePack(pack, sha1); + } + + public static float headRotation(Entity e){ + return ((CraftEntity)e).getHandle().getHeadRotation(); + } } diff --git a/FightSystem_9/src/de/steamwar/fightsystem/fight/FightWorld_9.java b/FightSystem_9/src/de/steamwar/fightsystem/fight/FightWorld_9.java index 06bdcc5..0b508a4 100644 --- a/FightSystem_9/src/de/steamwar/fightsystem/fight/FightWorld_9.java +++ b/FightSystem_9/src/de/steamwar/fightsystem/fight/FightWorld_9.java @@ -24,9 +24,12 @@ import net.minecraft.server.v1_9_R2.Chunk; import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.craftbukkit.v1_9_R2.CraftWorld; +import org.bukkit.craftbukkit.v1_9_R2.entity.CraftEntity; +import org.bukkit.craftbukkit.v1_9_R2.entity.CraftPlayer; +import org.bukkit.entity.Entity; import org.bukkit.entity.Player; -class FightWorld_9 { +public class FightWorld_9 { private FightWorld_9(){} static void resetChunk(World world, World backup, int x, int z){ @@ -44,4 +47,12 @@ class FightWorld_9 { ChunkListener.sendChunk(p, x, z); } } + + public static void sendResourcePack(Player player, String pack, String sha1){ + ((CraftPlayer)player).getHandle().setResourcePack(pack, sha1); + } + + public static float headRotation(Entity e){ + return ((CraftEntity)e).getHandle().getHeadRotation(); + } } diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/ResourcePack.java b/FightSystem_Main/src/de/steamwar/fightsystem/listener/ResourcePack.java index c4ae576..019ff5e 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/listener/ResourcePack.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/listener/ResourcePack.java @@ -1,7 +1,9 @@ package de.steamwar.fightsystem.listener; +import de.steamwar.core.VersionedRunnable; import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.FightSystem; +import de.steamwar.fightsystem.fight.*; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentListener; import org.bukkit.entity.Player; @@ -19,7 +21,7 @@ public class ResourcePack implements Listener { @EventHandler public void handlePlayerJoin(PlayerJoinEvent event) { Player player = event.getPlayer(); - player.setResourcePack("https://steamwar.de/antixray.zip"); + sendResourcePack(player, "https://steamwar.de/antixray.zip", "3e94f5abeb07cc95067b27705615ec14666abe7b"); } @EventHandler @@ -29,7 +31,17 @@ public class ResourcePack implements Listener { Player player = e.getPlayer(); player.sendMessage(FightSystem.PREFIX + "§cAuf Eventserver kann nur mit dem SteamWar-Resourcepack beigetreten werden"); - player.sendMessage(FightSystem.PREFIX + "§cDa du abgelehnt hast, musst du nun in der Serverliste erstmal wieder Ressourcenpakete von SteamWar aktivieren."); + player.sendMessage(FightSystem.PREFIX + "§cDa du abgelehnt hast, musst du nun in der Serverliste erst einmal wieder Ressourcenpakete von SteamWar aktivieren."); player.kickPlayer(null); } + + private void sendResourcePack(Player player, String pack, String sha1){ + VersionedRunnable.call( + new VersionedRunnable(() -> FightWorld_8.sendResourcePack(player, pack, sha1), 8), + new VersionedRunnable(() -> FightWorld_9.sendResourcePack(player, pack, sha1), 9), + new VersionedRunnable(() -> FightWorld_10.sendResourcePack(player, pack, sha1), 10), + new VersionedRunnable(() -> FightWorld_12.sendResourcePack(player, pack, sha1), 12), + new VersionedRunnable(() -> FightWorld_14.sendResourcePack(player, pack, sha1), 14), + new VersionedRunnable(() -> FightWorld_15.sendResourcePack(player, pack, sha1), 15)); + } } diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/record/RecordSystem.java b/FightSystem_Main/src/de/steamwar/fightsystem/record/RecordSystem.java index 6a4a645..f0282ff 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/record/RecordSystem.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/record/RecordSystem.java @@ -20,10 +20,10 @@ package de.steamwar.fightsystem.record; import de.steamwar.core.VersionedCallable; -import de.steamwar.core.VersionedRunnable; import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.Config; import de.steamwar.fightsystem.FightSystem; +import de.steamwar.fightsystem.fight.*; import de.steamwar.fightsystem.states.FightState; import de.steamwar.sql.SteamwarUser; import org.bukkit.Bukkit; @@ -107,9 +107,14 @@ public class RecordSystem { Recorder.rDouble(location.getZ()); Recorder.rFloat(location.getPitch()); Recorder.rFloat(location.getYaw()); - VersionedRunnable.call(new VersionedRunnable(() -> { - Recorder.rByte(RecordSystem_15.headRotation(e)); - }, 15)); + Recorder.rByte((int)(VersionedCallable.call( + new VersionedCallable<>(() -> FightWorld_8.headRotation(e), 8), + new VersionedCallable<>(() -> FightWorld_9.headRotation(e), 9), + new VersionedCallable<>(() -> FightWorld_10.headRotation(e), 10), + new VersionedCallable<>(() -> FightWorld_12.headRotation(e), 12), + new VersionedCallable<>(() -> FightWorld_14.headRotation(e), 14), + new VersionedCallable<>(() -> FightWorld_15.headRotation(e), 15) + ) * 256 / 360)); Recorder.flush(); }