Added back the tablist dimension indicator

This commit is contained in:
2025-03-25 21:17:12 +01:00
parent 7d4dca66f0
commit 83cc3a38e9
11 changed files with 73 additions and 155 deletions

View File

@ -8,7 +8,7 @@ import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.text.Text;
import net.minecraft.world.GameMode;
import wtf.hak.survivalfabric.utils.DimensionTeams;
import wtf.hak.survivalfabric.utils.Utils;
import java.util.HashMap;
import java.util.Map;
@ -20,23 +20,23 @@ public class SpectatorCommand {
public static void register(CommandDispatcher<ServerCommandSource> dispatcher, String... aliases) {
for (String str : aliases)
dispatcher.register(CommandManager.literal(str) // Ensure correct method name
dispatcher.register(CommandManager.literal(str)
.executes(SpectatorCommand::execute));
}
private static int execute(CommandContext<ServerCommandSource> context) {
ServerCommandSource source = context.getSource();
if (source.getEntity() == null) { // Ensure correct method name
if (source.getEntity() == null) {
source.sendMessage(Text.literal("Console cannot go into spectator mode!"));
return 0;
}
ServerPlayerEntity player = (ServerPlayerEntity) source.getEntity(); // Ensure correct method name
ServerPlayerEntity player = (ServerPlayerEntity) source.getEntity();
if (spectating.containsKey(player)) {
LocationData data = spectating.get(player);
player.teleport(data.world, data.x, data.y, data.z, Set.of(), data.yaw, data.pitch, false);
player.changeGameMode(GameMode.SURVIVAL);
spectating.remove(player);
//DimensionTeams.assignCorrectTeam(player, data.world.getRegistryKey().getValue().toTranslationKey());
Utils.updateListNames(player);
} else {
spectating.put(player, new LocationData(player
@ -47,7 +47,7 @@ public class SpectatorCommand {
.getPitch(), player
.getServerWorld()));
player.changeGameMode(GameMode.SPECTATOR);
//DimensionTeams.assignCorrectTeam(player, "");
Utils.updateListNames(player);
}
return 1;
}