improved communication system

This commit is contained in:
2023-05-12 14:24:28 +02:00
parent d066915ec7
commit 0c7e6d8ee1
22 changed files with 139 additions and 12 deletions

View File

@@ -43,7 +43,7 @@ public class PolarcraftMod implements ModInitializer {
ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> {
ServerPlayerEntity player = (ServerPlayerEntity) handler.player;
verifyFunction.onPlayerJoin(player);
verifyFunction.onPlayerJoin(player, server);
});
ServerPlayConnectionEvents.DISCONNECT.register((handler, server) -> {

View File

@@ -14,11 +14,12 @@ import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.text.Text;
public class verifyFunction {
public static void onPlayerJoin(ServerPlayerEntity player) {
public static void onPlayerJoin(ServerPlayerEntity player, MinecraftServer server) {
UUID uuid = player.getUuid();
try {
@@ -55,7 +56,9 @@ public class verifyFunction {
player.networkHandler.disconnect(Text.literal("Whitelist yourself by using this code: " + code));
} else {
messageFunctions.sendGameMessage(player.getUuid(), player.getDisplayName().getString() + " joined the game");
server.getCommandManager().executeWithPrefix(server.getCommandSource(), "/lp user " + player.getUuid() + " meta set display " + "\"" + jsonResponse.get("username").getAsString() + "\"");
messageFunctions.sendGameMessage(player.getUuid(), jsonResponse.get("usernameWithoutStyle").getAsString() + " joined the game");
}
} catch (IOException e) {
player.networkHandler.disconnect(Text.literal("There was an error while verifing your account"));