How to fix permissions?

Discussion in 'Plugin Development' started by NDUGAR, Apr 1, 2014.

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

    NDUGAR

    Hello, I am making a plugin which does not contain a command; this is a plugin which fires a firework in the air when a player logs in; but I am attempting to create a permission node. I have created the node in the yaml; it's bang.* but I require assistance in adding it into my code. I know what to do; but I do not know where... if(player.hasPermission("bang.*"){
    }
    Which I think is right... Someone help on where to put this :3 Thanks. Here is my code:
    Code:java
    1. package me.Schnel.EnterWithABang;
    2.  
    3.  
    4.  
    5. import org.bukkit.Bukkit;
    6.  
    7. import org.bukkit.Color;
    8.  
    9. import org.bukkit.FireworkEffect;
    10.  
    11. import org.bukkit.FireworkEffect.Type;
    12.  
    13. import org.bukkit.entity.Firework;
    14.  
    15. import org.bukkit.event.Listener;
    16.  
    17. import org.bukkit.plugin.java.JavaPlugin;
    18.  
    19. import org.bukkit.event.EventHandler;
    20.  
    21. import org.bukkit.event.player.PlayerJoinEvent;
    22.  
    23. import org.bukkit.inventory.meta.FireworkMeta;
    24.  
    25.  
    26.  
    27. public class Main extends JavaPlugin implements Listener {
    28.  
    29.  
    30.  
    31. public void onEnable(){
    32.  
    33. Bukkit.getServer().getPluginManager().registerEvents(this, this);
    34.  
    35. getLogger().info("Plugin Enabled");
    36.  
    37. }
    38.  
    39.  
    40.  
    41. public void onDisable(){
    42.  
    43. getLogger().info("Plugin Disabled");
    44.  
    45. }
    46.  
    47.  
    48.  
    49. @EventHandler
    50.  
    51. public void onPlayerJoin (final PlayerJoinEvent pje) {
    52.  
    53. Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable(){
    54.  
    55. public void run(){
    56.  
    57.  
    58.  
    59. Firework f = (Firework) pje.getPlayer().getWorld().spawn(pje.getPlayer().getLocation(), Firework.class);
    60.  
    61.  
    62.  
    63. FireworkMeta fm = f.getFireworkMeta();
    64.  
    65. fm.addEffect(FireworkEffect.builder()
    66.  
    67. .flicker(true)
    68.  
    69. .trail(true)
    70.  
    71. .with(Type.BALL)
    72.  
    73. .with(Type.BALL_LARGE)
    74.  
    75. .with(Type.STAR)
    76.  
    77. .with(Type.BURST)
    78.  
    79. .withColor(Color.OLIVE)
    80.  
    81. .withColor(Color.FUCHSIA)
    82.  
    83. .withFade(Color.LIME)
    84.  
    85. .withFade(Color.ORANGE)
    86.  
    87. .build());
    88.  
    89. fm.setPower(1);
    90.  
    91. f.setFireworkMeta(fm);
    92.  
    93. }
    94.  
    95. }, 10);
    96.  
    97.  
    98.  
    99. }
    100.  
    101.  
    102.  
    103. }
    104.  
    105.  


    So in summary, I would like it so that it only fires the firework if the player has the permission node 'bang.*'
     
  2. Offline

    1Rogue

    You should really have it as a specific node (bang.login-firework, etc), and then make that node a child node of bang.* in your plugin.yml

    As for checking, it's just Player#hasPermission("string");
     
Thread Status:
Not open for further replies.

Share This Page