BetterNick Wiki - Historical

Applied By DomeDD: Jun 2, 2018 at 4:28 PM

BetterNick Wiki
BetterNick Wiki
1. Installation:
1.1: How to use BetterNick on a single Spigot/Bukkit/Sponge server:
1. Install the "BetterNick 1.8.3 - 1.12.2.jar" on your server
2. Enable "Config.Nick On Join" in the config.yml if you want to get a nickname on join (if the player enabled autonick) or disable it if you don't want to get a nickname on join (if the player enabled autonick)
3. Set "MySQL.Enabled" to true if you want to save the data in a MySQL database or set it to false to save the data in a local file (slower)
3.1. Set up the MySQL connection by specifying username, password, database, host and port in the config.yml at "MySQL"

1.2: How to use BetterNick on a BungeeCord network:
Don't install the "BetterNick 1.8.3 - 1.12.2.jar" in your BungeeCord plugins folder! Always in the gameserver's plugins folder!
1. Install the "BetterNick 1.8.3 - 1.12.2.jar" on your gameserver(s)
2. Disable "Config.Nick On Join" in the config.yml on your Lobbyserver(s)
3. Set "Addons.AutoNick Item.Enabled" to true in the config.yml on your Lobbyserver(s)
4. Set "MySQL.Enabled" in the config.yml to true and set up the MySQL connection by specifying username, password, database, host and port in the config.yml at "MySQL" on all gameserver(s)

2. The config.yml:
- The default file can be found here
Code (Text):
Config:
    # If true, the plugin automaticly compares the plugin version with the version on spigotmc.org
    Auto Update Check: true
    # If true, the plugin automaticly downloads the newest plugin version from spigotmc.org if an update is available
    Auto Update Download: true
    # If true, the plugin will send some stats to bStats (https://bstats.org/plugin/bukkit/BetterNick)
    Send Metrics: true
    # If true, all commands and listeners will be disabled that you can make your one ones
    API Mode: false
    # If true, you will get a nickname on join if the client enabled AutoJoin
    Nick on Join: true
    # If true, the player can see their own new skin
    Skin Self Update: true
    # If true, the player will get an actionbar message while nicked
    Nicked Actionbar: true
    # If true, the old nickname of a player gets saved and re-used on re-join
    Keep NickName On Quit: false
Code (Text):
MySQL:
    # If true, the plugin will connect to the MySQL database
    Enabled: false
    Username: root
    Password: password
    Database: nicknames
    Host: localhost
    Port: '3306'
Code (Text):
Nick Options:
    # Use this to change the prefix of the nametag of a player. If NametagEdit or ColoredTags is installed you can use longer prefixes than 2 chars, otherwise you should leave it empty for optimal experience
    Nametag Prefix: ''
    # Use this to change the suffix of the nametag of a player. If NametagEdit or ColoredTags is installed you can use this, otherwise leave it empty
    Nametag Suffix: ''
    # Use this to change the prefix in the chat of a player. If Vault and a Vault compatible chat plugin is installed you can use this, otherwise leave it empty
    Chat Prefix: ''
    # Use this to change the suffix in the chat of a player. If Vault and a Vault compatible chat plugin is installed you can use this, otherwise leave it empty
    Chat Suffix: ''
    # Use this to change the prefix of the displayname of a player. Not recommended to do
    Displayname Prefix: ''
    # Use this to change the suffix of the displayname of a player. Not recommended to do
    Displayname Suffix: ''
    # Use this to change the prefix of the tablistname of a player.
    Tablist Prefix: ''
    # Use this to change the suffix of the tablistname of a player.
    Tablist Suffix: ''
