Solved Teleport Gui

Discussion in 'Spigot Plugin Development' started by MadMaxCookie, May 11, 2016.

  1. Hello so I have a teleport at gui :D
    then if they clicked that this will happen

    Code (Java):
    // this is inventory click event
    // p = (Player) e.getWhoClicked();
            if(e.getCurrentItem().getItemMeta().getDisplayName().contains(plugin.colorize("&b&lTeleport"))) {
                e.setCancelled(true);
                p.closeInventory();
                p.playSound(p.getLocation(), Sound.ENTITY_CHICKEN_EGG, 10, 10);
                String arg0 = plugin.getConfig().getString(p.getName() + ".Married");

                // this is the line 118 vv
                Player target = Bukkit.getServer().getPlayer(arg0);
                if(target == null) {
                    p.sendMessage(plugin.colorize("&8[&6RelationShip&8] &e>> &4Your partner is offline"));
                    return;
                }
                p.teleport(target);
                p.sendMessage(plugin.colorize("&8[&6RelationShip&8] &e>> &aSuccessfully teleported to your partner"));
                return;
            }
    this is my error
    Code (Java):
    [16:31:40 ERROR]: Could not pass event InventoryClickEvent to NoPermission v1.0
    org.bukkit.event.EventException
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.ja
    va:310) ~[spigot-latest.jar:git-Spigot-e6f93f4-ed60c01]
            at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.jav
    a:62) ~[spigot-latest.jar:git-Spigot-e6f93f4-ed60c01]
            at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.j
    ava:502) [spigot-latest.jar:git-Spigot-e6f93f4-ed60c01]
            at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.j
    ava:487) [spigot-latest.jar:git-Spigot-e6f93f4-ed60c01]
            at net.minecraft.server.v1_9_R1.PlayerConnection.a(PlayerConnection.java
    :1852) [spigot-latest.jar:git-Spigot-e6f93f4-ed60c01]
            at net.minecraft.server.v1_9_R1.PacketPlayInWindowClick.a(SourceFile:33)
    [spigot-latest.jar:git-Spigot-e6f93f4-ed60c01]
            at net.minecraft.server.v1_9_R1.PacketPlayInWindowClick.a(SourceFile:10)
    [spigot-latest.jar:git-Spigot-e6f93f4-ed60c01]
            at net.minecraft.server.v1_9_R1.PlayerConnectionUtils$1.run(SourceFile:1
    3) [spigot-latest.jar:git-Spigot-e6f93f4-ed60c01]
            at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [
    ?:1.8.0_91]
            at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_91]
            at net.minecraft.server.v1_9_R1.SystemUtils.a(SourceFile:45) [spigot-lat
    est.jar:git-Spigot-e6f93f4-ed60c01]
            at net.minecraft.server.v1_9_R1.MinecraftServer.D(MinecraftServer.java:7
    21) [spigot-latest.jar:git-Spigot-e6f93f4-ed60c01]
            at net.minecraft.server.v1_9_R1.DedicatedServer.D(DedicatedServer.java:4
    00) [spigot-latest.jar:git-Spigot-e6f93f4-ed60c01]
            at net.minecraft.server.v1_9_R1.MinecraftServer.C(MinecraftServer.java:6
    60) [spigot-latest.jar:git-Spigot-e6f93f4-ed60c01]
            at net.minecraft.server.v1_9_R1.MinecraftServer.run(MinecraftServer.java
    :559) [spigot-latest.jar:git-Spigot-e6f93f4-ed60c01]
            at java.lang.Thread.run(Unknown Source) [?:1.8.0_91]
    Caused by: java.lang.IllegalArgumentException: Name cannot be null
            at org.apache.commons.lang.Validate.notNull(Validate.java:192) ~[spigot-
    latest.jar:git-Spigot-e6f93f4-ed60c01]
            at org.bukkit.craftbukkit.v1_9_R1.CraftServer.getPlayer(CraftServer.java
    :407) ~[spigot-latest.jar:git-Spigot-e6f93f4-ed60c01]
            at org.madmaxcookie.GUI.onClick(GUI.java:118) ~[?:?]
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0
    _91]
            at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0
    _91]
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1
    .8.0_91]
            at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_91]
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.ja
    va:306) ~[spigot-latest.jar:git-Spigot-e6f93f4-ed60c01]
            ... 15 more
     
  2. MiniDigger

    Supporter

     
  3. thanks for reminding sorry for your time did this

    Code (Java):
    if(e.getCurrentItem().getItemMeta().getDisplayName().contains(plugin.colorize("&b&lTeleport"))) {
                e.setCancelled(true);
                p.closeInventory();
                p.playSound(p.getLocation(), Sound.ENTITY_CHICKEN_EGG, 10, 10);
                String arg0 = plugin.getConfig().getString(p.getName() + ".Married");
                if(arg0 != null) {
                    Player target = Bukkit.getServer().getPlayer(arg0);
                if(target == null) {
                    p.sendMessage(plugin.colorize("&8[&6RelationShip&8] &e>> &8: &4Your partner is offline"));
                    return;
                }
                p.teleport(target);
                p.sendMessage(plugin.colorize("&8[&6RelationShip&8] &e>>&8 : &aSuccessfully teleported to your partner"));
                return;
                }else {
                    p.sendMessage(plugin.colorize("&8[&6RelationShip&8] &eError >> &8: &4You must marry someone"));
                }
                return;
            }
     
  4. I think the problem is on the config, here:
    Code (Text):
    String arg0 = plugin.getConfig().getString(p.getName() + ".Married");
    Becouse you here test if the player is null:
    Code (Text):
                if(target == null) {
                    p.sendMessage(plugin.colorize("&8[&6RelationShip&8] &e>> &4Your partner is offline"));
                    return;
                }
    And you don´t know here:
    Code (Text):
    String arg0 = plugin.getConfig().getString(p.getName() + ".Married");
    if the arg0 is null, test the null after this line:
    Code (Text):
    String arg0 = plugin.getConfig().getString(p.getName() + ".Married");
    I tink this is your problem :D
     
  5. MiniDigger

    Supporter

    yep, that should work. did you see how easy it is to read your own stacktraces? Every info you need it there ^^
     
  6. you're really late :D
     
  7. yeah just learned how to read stacktraces now :D