I'm stumped.

Discussion in 'Plugin Development' started by redtsch, May 25, 2016.

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


    Hello Bukkit. As you can see from the title above, i need some help; in other words, i have some questions. Lets begin:

    First off, heres one of my classes:
    public class EzCore extends JavaPlugin {
        Logger logger = Logger.getLogger("Minecraft");
        PluginDescriptionFile pdf = getDescription();
        String versionId = pdf.getVersion(), plName = pdf.getName();
        private static EzCore ezcore;
        public static EzCore getInstance() {
            return ezcore;
        public void onEnable() {
            logger.info("[" + plName + "]" + " Enabled " + plName + " v" + versionId);
        public void registerEvents() {
            PluginManager pm = Bukkit.getServer().getPluginManager();
            pm.registerEvents(new MiningHelmet(), this);
        public void registerCommands() {
            getCommand("ez").setExecutor(new MiningHelmet());
        public void onDisable() {
            logger.info("[" + plName + "]" + " Disabled " + plName + " v" + versionId);       
    I don't think i have any problems here^.

    Next class.
    public class MiningHelmet implements Listener, CommandExecutor {
        String ezName = "MiningHelmet";
        EzUtils utils = EzUtils.getInstance();
        EzCore core = EzCore.getInstance();
        ItemStack miningHelmet = EzUtils.createItem(Material.LEATHER_HELMET, "§e" + ezName, 1, 0, null);
        ShapedRecipe miningHelmetCraft = new ShapedRecipe(miningHelmet);
        PotionEffect glowing = new PotionEffect(PotionEffectType.GLOWING, 20, 20, false);
        private static MiningHelmet ezMH;
        public static MiningHelmet getInstance() {
            return ezMH;
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
            if (!(sender instanceof Player)) {
                sender.sendMessage(ChatColor.RED + "You must be a player to use this command.");
                return true;
            Player player = (Player) sender;
            Inventory playerInv = player.getInventory();
            if (player.isOp() == false) {
                player.sendMessage("§cYou must be an operator to use this command.");
            } else {
                if (cmd.getName().equalsIgnoreCase("ez")) {
                    if (args[0].equalsIgnoreCase(ezName)) {
                        player.sendMessage("§6[Ez]: §eGiven Mining Helmet§6.");
            return false;
    1st Question: in my onCommand()(in MiningHelmet.java), where should i add my code to check if args[].lenght() < 2?

    2nd Question: also in MiningHelmet.java, i want to add a crafting recipe for the Mining Helmet, how should i go about doing this?

    3rd Question: still in MiningHelmet.java, i want the purpose of this Mining Helmet to be that when it is worn in light levels under 8, all Monsters and players within a 20x20x20 cube of the player will be given the Glowing potion effect; how can i target those mobs?

    All help is appreciated, thank you in advance =)
    PLEASE let me know if i have been vague on anything or if you need more info to help me!
  2. Offline


  3. Offline


    Thanks for the answer
    1) ok thanks.
    2) I know how to make use bukkits crafting recipes but it has to be in a constructor, so I didn't know if I needed to use a method like CraftItemEvent or something
    3) I figured. Maybe someone like @Zombie_Striker or @fireblast709 will know?
    Thanks for the help =)
  4. Offline


    @redtsch There is no need to log the plugin enabling as Bukkit automatically does this for you.
  5. Offline


    ah, thank you =)

    So i decided to remove the command, and make the items available to the player in a different fashion.

    I still need help with:
    3) the glowing effect.
  6. I think it'd be best if you had some sort of repeating scheduled task which would find all nearby entities within 20 blocks and apply the effect to them.

    Each time if checks the entities, add them to a list. Then, next time that repeating task is ran again, it checks through the list to see if there is any players who were in the list before but aren't now. If they aren't, then remove the effects.

    Check out:
    - world.getNearbyEntities()
    - http://wiki.bukkit.org/Scheduler_Programming
    redtsch likes this.
  7. Offline


Thread Status:
Not open for further replies.

Share This Page