Solved How to stop fireball's damaging paintings and item frames?

Discussion in 'Plugin Development' started by Simo389, Jan 7, 2014.

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

    Simo389

    I'm creating a plugin that allows players to shoot fireball's. I do this in the PlayerInteractEvent like so:
    Code:java
    1. player.launchProjectile(Fireball.class);

    My issue is that even with WorldGuard set with entity-painting-destroy and entity-item-frame-destroy to 'deny' and explosions disabled, players can still break paintings and item frames with fireball's.

    I even tried:
    Code:java
    1. @EventHandler(priority = EventPriority.HIGHEST)
    2. public void onPaintingBreak(PaintingBreakEvent e) {
    3. e.setCancelled(true);
    4. }

    But nothing I try is working.

    How do you stop fireball's from breaking paintings and item frames?
     
  2. That's weird. You didn't accidentally save your plugin as another name, thus meaning you have two plugins with the exact same code operating simultaneously under different names, did you? I do that sometimes, so I thought maybe you could check. If you did do that, all your cancelling and protection code will be useless. Because to be honest, from what I can tell, the method you posted should work fine.
     
  3. Offline

    Simo389

    Nope. I even tried running the plugin on a server by itself; still no luck. :p
     
  4. Offline

    Dako

    Try:
    Code:java
    1. @EventHandler
    2. public void onFrameBrake(HangingBreakByEntityEvent event){
    3. event.setCancelled(true);
    4. }

    or:
    Code:java
    1. @EventHandler
    2. public void onFrameBrake(HangingBreakEvent event){
    3. event.setCancelled(true);
    4. }


    greetz Dako
     
  5. Offline

    Simo389

    This did the trick:
    Code:java
    1. @EventHandler
    2. public void onFrameBrake(HangingBreakEvent e) {
    3. if (e.getCause().toString().equals("ENTITY") || e.getCause().toString().equals("EXPLOSION")) {
    4. e.setCancelled(true);
    5. }
    6. }

    Had to add the if statement, as without it we literally couldn't break any paintings or item frames. This way if you break the block behind them, they break normally. :p

    Thanks for the help! :)
     
Thread Status:
Not open for further replies.

Share This Page