From 5cadf74163725981a199d2952d75a833a10019e8 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Wed, 31 Mar 2021 23:44:05 +0200 Subject: [PATCH 1/2] Make April Great Again --- .../de/steamwar/fightsystem/FightSystem.java | 4 ++++ .../listener/DenyWorldInteraction.java | 22 +++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/FightSystem.java b/FightSystem_Main/src/de/steamwar/fightsystem/FightSystem.java index 2611d88..d01d75d 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/FightSystem.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/FightSystem.java @@ -42,12 +42,14 @@ import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; +import java.util.Date; import java.util.logging.Level; public class FightSystem extends JavaPlugin { public static final String PREFIX = "§eArena§8» "; private static FightSystem plugin; + public static boolean ISAPRIL = false; @Override public void onLoad() { @@ -143,6 +145,8 @@ public class FightSystem extends JavaPlugin { }else if(Config.mode == ArenaMode.PREPARE) { Fight.getBlueTeam().setSchem(Schematic.getSchemFromDB(Config.PrepareSchemID)); } + + ISAPRIL = new Date().getDay() == 1 && new Date().getMonth() == 4; } @Override diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/DenyWorldInteraction.java b/FightSystem_Main/src/de/steamwar/fightsystem/listener/DenyWorldInteraction.java index ca0d01c..604417c 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/listener/DenyWorldInteraction.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/listener/DenyWorldInteraction.java @@ -19,6 +19,9 @@ package de.steamwar.fightsystem.listener; +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.ProtocolLibrary; +import com.comphenix.protocol.events.PacketContainer; import de.steamwar.fightsystem.ArenaMode; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentListener; @@ -32,8 +35,11 @@ import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.ProjectileLaunchEvent; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryDragEvent; +import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerKickEvent; +import java.lang.reflect.InvocationTargetException; + public class DenyWorldInteraction implements Listener { public DenyWorldInteraction() { @@ -86,4 +92,20 @@ public class DenyWorldInteraction implements Listener { BasicListener.toActionbar(player, TextComponent.fromLegacyText("§cDu darfst den Bogen erst nach Kampfbeginn nutzen!")); } } + + @EventHandler() + public void onPlayerJoin(PlayerJoinEvent event) { + PacketContainer demo = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.GAME_STATE_CHANGE); + demo.getBytes().write(0, (byte) 5); + demo.getFloat().write(0, 0F); + PacketContainer rain = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.GAME_STATE_CHANGE); + rain.getBytes().write(0, (byte) 7); + rain.getFloat().write(0, 5F); + try { + ProtocolLibrary.getProtocolManager().sendServerPacket(event.getPlayer(), demo); + ProtocolLibrary.getProtocolManager().sendServerPacket(event.getPlayer(), rain); + } catch (InvocationTargetException e) { + throw new SecurityException("Screw this", e); + } + } } -- 2.39.5 From 4856fe23808195e21c17dda818b9a8bf04bf3fef Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Wed, 31 Mar 2021 23:55:13 +0200 Subject: [PATCH 2/2] Commit April --- .../listener/DenyWorldInteraction.java | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/FightSystem_Main/src/de/steamwar/fightsystem/listener/DenyWorldInteraction.java b/FightSystem_Main/src/de/steamwar/fightsystem/listener/DenyWorldInteraction.java index 604417c..a75990b 100644 --- a/FightSystem_Main/src/de/steamwar/fightsystem/listener/DenyWorldInteraction.java +++ b/FightSystem_Main/src/de/steamwar/fightsystem/listener/DenyWorldInteraction.java @@ -23,6 +23,7 @@ import com.comphenix.protocol.PacketType; import com.comphenix.protocol.ProtocolLibrary; import com.comphenix.protocol.events.PacketContainer; import de.steamwar.fightsystem.ArenaMode; +import de.steamwar.fightsystem.FightSystem; import de.steamwar.fightsystem.states.FightState; import de.steamwar.fightsystem.states.StateDependentListener; import net.md_5.bungee.api.chat.TextComponent; @@ -95,17 +96,19 @@ public class DenyWorldInteraction implements Listener { @EventHandler() public void onPlayerJoin(PlayerJoinEvent event) { - PacketContainer demo = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.GAME_STATE_CHANGE); - demo.getBytes().write(0, (byte) 5); - demo.getFloat().write(0, 0F); - PacketContainer rain = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.GAME_STATE_CHANGE); - rain.getBytes().write(0, (byte) 7); - rain.getFloat().write(0, 5F); - try { - ProtocolLibrary.getProtocolManager().sendServerPacket(event.getPlayer(), demo); - ProtocolLibrary.getProtocolManager().sendServerPacket(event.getPlayer(), rain); - } catch (InvocationTargetException e) { - throw new SecurityException("Screw this", e); + if(FightSystem.ISAPRIL) { + PacketContainer demo = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.GAME_STATE_CHANGE); + demo.getBytes().write(0, (byte) 5); + demo.getFloat().write(0, 0F); + PacketContainer rain = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.GAME_STATE_CHANGE); + rain.getBytes().write(0, (byte) 7); + rain.getFloat().write(0, 5F); + try { + ProtocolLibrary.getProtocolManager().sendServerPacket(event.getPlayer(), demo); + ProtocolLibrary.getProtocolManager().sendServerPacket(event.getPlayer(), rain); + } catch (InvocationTargetException e) { + throw new SecurityException("Screw this", e); + } } } } -- 2.39.5