Skip to content

Commit

Permalink
feat(game.world): methods for getting player-level map
Browse files Browse the repository at this point in the history
  • Loading branch information
WakelessSloth56 committed Oct 29, 2022
1 parent 05b21fa commit d725ed5
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/main/java/org/auioc/mcmod/arnicalib/game/world/LevelUtils.java
@@ -1,7 +1,11 @@
package org.auioc.mcmod.arnicalib.game.world;

import java.util.Map;
import java.util.UUID;
import java.util.function.Function;
import java.util.stream.Collectors;
import org.auioc.mcmod.arnicalib.game.chat.TextUtils;
import org.auioc.mcmod.arnicalib.game.server.ServerUtils;
import net.minecraft.Util;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Registry;
Expand Down Expand Up @@ -73,4 +77,15 @@ public static Component getBiomeName(Level level, BlockPos pos) {
return (b.isPresent()) ? TextUtils.translatable(Util.makeDescriptionId("biome", b.get().location())) : TextUtils.empty();
}


public static Map<ServerPlayer, ServerLevel> getPlayerLevelMap() {
return ServerUtils.getServer().getPlayerList().getPlayers()
.stream().collect(Collectors.toMap(Function.identity(), ServerPlayer::getLevel));
}

public static Map<UUID, ResourceLocation> getPlayerDimensionMap() {
return ServerUtils.getServer().getPlayerList().getPlayers()
.stream().collect(Collectors.toMap(ServerPlayer::getUUID, (p) -> p.getLevel().dimension().location()));
}

}

0 comments on commit d725ed5

Please sign in to comment.