Added Java Doc info for (almost) all Player object methods, as to prepare to create an automated java doc later

This commit is contained in:
gtpal 2021-12-18 14:38:23 -05:00
parent 1b8e3f6d76
commit db29a22e49
1 changed files with 213 additions and 11 deletions

View File

@ -68,11 +68,19 @@ public class Player extends LivingEntity implements CommandSender {
this.watcher = new DataWatcher(this); this.watcher = new DataWatcher(this);
this.watcher.update(); this.watcher.update();
} }
/** Returns the player's currently selected slot
*
* @return The player's currently selected slot
*/
public byte getSelectedSlot() { public byte getSelectedSlot() {
return selectedSlot; 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) { public void setSelectedSlot(byte slot) {
if(slot == selectedSlot) if(slot == selectedSlot)
return; return;
@ -85,10 +93,21 @@ public class Player extends LivingEntity implements CommandSender {
this.selectedSlot = slot; this.selectedSlot = slot;
} }
/**
* Retruns the player's current GameMode
*
* @return The player's current GameMode
*/
public GameMode getGamemode() { public GameMode getGamemode() {
return gamemode; return gamemode;
} }
/**
* Set the player's current GameMode
*
* @param gamemode the argument that defines the player's new GameMode.
*/
public void setGamemode(GameMode gamemode) { public void setGamemode(GameMode gamemode) {
if (!this.gamemode.equals(gamemode)) { if (!this.gamemode.equals(gamemode)) {
try { try {
@ -101,53 +120,103 @@ public class Player extends LivingEntity implements CommandSender {
this.gamemode = gamemode; this.gamemode = gamemode;
} }
/**
* Set the player's Entity ID DEPRECATED!
*
* @param entityId the argument that defines the player's unique entity id
*/
@Deprecated @Deprecated
protected void setEntityId(int entityId) { protected void setEntityId(int entityId) {
this.entityId = entityId; this.entityId = entityId;
} }
/**
* Returns the amount of additional hearts the player has
*
* @return How many additional hearts the player has
*/
public float getAdditionalHearts() { public float getAdditionalHearts() {
return additionalHearts; 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) { public void setAdditionalHearts(float additionalHearts) {
this.additionalHearts = additionalHearts; this.additionalHearts = additionalHearts;
} }
/**
*
* @return
*/
public int getScore() { public int getScore() {
return score; return score;
} }
/**
*
* @param score
*/
public void setScore(int score) { public void setScore(int score) {
this.score = score; this.score = score;
} }
/**
* Returns how many skin layers a player has
*
* @return How many skin layers the player has
*/
public byte getSkinLayers() { public byte getSkinLayers() {
return skinLayers; 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) { public void setSkinLayers(byte skinLayers) {
this.skinLayers = skinLayers; this.skinLayers = skinLayers;
} }
/**
*
* @return
*/
public byte getMainHand() { public byte getMainHand() {
return mainHand; return mainHand;
} }
/**
*
* @param mainHand
*/
public void setMainHand(byte mainHand) { public void setMainHand(byte mainHand) {
this.mainHand = mainHand; this.mainHand = mainHand;
} }
/**
*
*/
@Override @Override
public DataWatcher getDataWatcher() { public DataWatcher getDataWatcher() {
return watcher; return watcher;
} }
/**
*
*/
@Override @Override
public boolean isValid() { public boolean isValid() {
return Limbo.getInstance().getPlayers().contains(this); return Limbo.getInstance().getPlayers().contains(this);
} }
/**
*
*/
@Override @Override
public void remove() { 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 @Override
public String getName() { public String getName() {
return username; 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 @Override
public boolean hasPermission(String permission) { public boolean hasPermission(String permission) {
return Limbo.getInstance().getPermissionsManager().hasPermission(this, 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 @Override
public void teleport(Location location) { public void teleport(Location location) {
PlayerTeleportEvent event = Limbo.getInstance().getEventsManager().callEvent(new PlayerTeleportEvent(this, getLocation(), 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) { protected void setLocation(Location location) {
super.teleport(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) { public void sendMessage(String message, UUID uuid) {
sendMessage(new TextComponent(message), 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) { public void sendMessage(BaseComponent component, UUID uuid) {
sendMessage(new BaseComponent[] {component}, 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 @Override
public void sendMessage(BaseComponent[] component, UUID uuid) { public void sendMessage(BaseComponent[] component, UUID uuid) {
try { try {
@ -218,14 +325,29 @@ public class Player extends LivingEntity implements CommandSender {
} catch (IOException e) {} } 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) { public void sendMessage(String message) {
sendMessage(new TextComponent(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) { public void sendMessage(BaseComponent component) {
sendMessage(new 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 @Override
public void sendMessage(BaseComponent[] component) { public void sendMessage(BaseComponent[] component) {
try { try {
@ -234,26 +356,56 @@ public class Player extends LivingEntity implements CommandSender {
} catch (IOException e) {} } catch (IOException e) {}
} }
/**
* Disconnects the player from the server
*
*/
public void disconnect() { public void disconnect() {
disconnect(new TranslatableComponent("multiplayer.disconnect.kicked")); 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) { public void disconnect(String reason) {
disconnect(new TextComponent(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) { public void disconnect(BaseComponent reason) {
disconnect(new 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) { public void disconnect(BaseComponent[] reason) {
clientConnection.disconnect(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) { public void chat(String message) {
chat(message, false); 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) { public void chat(String message, boolean verbose) {
if (Limbo.getInstance().getServerProperties().isAllowChat()) { if (Limbo.getInstance().getServerProperties().isAllowChat()) {
PlayerChatEvent event = (PlayerChatEvent) Limbo.getInstance().getEventsManager().callEvent(new PlayerChatEvent(this, CHAT_DEFAULT_FORMAT, message, false)); 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) { public void setResourcePack(String url, String hash, boolean forced) {
setResourcePack(url, hash, forced, (BaseComponent[]) null); 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) { public void setResourcePack(String url, String hash, boolean forced, BaseComponent promptmessage) {
setResourcePack(url, hash, forced, new 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) { public void setResourcePack(String url, String hash, boolean forced, BaseComponent[] promptmessage) {
try { try {
PacketPlayOutResourcePackSend packsend = new PacketPlayOutResourcePackSend(url, hash, forced, promptmessage != null, promptmessage); 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) { public void setPlayerListHeaderFooter(BaseComponent[] header, BaseComponent[] footer) {
try { try {
PacketPlayOutPlayerListHeaderFooter packsend = new PacketPlayOutPlayerListHeaderFooter(header == null ? EMPTY_CHAT_COMPONENT : header, footer == null ? EMPTY_CHAT_COMPONENT : footer); 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(); 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) { public void setPlayerListHeaderFooter(BaseComponent header, BaseComponent footer) {
setPlayerListHeaderFooter(header == null ? EMPTY_CHAT_COMPONENT : new BaseComponent[] {header}, footer == null ? EMPTY_CHAT_COMPONENT : new 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) { 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)}); 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) { public void sendBungeeMessage(String subChannel, String argument) {
ByteArrayDataOutput out = ByteStreams.newDataOutput(); ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF(subChannel); out.writeUTF(subChannel);
@ -322,6 +519,11 @@ public class Player extends LivingEntity implements CommandSender {
} catch (IOException e) {e.printStackTrace();} } 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) { public void sendToServer(String server) {
sendBungeeMessage("Connect", server); sendBungeeMessage("Connect", server);
} }