From af7ce241e0623c5837d517fa46cdfcba8af3d80c Mon Sep 17 00:00:00 2001 From: micle Date: Sat, 20 Nov 2021 19:51:44 +0000 Subject: [PATCH] Changed groupId from com.micle to dev.micle. Updated code to match newest MCP mappings. --- .../events/OnKeyPressEventHandler.java | 89 ------------------- .../loginprotection/LoginProtection.java | 8 +- .../loginprotection/data/ProtectedPlayer.java | 4 +- .../data/ProtectedPlayers.java | 6 +- .../events/OnKeyPressEventHandler.java | 89 +++++++++++++++++++ .../OnLivingSetAttackTargetEventHandler.java | 12 +-- .../events/OnPlayerDamageEventHandler.java | 6 +- .../events/OnPlayerJoinEventHandler.java | 8 +- .../events/OnPlayerLeaveEventHandler.java | 6 +- .../events/OnPlayerTickEventHandler.java | 8 +- .../loginprotection/network/C2SKeyPress.java | 28 +++--- .../micle/loginprotection/setup/Config.java | 4 +- .../loginprotection/setup/Registration.java | 8 +- 13 files changed, 138 insertions(+), 138 deletions(-) delete mode 100755 src/main/java/com/micle/loginprotection/events/OnKeyPressEventHandler.java rename src/main/java/{com => dev}/micle/loginprotection/LoginProtection.java (82%) rename src/main/java/{com => dev}/micle/loginprotection/data/ProtectedPlayer.java (90%) rename src/main/java/{com => dev}/micle/loginprotection/data/ProtectedPlayers.java (92%) create mode 100755 src/main/java/dev/micle/loginprotection/events/OnKeyPressEventHandler.java rename src/main/java/{com => dev}/micle/loginprotection/events/OnLivingSetAttackTargetEventHandler.java (73%) rename src/main/java/{com => dev}/micle/loginprotection/events/OnPlayerDamageEventHandler.java (82%) rename src/main/java/{com => dev}/micle/loginprotection/events/OnPlayerJoinEventHandler.java (60%) rename src/main/java/{com => dev}/micle/loginprotection/events/OnPlayerLeaveEventHandler.java (82%) rename src/main/java/{com => dev}/micle/loginprotection/events/OnPlayerTickEventHandler.java (69%) rename src/main/java/{com => dev}/micle/loginprotection/network/C2SKeyPress.java (65%) rename src/main/java/{com => dev}/micle/loginprotection/setup/Config.java (98%) rename src/main/java/{com => dev}/micle/loginprotection/setup/Registration.java (84%) diff --git a/src/main/java/com/micle/loginprotection/events/OnKeyPressEventHandler.java b/src/main/java/com/micle/loginprotection/events/OnKeyPressEventHandler.java deleted file mode 100755 index cee48fd..0000000 --- a/src/main/java/com/micle/loginprotection/events/OnKeyPressEventHandler.java +++ /dev/null @@ -1,89 +0,0 @@ -package com.micle.loginprotection.events; - -import com.micle.loginprotection.LoginProtection; -import com.micle.loginprotection.network.C2SKeyPress; -import com.micle.loginprotection.setup.Config; -import net.minecraft.client.Minecraft; -import net.minecraft.client.multiplayer.ServerData; -import net.minecraft.server.integrated.IntegratedServer; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.client.event.InputEvent; -import net.minecraftforge.eventbus.api.SubscribeEvent; -import org.lwjgl.glfw.GLFW; - -public class OnKeyPressEventHandler { - @SubscribeEvent - @OnlyIn(Dist.CLIENT) - public void KeyPressEvent(InputEvent.KeyInputEvent event) { - Minecraft instance = Minecraft.getInstance(); - ServerData server_online = instance.getCurrentServer(); - IntegratedServer server_local = instance.getSingleplayerServer(); - if (server_online == null && server_local == null) { return; } - if (Minecraft.getInstance().screen != null) { return; } - if (checkKeyAllowed(instance, event.getKey())) { return; } - - try { - LoginProtection.INSTANCE.sendToServer(new C2SKeyPress()); - } catch (NullPointerException ignored) { } - } - - @SubscribeEvent - @OnlyIn(Dist.CLIENT) - public void MouseClickEvent(InputEvent.ClickInputEvent event) { - Minecraft instance = Minecraft.getInstance(); - ServerData server_online = instance.getCurrentServer(); - IntegratedServer server_local = instance.getSingleplayerServer(); - if (server_online == null && server_local == null) { return; } - if (Minecraft.getInstance().screen != null) { return; } - if (checkKeyAllowed(instance, event.getKeyBinding().getKey().getValue())) { return; } - - try { - LoginProtection.INSTANCE.sendToServer(new C2SKeyPress()); - } catch (NullPointerException ignored) { } - } - - @OnlyIn(Dist.CLIENT) - private static boolean checkKeyAllowed(Minecraft instance, int key) { - boolean isAllowed = false; - - if (key == GLFW.GLFW_KEY_ESCAPE) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.PAUSE.toString()); } - if (key == GLFW.GLFW_KEY_F3) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.DEBUG.toString()); } - if (key == instance.options.keyFullscreen.getKey().getValue()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.FULLSCREEN.toString()); } - if (key == instance.options.keyTogglePerspective.getKey().getValue()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.PERSPECTIVE.toString()); } - if (key == instance.options.keySmoothCamera.getKey().getValue()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.SMOOTH_CAMERA.toString()); } - if (key == instance.options.keyScreenshot.getKey().getValue()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.SCREENSHOT.toString()); } - if (key == instance.options.keySpectatorOutlines.getKey().getValue()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.SPECTATOR_OUTLINES.toString()); } - if (key == instance.options.keyAdvancements.getKey().getValue()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.ADVANCEMENTS.toString()); } - if (key == instance.options.keyPlayerList.getKey().getValue()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.PLAYER_LIST.toString()); } - if (key == instance.options.keyChat.getKey().getValue() || - key == instance.options.keyCommand.getKey().getValue() || - key == GLFW.GLFW_KEY_ENTER) { - isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.CHAT.toString()); - } - if (key == instance.options.keySocialInteractions.getKey().getValue()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.SOCIAL_INTERACTIONS.toString()); } - if (key == instance.options.keyLoadHotbarActivator.getKey().getValue()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.LOAD_HOTBAR_ACTIVATOR.toString()); } - if (key == instance.options.keySaveHotbarActivator.getKey().getValue()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.SAVE_HOTBAR_ACTIVATOR.toString()); } - if (key == instance.options.keySwapOffhand.getKey().getValue()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.SWAP_ITEM.toString()); } - if (key == instance.options.keyInventory.getKey().getValue()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.INVENTORY.toString()); } - for (int i = 0; i < instance.options.keyHotbarSlots.length; i++) { - if (key == instance.options.keyHotbarSlots[i].getKey().getValue()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.HOTBAR.toString()); } - } - if (key == instance.options.keyDrop.getKey().getValue()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.DROP_ITEM.toString()); } - if (key == instance.options.keyUse.getKey().getValue()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.USE_ITEM.toString()); } - if (key == instance.options.keyPickItem.getKey().getValue()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.PICK_BLOCK.toString()); } - if (key == instance.options.keyAttack.getKey().getValue()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.ATTACK.toString()); } - if (key == instance.options.keyUp.getKey().getValue() || - key == instance.options.keyRight.getKey().getValue() || - key == instance.options.keyDown.getKey().getValue() || - key == instance.options.keyLeft.getKey().getValue() || - key == instance.options.keySprint.getKey().getValue()) { - isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.MOVE.toString()); - } - if (key == instance.options.keyShift.getKey().getValue()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.SNEAK.toString()); } - if (key == instance.options.keyJump.getKey().getValue()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.JUMP.toString()); } - - return isAllowed; - } - -} diff --git a/src/main/java/com/micle/loginprotection/LoginProtection.java b/src/main/java/dev/micle/loginprotection/LoginProtection.java similarity index 82% rename from src/main/java/com/micle/loginprotection/LoginProtection.java rename to src/main/java/dev/micle/loginprotection/LoginProtection.java index 0b1d6de..ffde934 100755 --- a/src/main/java/com/micle/loginprotection/LoginProtection.java +++ b/src/main/java/dev/micle/loginprotection/LoginProtection.java @@ -1,8 +1,8 @@ -package com.micle.loginprotection; +package dev.micle.loginprotection; -import com.micle.loginprotection.data.ProtectedPlayers; -import com.micle.loginprotection.setup.Config; -import com.micle.loginprotection.setup.Registration; +import dev.micle.loginprotection.data.ProtectedPlayers; +import dev.micle.loginprotection.setup.Config; +import dev.micle.loginprotection.setup.Registration; import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.common.Mod; diff --git a/src/main/java/com/micle/loginprotection/data/ProtectedPlayer.java b/src/main/java/dev/micle/loginprotection/data/ProtectedPlayer.java similarity index 90% rename from src/main/java/com/micle/loginprotection/data/ProtectedPlayer.java rename to src/main/java/dev/micle/loginprotection/data/ProtectedPlayer.java index a9af11a..87b098a 100755 --- a/src/main/java/com/micle/loginprotection/data/ProtectedPlayer.java +++ b/src/main/java/dev/micle/loginprotection/data/ProtectedPlayer.java @@ -1,6 +1,6 @@ -package com.micle.loginprotection.data; +package dev.micle.loginprotection.data; -import com.micle.loginprotection.setup.Config; +import dev.micle.loginprotection.setup.Config; import java.util.UUID; diff --git a/src/main/java/com/micle/loginprotection/data/ProtectedPlayers.java b/src/main/java/dev/micle/loginprotection/data/ProtectedPlayers.java similarity index 92% rename from src/main/java/com/micle/loginprotection/data/ProtectedPlayers.java rename to src/main/java/dev/micle/loginprotection/data/ProtectedPlayers.java index 205ea9b..8ce8406 100755 --- a/src/main/java/com/micle/loginprotection/data/ProtectedPlayers.java +++ b/src/main/java/dev/micle/loginprotection/data/ProtectedPlayers.java @@ -1,6 +1,6 @@ -package com.micle.loginprotection.data; +package dev.micle.loginprotection.data; -import com.micle.loginprotection.setup.Config; +import dev.micle.loginprotection.setup.Config; import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.util.text.StringTextComponent; import net.minecraftforge.fml.server.ServerLifecycleHooks; @@ -38,7 +38,7 @@ public class ProtectedPlayers { if (protected_player == null) { return; } protected_players.remove(protected_player); - ServerPlayerEntity player = ServerLifecycleHooks.getCurrentServer().getPlayerList().getPlayer(player_uuid); + ServerPlayerEntity player = ServerLifecycleHooks.getCurrentServer().getPlayerList().getPlayerByUUID(player_uuid); if (player == null) { return; } if (!Config.Server.POST_GRACE_ENABLED.get()) { return; } diff --git a/src/main/java/dev/micle/loginprotection/events/OnKeyPressEventHandler.java b/src/main/java/dev/micle/loginprotection/events/OnKeyPressEventHandler.java new file mode 100755 index 0000000..59f86d1 --- /dev/null +++ b/src/main/java/dev/micle/loginprotection/events/OnKeyPressEventHandler.java @@ -0,0 +1,89 @@ +package dev.micle.loginprotection.events; + +import dev.micle.loginprotection.LoginProtection; +import dev.micle.loginprotection.network.C2SKeyPress; +import dev.micle.loginprotection.setup.Config; +import net.minecraft.client.Minecraft; +import net.minecraft.client.multiplayer.ServerData; +import net.minecraft.server.integrated.IntegratedServer; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraftforge.client.event.InputEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; +import org.lwjgl.glfw.GLFW; + +public class OnKeyPressEventHandler { + @SubscribeEvent + @OnlyIn(Dist.CLIENT) + public void KeyPressEvent(InputEvent.KeyInputEvent event) { + Minecraft instance = Minecraft.getInstance(); + ServerData server_online = instance.getCurrentServerData(); + IntegratedServer server_local = instance.getIntegratedServer(); + if (server_online == null && server_local == null) { return; } + if (Minecraft.getInstance().currentScreen != null) { return; } + if (checkKeyAllowed(instance, event.getKey())) { return; } + + try { + LoginProtection.INSTANCE.sendToServer(new C2SKeyPress()); + } catch (NullPointerException ignored) { } + } + + @SubscribeEvent + @OnlyIn(Dist.CLIENT) + public void MouseClickEvent(InputEvent.ClickInputEvent event) { + Minecraft instance = Minecraft.getInstance(); + ServerData server_online = instance.getCurrentServerData(); + IntegratedServer server_local = instance.getIntegratedServer(); + if (server_online == null && server_local == null) { return; } + if (Minecraft.getInstance().currentScreen != null) { return; } + if (checkKeyAllowed(instance, event.getKeyBinding().getKey().getKeyCode())) { return; } + + try { + LoginProtection.INSTANCE.sendToServer(new C2SKeyPress()); + } catch (NullPointerException ignored) { } + } + + @OnlyIn(Dist.CLIENT) + private static boolean checkKeyAllowed(Minecraft instance, int key) { + boolean isAllowed = false; + + if (key == GLFW.GLFW_KEY_ESCAPE) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.PAUSE.toString()); } + if (key == GLFW.GLFW_KEY_F3) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.DEBUG.toString()); } + if (key == instance.gameSettings.keyBindFullscreen.getKey().getKeyCode()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.FULLSCREEN.toString()); } + if (key == instance.gameSettings.keyBindTogglePerspective.getKey().getKeyCode()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.PERSPECTIVE.toString()); } + if (key == instance.gameSettings.keyBindSmoothCamera.getKey().getKeyCode()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.SMOOTH_CAMERA.toString()); } + if (key == instance.gameSettings.keyBindScreenshot.getKey().getKeyCode()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.SCREENSHOT.toString()); } + if (key == instance.gameSettings.keyBindSpectatorOutlines.getKey().getKeyCode()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.SPECTATOR_OUTLINES.toString()); } + if (key == instance.gameSettings.keyBindAdvancements.getKey().getKeyCode()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.ADVANCEMENTS.toString()); } + if (key == instance.gameSettings.keyBindPlayerList.getKey().getKeyCode()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.PLAYER_LIST.toString()); } + if (key == instance.gameSettings.keyBindChat.getKey().getKeyCode() || + key == instance.gameSettings.keyBindCommand.getKey().getKeyCode() || + key == GLFW.GLFW_KEY_ENTER) { + isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.CHAT.toString()); + } + if (key == instance.gameSettings.field_244602_au.getKey().getKeyCode()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.SOCIAL_INTERACTIONS.toString()); } + if (key == instance.gameSettings.keyBindLoadToolbar.getKey().getKeyCode()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.LOAD_HOTBAR_ACTIVATOR.toString()); } + if (key == instance.gameSettings.keyBindSaveToolbar.getKey().getKeyCode()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.SAVE_HOTBAR_ACTIVATOR.toString()); } + if (key == instance.gameSettings.keyBindSwapHands.getKey().getKeyCode()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.SWAP_ITEM.toString()); } + if (key == instance.gameSettings.keyBindInventory.getKey().getKeyCode()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.INVENTORY.toString()); } + for (int i = 0; i < instance.gameSettings.keyBindsHotbar.length; i++) { + if (key == instance.gameSettings.keyBindsHotbar[i].getKey().getKeyCode()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.HOTBAR.toString()); } + } + if (key == instance.gameSettings.keyBindDrop.getKey().getKeyCode()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.DROP_ITEM.toString()); } + if (key == instance.gameSettings.keyBindUseItem.getKey().getKeyCode()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.USE_ITEM.toString()); } + if (key == instance.gameSettings.keyBindPickBlock.getKey().getKeyCode()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.PICK_BLOCK.toString()); } + if (key == instance.gameSettings.keyBindAttack.getKey().getKeyCode()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.ATTACK.toString()); } + if (key == instance.gameSettings.keyBindForward.getKey().getKeyCode() || + key == instance.gameSettings.keyBindRight.getKey().getKeyCode() || + key == instance.gameSettings.keyBindBack.getKey().getKeyCode() || + key == instance.gameSettings.keyBindLeft.getKey().getKeyCode() || + key == instance.gameSettings.keyBindSprint.getKey().getKeyCode()) { + isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.MOVE.toString()); + } + if (key == instance.gameSettings.keyBindSneak.getKey().getKeyCode()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.SNEAK.toString()); } + if (key == instance.gameSettings.keyBindJump.getKey().getKeyCode()) { isAllowed = Config.Server.MAIN_KEY_ALLOW_LIST.get().contains(Config.Server.KEYS.JUMP.toString()); } + + return isAllowed; + } + +} diff --git a/src/main/java/com/micle/loginprotection/events/OnLivingSetAttackTargetEventHandler.java b/src/main/java/dev/micle/loginprotection/events/OnLivingSetAttackTargetEventHandler.java similarity index 73% rename from src/main/java/com/micle/loginprotection/events/OnLivingSetAttackTargetEventHandler.java rename to src/main/java/dev/micle/loginprotection/events/OnLivingSetAttackTargetEventHandler.java index cf0b85b..b111755 100644 --- a/src/main/java/com/micle/loginprotection/events/OnLivingSetAttackTargetEventHandler.java +++ b/src/main/java/dev/micle/loginprotection/events/OnLivingSetAttackTargetEventHandler.java @@ -1,8 +1,8 @@ -package com.micle.loginprotection.events; +package dev.micle.loginprotection.events; -import com.micle.loginprotection.LoginProtection; -import com.micle.loginprotection.data.ProtectedPlayer; -import com.micle.loginprotection.setup.Config; +import dev.micle.loginprotection.LoginProtection; +import dev.micle.loginprotection.data.ProtectedPlayer; +import dev.micle.loginprotection.setup.Config; import net.minecraft.entity.MobEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraftforge.event.entity.living.LivingSetAttackTargetEvent; @@ -14,10 +14,10 @@ public class OnLivingSetAttackTargetEventHandler { if (!(event.getTarget() instanceof PlayerEntity)) { return; } PlayerEntity target = (PlayerEntity) event.getTarget(); - ProtectedPlayer player = LoginProtection.protected_players.getPlayer(target.getUUID()); + ProtectedPlayer player = LoginProtection.protected_players.getPlayer(target.getUniqueID()); if (player == null) { return; } if (player.isLoading() && !Config.Server.MAIN_IGNORE_PLAYER_ENABLED.get()) { return; } if (!player.isLoading() && !Config.Server.POST_GRACE_IGNORE_PLAYER_ENABLED.get()) { return; } - ((MobEntity) event.getEntityLiving()).setTarget(null); + ((MobEntity) event.getEntityLiving()).setAttackTarget(null); } } diff --git a/src/main/java/com/micle/loginprotection/events/OnPlayerDamageEventHandler.java b/src/main/java/dev/micle/loginprotection/events/OnPlayerDamageEventHandler.java similarity index 82% rename from src/main/java/com/micle/loginprotection/events/OnPlayerDamageEventHandler.java rename to src/main/java/dev/micle/loginprotection/events/OnPlayerDamageEventHandler.java index cd1f3a7..eb3ddef 100755 --- a/src/main/java/com/micle/loginprotection/events/OnPlayerDamageEventHandler.java +++ b/src/main/java/dev/micle/loginprotection/events/OnPlayerDamageEventHandler.java @@ -1,6 +1,6 @@ -package com.micle.loginprotection.events; +package dev.micle.loginprotection.events; -import com.micle.loginprotection.LoginProtection; +import dev.micle.loginprotection.LoginProtection; import net.minecraft.entity.player.PlayerEntity; import net.minecraftforge.event.entity.living.LivingDamageEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; @@ -11,7 +11,7 @@ public class OnPlayerDamageEventHandler { if (!(event.getEntity() instanceof PlayerEntity)) { return; } PlayerEntity player = (PlayerEntity) event.getEntity(); - if (LoginProtection.protected_players.getPlayer(player.getUUID()) != null) { + if (LoginProtection.protected_players.getPlayer(player.getUniqueID()) != null) { event.setCanceled(true); } } diff --git a/src/main/java/com/micle/loginprotection/events/OnPlayerJoinEventHandler.java b/src/main/java/dev/micle/loginprotection/events/OnPlayerJoinEventHandler.java similarity index 60% rename from src/main/java/com/micle/loginprotection/events/OnPlayerJoinEventHandler.java rename to src/main/java/dev/micle/loginprotection/events/OnPlayerJoinEventHandler.java index fa343bc..7cc2938 100755 --- a/src/main/java/com/micle/loginprotection/events/OnPlayerJoinEventHandler.java +++ b/src/main/java/dev/micle/loginprotection/events/OnPlayerJoinEventHandler.java @@ -1,6 +1,6 @@ -package com.micle.loginprotection.events; +package dev.micle.loginprotection.events; -import com.micle.loginprotection.LoginProtection; +import dev.micle.loginprotection.LoginProtection; import net.minecraft.entity.player.PlayerEntity; import net.minecraftforge.event.entity.player.PlayerEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; @@ -11,7 +11,7 @@ public class OnPlayerJoinEventHandler { if (!(event.getEntity() instanceof PlayerEntity)) { return; } PlayerEntity player = (PlayerEntity) event.getEntity(); - LoginProtection.protected_players.addPlayer(player.getUUID()); - System.out.println(player.getUUID() + " (" + player.getDisplayName().getString() + ") is being protected!"); + LoginProtection.protected_players.addPlayer(player.getUniqueID()); + System.out.println(player.getUniqueID() + " (" + player.getDisplayName().getString() + ") is being protected!"); } } diff --git a/src/main/java/com/micle/loginprotection/events/OnPlayerLeaveEventHandler.java b/src/main/java/dev/micle/loginprotection/events/OnPlayerLeaveEventHandler.java similarity index 82% rename from src/main/java/com/micle/loginprotection/events/OnPlayerLeaveEventHandler.java rename to src/main/java/dev/micle/loginprotection/events/OnPlayerLeaveEventHandler.java index 15cda64..93f8aea 100755 --- a/src/main/java/com/micle/loginprotection/events/OnPlayerLeaveEventHandler.java +++ b/src/main/java/dev/micle/loginprotection/events/OnPlayerLeaveEventHandler.java @@ -1,6 +1,6 @@ -package com.micle.loginprotection.events; +package dev.micle.loginprotection.events; -import com.micle.loginprotection.LoginProtection; +import dev.micle.loginprotection.LoginProtection; import net.minecraft.entity.player.PlayerEntity; import net.minecraftforge.event.entity.player.PlayerEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; @@ -11,6 +11,6 @@ public class OnPlayerLeaveEventHandler { if (!(event.getEntity() instanceof PlayerEntity)) { return; } PlayerEntity player = event.getPlayer(); - LoginProtection.protected_players.removePlayer(player.getUUID()); + LoginProtection.protected_players.removePlayer(player.getUniqueID()); } } diff --git a/src/main/java/com/micle/loginprotection/events/OnPlayerTickEventHandler.java b/src/main/java/dev/micle/loginprotection/events/OnPlayerTickEventHandler.java similarity index 69% rename from src/main/java/com/micle/loginprotection/events/OnPlayerTickEventHandler.java rename to src/main/java/dev/micle/loginprotection/events/OnPlayerTickEventHandler.java index a8c7a86..bb8b44f 100755 --- a/src/main/java/com/micle/loginprotection/events/OnPlayerTickEventHandler.java +++ b/src/main/java/dev/micle/loginprotection/events/OnPlayerTickEventHandler.java @@ -1,14 +1,14 @@ -package com.micle.loginprotection.events; +package dev.micle.loginprotection.events; -import com.micle.loginprotection.LoginProtection; +import dev.micle.loginprotection.LoginProtection; import net.minecraftforge.event.TickEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; public class OnPlayerTickEventHandler { @SubscribeEvent public void PlayerTickEvent(TickEvent.PlayerTickEvent event) { - if (LoginProtection.protected_players.getPlayer(event.player.getUUID()) == null) { return; } + if (LoginProtection.protected_players.getPlayer(event.player.getUniqueID()) == null) { return; } - LoginProtection.protected_players.updateGracePeriod(event.player.getUUID()); + LoginProtection.protected_players.updateGracePeriod(event.player.getUniqueID()); } } diff --git a/src/main/java/com/micle/loginprotection/network/C2SKeyPress.java b/src/main/java/dev/micle/loginprotection/network/C2SKeyPress.java similarity index 65% rename from src/main/java/com/micle/loginprotection/network/C2SKeyPress.java rename to src/main/java/dev/micle/loginprotection/network/C2SKeyPress.java index 73df98d..fba3501 100755 --- a/src/main/java/com/micle/loginprotection/network/C2SKeyPress.java +++ b/src/main/java/dev/micle/loginprotection/network/C2SKeyPress.java @@ -1,7 +1,7 @@ -package com.micle.loginprotection.network; +package dev.micle.loginprotection.network; -import com.micle.loginprotection.LoginProtection; -import com.micle.loginprotection.setup.Config; +import dev.micle.loginprotection.LoginProtection; +import dev.micle.loginprotection.setup.Config; import net.minecraft.entity.player.ServerPlayerEntity; import net.minecraft.network.PacketBuffer; import net.minecraft.potion.EffectInstance; @@ -25,29 +25,29 @@ public class C2SKeyPress { context.enqueueWork(() -> { final ServerPlayerEntity sender = context.getSender(); if (sender == null) { return; } - if (LoginProtection.protected_players.getPlayer(sender.getUUID()) == null) { return; } - if (!LoginProtection.protected_players.getPlayer(sender.getUUID()).isLoading()) { return; } + if (LoginProtection.protected_players.getPlayer(sender.getUniqueID()) == null) { return; } + if (!LoginProtection.protected_players.getPlayer(sender.getUniqueID()).isLoading()) { return; } if (!Config.Server.POST_GRACE_ENABLED.get()) { - LoginProtection.protected_players.removePlayer(sender.getUUID()); - sender.sendMessage(new StringTextComponent("[LoginProtection] You are now seen as active."), sender.getUUID()); + LoginProtection.protected_players.removePlayer(sender.getUniqueID()); + sender.sendMessage(new StringTextComponent("[LoginProtection] You are now seen as active."), sender.getUniqueID()); } else { - LoginProtection.protected_players.getPlayer(sender.getUUID()).setLoading(false); - sender.sendMessage(new StringTextComponent("[LoginProtection] Grace period started!"), sender.getUUID()); + LoginProtection.protected_players.getPlayer(sender.getUniqueID()).setLoading(false); + sender.sendMessage(new StringTextComponent("[LoginProtection] Grace period started!"), sender.getUniqueID()); } if (sender.isInWater()) { if (Config.Server.POST_DROWN_ENABLED.get()) { - sender.setAirSupply(sender.getMaxAirSupply()); + sender.setAir(sender.getMaxAir()); } if (Config.Server.POST_WATER_ENABLED.get()) { - sender.addEffect(new EffectInstance(Effects.WATER_BREATHING, Config.Server.POST_WATER_DURATION.get()*20, 0)); + sender.addPotionEffect(new EffectInstance(Effects.WATER_BREATHING, Config.Server.POST_WATER_DURATION.get()*20, 0)); } } if (sender.isInLava() && Config.Server.POST_LAVA_ENABLED.get()) { - sender.addEffect(new EffectInstance(Effects.FIRE_RESISTANCE, Config.Server.POST_LAVA_DURATION.get()*20, 0)); + sender.addPotionEffect(new EffectInstance(Effects.FIRE_RESISTANCE, Config.Server.POST_LAVA_DURATION.get()*20, 0)); } - if (sender.isOnFire() && Config.Server.POST_FIRE_ENABLED.get()) { - sender.addEffect(new EffectInstance(Effects.FIRE_RESISTANCE, Config.Server.POST_FIRE_DURATION.get()*20, 0)); + if (sender.isBurning() && Config.Server.POST_FIRE_ENABLED.get()) { + sender.addPotionEffect(new EffectInstance(Effects.FIRE_RESISTANCE, Config.Server.POST_FIRE_DURATION.get()*20, 0)); } }); context.setPacketHandled(true); diff --git a/src/main/java/com/micle/loginprotection/setup/Config.java b/src/main/java/dev/micle/loginprotection/setup/Config.java similarity index 98% rename from src/main/java/com/micle/loginprotection/setup/Config.java rename to src/main/java/dev/micle/loginprotection/setup/Config.java index 29e0744..df27247 100644 --- a/src/main/java/com/micle/loginprotection/setup/Config.java +++ b/src/main/java/dev/micle/loginprotection/setup/Config.java @@ -1,7 +1,7 @@ -package com.micle.loginprotection.setup; +package dev.micle.loginprotection.setup; import com.google.common.collect.Lists; -import com.micle.loginprotection.LoginProtection; +import dev.micle.loginprotection.LoginProtection; import net.minecraftforge.common.ForgeConfigSpec; import net.minecraftforge.fml.ModLoadingContext; import net.minecraftforge.fml.common.Mod; diff --git a/src/main/java/com/micle/loginprotection/setup/Registration.java b/src/main/java/dev/micle/loginprotection/setup/Registration.java similarity index 84% rename from src/main/java/com/micle/loginprotection/setup/Registration.java rename to src/main/java/dev/micle/loginprotection/setup/Registration.java index cd6af9b..fc22ca3 100755 --- a/src/main/java/com/micle/loginprotection/setup/Registration.java +++ b/src/main/java/dev/micle/loginprotection/setup/Registration.java @@ -1,8 +1,8 @@ -package com.micle.loginprotection.setup; +package dev.micle.loginprotection.setup; -import com.micle.loginprotection.LoginProtection; -import com.micle.loginprotection.events.*; -import com.micle.loginprotection.network.C2SKeyPress; +import dev.micle.loginprotection.LoginProtection; +import dev.micle.loginprotection.events.*; +import dev.micle.loginprotection.network.C2SKeyPress; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.IEventBus; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;