player.hasPermission() not working

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

Thread Status:
Not open for further replies.
  1. My if()player.hasPermission() does not work :( Any ideas why. I think the code should be correct... Whats wrong?
    @EventHandler
    public void onPlayerMove(PlayerMoveEvent event) {
    Player player = event.getPlayer();
    Location loc = player.getLocation();
    loc.setY(loc.getY() - 1.0D);
    World world = player.getWorld();
    Block b = world.getBlockAt(loc);
    if (b.getType() != Material.STAINED_CLAY || b.getType() != Material.AIR || b.getType() != Material.getMaterial(98)) {
    if(player.hasPermission("risingempire.move")) {

    Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "warp parkour " + player.getName());
    Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "manudelp " + player.getName() + " risingempire.move");
    }
    }
    }
    }
    Please help me!
     
  2. What happens?
    Try to make an else statement and make it print something
     
  3. Put debug messages into your event to see if it's even getting to your permission check.
     
    • Agree Agree x 1
  4. Exactly nothing the plugin doesn't recoginze my if statement... The plugin runs forward like the if wouldn't be there
     
  5. My plugin.yml:

    name: RisingEmpire
    main: plugin.zozidalom.risingempire.Main
    version: 1.0
    depend: [TitleAPI]
    depend: [BarAPI]


    commands:
    geld:
    description: Jog vesz

    permissions:
    risingempire.move:
    description: Test
     
  6. Did you register your permission?
     
  7. O do I have to do it? :) Well I haven't I am only a beginner dev. How can I do that?
     
  8. In your onEnable()
    Code (Text):

            PluginManager pm = Bukkit.getPluginManager();
            Permission p = new Permission("your.permission");
            pm.addPermission(p);
    That's how I do it anyway. :)
     
    • Like Like x 1
  9. WTF
    11.05 16:28:32 [Server] ERROR Error occurred while enabling RisingEmpire v1.0 (Is it up to date?) 11.05 16:28:32 [Server] INFO java.lang.IllegalArgumentException: The permission risingempire.move is already defined! 11.05 16:28:32 [Server] INFO at org.bukkit.plugin.SimplePluginManager.addPermission(SimplePluginManager.java:599) ~[papircsap.jar:git-PaperSpigot-"8b18730"] 11.05 16:28:32 [Server] INFO at plugin.zozidalom.risingempire.Main.onEnable(Main.java:30) ~[?:?] 11.05 16:28:32 [Server] INFO at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:321) ~[papircsap.jar:git-PaperSpigot-"8b18730"] 11.05 16:28:32 [Server] INFO at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:332) [papircsap.jar:git-PaperSpigot-"8b18730"] 11.05 16:28:32 [Server] INFO at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:404) [papircsap.jar:git-PaperSpigot-"8b18730"] 11.05 16:28:32 [Server] INFO at com.rylinaux.plugman.util.PluginUtil.load(PluginUtil.java:363) [PlugMan.jar:?] 11.05 16:28:32 [Server] INFO at com.rylinaux.plugman.util.PluginUtil.load(PluginUtil.java:316) [PlugMan.jar:?] 11.05 16:28:32 [Server] INFO at com.rylinaux.plugman.util.PluginUtil.reload(PluginUtil.java:377) [PlugMan.jar:?] 11.05 16:28:32 [Server] INFO at com.rylinaux.plugman.command.ReloadCommand.execute(ReloadCommand.java:122) [PlugMan.jar:?] 11.05 16:28:32 [Server] INFO at com.rylinaux.plugman.PlugManCommandHandler.onCommand(PlugManCommandHandler.java:95) [PlugMan.jar:?] 11.05 16:28:32 [Server] INFO at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) [papircsap.jar:git-PaperSpigot-"8b18730"] 11.05 16:28:32 [Server] INFO at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:143) [papircsap.jar:git-PaperSpigot-"8b18730"] 11.05 16:28:32 [Server] INFO at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchCommand(CraftServer.java:666) [papircsap.jar:git-PaperSpigot-"8b18730"] 11.05 16:28:32 [Server] INFO at net.minecraft.server.v1_8_R3.PlayerConnection.handleCommand(PlayerConnection.java:1189) [papircsap.jar:git-PaperSpigot-"8b18730"] 11.05 16:28:32 [Server] INFO at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:1001) [papircsap.jar:git-PaperSpigot-"8b18730"] 11.05 16:28:32 [Server] INFO at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:45) [papircsap.jar:git-PaperSpigot-"8b18730"] 11.05 16:28:32 [Server] INFO at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:1) [papircsap.jar:git-PaperSpigot-"8b18730"] 11.05 16:28:32 [Server] INFO at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13) [papircsap.jar:git-PaperSpigot-"8b18730"] 11.05 16:28:32 [Server] INFO at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_77] 11.05 16:28:32 [Server] INFO at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_77] 11.05 16:28:32 [Server] INFO at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:44) [papircsap.jar:git-PaperSpigot-"8b18730"] 11.05 16:28:32 [Server] INFO at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:774) [papircsap.jar:git-PaperSpigot-"8b18730"] 11.05 16:28:32 [Server] INFO at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:378) [papircsap.jar:git-PaperSpigot-"8b18730"] 11.05 16:28:32 [Server] INFO at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:713) [papircsap.jar:git-PaperSpigot-"8b18730"] 11.05 16:28:32 [Server] INFO at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:616) [papircsap.jar:git-PaperSpigot-"8b18730"] 11.05 16:28:32 [Server] INFO at java.lang.Thread.run(Unknown Source) [?:1.8.0_77] 11.05 16:28:32 [Server] INFO [RisingEmpire] Disabling RisingEmpire v1.0
     
  10. Instead of using plugman, try to /restart
     
  11. MiniDigger

    Supporter

    use the code tags pls...
    there is your error, go fix that (don't register your perms via code if you have done it in the plugin.yml already)
    and don't use plugman or do reloads, they are bad
     
  12. Tryed to restart the full server but still nothing
    My full plugin: magyarpluginok.pe.hu/RisingEmpire.jar
     
  13. Can I see your plugin.yml please?
     
  14. Code (Text):
    Permission permName = new Permission("Your permission")
     
    • Optimistic Optimistic x 1
  15. Have you read the thread? He's already tried this.
     
    • Agree Agree x 1
  16. I am not 100% sure but it should work even if it is not in your plugin.yml?
     
    • Agree Agree x 1
  17. You don't need to register permissions...
     
    • Agree Agree x 4
  18. My only guess is that you are using the normal Spigot.jar which the server is supposed to run off. Use BuildTools to get the one for developing.
     
Thread Status:
Not open for further replies.