From b02edc92a1863ee9ee370ad7f48e7bbb0c629a14 Mon Sep 17 00:00:00 2001 From: micle Date: Fri, 1 Oct 2021 15:45:47 +0100 Subject: [PATCH] Updated to version 2.1.1. Fixed issue where the mod didn't work in single-player and LAN. --- build.gradle | 2 +- .../events/OnKeyPressEventHandler.java | 11 +++++++---- .../events/OnPlayerJoinEventHandler.java | 3 --- .../events/OnPlayerLeaveEventHandler.java | 3 --- src/main/resources/META-INF/mods.toml | 2 +- 5 files changed, 9 insertions(+), 12 deletions(-) diff --git a/build.gradle b/build.gradle index fec8c31..da2fd76 100644 --- a/build.gradle +++ b/build.gradle @@ -13,7 +13,7 @@ apply plugin: 'net.minecraftforge.gradle' apply plugin: 'eclipse' apply plugin: 'maven-publish' -version = '1.17.1-2.1.0' +version = '1.17.1-2.1.1' group = 'com.micle.loginprotection' // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = 'LoginProtection-Forge' diff --git a/src/main/java/com/micle/loginprotection/events/OnKeyPressEventHandler.java b/src/main/java/com/micle/loginprotection/events/OnKeyPressEventHandler.java index 6104af7..ec8c09f 100755 --- a/src/main/java/com/micle/loginprotection/events/OnKeyPressEventHandler.java +++ b/src/main/java/com/micle/loginprotection/events/OnKeyPressEventHandler.java @@ -5,6 +5,7 @@ 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.client.server.IntegratedServer; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.client.event.InputEvent; @@ -16,8 +17,9 @@ public class OnKeyPressEventHandler { @OnlyIn(Dist.CLIENT) public void KeyPressEvent(InputEvent.KeyInputEvent event) { Minecraft instance = Minecraft.getInstance(); - ServerData server = instance.getCurrentServer(); - if (server == null) { return; } + 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; } @@ -30,8 +32,9 @@ public class OnKeyPressEventHandler { @OnlyIn(Dist.CLIENT) public void MouseClickEvent(InputEvent.ClickInputEvent event) { Minecraft instance = Minecraft.getInstance(); - ServerData server = instance.getCurrentServer(); - if (server == null) { return; } + 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; } diff --git a/src/main/java/com/micle/loginprotection/events/OnPlayerJoinEventHandler.java b/src/main/java/com/micle/loginprotection/events/OnPlayerJoinEventHandler.java index b5a0794..79e5ecf 100755 --- a/src/main/java/com/micle/loginprotection/events/OnPlayerJoinEventHandler.java +++ b/src/main/java/com/micle/loginprotection/events/OnPlayerJoinEventHandler.java @@ -2,14 +2,11 @@ package com.micle.loginprotection.events; import com.micle.loginprotection.LoginProtection; import net.minecraft.world.entity.player.Player; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.event.entity.player.PlayerEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; public class OnPlayerJoinEventHandler { @SubscribeEvent - @OnlyIn(Dist.DEDICATED_SERVER) public void EntityJoinWorldEvent(PlayerEvent.PlayerLoggedInEvent event) { if (!(event.getEntity() instanceof Player)) { return; } Player player = (Player) event.getEntity(); diff --git a/src/main/java/com/micle/loginprotection/events/OnPlayerLeaveEventHandler.java b/src/main/java/com/micle/loginprotection/events/OnPlayerLeaveEventHandler.java index b4e2286..cfcfa9e 100755 --- a/src/main/java/com/micle/loginprotection/events/OnPlayerLeaveEventHandler.java +++ b/src/main/java/com/micle/loginprotection/events/OnPlayerLeaveEventHandler.java @@ -2,14 +2,11 @@ package com.micle.loginprotection.events; import com.micle.loginprotection.LoginProtection; import net.minecraft.world.entity.player.Player; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.event.entity.player.PlayerEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; public class OnPlayerLeaveEventHandler { @SubscribeEvent - @OnlyIn(Dist.DEDICATED_SERVER) public void PlayerLeaveEvent(PlayerEvent.PlayerLoggedOutEvent event) { if (!(event.getEntity() instanceof Player)) { return; } Player player = event.getPlayer(); diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index eccadf9..f5066d0 100755 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -19,7 +19,7 @@ modId="loginprotection" #mandatory # The version number of the mod - there's a few well known ${} variables useable here or just hardcode it # ${file.jarVersion} will substitute the value of the Implementation-Version as read from the mod's JAR file metadata # see the associated build.gradle script for how to populate this completely automatically during a build -version="2.1.0" #mandatory +version="2.1.1" #mandatory # A display name for the mod displayName="Micle's Login Protection" #mandatory # A URL to query for updates for this mod. See the JSON update specification https://mcforge.readthedocs.io/en/latest/gettingstarted/autoupdate/