Hello, this is a simple API for the UUID system. API: http://bit.ly/UUIDApi Credit goes to Yive for making MineSkin and the website API, and DenialMC for making the core getUUIDsAsString() method for me. Temporary credit goes to: CraftThatBlock for the getName() method - but this will be changed to be using MineSkin once Yive has updated it. Example use: Code: public class Main extends JavaPlugin { public void onEnable() { this.getCommand("kills").setExecutor(this); } public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { if (cmd.getName().equals("kills")) { if (args.length == 1) { String strTargetName = args[0]; String targetUUID = UUIDApi.getUUIDAsString(strTargetName); if (targetUUID != null) { int playerKills = this.getConfig().contains(targetUUID) ? this.getConfig().getInt(targetUUID) : 0; sender.sendMessage(ChatColor.GOLD + "Kills: " + playerKills); } else { sender.sendMessage(ChatColor.RED + "That player does not exist."); } } else { sender.sendMessage(ChatColor.GOLD + "UUIDApi v1.0.1 example"); } return true; } return false; } } Changelog:
Your example will freeze the server's main thread until UUIDFetcher is done fetching the data from mojang.
How-so? I mean, if it's fetching the data, it would only take a while to send the message "Kills:", other things won't matter, would they? Also, to fix this, would I have to create a new Thread? I'll do some testing, thanks for the notice though. Okay, so I did some testing blablubbabc and when the server starts, I made it fetch UUID from my username and a few others, and it did pause for 3 seconds. However, when I joined and typed /kills KingFaris10 - I could still do everything and type commands but the messages from the commands (and /kills) didn't show up until it was loaded. I'm getting this error every second time I type the command: That's strange. I reloaded the server and the error's gone... But if I reload again a few times or so it comes back, seems like the plugin can't fetch data at some times. EDIT by Moderator: merged posts, please use the edit button instead of double posting.
This however will freeze as well if the server has to lookup the uuid via the mojang lookup service. Though I think it caches the result of that lookup then for about 1 month on the server, so requests for the same name go faster afterwards.. Also I am not sure if this method works on both, offline and online mode servers, equally well because I am not sure if it will return the offline mode uuid for a player on an offline mode server or looks up an online mode uuid for the given name.. And on online mode servers it might return wrong results as well, for example if the mojang services are temporary not reach-able: it might then return an offline mode uuid instead, which, on an online mode server, is useless for persistent storage or lookup at that moment..
It works for both, but I won't be using this method until Bukkit have improved their system for it as they said they would in future versions.
On line 12 you could have used "int playerKills = this.getConfig.getInt(targetUUID,0);" Bukkit's API for configurations include returning default values if it can't find what you are looking for.
I'm using this API for a plugin I'm making now, slightly modified to DRY (don't repeat yourself). But I'm getting an error. Code: [14:53:07 WARN]: Unexpected token END OF FILE at position 0. [14:53:07 WARN]: at org.json.simple.parser.JSONParser.parse(Unknown Sourc e) [14:53:07 WARN]: at org.json.simple.parser.JSONParser.parse(Unknown Sourc e) The plugin does work fine, I'm just getting this error in the console :C
Updated to v1.0.1! All bugs have been fixed and it now uses MineSkin's API thanks to Yive! It has almost 100% uptime compared to Mojang's UUID API server. Note: getName() coming soon!
Updated to v1.0.2! Added a "isSkin" option as skins do not take dashes and so when returning the UUID, the dashes must be removed. Also made preparations for the new MineSkin multiple-name API. Latest update code changes: https://gist.github.com/KingFaris10/5ce37e3e6cab38790901/revisions
KingFaris11 I know this is completely off topic from this thread but I love your KingKits plugin, when I had zero java experience I always used your plugin since I owned a kitPvP server with 20-40 active players, amazing plugin xD
Yeah, I realised that, getName() wasn't coded by me but was taken from an open source (SwordPvP). I'll try working something out with it, the problem is, Yive's API only allows single UUIDs for now, and not multiple (as a list).
This does rely on Mojang's servers because the API you are using relies on it. Sorry to burst your bubble.
"bubble" It was misleading, but not "trollish". Anyway, I realised that almost as soon as I posted the latest version, this project/class is just abandoned therefore I didn't change the title/desc.