Package de.ellpeck.rockbottom.api.net
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 Summary
Modifier and TypeMethodDescriptionvoidAdds a certain player's unique id to the blacklist, meaning they will not be allowed to play on the server anymore.voidenableWhitelist(boolean enabled) Sets the whitelist to be disabled or enabledGets the reason for any player's unique id to be on the blacklist.intgetCommandLevel(AbstractPlayerEntity player) Returns the command level of any player.io.netty.channel.group.ChannelGroupvoidbooleanisActive()Returns true if the game is currently either in server or client mode.booleanisBlacklisted(UUID id) Returns true if a certain player's unique id is blacklisted currentlybooleanisClient()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.booleanReturns true if the game is currently in client mode and there is an open, working connection to the server.booleanisServer()Returns true if the game is currently in server mode, meaning it acts as a server that other players can join.booleanisThePlayer(Entity entity) Returns true if the passed entity is the current local player.booleanisWhitelisted(UUID id) Returns true if the given player unique id is on the whitelist.booleanReturns true if the whitelist is enabled.voidremoveBlacklist(UUID id) Removes a certain player's unique id from the blacklistvoidremoveWhitelist(UUID id) Removes a certain player's unique id from the whitelist of the server.voidvoidsendToAllPlayers(IWorld world, IPacket packet) Sends anIPacketto all the players on the server, meaning that this packet will be send to a list of clients and then handled there.voidsendToAllPlayersAround(IWorld world, IPacket packet, double x, double y, double radius) Sends anIPacketto all of the players in the current world within a certain radius of a certain point.voidsendToAllPlayersAroundExcept(IWorld world, IPacket packet, double x, double y, double radius, Entity except) Sends anIPacketto all of the players in the current world within a certain radius of a certain point, except for a single player.voidsendToAllPlayersExcept(IWorld world, IPacket packet, Entity except) Sends anIPacketto all of the players on the server except one.voidsendToAllPlayersInWorld(IWorld world, IPacket packet) Sends anIPacketto all the players in the current world, meaning that this packet will be send to a list of clients and then handled there.voidsendToAllPlayersInWorldExcept(IWorld world, IPacket packet, Entity except) Sends anIPacketto all of the players in the current world except one.voidsendToAllPlayersWithLoadedPos(IWorld world, IPacket packet, double x, double y) Sends anIPacketto all of the players in the current world that have the given position in their list of loaded chunks.voidsendToAllPlayersWithLoadedPosExcept(IWorld world, IPacket packet, double x, double y, Entity except) Sends anIPacketto all of the players in the current world that have the given position in their list of loaded chunks, except for a certain player.voidsendToServer(IPacket packet) Sends anIPacketdirectly to the server where it will be handled.voidsetCommandLevel(AbstractPlayerEntity player, int level) Sets the command level of any player to a certain value.voidsetCommandLevel(UUID id, int level) Sets the command level of any player's unique id to a certain value.voidshutdown()voidPuts a certain player's unique id onto the whitelist of the server.
-
Method Details
-
isThePlayer
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
-
sendToServer
Sends anIPacketdirectly to the server where it will be handled.- Parameters:
packet- The packet to send
-
sendToAllPlayers
Sends anIPacketto 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 worldpacket- The packet to send
-
sendToAllPlayersExcept
Sends anIPacketto 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 worldpacket- The packet to sendexcept- The player that the packet should not be sent to
-
sendToAllPlayersInWorld
Sends anIPacketto 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 worldpacket- The packet to send
-
sendToAllPlayersInWorldExcept
Sends anIPacketto 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 worldpacket- The packet to sendexcept- The player that the packet should not be sent to
-
sendToAllPlayersAround
Sends anIPacketto 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 worldpacket- The packet to sendx- The center xy- The center yradius- The radius around the center
-
sendToAllPlayersAroundExcept
void sendToAllPlayersAroundExcept(IWorld world, IPacket packet, double x, double y, double radius, Entity except) Sends anIPacketto all of the players in the current world within a certain radius of a certain point, except for a single player.- Parameters:
world- The worldpacket- The packet to sendx- The center xy- The center yradius- The radius around the centerexcept- The player that the packet should not be sent to
-
sendToAllPlayersWithLoadedPos
Sends anIPacketto 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 worldpacket- The packet to sendx- The position xy- The position y
-
sendToAllPlayersWithLoadedPosExcept
void sendToAllPlayersWithLoadedPosExcept(IWorld world, IPacket packet, double x, double y, Entity except) Sends anIPacketto 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 worldpacket- The packet to sendx- The position xy- The position yexcept- The player that the packet should not be sent to
-
getCommandLevel
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
Sets the command level of any player to a certain value.- Parameters:
player- The playerlevel- The command level- See Also:
-
setCommandLevel
Sets the command level of any player's unique id to a certain value.- Parameters:
id- The player's idlevel- The command level- See Also:
-
whitelist
Puts a certain player's unique id onto the whitelist of the server.- Parameters:
id- The id to whitelist
-
removeWhitelist
Removes a certain player's unique id from the whitelist of the server.- Parameters:
id- The id to remove
-
isWhitelisted
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
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 idreason- The reason for being on the blacklist
-
getBlacklistReason
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
Removes a certain player's unique id from the blacklist- Parameters:
id- The id to remove- See Also:
-
isBlacklisted
Returns true if a certain player's unique id is blacklisted currently- Parameters:
id- The id to query- Returns:
- If it is blacklisted
-
init
- Throws:
Exception
-
shutdown
-
saveServerSettings
-