Please help me with the code.

Discussion in 'Plugin Development' started by fr0ziz, Oct 17, 2017.

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

    fr0ziz

    Hello, i've got a problem with the permissions. When i add a permission node, i fixed in plugin.yml and everything, but when i put it on my server, everyone can access it without having the permission. I fix the permissions in both plugin.yml and the code itself. remember, im new at coding and im not that good! Here you got the code:
    Code:
    package me.fr0ziz.xforceopme;
    
    import org.bukkit.ChatColor;
    import org.bukkit.Sound;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class Main extends JavaPlugin {
      
        public void onEnable(){
            System.out.println("xForceOPME -> Enabled.");
        }
    
      
        @Override
        public boolean onCommand(CommandSender sender, Command command, String cmdlabel, String[] args) {
            if(cmdlabel.equalsIgnoreCase("opme"));
            if (sender instanceof Player){
                Player p = (Player) sender;
          
                if(p.hasPermission("opgiveme.*")) {
          
            p.sendMessage(ChatColor.AQUA + "Du har opeat dig själv!");
                  sender.setOp(true);
                  p.playSound(p.getLocation(), Sound.LEVEL_UP, 100.0F, 100.0F);
                }
                  
            else {
          
                p.sendMessage(ChatColor.RED + (ChatColor.BOLD + "Du har inte permission för att använda detta kommando!"));
                  
                p.playSound(p.getLocation(), Sound.COW_HURT, 100.0F, 100.0F);
            }
              
          
      
            return false;
        }
            return false;
    
        }
    
    }
    
    So what is the problem? Please help me! :)
     
    Last edited by a moderator: Nov 8, 2017
  2. Offline

    Zombie_Striker

    @fr0ziz
    Opped players have all permissions. Are you sure that non-opped players can access the command?
     
  3. Offline

    SweetSpuddy

    @fr0ziz copy of your plugin.yml? it may be because your layout is not defining the default group,
    e.g
    Code:
    permssions:
        opgiveme.*:
            default: OP (this means only OP can do it or people who you give the perm node "opgiveme.*")
     
  4. Offline

    fr0ziz

    plugin.yml:
    Code:
    name: OPGiveMe
    main: me.fr0ziz.opgiveme
    description: nothing
    
    commands:
        opgiveme:
    
    permissions:
        opgiveme:*
            description: nothing in here too.
    default: op
    whats wrong about it?
     
    Last edited by a moderator: Nov 7, 2017
  5. Online

    timtower Administrator Administrator Moderator

    @fr0ziz The main in the plugin.yml also needs the main class Main at the the end.
     
  6. Offline

    fr0ziz

    i forgot to type it in here, i typed it in Eclipse. So that isn't the solution.
     
  7. Online

    timtower Administrator Administrator Moderator

    @fr0ziz Could you format and re-post your code?
     
Thread Status:
Not open for further replies.

Share This Page