Configuration reference fun house

Discussion in 'Plugin Development' started by Reinified, Sep 22, 2017.

Thread Status:
Not open for further replies.
  1. Alright, so.

    Here's the configuration example I thought of:
    Code:
    total: 0
    players:
      Reinified:
        uuid: 1234567890
        ip: 0987654321
        whitelisted: true
    Lets say I get a joining player who has not got an entry in the players directory.
    This would mean that this is their first join.
    However, the UUID of that player IS in the players directory.
    This would mean a username change.

    I want to get whether this new user is whitelisted.

    Thanks in advance.
     
  2. Offline

    Zombie_Striker

    @Reinified
    1. If you are just implementing this feature, flip those two variables around. It should be that the player's name is the stored value, and the UUID is a part of the path.
    2. If you have already used this system, and there are already servers storing player's data like this, then write a quick conversion tool. Get the configuration section "players" and then get the keys using getKeys(false). Then, check if the path is a UUID. If it is, treat it as such. However, if it is not, then it is the player's name, and you should swap the entries around so that the UUID is in the path. This is exactly why most of the Bukkit.getPlayer() methods are deprecated, to raise awareness that names should not be used to store anything.
    Once you do one of the two, just check if the config contains the player's UUID.
     
    Minesuchtiiii likes this.
  3. No, lets say that I do as you suggest and make the system use uuids.
    I get a player connecting who'se ip matches an IP in the config. How do I check the name of the person who'se ip is the same as the ip of the person connecting now?
     
  4. Offline

    Zombie_Striker

    @Reinified
    There is no need to check the names. Players can always change their names, while UUIDs will always be the same. Compare UUIDs instead.

    If you don't have the UUIDs for some players, you can use Bukkit.getOfflinePlayer(NAME).getUniqueID() to get their UUID.
     
Thread Status:
Not open for further replies.

Share This Page