Class GeyserWorldManager

java.lang.Object
org.geysermc.geyser.level.WorldManager
org.geysermc.geyser.level.GeyserWorldManager
Direct Known Subclasses:
GeyserSpigotWorldManager

public class GeyserWorldManager extends WorldManager
  • Constructor Details

    • GeyserWorldManager

      public GeyserWorldManager()
  • Method Details

    • getBlockAt

      public int getBlockAt(GeyserSession session, int x, int y, int z)
      Description copied from class: WorldManager
      Gets the Java block state at the specified location
      Specified by:
      getBlockAt in class WorldManager
      Parameters:
      session - the session
      x - the x coordinate to get the block at
      y - the y coordinate to get the block at
      z - the z coordinate to get the block at
      Returns:
      the block state at the specified location
    • hasOwnChunkCache

      public boolean hasOwnChunkCache()
      Description copied from class: WorldManager
      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.

      Specified by:
      hasOwnChunkCache in class WorldManager
      Returns:
      whether or not this world manager has access to more block data than the chunk cache
    • getLecternDataAt

      public com.nukkitx.nbt.NbtMap getLecternDataAt(GeyserSession session, int x, int y, int z, boolean isChunkLoad)
      Description copied from class: WorldManager
      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.
      Specified by:
      getLecternDataAt in class WorldManager
      Parameters:
      session - the session of the player
      x - the x coordinate of the lectern
      y - the y coordinate of the lectern
      z - the z coordinate of the lectern
      isChunkLoad - 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 boolean shouldExpectLecternHandled()
      Specified by:
      shouldExpectLecternHandled in class WorldManager
      Returns:
      whether we should expect lectern data to update, or if we have to fall back on a workaround.
    • setGameRule

      public void setGameRule(GeyserSession session, String name, Object value)
      Description copied from class: WorldManager
      Updates a gamerule value on the Java server
      Specified by:
      setGameRule in class WorldManager
      Parameters:
      session - The session of the user that requested the change
      name - The gamerule to change
      value - The new value for the gamerule
    • getGameRuleBool

      public Boolean getGameRuleBool(GeyserSession session, GameRule gameRule)
      Description copied from class: WorldManager
      Gets a gamerule value as a boolean
      Specified by:
      getGameRuleBool in class WorldManager
      Parameters:
      session - The session of the user that requested the value
      gameRule - The gamerule to fetch the value of
      Returns:
      The boolean representation of the value
    • getGameRuleInt

      public int getGameRuleInt(GeyserSession session, GameRule gameRule)
      Description copied from class: WorldManager
      Get a gamerule value as an integer
      Specified by:
      getGameRuleInt in class WorldManager
      Parameters:
      session - The session of the user that requested the value
      gameRule - The gamerule to fetch the value of
      Returns:
      The integer representation of the value
    • setPlayerGameMode

      public void setPlayerGameMode(GeyserSession session, com.github.steveice10.mc.protocol.data.game.entity.player.GameMode gameMode)
      Description copied from class: WorldManager
      Change the game mode of the given session
      Specified by:
      setPlayerGameMode in class WorldManager
      Parameters:
      session - The session of the player to change the game mode of
      gameMode - The game mode to change the player to
    • setDifficulty

      public void setDifficulty(GeyserSession session, com.github.steveice10.mc.protocol.data.game.setting.Difficulty difficulty)
      Description copied from class: WorldManager
      Change the difficulty of the Java server
      Specified by:
      setDifficulty in class WorldManager
      Parameters:
      session - The session of the user that requested the change
      difficulty - The difficulty to change to
    • hasPermission

      public boolean hasPermission(GeyserSession session, String permission)
      Description copied from class: WorldManager
      Checks if the given session's player has a permission
      Specified by:
      hasPermission in class WorldManager
      Parameters:
      session - The session of the player to check the permission of
      permission - The permission node to check
      Returns:
      True if the player has the requested permission, false if not