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

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

  1. Offline

    Simo389

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    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?

    This post has been edited 4 times. It was last edited by Simo389 Jan 7, 2014.
  2. Offline

    nuclearmissile

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    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

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Nope. I even tried running the plugin on a server by itself; still no luck. :p
  4. Offline

    Dako

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    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

    This post has been edited 1 time. It was last edited by Dako Jan 8, 2014.
  5. Offline

    Simo389

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    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! :)

    This post has been edited 3 times. It was last edited by Simo389 Jan 9, 2014.

Share This Page