Trying to write to file using formatter...

Discussion in 'Plugin Development' started by randomman159, Sep 5, 2011.

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

    randomman159

    So here is a snippet of my code:

    Code:
    public static void OpenFile(Player player)
        {
            try
            {
                f = new Formatter(player.getName() + ".txt");
            }
            catch(Exception e)
            {
                System.out.println("error present");
            }
        }
    
        public static void SetSpawn(Player player)
        {
            f.format("%s%d%d%d", player.getName(), player.getLocation().getX(), player.getLocation().getY(), player.getLocation().getZ());
        }
    
        public static void closeFile()
        {
            f.close();
        }

    The functions are called in the order shown.

    However i am getting errors:


    23:56:36 [SEVERE] Could not pass event PLAYER_INTERACT to AdventureMapControls
    java.util.IllegalFormatConversionException: d != java.lang.Double
    at java.util.Formatter$FormatSpecifier.failConversion(Unknown Source)
    at java.util.Formatter$FormatSpecifier.printInteger(Unknown Source)
    at java.util.Formatter$FormatSpecifier.print(Unknown Source)
    at java.util.Formatter.format(Unknown Source)
    at java.util.Formatter.format(Unknown Source)
    at Randomman159.AdventureMapControls.SLAPI.SetSpawn(SLAPI.java:40)
    at Randomman159.AdventureMapControls.AMCPlayerListener.onPlayerInteract(
    AMCPlayerListener.java:54)
    at org.bukkit.plugin.java.JavaPluginLoader$10.execute(JavaPluginLoader.j
    ava:307)
    at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.jav
    a:58)
    at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.j
    ava:321)
    at org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEven
    t(CraftEventFactory.java:168)
    at net.minecraft.server.ItemInWorldManager.interact(ItemInWorldManager.j
    ava:210)
    at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:552)
    at net.minecraft.server.Packet15Place.a(SourceFile:57)
    at net.minecraft.server.NetworkManager.b(NetworkManager.java:226)
    at net.minecraft.server.NetServerHandler.a(NetServerHandler.java:84)
    at net.minecraft.server.NetworkListenThread.a(SourceFile:105)
    at net.minecraft.server.MinecraftServer.h(MinecraftServer.java:451)
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:361)
    at net.minecraft.server.ThreadServerApplication.run(SourceFile:422)

    Anyone have any idea why this may be happening?
     
  2. Offline

    Acrobot

  3. Offline

    randomman159

    haha yeah i found that f thing just after i posted the topic (but then had to go to bed). But thanks anyway, and yes thankyou even more for the .getBlockX thing, that's much better.
     
Thread Status:
Not open for further replies.

Share This Page