Solved Level Settings

Discussion in 'Spigot Plugin Development' started by Xanmanxan, May 22, 2016.

  1. I've made a level system for my server that uses UUID's for it. But I am confused on how to convert a UUID to the players name so when a person does /test level xanmanxan 1 it set's xanmanxan's level to level 1. but then I want it to save to the config as a UUID

    Code (Text):
                if (args[0].equalsIgnoreCase("level")) {
                    if (args.length == 0) {
                        p.sendMessage("§b§lPvp§8 »§7 Please enter a integer level");
                        return true;
                    }
                    Player target = Bukkit.getServer().getPlayer(args[0]);
                    if (target == null) {
                    p.sendMessage("§b§lPvp§8 »§7 Player is §coffline§7, player is required to be §aonline§7!");
                   return true;
                }
                       plugin.getConfig().set("PlayerData."+ p.getUniqueId() + ".level", args[1]);
            }
     
  2. You can use Bukkit#getPlayer to get a player from a uuid and then get the name of that player.
     
  3. Change
    Code (Java):
    plugin.getConfig().set("PlayerData."+ p.getUniqueId() + ".level", args[1]);
    to
    Code (Java):
    plugin.getConfig().set("PlayerData."+ target.getUniqueId() + ".level", args[1]);
     
    • Like Like x 1
  4. Problem Solved -----------