Help with a diamond announcer plugin

Discussion in 'Plugin Development' started by redcanoe, Aug 14, 2014.

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


    Hey folks,

    I'm trying to get my diamond announcer plugin to announce "[Alert] Player found 6 diamond ore.", as opposed to [Alert] Player mined a diamond ore." six times.

    I am not sure where to begin, how would I do this? Here is my current code:

    1. @EventHandler
    2. public void onBlockBreak(BlockBreakEvent e)
    3. {
    4. if ((e.getBlock().getType() == Material.DIAMOND_ORE) &&
    5. (e.getBlock().getY() <= 20))
    6. {
    7. Player player = e.getPlayer();
    8. Date date = new Date();
    9. Bukkit.broadcast(ChatColor.GOLD + "[Alert] " + ChatColor.WHITE + player.getName() + ChatColor.GOLD +
    10. " found diamond ore.", "bukkit.broadcast.admin");
  2. Offline


    I guess you would have to check the nearby blocks (in every direction possible) to see if there is another diamond ore.

    Also, what do you use this for:

  3. Offline


    That is for later where I log the ore to a text file, it saves the date and coordinates.

    Can you please explain how I would check every block around?
  4. Offline


  5. Offline


    Block Broken = e.getBlock();
    Block Up = Broken.getRelative(BlockFace.UP);
    Block Down = Broken.getRelative(BlockFace.DOWN);
    Block East = Broken.getRelative(BlockFace.EAST);
    Block West = Broken.getRelative(BlockFace.WEST);
    Block North = Broken.getRelative(BlockFace.NORTH);
    Block South = Broken.getRelative(BlockFace.SOUTH);}
  6. Offline


Thread Status:
Not open for further replies.

Share This Page