Adding location of sign to the config

Discussion in 'Plugin Development' started by mouz_, Dec 2, 2015.

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

    mouz_

    Hi, I have problems with adding location of the sign to the config. Code:
    Code:
        @EventHandler
        public void onSignChange(final SignChangeEvent e) {
            Player p = e.getPlayer();
            if (!p.hasPermission("castlewars.admin")) {
                return;
            }
            final FileConfiguration config = this.getConfig();
            Block sign = e.getBlock();
            locations.add(sign.getLocation());
            config.set("signs", locations);
            config.options().copyDefaults(true);
            this.saveConfig();
        }
    Error:
    Code:
    [02:57:49] [Server thread/ERROR]: Could not pass event SignChangeEvent to CastleWars v1.0
    org.bukkit.event.EventException
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:302) ~[x.jar:git-PaperSpigot-1f7d532]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[x.jar:git-PaperSpigot-1f7d532]
        at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:509) [x.jar:git-PaperSpigot-1f7d532]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:494) [x.jar:git-PaperSpigot-1f7d532]
        at net.minecraft.server.v1_7_R4.PlayerConnection.a(PlayerConnection.java:1732) [x.jar:git-PaperSpigot-1f7d532]
        at net.minecraft.server.v1_7_R4.PacketPlayInUpdateSign.a(PacketPlayInUpdateSign.java:58) [x.jar:git-PaperSpigot-1f7d532]
        at net.minecraft.server.v1_7_R4.PacketPlayInUpdateSign.handle(PacketPlayInUpdateSign.java:78) [x.jar:git-PaperSpigot-1f7d532]
        at net.minecraft.server.v1_7_R4.NetworkManager.a(NetworkManager.java:189) [x.jar:git-PaperSpigot-1f7d532]
        at net.minecraft.server.v1_7_R4.ServerConnection.c(ServerConnection.java:81) [x.jar:git-PaperSpigot-1f7d532]
        at net.minecraft.server.v1_7_R4.MinecraftServer.v(MinecraftServer.java:795) [x.jar:git-PaperSpigot-1f7d532]
        at net.minecraft.server.v1_7_R4.DedicatedServer.v(DedicatedServer.java:307) [x.jar:git-PaperSpigot-1f7d532]
        at net.minecraft.server.v1_7_R4.MinecraftServer.u(MinecraftServer.java:643) [x.jar:git-PaperSpigot-1f7d532]
        at net.minecraft.server.v1_7_R4.MinecraftServer.run(MinecraftServer.java:549) [x.jar:git-PaperSpigot-1f7d532]
        at net.minecraft.server.v1_7_R4.ThreadServerApplication.run(SourceFile:628) [x.jar:git-PaperSpigot-1f7d532]
    Caused by: java.lang.NullPointerException
        at x.x.castlewars.Main.onSignChange(Main.java:292) ~[?:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_60]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_60]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_60]
        at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_60]
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:298) ~[x.jar:git-PaperSpigot-1f7d532]
        ... 13 more
    Line numer 292 is: "locations.add(sign.getLocation());"
    I use: public List<Location> locations = new ArrayList<Location>();
     
  2. Offline

    Scimiguy

    Either sign is null or locations is
     
  3. Offline

    Mrs. bwfctower

  4. Offline

    Scimiguy

    @Mrs. bwfctower
    Keeping in mind that this is the third time he's posted the same thing
     
  5. Offline

    eyamaz

    This thread is locked.

    @mouz_ after going through the last two threads you posted about signs, you have almost no knowledge of how java works. These forums are not for beginner java students. Please consult some basic tutorials and acquire the fundamentals of java programming knowledge before trying to program a bukkit plugin.
     
    mcdorli, timtower and Mrs. bwfctower like this.
Thread Status:
Not open for further replies.

Share This Page