Drops from ores! Please Help!

Discussion in 'Plugin Development' started by MrBadCoder, May 11, 2014.

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

    MrBadCoder

    Hello everyvone!
    I am a really bad coder and I wonder if I can get some help with my plugin I am going to use.

    1.This is how it works you type in the command /ores
    2. Then you select a block by clicking on it.(an ore like an iron ore you can also select many ores at the same time.)
    3. Then you can do /ores again and when a normal player mines that ore or ores
    4. It will have the change of 33%(if 33% dosen't work you can take 50%) to drop an ingot and if not it drops nothing. This will work with all ores! Gold Diamond Iron (redstone coal emerald)
    I have tryed myself but I am really bad! I would love to get some help :) !
    Thanks /MrBadCoder

    And if you can fix like
    Premissions
    ores.*
    or just so op can do it.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 8, 2016
  2. Offline

    Konkz

    This looks like a request. We help you develop the plugin if you have bugs which you can't squish and not make a whole code for you.

    You said you tried yourself, what have you tried? What errors did it encounter?

    If we write up all the code for you then you won't learn from it, even if you read it 100 times as for example
    you'd have no clue what a HashMap is and such.
     
  3. Offline

    MrBadCoder

    Ok thank you Konkz for telling me :)!

    This is what i have done so far:

    package me.MrBadCoder.ores;

    import java.util.logging.Logger;

    import org.bukkit.plugin.java.JavaPlugin;

    public class Block extends JavaPlugin
    {
    public final Logger logger = Logger.getLogger("Minecraft");

    public void onEnable()
    {
    new BlockListener(); Error here(Because he haven't make one yet?)
    logger.info("Plugin enabled!");
    }

    public void onDisable()
    {
    logger.info("Plugin disabled!");
    }

    }
    That was the first part
    package me.Rajen007.Fields;
    import javax.tools.JavaFileManager.Location;
    import org.bukkit.Material;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.BlockBreakEvent;
    public class BlockListener implements Listener
    {
    private Blocks plugin;
    public Blocks getPlugin() {
    return plugin;
    }
    public void setPlugin(Blocks plugin) {
    this.plugin = plugin;
    }
    public Material[] ores = { Material.IRON_ORE, Material.DIAMOND_ORE, Material.COAL_ORE, Material.REDSTONE_ORE };

    public BlockListener(Blocks instance)
    {
    plugin = instance;
    plugin.getServer().getPluginManager().registerEvents(this, plugin);
    }

    @EventHandler
    public void onBreak(BlockBreakEvent e)
    {
    Player p = e.getPlayer();
    Location l = (Location) p.getLocation();

    } <-- ERROR!
    The problem is that i don't know what to do here to make the player get the ingot and how to make the chance of getting an ingot. I also dont know how to make the thing when you click at the block it will work with the rest of the code. Like it's just gonna be on that block that we clicked on and it is that block or blocks the plugin is focus on not the whole world of minecraft.
    You see here at eventhadler I dont know what to put there. I should put that the player get 33% chanse of getting the ingot (the block drops it) but I dont know how to code that. Then I havent done the click event because I don't know how i should make it work with a command.

    I fixed the me.MrBadCoder.Ores;

    Code:
    package me.MrBadCoder.ores;
     
    import java.util.logging.Logger;
     
    import org.bukkit.plugin.java.JavaPlugin;
     
    public class Block extends JavaPlugin
    {
        public final Logger logger = Logger.getLogger("Minecraft");
       
        public void onEnable()
        {
            new BlockListener();
            logger.info("Plugin enabled!");
        }
       
        public void onDisable()
        {
            logger.info("Plugin disabled!");
        }
     
    }
    [CODE]package me.MrBadCoder.ores;
     
    import javax.tools.JavaFileManager.Location;
     
    import org.bukkit.Material;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.BlockBreakEvent;
     
    public class BlockListener implements Listener
    {
        private Blocks plugin;
     
        public Blocks getPlugin() {
            return plugin;
        }
     
        public void setPlugin(Blocks plugin) {
            this.plugin = plugin;
        }
        public Material[] ores = { Material.IRON_ORE, Material.DIAMOND_ORE, Material.COAL_ORE, Material.REDSTONE_ORE };
       
        public BlockListener(Blocks instance)
        {
            plugin = instance;
            plugin.getServer().getPluginManager().registerEvents(this, plugin);
        }
       
        @EventHandler
        public void onBreak(BlockBreakEvent e)
        {
            Player p = e.getPlayer();
            Location l = (Location) p.getLocation();
     
       
        }
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 8, 2016
Thread Status:
Not open for further replies.

Share This Page