Potion Kit Plugin

Discussion in 'Plugin Development' started by GamingShades, Jul 14, 2015.

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

    GamingShades

    I'm making this myself custom for my server so if you're going to redirect me to another plugin you might as well just not post >.>

    Code:
    package me.valaiyar.kits;
    
    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;
    import org.bukkit.potion.PotionEffect;
    import org.bukkit.potion.PotionEffectType;
    
    public class main extends JavaPlugin{
      
        @Override
        public void onEnable() {
                getLogger().info("Enabled!");
              
    }
      
        @Override
        public void onDisable() {
                getLogger().info("Disabled!");
        }
      
        public boolean onCommand(CommandSender sender, Command command,
                String label, String[] args) {
            if(label.equalsIgnoreCase("miner")) {
                Player player = (Player) sender;
                player.addPotionEffect(new PotionEffect(PotionEffectType.FAST_DIGGING, 6000, 2));
                player.sendMessage(ChatColor.GOLD + "You have received Haste III.");
              
                }
              
          
            return false;
        }
    }
    
    
    
    Code:
    main: me.valaiyar.kits.main
    version: 1.0
    name: bpvpPKits
    
    commands:
      m:
        description: Receive Haste III for 5 minutes! 
    I've no idea what's wrong with my code, when I reload the server the plugin does not work nor does it show in /pl or /plugins. If you know what's wrong please contact me ASAP.
     
  2. Offline

    Creeperzombi3

    @GamingShades
    Your plugin.yml shows the command as "m" instead of "miner"
     
  3. 1. Follow java naming conventions
    2. Don't log when your plugin enables/disables
    3. use command.getName() instead of commandLabel to allow aliases
    4. Don't return false in onCommand or the usage (which you didn't defined) shows up
    5. You need to put usage: /<command> or something like that under description of your command
    6. Show us the server log
     
  4. Offline

    GamingShades

    Last edited by a moderator: Oct 27, 2016
  5. Offline

    Eos

    [quote uid=90911074 name="GamingShades" post=3170277]@Creeperzombi3
    @FisheyLP
    <Edit by Moderator: Redacted mediafire url>
    Fix your plugin.yml change m to miner

    Try the following.
    Code:
    java said: 
    
    package me.valaiyar.kits;
    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;
    import org.bukkit.potion.PotionEffect;
    import org.bukkit.potion.PotionEffectType;
    public class main extends JavaPlugin {
    
        @
        Overridepublic void onEnable() {
            getLogger().info("Enabled!");
        }
    
        @
        Overridepublic void onDisable() {
            getLogger().info("Disabled!");
        }
    
        public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
            if (command.getName().equalsIgnoreCase("miner")) {
                Player player = (Player) sender;
                player.addPotionEffect(new PotionEffect(PotionEffectType.FAST_DIGGING, 6000, 2));
                player.sendMessage(ChatColor.GOLD + "You have received Haste III.");
            }
    
    
            return false;
        }
    }
    
     
    Last edited by a moderator: Oct 27, 2016
  6. the code is still pretty wrong: https://bukkit.org/threads/common-mistakes.100544/
     
Thread Status:
Not open for further replies.

Share This Page