Solved How to fix this!?

Discussion in 'Plugin Development' started by mine-care, Apr 25, 2014.

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

    mine-care

    Well i am taking a name of a item that is: Admin | fillpant and i want to remove spaces, Admin, | so i am left with only the fillpant wich is a players name. But when i do this:
    Code:java
    1. ChatColor.stripColor(e.getCurrentItem().getItemMeta().getDisplayName().replaceAll(" ", "").replaceAll("Admin", "").replaceAll("|", "").replaceAll(":", "")));

    and i send the string to a player, despit ethe replaceall, it still shows: Admin | fillpant
    How can i split it?

    PS: just tested the replace with null and gives out null pointer exception as expected.
    Edit: neather does replace with - and then replace - to null
     
  2. mine-care We don't support third party builds here (and that doesn't mean just switch to bukkit to get our support)
     
  3. Offline

    mine-care

    Ugh yes i opened wrong server, sending the right error one sec

    There the error:
    Code:
    [12:45:40 ERROR]: Could not pass event InventoryClickEvent to StaffAsist v1.0
    org.bukkit.event.EventException
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.ja
    va:320) ~[craftbukkit-1.7.2-R0.3.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.jav
    a:62) ~[craftbukkit-1.7.2-R0.3.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.j
    ava:486) [craftbukkit-1.7.2-R0.3.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.j
    ava:471) [craftbukkit-1.7.2-R0.3.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at net.minecraft.server.v1_7_R1.PlayerConnection.a(PlayerConnection.java
    :1361) [craftbukkit-1.7.2-R0.3.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at net.minecraft.server.v1_7_R1.PacketPlayInWindowClick.a(SourceFile:32)
    [craftbukkit-1.7.2-R0.3.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at net.minecraft.server.v1_7_R1.PacketPlayInWindowClick.handle(SourceFil
    e:10) [craftbukkit-1.7.2-R0.3.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at net.minecraft.server.v1_7_R1.NetworkManager.a(NetworkManager.java:146
    ) [craftbukkit-1.7.2-R0.3.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at net.minecraft.server.v1_7_R1.ServerConnection.c(SourceFile:134) [craf
    tbukkit-1.7.2-R0.3.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at net.minecraft.server.v1_7_R1.MinecraftServer.u(MinecraftServer.java:6
    55) [craftbukkit-1.7.2-R0.3.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at net.minecraft.server.v1_7_R1.DedicatedServer.u(DedicatedServer.java:2
    50) [craftbukkit-1.7.2-R0.3.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at net.minecraft.server.v1_7_R1.MinecraftServer.t(MinecraftServer.java:5
    45) [craftbukkit-1.7.2-R0.3.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at net.minecraft.server.v1_7_R1.MinecraftServer.run(MinecraftServer.java
    :457) [craftbukkit-1.7.2-R0.3.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at net.minecraft.server.v1_7_R1.ThreadServerApplication.run(SourceFile:6
    17) [craftbukkit-1.7.2-R0.3.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    Caused by: java.lang.NullPointerException
            at java.util.regex.Matcher.appendReplacement(Unknown Source) ~[?:1.7.0_5
    1]
            at java.util.regex.Matcher.replaceAll(Unknown Source) ~[?:1.7.0_51]
            at java.lang.String.replaceAll(Unknown Source) ~[?:1.7.0_51]
            at me.fillpant.staffasist.StaffAsist.ice(StaffAsist.java:108) ~[?:?]
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0
    _51]
            at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0
    _51]
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1
    .7.0_51]
            at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.7.0_51]
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.ja
    va:318) ~[craftbukkit-1.7.2-R0.3.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            ... 13 more
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  4. mine-care Sure you did.

    Two things: If an item doesn't have a display name or item meta, you'll get an NPE (like that) - check if there is one before assuming there is. Secondly, use replace() instead of replaceAll(). replaceAll() is for regex.
     
  5. Offline

    mine-care

    on it, and yes it has name, it is given back in the code <this is a GUI inventory enviroment>
    ill return with results

    :O worked! thx a lot!

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  6. Offline

    Jade

    Locked. We do not support unofficial builds.
     
Thread Status:
Not open for further replies.

Share This Page