Code (Text):
Addons:
    AutoNick Item:
        # If true, this addon is active
        Enabled: false
        # If true, the player with the right permission will get an item to enable/disable autonick on join
        Get On Server Join: true
        # If the player joins into one of these specified worlds, the player will get an item to enable/disable autonick
        Get On World Change:
        - world
        # In these specified worlds you can use the item
        Enabled Worlds:
        - world
        # ID:SubID, Displayname, Slot
        Item: 421:0, &5Nick Tool, 4
        # If true, the player can move the item in their inventory
        Item Moveable: false
        Inventory:
            # The title of the inventory
            Name: '&8[&5BetterNick&8] &5AutoNick'
            # ID:SubID, Displayname, Slot (has to be the same slot as at "Addons.AutoNick Item.Inventory.AutoNick False")
            AutoNick True: 348:0, &7AutoNick &8>> &2TRUE, 4
            # ID:SubID, Displayname, Slot (has to be the same slot as at "Addons.AutoNick Item.Inventory.AutoNick True")
            AutoNick False: 289:0, &7AutoNick &8>> &cFALSE, 4
    Random Nick Gui:
        # If true, this addon is active
        Enabled: false
        Inventory:
            # The title of the inventory
            Name: '&5Random Nicks'
            # Only change the colorcode. Don't add anything else
            Nick Item Name: '&5[NAME]'
            Nick Item Lore: '&7Click to set a new nickname.'
3. Advanced features with 3rd party plugins:
3.1. Longer Nametags with NametagEdit or ColoredTags:
- with one of these plugins you can set "Nick Options.Nametag Prefix" in the config.yml to a longer prefix than to one with only two chars
- with one of these plugins you can set up a Nametag Suffix at "Nick Options.Nametag Suffix" in the config.myl

3.2. Chat Prefix and Suffix:
- You can either use Vault and a Vault compatible Chat plugin or Vault and Essentials(X)Chat, but Vault is required for both options
- Alternative option: Using a Chat plugin that supports PlaceholderAPI, but Vault is required, too

3.2.1. Using Vault & Essentials(X)Chat:
- Use '{NICKPREFIX}' for the prefix of a player, '{NICKSUFFIX}' for the suffix and '{NICKNAME}' for the name of a player at "chat.format" in the Essentials(X) config.yml
3.2.2. Using Vault & a chat plugin compatible with PlaceholderAPI:
- Use '%betternick_prefix%' for the prefix of a player, '%betternick_suffix%' for the suffix and '%betternick_name%' for the name of a player
4. Developer API
4.1. BetterNick API:
- The full BetterNickAPI can be found here

- To access the BetterNickAPI your main class should contain this:
Code (Text):
public static BetterNickAPI api;
 
@Override
public void onEnable() {
    if(Bukkit.getPluginManager().getPlugin("BetterNick") != null) {
        api = BetterNick.getApi();
    }
}
- To create a /nick [name] command you could use this example (IMPORTANT: Keep this order of the methods):
Code (Text):
@Override
public boolean onCommand(CommandSender sender, Command cmd, String cmdlabel, String[] args) {
    Player player = (Player) sender;
    if(args.length == 0) {
        api.setRandomPlayerNickName(player, nametagprefix, nametagsuffix);
        api.setPlayerChatName(player, api.getNickName(player), chatprefix, chatsuffix);
        api.setPlayerDisplayName(player, api.getNickName(player), displaynameprefix, displaynamesuffix);
        api.setPlayerTablistName(player, api.getNickName(player), tablistprefix, tablistsuffix);
        api.setRandomPlayerSkin(player);
    } else if(args.length == 1) {
        String nickname = args[0];
        api.setPlayerNickName(player, nickname, nametagprefix, nametagsuffix);
        api.setPlayerChatName(player, api.getNickName(player), chatprefix, chatsuffix);
        api.setPlayerDisplayName(player, api.getNickName(player), displaynameprefix, displaynamesuffix);
        api.setPlayerTablistName(player, api.getNickName(player), tablistprefix, tablistsuffix);
        api.setRandomPlayerSkin(player);
    }
}
- To create a /skin [name] command you could use this example:
Code (Text):
@Override
public boolean onCommand(CommandSender sender, Command cmd, String cmdlabel, String[] args) {
    Player player = (Player) sender;
    if(args.length == 0) {
        api.setRandomPlayerSkin(player);
    } else if(args.length == 1) {
        String skin = args[0];
        api.setPlayerSkin(player, skin);
    }
}
-To create a /nicklist command you could use this example:
Code (Text):
@Override
public boolean onCommand(CommandSender sender, Command cmd, String cmdlabel, String[] args) {
    Player player = (Player) sender;        if(args.length == 0) {
        for(Player nps : api.getNickedPlayers()) {
            player.sendMessage(api.getNickName(nps) + " -> " + api.getRealName(nps));
        }
    }
}
- To create a /unnick command you could use this example:
Code (Text):
@Override
public boolean onCommand(CommandSender sender, Command cmd, String cmdlabel, String[] args) {
    Player player = (Player) sender;
    if(args.length == 0) {
        if(api.isPlayerNicked(player)) {
            api.resetPlayerNickName(player);
            api.resetPlayerDisplayName(player);
            api.resetPlayerTablistName(player);
            api.resetPlayerChatName(player);
        }
        api.resetPlayerSkin(player);
        api.removeNickedPlayer(p);
    }
}

