diff --git a/src/main/java/com/loohp/limbo/player/Player.java b/src/main/java/com/loohp/limbo/player/Player.java index b277133..53c5a2b 100644 --- a/src/main/java/com/loohp/limbo/player/Player.java +++ b/src/main/java/com/loohp/limbo/player/Player.java @@ -68,11 +68,19 @@ public class Player extends LivingEntity implements CommandSender { this.watcher = new DataWatcher(this); this.watcher.update(); } - + /** Returns the player's currently selected slot + * + * @return The player's currently selected slot + */ public byte getSelectedSlot() { return selectedSlot; } + /** + * Set the player's currently selected slot + * + * @param slot the argument that defines the player's new selected inventory slot. + */ public void setSelectedSlot(byte slot) { if(slot == selectedSlot) return; @@ -85,10 +93,21 @@ public class Player extends LivingEntity implements CommandSender { this.selectedSlot = slot; } + /** + * Retruns the player's current GameMode + * + * @return The player's current GameMode + */ public GameMode getGamemode() { return gamemode; } + + /** + * Set the player's current GameMode + * + * @param gamemode the argument that defines the player's new GameMode. + */ public void setGamemode(GameMode gamemode) { if (!this.gamemode.equals(gamemode)) { try { @@ -101,53 +120,103 @@ public class Player extends LivingEntity implements CommandSender { this.gamemode = gamemode; } + /** + * Set the player's Entity ID DEPRECATED! + * + * @param entityId the argument that defines the player's unique entity id + */ @Deprecated protected void setEntityId(int entityId) { this.entityId = entityId; } + /** + * Returns the amount of additional hearts the player has + * + * @return How many additional hearts the player has + */ public float getAdditionalHearts() { return additionalHearts; } + /** + * Set the amount of additional hearts the player has + * + * @param additionalHearts the argument that defines how many additional hearts the player should have. + */ public void setAdditionalHearts(float additionalHearts) { this.additionalHearts = additionalHearts; } + /** + * + * @return + */ public int getScore() { return score; } + /** + * + * @param score + */ public void setScore(int score) { this.score = score; } + /** + * Returns how many skin layers a player has + * + * @return How many skin layers the player has + */ public byte getSkinLayers() { return skinLayers; } + /** + * Sets how many skin layers a player has + * + * @param skinLayers the argument that defines how many skin layers the player should have + */ public void setSkinLayers(byte skinLayers) { this.skinLayers = skinLayers; } + /** + * + * @return + */ public byte getMainHand() { return mainHand; } + /** + * + * @param mainHand + */ public void setMainHand(byte mainHand) { this.mainHand = mainHand; } + /** + * + */ @Override public DataWatcher getDataWatcher() { return watcher; } + /** + * + */ @Override public boolean isValid() { return Limbo.getInstance().getPlayers().contains(this); } + /** + * + */ @Override public void remove() { @@ -171,16 +240,31 @@ public class Player extends LivingEntity implements CommandSender { } */ + /** + * Returns the player's in game username + * + * @return The player's username + */ @Override public String getName() { return username; } + /** + * Determines if the player has a certain permission or not + * + * @return A boolean defining whether or not the player has the permission. + */ @Override public boolean hasPermission(String permission) { return Limbo.getInstance().getPermissionsManager().hasPermission(this, permission); } + /** + * Teleport the player to a new location + * + * @param location the argument that defines where the player will be teleported too + */ @Override public void teleport(Location location) { PlayerTeleportEvent event = Limbo.getInstance().getEventsManager().callEvent(new PlayerTeleportEvent(this, getLocation(), location)); @@ -198,18 +282,41 @@ public class Player extends LivingEntity implements CommandSender { } } + /** + * Teleports the player to a new location + * + * @param location the argument that defines where the player will be teleported too + */ protected void setLocation(Location location) { super.teleport(location); } + /** + * Send the player a message in chat + * + * @param message the argument that defines the message to be sent to the player + * @param uuid + */ public void sendMessage(String message, UUID uuid) { sendMessage(new TextComponent(message), uuid); } - + + /** + * Send the player a message in chat + * + * @param message the argument that defines the message to be sent to the player + * @param uuid + */ public void sendMessage(BaseComponent component, UUID uuid) { sendMessage(new BaseComponent[] {component}, uuid); } - + + /** + * Send the player a message in chat + * + * @param message the argument that defines the message to be sent to the player + * @param + */ @Override public void sendMessage(BaseComponent[] component, UUID uuid) { try { @@ -218,14 +325,29 @@ public class Player extends LivingEntity implements CommandSender { } catch (IOException e) {} } + /** + * Send the player a message in chat + * + * @param message the argument that defines the message to be sent to the player + */ public void sendMessage(String message) { sendMessage(new TextComponent(message)); } - + + /** + * Send the player a message in chat + * + * @param message the argument that defines the message to be sent to the player + */ public void sendMessage(BaseComponent component) { sendMessage(new BaseComponent[] {component}); } - + + /** + * Send the player a message in chat + * + * @param message the argument that defines the message to be sent to the player + */ @Override public void sendMessage(BaseComponent[] component) { try { @@ -234,26 +356,56 @@ public class Player extends LivingEntity implements CommandSender { } catch (IOException e) {} } + /** + * Disconnects the player from the server + * + */ public void disconnect() { disconnect(new TranslatableComponent("multiplayer.disconnect.kicked")); } - + + /** + * Disconnects the player from the server with a reason + * + * @param reason the argument that defines the reason for disconnecting the player + */ public void disconnect(String reason) { disconnect(new TextComponent(reason)); } - + + /** + * Disconnects the player from the server with a reason + * + * @param reason the argument that defines the reason for disconnecting the player + */ public void disconnect(BaseComponent reason) { disconnect(new BaseComponent[] {reason}); } - + + /** + * Disconnects the player from the server with a reason + * + * @param reason the argument that defines the reason for disconnecting the player + */ public void disconnect(BaseComponent[] reason) { clientConnection.disconnect(reason); } + /** + * Sends a chat message from the player to everyone else + * + * @param message the argument that defines the chat message to be sent + */ public void chat(String message) { chat(message, false); } + /** + * Sends a chat message from the player to everyone else + * + * @param message the argument that defines the chat message to be sent + * @param verbose + */ public void chat(String message, boolean verbose) { if (Limbo.getInstance().getServerProperties().isAllowChat()) { PlayerChatEvent event = (PlayerChatEvent) Limbo.getInstance().getEventsManager().callEvent(new PlayerChatEvent(this, CHAT_DEFAULT_FORMAT, message, false)); @@ -278,14 +430,36 @@ public class Player extends LivingEntity implements CommandSender { } } + /** + * Sends the player a resource pack to download + * + * @param url the argument that defines the download url for the resource pack + * @param hash the argument that defines the SHA1 hash of the resource pack folder + * @param forced the argument that defines whether or not the resource pack is required to join the server + */ public void setResourcePack(String url, String hash, boolean forced) { setResourcePack(url, hash, forced, (BaseComponent[]) null); } + /** + * Sends the player a resource pack to download + * + * @param url the argument that defines the download url for the resource pack + * @param hash the argument that defines the SHA1 hash of the resource pack folder + * @param forced the argument that defines whether or not the resource pack is required to join the server + * @param promptmessage the argument that defines the message to be displayed when asking to download the resource pack + */ public void setResourcePack(String url, String hash, boolean forced, BaseComponent promptmessage) { setResourcePack(url, hash, forced, new BaseComponent[] {promptmessage}); } - + /** + * Sends the player a resource pack to download + * + * @param url the argument that defines the download url for the resource pack + * @param hash the argument that defines the SHA1 hash of the resource pack folder + * @param forced the argument that defines whether or not the resource pack is required to join the server + * @param promptmessage the argument that defines the message to be displayed when asking to download the resource pack + */ public void setResourcePack(String url, String hash, boolean forced, BaseComponent[] promptmessage) { try { PacketPlayOutResourcePackSend packsend = new PacketPlayOutResourcePackSend(url, hash, forced, promptmessage != null, promptmessage); @@ -295,6 +469,12 @@ public class Player extends LivingEntity implements CommandSender { } } + /** + * Set the player's header and footer in their TAB menu + * + * @param header the argument that defines the header of the tab + * @param footer the argument that defines the footer of the tab + */ public void setPlayerListHeaderFooter(BaseComponent[] header, BaseComponent[] footer) { try { PacketPlayOutPlayerListHeaderFooter packsend = new PacketPlayOutPlayerListHeaderFooter(header == null ? EMPTY_CHAT_COMPONENT : header, footer == null ? EMPTY_CHAT_COMPONENT : footer); @@ -303,16 +483,33 @@ public class Player extends LivingEntity implements CommandSender { e.printStackTrace(); } } - + + /** + * Set the player's header and footer in their TAB menu + * + * @param header the argument that defines the header of the tab + * @param footer the argument that defines the footer of the tab + */ public void setPlayerListHeaderFooter(BaseComponent header, BaseComponent footer) { setPlayerListHeaderFooter(header == null ? EMPTY_CHAT_COMPONENT : new BaseComponent[] {header}, footer == null ? EMPTY_CHAT_COMPONENT : new BaseComponent[] {footer}); } + /** + * Set the player's header and footer in their TAB menu + * + * @param header the argument that defines the header of the tab + * @param footer the argument that defines the footer of the tab + */ public void setPlayerListHeaderFooter(String header, String footer) { setPlayerListHeaderFooter(header == null ? EMPTY_CHAT_COMPONENT : new BaseComponent[] {new TextComponent(header)}, footer == null ? EMPTY_CHAT_COMPONENT : new BaseComponent[] {new TextComponent(footer)}); } - + /** + * Sends a message to the bungee server to communicate with it + * + * @param subChannel the argument that defines the sub channel of which the message should be sent through + * @param argument the argument that defines the info that will be sent through the sub channel + */ public void sendBungeeMessage(String subChannel, String argument) { ByteArrayDataOutput out = ByteStreams.newDataOutput(); out.writeUTF(subChannel); @@ -322,6 +519,11 @@ public class Player extends LivingEntity implements CommandSender { } catch (IOException e) {e.printStackTrace();} } + /** + * Sends the player to a different bungee server + * + * @param server the argument that defines the server to send the player too + */ public void sendToServer(String server) { sendBungeeMessage("Connect", server); }