public class NameTagChanger extends Object
Modifier and Type | Field and Description |
---|---|
static NameTagChanger |
INSTANCE
The singleton instance to access all NameTagChanger methods
|
static String |
VERSION
The version of NameTagChanger
|
Modifier and Type | Method and Description |
---|---|
void |
changePlayerName(org.bukkit.entity.Player player,
String newName)
Changes the name displayed above the player's head.
|
void |
disable()
Disables NameTagChanger and restores all names to normal,
and removes all packet handlers.
|
void |
enable()
Enables NameTagChanger and creates necessary packet handlers.
|
String |
getChangedName(org.bukkit.entity.Player player)
Gets a player's changed name
|
Map<UUID,String> |
getChangedPlayers()
Gets all players who currently have changed names.
|
Skin |
getChangedSkin(org.bukkit.entity.Player player)
Gets a player's changed skin
|
Skin |
getDefaultSkinFromPlayer(org.bukkit.entity.Player player)
Gets the default skin from a player, if one exists locally, otherwise Skin.EMPTY_SKIN is returned.
|
void |
getSkin(String username,
SkinCallBack callBack)
Gets the skin for a username.
|
void |
getSkin(UUID uuid,
SkinCallBack callBack)
Gets the skin for a UUID.
|
Skin |
getSkinFromGameProfile(GameProfileWrapper profile)
Gets the skin from a game profile, if one exists, otherwise Skin.EMPTY_SKIN is returned.
|
void |
init()
Empty method to call for initializing the class.
|
boolean |
isEnabled()
Checks if NameTagChanger is enabled.
|
void |
resetPlayerName(org.bukkit.entity.Player player)
Resets the player's name back to normal.
|
void |
resetPlayerSkin(org.bukkit.entity.Player player)
Resets a player's skin back to normal
NOTE: This does not update the player's skin, so a call to
updatePlayer() is needed for the changes to take effect.
|
void |
setPlayerSkin(org.bukkit.entity.Player player,
Skin skin)
Sets a players skin.
|
void |
setPlugin(org.bukkit.plugin.Plugin plugin)
Sets the plugin instance to use for registering packet/event listeners.
|
void |
updatePlayer(org.bukkit.entity.Player player)
Sends packets to update a player to reflect any changes in skin or
name.
|
public static final String VERSION
public static final NameTagChanger INSTANCE
public void setPlayerSkin(org.bukkit.entity.Player player, Skin skin)
NOTE: This does not update the player's skin, so a call to updatePlayer() is needed for the changes to take effect.
player
- the player to set the skin ofskin
- the skinpublic void resetPlayerSkin(org.bukkit.entity.Player player)
NOTE: This does not update the player's skin, so a call to updatePlayer() is needed for the changes to take effect.
player
- the player to resetpublic void changePlayerName(org.bukkit.entity.Player player, String newName)
player
- the playernewName
- the new name of the playerpublic void resetPlayerName(org.bukkit.entity.Player player)
player
- the playerpublic String getChangedName(org.bukkit.entity.Player player)
player
- the player to get the changed name ofpublic Skin getChangedSkin(org.bukkit.entity.Player player)
player
- the player to get the changed skin ofpublic Skin getDefaultSkinFromPlayer(org.bukkit.entity.Player player)
player
- the playerpublic Skin getSkinFromGameProfile(GameProfileWrapper profile)
profile
- the profilepublic void updatePlayer(org.bukkit.entity.Player player)
NOTE: This is done automatically by #changePlayerName and #resetPlayerName, so the only real use for this is when changing skins, as those methods do not automatically update.
player
- the player to updatepublic Map<UUID,String> getChangedPlayers()
public boolean isEnabled()
public void disable()
public void enable()
public void setPlugin(org.bukkit.plugin.Plugin plugin)
plugin
- the plugin instancepublic void getSkin(String username, SkinCallBack callBack)
Since fetching this skin requires making asynchronous requests to Mojang's servers, a call back mechanism using the SkinCallBack class is implemented. This call back allows you to also handle any errors that might have occurred while fetching the skin. If no users with the specified username can be found, the skin passed to the callback will be Skin.EMPTY_SKIN.
The call back will always be fired on the main thread.
username
- the username to get the skin ofcallBack
- the call back to handle the result of the requestpublic void getSkin(UUID uuid, SkinCallBack callBack)
Since fetching this skin might require making asynchronous requests to Mojang's servers, a call back mechanism using the SkinCallBack class is implemented. This call back allows you to also handle any errors that might have occurred while fetching the skin.
The call back will always be fired on the main thread.
uuid
- the uuid to get the skin ofcallBack
- the call back to handle the result of the requestpublic void init()
Copyright © 2017 AlvinB. MIT License.