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

    redcanoe

    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:


    Code:java
    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

    DinosParkour

    redcanoe
    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

    redcanoe

    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

    xTigerRebornx

  5. Offline

    DinosParkour

    redcanoe
    Code:
    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

    xTigerRebornx

Thread Status:
Not open for further replies.

Share This Page