YamlConfiguration Randomly Broke?

Discussion in 'Plugin Development' started by jkcclemens, Dec 10, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    jkcclemens

    Now, from what I've been searching on Google, no one seems to have a fix for this. I cannot figure out what I'm doing wrong. I've got a playerListener set on PLAYER_JOIN to log someone's IP address so it can be recalled via command regardless of whether or not the player is online. That being said, it was working flawlessly last night; however, this morning it completely stopped working. It won't even give me a line number, but I'm almost certain that it's this:

    Code:
    
    public void onPlayerJoin(PlayerJoinEvent event) {
    		File datafile = new File(plugin.getDataFolder() + "/userdata/"
    				+ event.getPlayer().getName() + ".yml");
    		if (!datafile.exists()) {
    			log.info("[RoyalCommands] Creating userdata for user "
    					+ event.getPlayer().getName() + ".");
    			try {
    				datafile.createNewFile();
    				FileWriter fstream = new FileWriter(plugin.getDataFolder()
    						+ "/userdata/" + event.getPlayer().getName() + ".yml");
    				BufferedWriter out = new BufferedWriter(fstream);
    				out.write("name: " + event.getPlayer().getName() + "\n");
    				out.write("dispname: " + event.getPlayer().getDisplayName()
    						+ "\n");
    
    				out.write("ip: " + event.getPlayer().getAddress().getAddress()
    						+ "\n");
    				out.close();
    				log.info("[RoyalCommands] Userdata creation finished.");
    			} catch (Exception e) {
    				log.severe("[RoyalCommands] Could not create userdata for user "
    						+ event.getPlayer().getName() + "!");
    				log.severe(e.getMessage());
    			}
    		} else {
    			log.info("[RoyalCommands] Updating the IP for "
    					+ event.getPlayer().getName() + ".");
    			File p1confl = new File(plugin.getDataFolder() + "/userdata/"
    					+ event.getPlayer().getName() + ".yml");
    			FileConfiguration p1conf = YamlConfiguration
    					.loadConfiguration(p1confl);
    			p1conf.set("ip", event.getPlayer().getAddress().getAddress());
    			p1conf.set("dispname", event.getPlayer().getDisplayName());
    		}
    	}
    
    Which gives me:

    Code:
    12:54:24 [INFO] [RoyalCommands] Updating the IP for SomePlayer.
    12:54:24 [SEVERE] Could not pass event PLAYER_JOIN to RoyalCommands
    java.lang.IllegalArgumentException: Cannot store /12.34.56.789 into YamlConfiguration[path='', root='YamlConfiguration'], unsupported class
            at org.bukkit.configuration.MemorySection.prepForStorage(MemorySection.java:908)
            at org.bukkit.configuration.MemorySection.set(MemorySection.java:193)
            at tk.royalcraf.royalcommands.RoyalCommandsPlayerListener.onPlayerJoin(Unknown Source)
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:265)
            at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:58)
            at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:339)
            at net.minecraft.server.ServerConfigurationManager.c(ServerConfigurationManager.java:129)
            at net.minecraft.server.NetLoginHandler.b(NetLoginHandler.java:113)
            at net.minecraft.server.NetLoginHandler.a(NetLoginHandler.java:80)
            at net.minecraft.server.Packet1Login.a(SourceFile:59)
            at net.minecraft.server.NetworkManager.b(NetworkManager.java:226)
            at net.minecraft.server.NetLoginHandler.a(NetLoginHandler.java:46)
            at net.minecraft.server.NetworkListenThread.a(SourceFile:94)
            at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:527)
            at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:425)
            at net.minecraft.server.ThreadServerApplication.run(SourceFile:457)
    
    Code:
    12:58:19 [INFO] This server is running Craftbukkit version git-Bukkit-1.8.1-R4-99-g893d9d9-b1572jnks (MC: 1.0.1) (Implementing API version 1.0.0-R1-SNAPSHOT)
    I don't understand how it went from working perfectly to not working at all.

    I'm thinking this is an obvious problem, but I've been over this thing so many times for the past couple of hours, and I don't have a clue as to what is causing this.

    In case it helps you, I'm running on Debian 6 64bit.

    Any clue?

    EDIT --
    The plugin is built with the latest release of Bukkit (1064).

    I'm using CB 1572 on my server, and Bukkit 1064 for the plugin.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 22, 2016
  2. Try stripping off the slash of the IP address, it's used as escape sequence, so it might be a problem when it's there.
     
    jkcclemens likes this.
  3. Offline

    jkcclemens

    By the gods, it worked!

    In case anyone has the same problem:
    Code:
    FileConfiguration p1conf = YamlConfiguration
    .loadConfiguration(p1confl);
    String playerip = event.getPlayer().getAddress().getAddress().toString();
    playerip = playerip.replace("/", "");
    p1conf.set("ip", playerip);
    
    That's the fix.

    Pandemoneus, I never would've thought the slash was a problem.
     
Thread Status:
Not open for further replies.

Share This Page