Solved Error

Discussion in 'Plugin Help/Development/Requests' started by jakemaster2003, Dec 9, 2016.

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

    jakemaster2003

    Best poeple of this forum,

    i have made a plugin for my server and runned it on my test server but this error popped up:
    Click here

    My code:
    Main Class
    Code:
    package me.YourPalJake;
    
    import org.bukkit.ChatColor;
    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{
      
      
        @Override
        public void onEnable(){
            getLogger().info(">> AntiJump has been Enabled <<");
            getServer().getPluginManager().registerEvents(new AntiJump(), this);
          
        }
      
      
        @Override
        public void onDisable(){
            getLogger().info(">> AntiJump has been Disabled <<");
          
        }
      
      
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
          
            Player p = (Player)sender;
          
            if(cmd.getName().equalsIgnoreCase("antijump version")){
                if(!p.hasPermission("antijump.admin")){
                    p.sendMessage(ChatColor.DARK_RED + "Je hebt hier geen permissie voor!");
                }
              
                p.sendMessage(ChatColor.DARK_GREEN + "AntiJump" + ChatColor.GREEN + "Version" + ChatColor.DARK_RED + "1.0");
            }
            return true;
        }
    
    }
    
    AntiJump class

    Code:
    package me.YourPalJake;
    
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerJoinEvent;
    import org.bukkit.potion.PotionEffect;
    import org.bukkit.potion.PotionEffectType;
    
    public class AntiJump implements Listener{
      
        @EventHandler
        public void onPlayerJoinEvent(PlayerJoinEvent e){
            Player p = (Player)e;
            if(!p.hasPermission("antijump.admin")){
                p.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 1000000, 127));
               
            }
        }
      
    
    }
    
    NOTE: I have some dutch string because my server is dutch but that is not where the error lies on.
    Please help me.


    Greetings Jake
     
  2. Offline

    timtower Moderator Moderator

    @jakemaster2003 You have used that package and class name before haven't you?
    That is why it is best to have the plugin name in the package and not use "Main" as main class name.

    And don't log to the console for onEnable and onDisable, Bukkit does that for you.
    Please check if the sender is a player before casting.
     
  3. Offline

    jakemaster2003

    Thanks for the assistence,

    I have edited my code as well and added new features soon i wil make a public version for on bukkit with a config to change the messages.

    Oh and as well never put in a equealignorecase a space between a command

    Greetings Jake
     
Thread Status:
Not open for further replies.

Share This Page