From 00bfe748cc11880d3f8bf187a6bdb81d81b42e7d Mon Sep 17 00:00:00 2001 From: "Ansgar [Hiajen]" Date: Sun, 20 Jun 2021 19:04:05 +0200 Subject: [PATCH] implement reload --- src/main/java/net/saltymc/eaa/EaaMod.java | 1 + .../eaa/commands/CheckPlayerCommand.java | 1 + .../saltymc/eaa/commands/ReloadCommand.java | 32 +++++++++++++++++++ 3 files changed, 34 insertions(+) create mode 100644 src/main/java/net/saltymc/eaa/commands/ReloadCommand.java diff --git a/src/main/java/net/saltymc/eaa/EaaMod.java b/src/main/java/net/saltymc/eaa/EaaMod.java index ac67067..2c50258 100644 --- a/src/main/java/net/saltymc/eaa/EaaMod.java +++ b/src/main/java/net/saltymc/eaa/EaaMod.java @@ -26,6 +26,7 @@ public final class EaaMod implements ClientModInitializer { new TagCommand(); new CheckPlayerCommand(); new CheckLobbyCommand(); + new ReloadCommand(); } } diff --git a/src/main/java/net/saltymc/eaa/commands/CheckPlayerCommand.java b/src/main/java/net/saltymc/eaa/commands/CheckPlayerCommand.java index 7fdc9c0..21040bd 100644 --- a/src/main/java/net/saltymc/eaa/commands/CheckPlayerCommand.java +++ b/src/main/java/net/saltymc/eaa/commands/CheckPlayerCommand.java @@ -33,6 +33,7 @@ public class CheckPlayerCommand extends EaaModCommand{ try { String playerUUID = MinecraftClient.getInstance().getNetworkHandler().getPlayerListEntry(player).getProfile().getId().toString(); + TagCommand.loadPlayer(playerUUID, true); List names = PlayerInfo.playerUUIDToNames(playerUUID); for (int i = 1; i <= names.size(); i++) diff --git a/src/main/java/net/saltymc/eaa/commands/ReloadCommand.java b/src/main/java/net/saltymc/eaa/commands/ReloadCommand.java new file mode 100644 index 0000000..675dbf0 --- /dev/null +++ b/src/main/java/net/saltymc/eaa/commands/ReloadCommand.java @@ -0,0 +1,32 @@ +package net.saltymc.eaa.commands; + +import com.mojang.brigadier.builder.LiteralArgumentBuilder; +import com.mojang.brigadier.context.CommandContext; +import net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource; +import net.minecraft.text.Text; + + +import static net.fabricmc.fabric.api.client.command.v1.ClientCommandManager.literal; + +public class ReloadCommand extends EaaModCommand{ + + @Override + public int run(CommandContext context) { + FabricClientCommandSource source = context.getSource(); + + try { + TagCommand.getHashMap().clear(); + + source.sendFeedback(Text.of("Reloaded!")); + } catch (Exception e) { + source.sendFeedback(Text.of(e.toString())); + } + + return 1; + } + + @Override + public LiteralArgumentBuilder getCommandSpecification() { + return literal("/reload").executes(this); + } +} \ No newline at end of file