Solved Problem with multiple strings

Discussion in 'Spigot Plugin Development' started by --TOMAS--, Jun 24, 2016.

  1. What am I doing wrong here?

    Code (Text):
        @EventHandler(priority=EventPriority.HIGHEST)
        public void setTabList(PlayerJoinEvent e){
            //variables
            Player player = e.getPlayer();
            String grupos = plugin.getChatConfig().getString("Groups.");
            //code
            if(player.hasPermission(plugin.getChatConfig().getString("Groups." + grupos + ".permission"))){
                player.setPlayerListName(ChatColor.translateAlternateColorCodes('&',
                        plugin.getChatConfig().getString("Groups.") + grupos + ".format")
                            .replaceAll("%player%", player.getName()));
            }else{
                player.setPlayerListName(ChatColor.translateAlternateColorCodes('&',
                        plugin.getChatConfig().getString("TabListPrefix.default")
                            .replaceAll("%player%", player.getName())));
            }
        }

    Code (Text):
    TabListPrefix:
        default: '&7%player%'
        messages:
            listNameSetted: '&aYour tab list name has been setted to: &r%nick%'
    Groups:
        user:
            permission: ultralobby.tlp.user
            format: '&7&lUSER: &7%player%'

    Code (Text):
    [11:28:50] [Server thread/ERROR]: Could not pass event PlayerJoinEvent to UltraLobby v4.0
    org.bukkit.event.EventException
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:310) ~[spigot-1.8.8.jar:git-Spigot-e4d4710-e1ebe52]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[spigot-1.8.8.jar:git-Spigot-e4d4710-e1ebe52]
        at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) [spigot-1.8.8.jar:git-Spigot-e4d4710-e1ebe52]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487) [spigot-1.8.8.jar:git-Spigot-e4d4710-e1ebe52]
        at net.minecraft.server.v1_8_R3.PlayerList.onPlayerJoin(PlayerList.java:298) [spigot-1.8.8.jar:git-Spigot-e4d4710-e1ebe52]
        at net.minecraft.server.v1_8_R3.PlayerList.a(PlayerList.java:157) [spigot-1.8.8.jar:git-Spigot-e4d4710-e1ebe52]
        at net.minecraft.server.v1_8_R3.LoginListener.b(LoginListener.java:144) [spigot-1.8.8.jar:git-Spigot-e4d4710-e1ebe52]
        at net.minecraft.server.v1_8_R3.LoginListener.c(LoginListener.java:54) [spigot-1.8.8.jar:git-Spigot-e4d4710-e1ebe52]
        at net.minecraft.server.v1_8_R3.NetworkManager.a(NetworkManager.java:231) [spigot-1.8.8.jar:git-Spigot-e4d4710-e1ebe52]
        at net.minecraft.server.v1_8_R3.ServerConnection.c(ServerConnection.java:148) [spigot-1.8.8.jar:git-Spigot-e4d4710-e1ebe52]
        at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:814) [spigot-1.8.8.jar:git-Spigot-e4d4710-e1ebe52]
        at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374) [spigot-1.8.8.jar:git-Spigot-e4d4710-e1ebe52]
        at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) [spigot-1.8.8.jar:git-Spigot-e4d4710-e1ebe52]
        at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [spigot-1.8.8.jar:git-Spigot-e4d4710-e1ebe52]
        at java.lang.Thread.run(Unknown Source) [?:1.8.0_91]
    Caused by: java.lang.IllegalArgumentException: Permission name cannot be null
        at org.bukkit.permissions.PermissibleBase.isPermissionSet(PermissibleBase.java:50) ~[spigot-1.8.8.jar:git-Spigot-e4d4710-e1ebe52]
        at ru.tehkode.permissions.bukkit.regexperms.PermissiblePEX.hasPermission(PermissiblePEX.java:135) ~[?:?]
        at org.bukkit.craftbukkit.v1_8_R3.entity.CraftHumanEntity.hasPermission(CraftHumanEntity.java:102) ~[spigot-1.8.8.jar:git-Spigot-e4d4710-e1ebe52]
        at me.FiesteroCraft.ultralobby.chatSystem.TabListPrefix.setTabList(TabListPrefix.java:65) ~[?:?]
        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.java:306) ~[spigot-1.8.8.jar:git-Spigot-e4d4710-e1ebe52]
        ... 14 more
    [11:28:51] [Server thread/INFO]: FiesteroCraft[/127.0.0.1:55516] logged in with entity id 112 at ([lobby]-237.0987059189149, 11.0, 771.54357389483)
    [11:28:53] [pool-17-thread-1/ERROR]: [PermissionsEx] Error occurred with PermissionsEx! Please post it to http://git.io/<html><body>You are being <a href="https://git.io/create">redirected</a>.</body></html>. Full error:
    java.lang.IllegalArgumentException: Permissions being checked must not be null!
        at org.apache.commons.lang.Validate.notNull(Validate.java:192)
        at ru.tehkode.permissions.bukkit.regexperms.PermissiblePEX.permissionValue(PermissiblePEX.java:227)
        at ru.tehkode.permissions.bukkit.regexperms.PermissiblePEX.hasPermission(PermissiblePEX.java:127)
        at org.bukkit.craftbukkit.v1_8_R3.entity.CraftHumanEntity.hasPermission(CraftHumanEntity.java:102)
        at me.FiesteroCraft.ultralobby.chatSystem.TabListPrefix.setTabList(TabListPrefix.java:65)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306)
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62)
        at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502)
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487)
        at net.minecraft.server.v1_8_R3.PlayerList.onPlayerJoin(PlayerList.java:298)
        at net.minecraft.server.v1_8_R3.PlayerList.a(PlayerList.java:157)
        at net.minecraft.server.v1_8_R3.LoginListener.b(LoginListener.java:144)
        at net.minecraft.server.v1_8_R3.LoginListener.c(LoginListener.java:54)
        at net.minecraft.server.v1_8_R3.NetworkManager.a(NetworkManager.java:231)
        at net.minecraft.server.v1_8_R3.ServerConnection.c(ServerConnection.java:148)
        at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:814)
        at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374)
        at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654)
        at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557)
        at java.lang.Thread.run(Unknown Source)
     
     
  2. Ever heard of reading the stacktrace?

    IllegalArgumentException: Permissions being checked must not be null!
    Permission name cannot be null
     
  3. Yes, i read it. But, i setted a permission in a config. ultralobby.tlp.user
     
  4. That is null as you check for

    if(player.hasPermission(plugin.getChatConfig().getString("Groups." + grupos
    and grupos == String grupos = plugin.getChatConfig().getString("Groups.");
    SO it will look for Groups.Groups.Permission
     
  5. Well, how do I get that you can add more grupos?
     
  6. getting configurationsection with getkeys();
    that will return everything in the ladder of Groups

    So if I have a config like:

    Groups:
    Group1:
    permission: "Something"
    Group2:
    permission: "Something"
    it will return group 1 and group 2
    then you can do;

    hasPermission(getConfig().getString("Groups." + key + ".permission");
    and the variable key is the configsection;

    for(String key : getconfigsection("Groups").getKeys(false)){
     
    • Like Like x 1
  7. Thanks :D
     
    • Like Like x 1
  8. Then it will be like that?
    Code (Text):
     for(String key : plugin.getChatConfig().getConfigurationSection("Groups").getKeys(false)){
                if(player.hasPermission(plugin.getChatConfig().getString("Groups." + key + ".permission"))){
                }
            }
     
  9. Correcto.