4.2. BetterNick Events:
- All events can be found here
- More examples can be found here

- To create a /nick [name] command you could use this example (IMPORTANT: Keep this order of the methods):
Code (Text):
@Override
public boolean onCommand(CommandSender sender, Command cmd, String cmdlabel, String[] args) {
    Player player = (Player) sender;
    if(args.length == 0) {
        Bukkit.getPluginManager().callEvent(new PlayerCallRandomNickEvent(p));
        Bukkit.getPluginManager().callEvent(new PlayerCallRandomSkinEvent(p));
    } else if(args.length == 1) {
        String nickname = args[0];
        Bukkit.getPluginManager().callEvent(new PlayerCallNickEvent(p, nickname));
    }
}
Code (Text):
@EventHandler
public void onPlayerCallNick(PlayerCallNickEvent e) {
    e.setNickName(e.getNickName(), nametagprefix, nametagsuffix);
    e.setPlayerChatName(e.getNickName(), chatprefix, chatsuffix);
    e.setPlayerDisplayName(e.getNickName(), displaynameprefix, displaynamesuffix);
    e.setPlayerTablistName(e.getNickName(), tablistprefix, tablistsuffix);
}
@EventHandler
public void onPlayerCallRandomNick(PlayerCallRandomNickEvent e) {
    e.setRandomNickName(nametagprefix, nametagsuffix);
    e.setPlayerChatName(e.getNickName(), chatprefix, chatsuffix);
    e.setPlayerDisplayName(e.getNickName(), displaynameprefix, displaynamesuffix);
    e.setPlayerTablistName(e.getNickName(), tablistprefix, tablistsuffix);
}
@EventHandler
public void onPlayerNick(PlayerNickEvent e) {
    e.setNickMessage(message);
    e.stopNickActionbarMessage();
    e.setNickActionbarMessage(message);
}
@EventHandler
public void onPlayerCallRandomSkin(PlayerCallRandomSkinEvent e) {
    e.setRandomSkin();
}
@EventHandler
public void onPlayerSkinSetEvent(PlayerSkinSetEvent e) {
   e.setSkinSetMessage(message);
}
- To create a /unnick command you could use this example:
Code (Text):
@Override
public boolean onCommand(CommandSender sender, Command cmd, String cmdlabel, String[] args) {
    Player player = (Player) sender;
    if(args.length == 0) {
        if(api.isPlayerNicked(player)) {
        Bukkit.getPluginManager().callEvent(new PlayerCallUnnickEvent(p));
        }
        Bukkit.getPluginManager().callEvent(new PlayerCallSkinResetEvent(p));
        BetterNickAPI.getApi().removeNickedPlayer(p);
    }
}
Code (Text):
@EventHandler
public void onPlayerCallUnnick(PlayerCallUnnickEvent e) {
    e.resetPlayerNickName();
    e.resetPlayerDisplayName();
    e.resetPlayerTablistName();
    e.resetPlayerChatName();
}
@EventHandler
public void onPlayerUnnick(PlayerUnnickEvent e) {
    e.setUnNickMessage(message);
    e.stopNickActionbarMessage();
}
@EventHandler
public void onPlayerCallSkinReset(PlayerCallSkinResetEvent e) {
    e.resetSkin();
}
@EventHandler
public void onPlayerResetSkin(PlayerSkinResetEvent e) {
    e.setSkinResetMessage(message);
}