Skip to content

Commit

Permalink
feat: implement pollGameRules()
Browse files Browse the repository at this point in the history
  • Loading branch information
smartcmd committed Oct 16, 2024
1 parent 61bbc73 commit 3209eb0
Showing 1 changed file with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@
import org.allaymc.api.server.Server;
import org.allaymc.api.utils.Identifier;
import org.allaymc.api.world.DimensionInfo;
import org.allaymc.api.world.World;
import org.allaymc.api.world.chunk.Chunk;

import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Objects;

/**
* @author IWareQ
Expand Down Expand Up @@ -54,8 +58,19 @@ public ChunksResult<AllayChunkInfo> pollChunks() {
}

@Override
public GameRulesResult pollGameRules() {
// TODO
public GameRulesResult pollGameRules() {GameRulesResult data = new GameRulesResult();
for (World world : Server.getInstance().getWorldPool().getWorlds().values()) {
for (var gameRuleEntry : world.getWorldData().getGameRules().getGameRules().entrySet()) {
Object value = gameRuleEntry.getValue();
data.put(gameRuleEntry.getKey().getName(), world.getWorldData().getName(), Objects.toString(value));
}
}

return data;
}

@Override
public Collection<DataPackInfo> pollDataPacks() {
return null;
}

Expand Down Expand Up @@ -83,7 +98,7 @@ public CountMap<Identifier> getEntityCounts() {

@Override
public String entityTypeName(Identifier identifier) {
return identifier.path();
return identifier.toString();
}
}
}

0 comments on commit 3209eb0

Please sign in to comment.