ORES SIMPLE PLUGIN

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

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

    BadGirlCoder

    Hello guys I have been trying to make a ore plugin :) !
    I going to describe the plugin so you can understand better!
    1.This is how it works you type in the command /ores iron, /ores diamond, /ores gold
    2. Then you select a block by clicking on it and if u do /ores iron you have to select iron ores. Because it is like you select those blocks who gonna drop an iron ingot then you cant select a diamond ore.
    ( you can also select many ores at the same time.)
    3. Then you can do /ores create [Name] (that will be a group for all the selected ores and it have to be the same ore like just iron or just gold, you can do many diffrent groups not just one) and when a normal player mines that ore or ores. (You can do /ores delete [Name] too.)
    4. It will have the chanse of 33%(if 33% dosen't work you can take 50%) to drop an ingot and if it dosen't drops anything(it becomes an ore again untill you get the ingot and then it vanish). This will work with all ores! Gold, Diamond, Iron
    5. This plugin should be focus on the blocks that are selected not the whole minecraft world!
    6. (I don't want any xp drops)
    7. After 60 min all the selected blocks are going to regen(they come back).
    8. Do premissions like ores.* or so just op can do it. If you can make premissions :)
    I have only done the thing when you break the block you get an ingot. But I want the thing when you type in a command and then you press the block and then you save it as a group. Because I don't know how I gonna make the command work the plugin. Then I don't know how I should fix the chanses of getting an ingot. And I don't know how I should fix that the block regened!

    I would love some help and here is my code for now!:)
    Code:
    MAIN HERE
    package plugins.BadGirlCoder.oreS;
     
    import org.bukkit.Location;
    import org.bukkit.Material;
    import org.bukkit.World;
    import org.bukkit.block.Block;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.BlockBreakEvent;
    import org.bukkit.inventory.ItemStack;
     
    public class MainHandler
      implements Listener
    {
      @EventHandler
      public void onBreak(BlockBreakEvent e)
      {
        Block it = e.getBlock();
        Location loc = it.getLocation();
        if (it.getType() == Material.IRON_ORE) {
          it.setType(Material.AIR);
          loc.getWorld().dropItemNaturally(loc, new ItemStack(Material.IRON_INGOT));
          return;
        }
        if (it.getType() == Material.GOLD_ORE) {
          it.setType(Material.AIR);
          loc.getWorld().dropItemNaturally(loc, new ItemStack(Material.GOLD_INGOT));
          return;
        }
      }
    }
     
    ORES TO INGOT
     
    package plugins.BadGirlCoder.ores;
     
    import java.util.logging.Logger;
    import org.bukkit.Bukkit;
    import org.bukkit.Server;
    import org.bukkit.plugin.PluginManager;
    import org.bukkit.plugin.java.JavaPlugin;
     
    public class OresToIngots extends JavaPlugin
    {
      public Logger log;
     
      public void onEnable()
      {
        loadListeners();
     
        this.log = getLogger();
     
        this.log.info("OresToIngots on");
      }
     
      public void loadListeners() {
        PluginManager pm = Bukkit.getServer().getPluginManager();
        pm.registerEvents(new MainHandler(), this);
      }
     
      public void onDisable() {
        this.log.info("OresToIngots off");
      }
    }
    
     
  2. Offline

    RawCode

    plugin request section located elsewhere
     
  3. Offline

    CarPet

    He isn't making a request he is describing the plugin so we can actually help him instead of just making us shoot into the darkness

    Code:java
    1. public boolean onCommand(CommandSender sender, Command cmd,
    2. String commandLabel, String[] args) {
    3. if (cmd.getName().equalsIgnoreCase("test")) { //Do your stuff }
    4. return false;
    5. }


    That's how you register a command

    I don't really understand the rest of it, but that is how you make commands
     
Thread Status:
Not open for further replies.

Share This Page