Crazy issue with UUID

Discussion in 'Plugin Development' started by DerFreakey, Aug 8, 2015.

Thread Status:
Not open for further replies.
  1. Hello Guys,
    actually I am working on a ticket management plugin. I have a method, that saves all open tickets to all file, when the plugin stops. This one works fine.
    But I also have a method, when the server starts that all saved tickets are being loaded.

    And there I have a really crazy bug... I get a invalid argument exception that tells me that my provided uuid string is null. The point is, that this string isn't null, so if I print out the cfg.getString("Ti.Creator"); i get the right uuid, but I can't parse it to an uuid object because it tells me that this string is null.

        public Ticket loadTicket(File file) {
            FileConfiguration cfg = YamlConfiguration.loadConfiguration(file);
            String uuid = cfg.getString("Ti.Creator");
            UUID creator = UUID.fromString(uuid);
            String title = cfg.getString("Ti.Title");
            int id = cfg.getInt("Ti.Ticket ID");
            TicketStatus status = TicketStatus.valueOf(cfg.getString("Ti.Status"));
            String timestamp = cfg.getString("Ti.Timestamp");
            UUID assignee = UUID.fromString(cfg.getString("Ti.Assignee"));
            ArrayList<String> log = (ArrayList<String>) cfg.get("Ti.Log");
            String loc = cfg.getString("Ti.Location");
            Location location = fileutil.deserializeLocation(loc);
            Ticket ti =  new Ticket(Bukkit.getPlayer(creator), title, timestamp, Bukkit.getPlayer(assignee), location, log, status, id);
            return ti;
  2. Offline


    @DerFreakey are you saving the uuid as a string? uuid#toString()
  3. Yes, I do.

    I tried to print it out with System.out.println and it gave me the exact uuid: e4b4e60e-ec62-4e1f-acf0-dd4e0d6bfa1a that was in the file.

    <Edited by bwfcwalshy: Merged posts, please use the edit button rather than double posting.>
    Last edited by a moderator: Aug 9, 2015
  4. Offline



    Whatever is being implicitly converted from a String at on line 79 is null.

    Seems pretty unambigious to me.
  5. I know, I'm trying to parse a String to an UUID. But when I print out the String, it just shows me the string and not null.. This doesn't make any sense...
  6. Offline


  7. Code:
        public void saveTicket(Ticket ticket, ArchiveType type) {
            String timestamp = ticket.getTimeStamp();
            String title = ticket.getTitle();
            Player assignee = ticket.getAssignee();
            Player creator = ticket.getCreator();
            String status = ticket.getStatus().name();
            Location loc = ticket.getLocation();
            int id = ticket.getID();
            ArrayList<String> log = ticket.getLog();
            File file = null;
            PrintStream writer = null;
            if(type == ArchiveType.ARCHIVED) {
                file = new File("plugins/TicketManager/archive/ti_"+id+".ticket");
                try {
                    writer = new PrintStream(file);
                } catch (FileNotFoundException e) {
                    // TODO Auto-generated catch block
            if(type == ArchiveType.ARCHIVED) {
                writer.println("TicketManager by Freakey | Archived ticket");
                writer.println("Title: "+title);
                writer.println("Creator: "+creator.getName());
                writer.println("Ticket ID: "+id);
                writer.println("Status: "+status);
                writer.println("Timestamp: "+timestamp);
                for(String s : fileutil.archiveLocation(loc)) {
                if(assignee == null) {
                    writer.println("Assignee: no one");
                } else {
                    writer.println("Assignee: "+assignee.getName());
                writer.println(" Ticket Log");
                for(String line : log) {
                    line = ChatColor.stripColor(line);
            if(type == ArchiveType.TEMP) {
                File fi= new File("plugins/TicketManager/temp", "temp_"+id+".yml");
                FileConfiguration cfg = YamlConfiguration.loadConfiguration(fi);
                cfg.set("Ti.Title", title);
                cfg.set("Ti.Creator", creator.getUniqueId().toString());
                cfg.set("Ti.Ticket ID", id);
                cfg.set("Ti.Status", status);
                cfg.set("Ti.Location", fileutil.serializeLocation(loc));
                cfg.set("Ti.Timestamp", timestamp);
                if(assignee == null) {
                    cfg.set("Ti.Assignee", "null");
                } else {
                    cfg.set("Ti.Assignee", assignee.getUniqueId());
                for(int i = 0; i < log.size(); i++) {
                  log.set(i, log.get(i).replace("§", "[$_]"));
                cfg.set("Ti.Log", log);
                try {
                } catch (IOException e) {
                    // TODO Auto-generated catch block
    The ArchiveType.ARCHIVED part is not needed, this one is one-way and works.

    @mythbusterma @leet4044

    Well, I fixed it.. I'll just don't use the player's uuid. I'll use his name, it will work, because the things are only saved, when the server is down.

    <Edited by bwfcwalshy: Merged posts, please use the edit button rather than triple posting.>
    Last edited by a moderator: Aug 9, 2015
Thread Status:
Not open for further replies.

Share This Page