Permissions not found

Discussion in 'Spigot Plugin Help' started by Newpredator, May 2, 2015.

  1. The permission not found, users can use the command /setspawn




    Code (Text):
    package me.newpredator;

    import java.util.logging.Level;
    import java.util.logging.Logger;

    import org.bukkit.ChatColor;
    import org.bukkit.Location;
    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 UtilCommands
      extends JavaPlugin
    {
      public static final Logger log = Logger.getLogger("Minecraft:");
      public void onEnable()
      {
        log.log(Level.INFO, "Plugin Activated");
        if (!Config.configFile.exists()) {
          Config.save();
        }
        Config.load();
      }
      public void onDisable() {}
      @Override
      public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args)
      {
          switch(cmd.getLabel().toLowerCase())
          {
              case "getname":
                  Player player = (Player)sender;
                  sender.sendMessage("");
                  sender.sendMessage(ChatColor.translateAlternateColorCodes('&',Config.msg));
                  sender.sendMessage(ChatColor.GREEN + sender.getName());
                  sender.sendMessage("");
                  player.playSound(player.getLocation(), Sound.NOTE_PLING, 1.0F, 1.0F);
                  return true;
              case "info":
                  Player player1 = (Player)sender;
                  sender.sendMessage("");
                  sender.sendMessage(ChatColor.translateAlternateColorCodes('&', Config.shop));
                  sender.sendMessage(ChatColor.translateAlternateColorCodes('&', Config.twitter));
                  sender.sendMessage(ChatColor.translateAlternateColorCodes('&', Config.info));
                  sender.sendMessage(ChatColor.translateAlternateColorCodes('&', Config.facebook));
                  sender.sendMessage(ChatColor.translateAlternateColorCodes('&', Config.youtube));
                  sender.sendMessage("");
                  player1.playSound(player1.getLocation(), Sound.PORTAL_TRAVEL, 1.0F, 1.0F);
                  return true;
              case "shop":
                  Player player2 = (Player)sender;
                  sender.sendMessage("");
                  sender.sendMessage(ChatColor.translateAlternateColorCodes('&', Config.vipmessage));
                  sender.sendMessage(ChatColor.translateAlternateColorCodes('&', Config.viplink));
                  sender.sendMessage("");
                  player2.playSound(player2.getLocation(), Sound.ENDERDRAGON_WINGS, 1.0F, 1.0F);
                  return true;
              case "setspawn":
              Player p = (Player)sender;
              Location loc = p.getLocation();
              {
              if (p.hasPermission("set.spawn"))
                 
                  p.getWorld().setSpawnLocation(loc.getBlockX(), (int)loc.getY(), (int)loc.getZ());
          }
                  p.getPlayer().getWorld().playSound(p.getPlayer().getLocation(), Sound.ANVIL_USE, 1.0F, 1.0F);
                  p.sendMessage(ChatColor.translateAlternateColorCodes('&', Config.setspawn));
                  return true;
              case  "spawn":
                  Player p1 = (Player)sender;
                  Location loc1 = p1.getWorld().getSpawnLocation();
                  p1.teleport(loc1);
                  p1.sendMessage(ChatColor.translateAlternateColorCodes('&', Config.teleportspawn));
                  p1.getPlayer().getWorld().playSound(p1.getPlayer().getLocation(), Sound.ENDERMAN_TELEPORT, 1.0F, 1.0F);
                  return true;
          }
        return false;
    }
    }

     
     
  2. if (p.hasPermission("set.spawn")){
    p.getWorld().setSpawnLocation(loc.getBlockX(), (int)loc.getY(), (int)loc.getZ());
    }else{
    p.sendmessage("")
    }
     
  3. THE PERMISSION NOT FOUND

    Code (Text):
    package me.newpredator;

    import java.util.logging.Level;
    import java.util.logging.Logger;

    import org.bukkit.ChatColor;
    import org.bukkit.Location;
    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 UtilCommands
      extends JavaPlugin
    {
      public static final Logger log = Logger.getLogger("Minecraft:");
      public void onEnable()
      {
        log.log(Level.INFO, "Plugin Activated");
        if (!Config.configFile.exists()) {
          Config.save();
        }
        Config.load();
      }
      public void onDisable() {}
      @Override
      public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args)
      {
          switch(cmd.getLabel().toLowerCase())
          {
              case "getname":
                  Player player = (Player)sender;
                  sender.sendMessage("");
                  sender.sendMessage(ChatColor.translateAlternateColorCodes('&',Config.msg));
                  sender.sendMessage(ChatColor.GREEN + sender.getName());
                  sender.sendMessage("");
                  player.playSound(player.getLocation(), Sound.NOTE_PLING, 1.0F, 1.0F);
                  return true;
              case "info":
                  Player player1 = (Player)sender;
                  sender.sendMessage("");
                  sender.sendMessage(ChatColor.translateAlternateColorCodes('&', Config.shop));
                  sender.sendMessage(ChatColor.translateAlternateColorCodes('&', Config.twitter));
                  sender.sendMessage(ChatColor.translateAlternateColorCodes('&', Config.info));
                  sender.sendMessage(ChatColor.translateAlternateColorCodes('&', Config.facebook));
                  sender.sendMessage(ChatColor.translateAlternateColorCodes('&', Config.youtube));
                  sender.sendMessage("");
                  player1.playSound(player1.getLocation(), Sound.PORTAL_TRAVEL, 1.0F, 1.0F);
                  return true;
              case "shop":
                  Player player2 = (Player)sender;
                  sender.sendMessage("");
                  sender.sendMessage(ChatColor.translateAlternateColorCodes('&', Config.vipmessage));
                  sender.sendMessage(ChatColor.translateAlternateColorCodes('&', Config.viplink));
                  sender.sendMessage("");
                  player2.playSound(player2.getLocation(), Sound.ENDERDRAGON_WINGS, 1.0F, 1.0F);
                  return true;
              case "setspawn":
              Player p = (Player)sender;
              Location loc = p.getLocation();
              {
                  if (p.hasPermission("set.spawn")){
                      p.getWorld().setSpawnLocation(loc.getBlockX(), (int)loc.getY(), (int)loc.getZ());
                      }else{
                      p.sendMessage(ChatColor.translateAlternateColorCodes('&',Config.setspawn));
                      }
              }
                  return true;
              case  "spawn":
                  Player p1 = (Player)sender;
                  Location loc1 = p1.getWorld().getSpawnLocation();
                  p1.teleport(loc1);
                  p1.sendMessage(ChatColor.translateAlternateColorCodes('&', Config.teleportspawn));
                  p1.getPlayer().getWorld().playSound(p1.getPlayer().getLocation(), Sound.ENDERMAN_TELEPORT, 1.0F, 1.0F);
                  return true;
          }
        return false;
    }
    }
     
     
  4. if (p.hasPermission("set.spawn")){
    p.getWorld().setSpawnLocation(loc.getBlockX(), (int)loc.getY(), (int)loc.getZ());
    }else{
    p.sendmessage("you don't have permissions to use the command") //message for you don't have permissions to use the command
    }
     
  5. You need to give us more informations so we can help you !
     
  6. Why are u switching cases on cmds? ....