From af701ae170c6585c1a764590814c1c8b197aad7b Mon Sep 17 00:00:00 2001 From: samo_lego <34912839+samolego@users.noreply.github.com> Date: Sun, 26 Jul 2020 11:04:47 +0200 Subject: [PATCH 1/4] Update issue templates --- .github/ISSUE_TEMPLATE/bug_report.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 8d6eee8..51616a7 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -1,12 +1,16 @@ --- name: Bug report about: Create a report to help us improve -title: "[BUG]" -labels: '' -assignees: '' +title: "[BUG] [Fabric/Forge]" +labels: bug +assignees: samolego --- +**Mod Loader** +- [x] Fabric +- [ ] Forge + **Describe the bug** A clear and concise description of what the bug is. From fa1557a577d623f0c0bc397eb80145899cd98078 Mon Sep 17 00:00:00 2001 From: samo_lego <34912839+samolego@users.noreply.github.com> Date: Mon, 27 Jul 2020 09:28:34 +0200 Subject: [PATCH 2/4] Minor change --- gradle.properties | 2 +- src/main/java/org/samo_lego/simpleauth/SimpleAuth.java | 5 +++-- .../org/samo_lego/simpleauth/event/AuthEventHandler.java | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/gradle.properties b/gradle.properties index 11e0896..f21adcf 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,7 +7,7 @@ yarn_mappings=1.16.1+build.21 loader_version=0.9.0+build.204 #Fabric api -fabric_version=0.14.1+build.372-1.16 +fabric_version=0.16.0+build.384-1.16.1 # Mod Properties mod_version = 1.4.7 diff --git a/src/main/java/org/samo_lego/simpleauth/SimpleAuth.java b/src/main/java/org/samo_lego/simpleauth/SimpleAuth.java index 66dc03e..a504c47 100644 --- a/src/main/java/org/samo_lego/simpleauth/SimpleAuth.java +++ b/src/main/java/org/samo_lego/simpleauth/SimpleAuth.java @@ -164,12 +164,13 @@ public class SimpleAuth implements DedicatedServerModInitializer { // Authenticates player and sends the message public static void authenticatePlayer(ServerPlayerEntity player, Text msg) { + PlayerCache playerCache = deauthenticatedUsers.get(convertUuid(player)); // Teleporting player back if(config.main.spawnOnJoin) teleportPlayer(player, false); // Updating blocks if needed (if portal rescue action happened) - if(deauthenticatedUsers.get(convertUuid(player)).wasInPortal) { + if(playerCache.wasInPortal) { World world = player.getEntityWorld(); BlockPos pos = player.getBlockPos(); @@ -181,7 +182,7 @@ public class SimpleAuth implements DedicatedServerModInitializer { // Setting last air to player if(player.isSubmergedInWater()) - player.setAir(deauthenticatedUsers.get(convertUuid(player)).lastAir); + player.setAir(playerCache.lastAir); deauthenticatedUsers.remove(convertUuid(player)); diff --git a/src/main/java/org/samo_lego/simpleauth/event/AuthEventHandler.java b/src/main/java/org/samo_lego/simpleauth/event/AuthEventHandler.java index 3752119..5d65858 100644 --- a/src/main/java/org/samo_lego/simpleauth/event/AuthEventHandler.java +++ b/src/main/java/org/samo_lego/simpleauth/event/AuthEventHandler.java @@ -76,7 +76,7 @@ public class AuthEventHandler { playerCache.validUntil >= System.currentTimeMillis() && player.getIp().equals(playerCache.lastIp) ) { - deauthenticatedUsers.remove(uuid); // Makes player authenticated + authenticatePlayer(player, null); // Makes player authenticated return; } // Invalidating session From 36c6bcf9b01c5e9c5912ca0430a9f2a899206574 Mon Sep 17 00:00:00 2001 From: samo_lego <34912839+samolego@users.noreply.github.com> Date: Mon, 27 Jul 2020 10:09:27 +0200 Subject: [PATCH 3/4] Update bug_report.md --- .github/ISSUE_TEMPLATE/bug_report.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 51616a7..61845fe 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -11,6 +11,10 @@ assignees: samolego - [x] Fabric - [ ] Forge +**Versions** +* SimpleAuth X.Y.Z +* Fabric API X.Y.Z / Forge X.Y.Z + **Describe the bug** A clear and concise description of what the bug is. From cd704bfbf366a3b2e7c9f9e351e416264185f76e Mon Sep 17 00:00:00 2001 From: samo_lego <34912839+samolego@users.noreply.github.com> Date: Tue, 28 Jul 2020 10:14:19 +0200 Subject: [PATCH 4/4] Fixing #13 --- build.gradle | 8 +++-- gradle.properties | 4 +-- .../org/samo_lego/simpleauth/SimpleAuth.java | 32 ++++++++++++------- .../simpleauth/event/AuthEventHandler.java | 6 +++- .../simpleauth/storage/PlayerCache.java | 3 ++ 5 files changed, 35 insertions(+), 18 deletions(-) diff --git a/build.gradle b/build.gradle index aac007d..11f089b 100644 --- a/build.gradle +++ b/build.gradle @@ -6,9 +6,11 @@ plugins { repositories { // Carpet mod maven { - //url 'https://masa.dy.fi/maven' url 'https://jitpack.io' } + maven { + url 'https://masa.dy.fi/maven' + } } sourceCompatibility = JavaVersion.VERSION_1_8 @@ -47,9 +49,9 @@ dependencies { // carpetMod // from masa's maven //modImplementation "carpet:fabric-carpet:${project.minecraft_version}-${project.carpet_core_version}" - + modImplementation "carpet:fabric-carpet:1.16-${project.carpet_core_version}" // jitpack for quicker updating - modImplementation "com.github.gnembon:fabric-carpet:${project.carpet_branch}-SNAPSHOT" + //modImplementation "com.github.gnembon:fabric-carpet:${project.carpet_branch}-SNAPSHOT" } processResources { diff --git a/gradle.properties b/gradle.properties index f21adcf..a61c7de 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,10 +10,10 @@ loader_version=0.9.0+build.204 fabric_version=0.16.0+build.384-1.16.1 # Mod Properties -mod_version = 1.4.7 +mod_version = 1.4.8 maven_group = org.samo_lego archives_base_name = simpleauth # Carpet for debugging -#carpet_core_version = 1.3.23+v200513 +carpet_core_version = 1.4.0+v200623 carpet_branch = 1.16 diff --git a/src/main/java/org/samo_lego/simpleauth/SimpleAuth.java b/src/main/java/org/samo_lego/simpleauth/SimpleAuth.java index a504c47..b6a60e2 100644 --- a/src/main/java/org/samo_lego/simpleauth/SimpleAuth.java +++ b/src/main/java/org/samo_lego/simpleauth/SimpleAuth.java @@ -49,6 +49,8 @@ public class SimpleAuth implements DedicatedServerModInitializer { public static final ExecutorService THREADPOOL = Executors.newCachedThreadPool(); + private static final Timer TIMER = new Timer(); + // HashMap of players that are not authenticated // Rather than storing all the authenticated players, we just store ones that are not authenticated // It stores some data as well, e.g. login tries and user password @@ -184,6 +186,10 @@ public class SimpleAuth implements DedicatedServerModInitializer { if(player.isSubmergedInWater()) player.setAir(playerCache.lastAir); + // In case player is in lava during authentication proccess + if(!playerCache.wasOnFire) + player.setFireTicks(0); + deauthenticatedUsers.remove(convertUuid(player)); // Player no longer needs to be invisible and invulnerable @@ -197,9 +203,9 @@ public class SimpleAuth implements DedicatedServerModInitializer { if(DB.isClosed()) return; - // Marking player as not authenticated, (re)setting login tries to zero + // Marking player as not authenticated String uuid = convertUuid(player); - SimpleAuth.deauthenticatedUsers.put(uuid, new PlayerCache(uuid, player)); + deauthenticatedUsers.put(uuid, new PlayerCache(uuid, player)); // Teleporting player to spawn to hide its position if(config.main.spawnOnJoin) @@ -211,15 +217,17 @@ public class SimpleAuth implements DedicatedServerModInitializer { // Setting the player to be invisible to mobs and also invulnerable player.setInvulnerable(SimpleAuth.config.experimental.playerInvulnerable); player.setInvisible(SimpleAuth.config.experimental.playerInvisible); - Timer timer = new Timer(); - timer.schedule(new TimerTask() { - @Override - public void run() { - // Kicking player if not authenticated - if(!SimpleAuth.isAuthenticated(player) && player.networkHandler.getConnection().isOpen()) - player.networkHandler.disconnect(new LiteralText(SimpleAuth.config.lang.timeExpired)); - } - }, SimpleAuth.config.main.delay * 1000); + + // Timer should start only if player has joined, not left the server (in case os session) + if(player.networkHandler.getConnection().isOpen()) + TIMER.schedule(new TimerTask() { + @Override + public void run() { + // Kicking player if not authenticated + if(!isAuthenticated(player) && player.networkHandler.getConnection().isOpen()) + player.networkHandler.disconnect(new LiteralText(SimpleAuth.config.lang.timeExpired)); + } + }, SimpleAuth.config.main.delay * 1000); } // Checking is player is a fake (carpetmod) player @@ -233,7 +241,7 @@ public class SimpleAuth implements DedicatedServerModInitializer { MinecraftServer server = player.getServer(); if(server == null || config.worldSpawn.dimension == null) return; - // registry for dimensions + if (toSpawn) { // Teleports player to spawn player.teleport( diff --git a/src/main/java/org/samo_lego/simpleauth/event/AuthEventHandler.java b/src/main/java/org/samo_lego/simpleauth/event/AuthEventHandler.java index 5d65858..f2a7ef8 100644 --- a/src/main/java/org/samo_lego/simpleauth/event/AuthEventHandler.java +++ b/src/main/java/org/samo_lego/simpleauth/event/AuthEventHandler.java @@ -12,6 +12,7 @@ import net.minecraft.text.LiteralText; import net.minecraft.util.ActionResult; import net.minecraft.util.TypedActionResult; import net.minecraft.util.math.BlockPos; +import org.samo_lego.simpleauth.SimpleAuth; import org.samo_lego.simpleauth.mixin.BlockUpdateS2CPacketAccessor; import org.samo_lego.simpleauth.storage.PlayerCache; @@ -79,6 +80,10 @@ public class AuthEventHandler { authenticatePlayer(player, null); // Makes player authenticated return; } + // Ugly fix for #13 + player.setInvulnerable(SimpleAuth.config.experimental.playerInvulnerable); + player.setInvisible(SimpleAuth.config.experimental.playerInvisible); + // Invalidating session playerCache.wasAuthenticated = false; player.sendMessage(notAuthenticated(player), false); @@ -106,7 +111,6 @@ public class AuthEventHandler { ((BlockUpdateS2CPacketAccessor) headPacket).setState(Blocks.AIR.getDefaultState()); ((BlockUpdateS2CPacketAccessor) headPacket).setBlockPos(pos.up()); player.networkHandler.sendPacket(headPacket); - System.out.println(headPacket); // Teleporting player to the middle of the block player.teleport(pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5); diff --git a/src/main/java/org/samo_lego/simpleauth/storage/PlayerCache.java b/src/main/java/org/samo_lego/simpleauth/storage/PlayerCache.java index 793ad99..4c68820 100644 --- a/src/main/java/org/samo_lego/simpleauth/storage/PlayerCache.java +++ b/src/main/java/org/samo_lego/simpleauth/storage/PlayerCache.java @@ -9,6 +9,7 @@ import static org.samo_lego.simpleauth.SimpleAuth.config; public class PlayerCache { public boolean isRegistered; + // If player from another location (different IP) joins, session is invalidated using this boolean public boolean wasAuthenticated; public String password; public int loginTries; @@ -16,6 +17,7 @@ public class PlayerCache { public long validUntil; public int lastAir = 300; + public boolean wasOnFire = false; public String lastDim; public double lastX; @@ -34,6 +36,7 @@ public class PlayerCache { this.lastIp = player.getIp(); this.lastAir = player.getAir(); + this.wasOnFire = player.isOnFire(); // Setting position cache this.lastDim = String.valueOf(player.getEntityWorld().getRegistryKey().getValue());