Holographic Display above Blocks

Discussion in 'Plugin Development' started by BiskitDEV, Aug 2, 2015.

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

    BiskitDEV

    Hey!

    I am trying to build a plugin (Note the TRYING), and for some reason this code wouldn't work.. Got any ideas?

    Code:
    public class Main extends JavaPlugin implements Listener {
          
            public void onEnable() {
                    Bukkit.getServer().getPluginManager().registerEvents(this, this);
            }
          
            @EventHandler
            public void onBlockPlace(BlockPlaceEvent e) {
                  if(e.getBlock().equals(Material.CHEST))
                    HolographicDisplaysAPI.createHologram(
                                    this,
                                    e.getBlock().getLocation().add(0, 2, 0),
                                    ChatColor.GRAY + "This is a HOLOGRAM!");
            }
    }
    
    This is using the HolographicDisplays library along with Craftbukkit.

    Thanks!
     
  2. Offline

    NickDEV

    On 9th line (if(e.getBlock().equals(Material.CHEST))) you forgot { and than you need to add another }.
     
  3. Offline

    BiskitDEV

    Ahh, thanks. Didn't catch it >.<

    EDIT: Didn't seem to work...?
     
  4. Offline

    NickDEV

    @BiskitDEV No problem hope the problem is solved now. Yeah the hardest thing is to see your mistakes.
     
  5. Offline

    BiskitDEV

    It's hard to see them when you have no errors.. Like now :p
     
  6. Offline

    NickDEV

    @BiskitDEV Wait does your plugin work? xD (now)
     
  7. Offline

    BiskitDEV

    I thought it did, no errors or anything, just doesn't work in-game :p
     
  8. Offline

    NickDEV

    @BiskitDEV I don't know what's wrong now. We will wait for answer :)
     
  9. Offline

    Chiller

    @BiskitDEV @NickDEV @bwfcwalshy
    He said there were no errors and also no compiler errors, to debug this you actually have to look at the code!
    Also NickDEV he did not need those curly braces because there was only one line after the if statement.
    The error is in your if statement, look closely at it and tell my if Block is the same as Material?
    (hint: to get the material type of a block: block.getType())
     
  10. Offline

    BiskitDEV

    Still not working for me :c
     
  11. Offline

    Permeer

  12. Not required if you just execute 1 line of code
    Code:
    e.getBlock().equals(Material.CHEST)
    It's like the people on these forums all need glasses.
    BlockBreakEvent#getBlock() -> Block, can't be a Material >.< use Block#getType() to get the Material.
    Also, what is your current code?
     
  13. Offline

    BiskitDEV

    Code:
        @EventHandler
        public void onBlockPlace(BlockPlaceEvent e) {
            Player p = e.getPlayer();  
            Block block = e.getBlockPlaced();
            if(block.getType().equals(Material.CHEST)) {
                HolographicDisplaysAPI.createHologram
                (this, e.getBlock()
                        .getLocation().add(0, 2, 0), ChatColor.GRAY + "Building: "
                        + ChatColor.GREEN + "HOUSE" + ChatColor.RED + " 59%");
                p.sendMessage(ChatColor.GRAY + "Currently building :" + ChatColor.GREEN + " HOUSE");
            }
        }
    }
    
    Current Code.
     
  14. Offline

    Chiller

    @BiskitDEV So now is it sending the message at all?
     
  15. Offline

    BiskitDEV

    Nope. The whole thing is not working.
     
  16. Offline

    Chiller

    @BiskitDEV Are you sure your plugin.yml is setup correctly, does it depend on the library?
     
Thread Status:
Not open for further replies.

Share This Page