Package org.geysermc.geyser.level
Class WorldManager
java.lang.Object
org.geysermc.geyser.level.WorldManager
- Direct Known Subclasses:
GeyserWorldManager
Class that manages or retrieves various information
from the world. Everything in this class should be
safe to return null or an empty value in the event
that chunk caching or anything of the sort is disabled
on the standalone version of Geyser.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract int
getBlockAt(GeyserSession session, int x, int y, int z)
Gets the Java block state at the specified locationint
getBlockAt(GeyserSession session, com.github.steveice10.mc.protocol.data.game.entity.metadata.Position position)
Gets the Java block state at the specified locationint
getBlockAt(GeyserSession session, com.nukkitx.math.vector.Vector3i vector)
Gets the Java block state at the specified locationabstract Boolean
getGameRuleBool(GeyserSession session, GameRule gameRule)
Gets a gamerule value as a booleanabstract int
getGameRuleInt(GeyserSession session, GameRule gameRule)
Get a gamerule value as an integerabstract com.nukkitx.nbt.NbtMap
getLecternDataAt(GeyserSession session, int x, int y, int z, boolean isChunkLoad)
Sigh.abstract boolean
Checks whether or not this world manager requires a separate chunk cache/has access to more block data than the chunk cache.abstract boolean
hasPermission(GeyserSession session, String permission)
Checks if the given session's player has a permissionabstract void
setDifficulty(GeyserSession session, com.github.steveice10.mc.protocol.data.game.setting.Difficulty difficulty)
Change the difficulty of the Java serverabstract void
setGameRule(GeyserSession session, String name, Object value)
Updates a gamerule value on the Java serverabstract void
setPlayerGameMode(GeyserSession session, com.github.steveice10.mc.protocol.data.game.entity.player.GameMode gameMode)
Change the game mode of the given sessionabstract boolean
-
Constructor Details
-
WorldManager
public WorldManager()
-
-
Method Details
-
getBlockAt
public int getBlockAt(GeyserSession session, com.github.steveice10.mc.protocol.data.game.entity.metadata.Position position)Gets the Java block state at the specified location- Parameters:
session
- the sessionposition
- the position- Returns:
- the block state at the specified location
-
getBlockAt
Gets the Java block state at the specified location- Parameters:
session
- the sessionvector
- the position- Returns:
- the block state at the specified location
-
getBlockAt
Gets the Java block state at the specified location- Parameters:
session
- the sessionx
- the x coordinate to get the block aty
- the y coordinate to get the block atz
- the z coordinate to get the block at- Returns:
- the block state at the specified location
-
hasOwnChunkCache
public abstract boolean hasOwnChunkCache()Checks whether or not this world manager requires a separate chunk cache/has access to more block data than the chunk cache.Some world managers (e.g. Spigot) can provide access to block data outside of the chunk cache, and even with chunk caching disabled. This method provides a means to check if this manager has this capability.
- Returns:
- whether or not this world manager has access to more block data than the chunk cache
-
getLecternDataAt
public abstract com.nukkitx.nbt.NbtMap getLecternDataAt(GeyserSession session, int x, int y, int z, boolean isChunkLoad)Sigh.
So, on Java Edition, the lectern is an inventory. Java opens it and gets the contents of the book there. On Bedrock, the lectern contents are part of the block entity tag. Therefore, Bedrock expects to have the contents of the lectern ready and present in the world. If the contents are not there, it takes at least two clicks for the lectern to update the tag and then present itself.
We solve this problem by querying all loaded lecterns, where possible, and sending their information in a block entity tag.- Parameters:
session
- the session of the playerx
- the x coordinate of the lecterny
- the y coordinate of the lecternz
- the z coordinate of the lecternisChunkLoad
- if this is called during a chunk load or not. Changes behavior in certain instances.- Returns:
- the Bedrock lectern block entity tag. This may not be the exact block entity tag - for example, Spigot's block handled must be done on the server thread, so we send the tag manually there.
-
shouldExpectLecternHandled
public abstract boolean shouldExpectLecternHandled()- Returns:
- whether we should expect lectern data to update, or if we have to fall back on a workaround.
-
setGameRule
Updates a gamerule value on the Java server- Parameters:
session
- The session of the user that requested the changename
- The gamerule to changevalue
- The new value for the gamerule
-
getGameRuleBool
Gets a gamerule value as a boolean- Parameters:
session
- The session of the user that requested the valuegameRule
- The gamerule to fetch the value of- Returns:
- The boolean representation of the value
-
getGameRuleInt
Get a gamerule value as an integer- Parameters:
session
- The session of the user that requested the valuegameRule
- The gamerule to fetch the value of- Returns:
- The integer representation of the value
-
setPlayerGameMode
public abstract void setPlayerGameMode(GeyserSession session, com.github.steveice10.mc.protocol.data.game.entity.player.GameMode gameMode)Change the game mode of the given session- Parameters:
session
- The session of the player to change the game mode ofgameMode
- The game mode to change the player to
-
setDifficulty
public abstract void setDifficulty(GeyserSession session, com.github.steveice10.mc.protocol.data.game.setting.Difficulty difficulty)Change the difficulty of the Java server- Parameters:
session
- The session of the user that requested the changedifficulty
- The difficulty to change to
-
hasPermission
Checks if the given session's player has a permission- Parameters:
session
- The session of the player to check the permission ofpermission
- The permission node to check- Returns:
- True if the player has the requested permission, false if not
-