Permissions help?

Discussion in 'Plugin Development' started by Flipsen, Nov 23, 2011.

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

    Flipsen

    Hello!
    Can anyone help me with permissions for my plugin please? :)

    The code:
    Code:
    package me.Flipsen.iHelp.plugin;
    
    import java.io.File;
    import java.util.logging.Logger;
    import org.bukkit.plugin.Plugin;
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class iHelp extends JavaPlugin {
    
        Plugin p;
    
        static File folder = new File("plugins" + File.separator + "iHelp");
        static File file = new File("plugins" + File.separator + "iHelp"
                + File.separator + "message.txt");
        Logger log = Logger.getLogger("Minecraft");
    
        @Override
        public void onDisable() {
    
            log.info("[iHelp] Disabled!");
    
        }
    
        @Override
        public void onEnable() {
    
            getCommand("help").setExecutor(new MAEX());
    
            log.info("[iHelp] Enabled!");
    
            if (!folder.exists()) {
                folder.mkdir();
            }
    
            if (!file.exists()) {
                try {
                    file.createNewFile();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
    
        }
    
    }
    Code:
    package me.Flipsen.iHelp.plugin;
    
    import java.io.File;
    import java.util.Scanner;
    
    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    
    public class MAEX implements CommandExecutor {
        public static String scan = "";
    
        @Override
        public boolean onCommand(CommandSender sender, Command cmd,
                String commandLabel, String[] args) {
            if (commandLabel.equalsIgnoreCase("help")) {
                File file = new File("plugins" + File.separator
                        + "iHelp" + File.separator + "message.txt");
                try {
                    Scanner sc = new Scanner(file);
                    while (sc.hasNext()) {
                        if (!sc.hasNextLine()) {
                            scan = sc.next();
                            sender.sendMessage(ChatColor.GOLD + scan
                                    + ChatColor.WHITE);
                            return true;
                        } else {
                            while (sc.hasNextLine()) {
                                scan = sc.nextLine();
                                sender.sendMessage(ChatColor.GOLD + scan
                                        + ChatColor.WHITE);
                            }
                            return true;
                        }
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            return false;
        }
    }
    Please help me! :D

    -flipsen
     
  2. Offline

    halley

    So, what's wrong? What do you need help with?
     
  3. Offline

    Flipsen

    I need help to add permissions to the help command.
     
  4. Offline

    Flipsen

  5. Offline

    Taco

    if(sender instanceof Player)
    {
    Player player = (Player) sender;​
    if(player.hasPermission("permission.node")​
    {​
    //Do stuff​
    }​
    }
     
Thread Status:
Not open for further replies.

Share This Page