Interface INetHandler


public interface INetHandler
This class handles all of the multiplayer and IPacket managing. You can receive an instance of this class using RockBottomAPI.getNet().
  • Method Details

    • isThePlayer

      boolean isThePlayer(Entity entity)
      Returns true if the passed entity is the current local player. Note that this will always return false on the dedicated server as it does not have a local player.
      Parameters:
      entity - The entity to query
      Returns:
      If the entity is the local player
      See Also:
    • isClient

      boolean isClient()
      Returns true if the game is currently in client mode, meaning it houses a player that is currently connected to a local or dedicated server that a different player is hosting. Note that, if a player opens a local server using the ingame menu, this will not be true.
      Returns:
      If the game is a client currently
      See Also:
    • isServer

      boolean isServer()
      Returns true if the game is currently in server mode, meaning it acts as a server that other players can join. Note that this will both be true for the dedicated server and the local server hosted from within the ingame menu.
      Returns:
      If the game is a server currently
      See Also:
    • isActive

      boolean isActive()
      Returns true if the game is currently either in server or client mode.
      Returns:
      If the net handler is active
      See Also:
    • isConnectedToServer

      boolean isConnectedToServer()
      Returns true if the game is currently in client mode and there is an open, working connection to the server. This is rather useless for modders as client-mode will automatically be terminated whenever this method does not return true.
      Returns:
      If the game is connected to a server
      See Also:
    • getConnectedClients

      @ApiInternal io.netty.channel.group.ChannelGroup getConnectedClients()
    • sendToServer

      void sendToServer(IPacket packet)
      Sends an IPacket directly to the server where it will be handled.
      Parameters:
      packet - The packet to send
    • sendToAllPlayers

      void sendToAllPlayers(IWorld world, IPacket packet)
      Sends an IPacket to all the players on the server, meaning that this packet will be send to a list of clients and then handled there.
      Parameters:
      world - The world
      packet - The packet to send
    • sendToAllPlayersExcept

      void sendToAllPlayersExcept(IWorld world, IPacket packet, Entity except)
      Sends an IPacket to all of the players on the server except one. This can be useful for if a packet is being sent from a player that already has a certain bit of information, possibly from having sent it to the server prior.
      Parameters:
      world - The world
      packet - The packet to send
      except - The player that the packet should not be sent to
    • sendToAllPlayersInWorld

      void sendToAllPlayersInWorld(IWorld world, IPacket packet)
      Sends an IPacket to all the players in the current world, meaning that this packet will be send to a list of clients and then handled there.
      Parameters:
      world - The world
      packet - The packet to send
    • sendToAllPlayersInWorldExcept

      void sendToAllPlayersInWorldExcept(IWorld world, IPacket packet, Entity except)
      Sends an IPacket to all of the players in the current world except one. This can be useful for if a packet is being sent from a player that already has a certain bit of information, possibly from having sent it to the server prior.
      Parameters:
      world - The world
      packet - The packet to send
      except - The player that the packet should not be sent to
    • sendToAllPlayersAround

      void sendToAllPlayersAround(IWorld world, IPacket packet, double x, double y, double radius)
      Sends an IPacket to all of the players in the current world within a certain radius of a certain point. This can be useful for thigns like machines or entity or tile-based actions where a player that is too far away to see the change does not need to receive the packet.
      Parameters:
      world - The world
      packet - The packet to send
      x - The center x
      y - The center y
      radius - The radius around the center
    • sendToAllPlayersAroundExcept

      void sendToAllPlayersAroundExcept(IWorld world, IPacket packet, double x, double y, double radius, Entity except)
      Sends an IPacket to all of the players in the current world within a certain radius of a certain point, except for a single player.
      Parameters:
      world - The world
      packet - The packet to send
      x - The center x
      y - The center y
      radius - The radius around the center
      except - The player that the packet should not be sent to
    • sendToAllPlayersWithLoadedPos

      void sendToAllPlayersWithLoadedPos(IWorld world, IPacket packet, double x, double y)
      Sends an IPacket to all of the players in the current world that have the given position in their list of loaded chunks. What this means is that the packet will only be sent to those players that are close enough to the position for the chunk that contains it to be loaded on their end. This can greatly increase server performance for things that happen in the world and for which players that don't have a given position loaded also do not have to receive the information.
      Parameters:
      world - The world
      packet - The packet to send
      x - The position x
      y - The position y
    • sendToAllPlayersWithLoadedPosExcept

      void sendToAllPlayersWithLoadedPosExcept(IWorld world, IPacket packet, double x, double y, Entity except)
      Sends an IPacket to all of the players in the current world that have the given position in their list of loaded chunks, except for a certain player.
      Parameters:
      world - The world
      packet - The packet to send
      x - The position x
      y - The position y
      except - The player that the packet should not be sent to
    • getCommandLevel

      int getCommandLevel(AbstractPlayerEntity player)
      Returns the command level of any player. This can be seen as a sort of permission to check how much access to commands any player has.
      Parameters:
      player - The player
      Returns:
      The player's command level
      See Also:
    • setCommandLevel

      void setCommandLevel(AbstractPlayerEntity player, int level)
      Sets the command level of any player to a certain value.
      Parameters:
      player - The player
      level - The command level
      See Also:
    • setCommandLevel

      void setCommandLevel(UUID id, int level)
      Sets the command level of any player's unique id to a certain value.
      Parameters:
      id - The player's id
      level - The command level
      See Also:
    • whitelist

      void whitelist(UUID id)
      Puts a certain player's unique id onto the whitelist of the server.
      Parameters:
      id - The id to whitelist
    • removeWhitelist

      void removeWhitelist(UUID id)
      Removes a certain player's unique id from the whitelist of the server.
      Parameters:
      id - The id to remove
    • isWhitelisted

      boolean isWhitelisted(UUID id)
      Returns true if the given player unique id is on the whitelist.
      Parameters:
      id - The id to query
      Returns:
      If it is whitelisted
    • isWhitelistEnabled

      boolean isWhitelistEnabled()
      Returns true if the whitelist is enabled. If it is not enabled, there will still be certain players on the whitelist, however, who is and who isn't will take no effect on their permissions and wether or not they are allowed to play on the server.
      Returns:
      If the whitelist is enabled
    • enableWhitelist

      void enableWhitelist(boolean enabled)
      Sets the whitelist to be disabled or enabled
      Parameters:
      enabled - The value
      See Also:
    • blacklist

      void blacklist(UUID id, String reason)
      Adds a certain player's unique id to the blacklist, meaning they will not be allowed to play on the server anymore. Optionally, you can supply a reason that will be displayed to the player when they try to join the server.
      Parameters:
      id - The id
      reason - The reason for being on the blacklist
    • getBlacklistReason

      String getBlacklistReason(UUID id)
      Gets the reason for any player's unique id to be on the blacklist. If the player's id is not blacklisted, then this method will return null. It will also return null if there is no reason.
      Parameters:
      id - The id
      Returns:
      The reson for being on the blacklist
    • removeBlacklist

      void removeBlacklist(UUID id)
      Removes a certain player's unique id from the blacklist
      Parameters:
      id - The id to remove
      See Also:
    • isBlacklisted

      boolean isBlacklisted(UUID id)
      Returns true if a certain player's unique id is blacklisted currently
      Parameters:
      id - The id to query
      Returns:
      If it is blacklisted
    • init

      @ApiInternal void init(String ip, int port, boolean isServer) throws Exception
      Throws:
      Exception
    • shutdown

      @ApiInternal void shutdown()
    • saveServerSettings

      @ApiInternal void saveServerSettings()