From 103d634eb2a352c57005d9528fd8bec66ab25e86 Mon Sep 17 00:00:00 2001 From: samo_lego <34912839+samolego@users.noreply.github.com> Date: Mon, 29 Jun 2020 12:06:02 +0200 Subject: [PATCH] Fixing #6 --- build.gradle | 2 +- gradle.properties | 6 ++--- .../org/samo_lego/simpleauth/SimpleAuth.java | 22 ++++++++++++++----- .../simpleauth/storage/AuthConfig.java | 1 + .../simpleauth/storage/PlayerCache.java | 2 +- 5 files changed, 23 insertions(+), 10 deletions(-) diff --git a/build.gradle b/build.gradle index 881cab1..aac007d 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'fabric-loom' version '0.4-SNAPSHOT' + id 'fabric-loom' version '0.4.29' id 'maven-publish' } diff --git a/gradle.properties b/gradle.properties index e08bf10..098c668 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,12 +2,12 @@ org.gradle.jvmargs=-Xmx1G # Fabric properties -minecraft_version=1.16 -yarn_mappings=1.16+build.1 +minecraft_version=1.16.1 +yarn_mappings=1.16.1+build.17 loader_version=0.8.8+build.202 #Fabric api -fabric_version=0.13.1+build.370-1.16 +fabric_version=0.14.0+build.371-1.16 # Mod Properties mod_version = 1.4.4 diff --git a/src/main/java/org/samo_lego/simpleauth/SimpleAuth.java b/src/main/java/org/samo_lego/simpleauth/SimpleAuth.java index 63873d0..a3bb42f 100644 --- a/src/main/java/org/samo_lego/simpleauth/SimpleAuth.java +++ b/src/main/java/org/samo_lego/simpleauth/SimpleAuth.java @@ -238,13 +238,25 @@ public class SimpleAuth implements DedicatedServerModInitializer { } PlayerCache cache = deauthenticatedUsers.get(convertUuid(player)); // Puts player to last cached position - player.teleport( - server.getWorld(RegistryKey.of(Registry.DIMENSION, new Identifier(cache.lastDim))), + try { + player.teleport( + server.getWorld(RegistryKey.of(Registry.DIMENSION, new Identifier(cache.lastDim))), + cache.lastX, + cache.lastY, + cache.lastZ, + 0, + 0 + ); + } catch (Error e) { + player.sendMessage(new LiteralText(config.lang.corruptedPosition), false); + LOGGER.error("[SimpleAuth] Couldn't teleport player " + player.getName().asString()); + LOGGER.error( + String.format("[SimpleAuth] Last recorded position is X: %s, Y: %s, Z: %s in dimension %s", cache.lastX, cache.lastY, cache.lastZ, - 0, - 0 - ); + cache.lastDim + )); + } } } \ No newline at end of file diff --git a/src/main/java/org/samo_lego/simpleauth/storage/AuthConfig.java b/src/main/java/org/samo_lego/simpleauth/storage/AuthConfig.java index 4cdbfc2..d8caf5e 100644 --- a/src/main/java/org/samo_lego/simpleauth/storage/AuthConfig.java +++ b/src/main/java/org/samo_lego/simpleauth/storage/AuthConfig.java @@ -93,6 +93,7 @@ public class AuthConfig { public String disallowedUsername = "§6Invalid username characters! Allowed character regex: %s"; public String playerAlreadyOnline = "§cPlayer %s is already online!"; public String worldSpawnSet = "§aSpawn for logging in was set successfully."; + public String corruptedPosition = "§cYour position data is probably corrupted. Please contact admin."; } public static class ExperimentalConfig { // Prevents player being kicked because another player with the same name has joined the server 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 a3d8360..495942c 100644 --- a/src/main/java/org/samo_lego/simpleauth/storage/PlayerCache.java +++ b/src/main/java/org/samo_lego/simpleauth/storage/PlayerCache.java @@ -38,7 +38,7 @@ public class PlayerCache { this.lastAir = player.getAir(); // Setting position cache - this.lastDim = String.valueOf(player.getEntityWorld().getDimension()); + this.lastDim = String.valueOf(player.getEntityWorld().getRegistryKey().getValue()); this.lastX = player.getX(); this.lastY = player.getY(); this.lastZ = player.getZ();