improved communication system
This commit is contained in:
@@ -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) -> {
|
||||
|
@@ -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"));
|
||||
|
Reference in New Issue
Block a user