Protect creeper block dameage


#1

How to protect when creeper explosion block damage in spongeforge 1.8.9-4.1.0-1330.

Thank you for every comment


#2

/gamerule mobGriefing false ? :smiley:


#3
@Listener
public void onBlockChange(ChangeBlockEvent e) {
    if (e.getCause().first(Creeper.class).isPresent()){
        e.setCancelled(true);
        }
    }

#4

Where file input code


#5

@collller Your code can be shortened using filter annotations: https://docs.spongepowered.org/master/en/plugin/event/filters.html#parameter-source-annotations
@11115 You have to put your code in your plugin. You also can change this code a bit so it is compatible with Sponge javascript. Or just request such a plugin and wait until someone has done it.


#6

thanks
like this๏ผŸ

@Listener
@IsCancelled(Tristate.FALSE)
    public void antiexplosion(ChangeBlockEvent e,@First Explosive explo ) {
        e.setCancelled(true);
}

#7

I think your @IsCancelled behavior is the default behavior so you don't have to specify that.
Now the event gets cancelled when an explosive has caused a block change. I thought you wanted to only do this when a Creeper is the first cause. So change to method(..., @First Creeper creeper){}


#8

Doesn't that effect the whole world? What if I want to turn off creepers in just 1 area like a town?


#9

Correct ... I'd suggest using some protection plugin then. FoxGuard should be capable of doing that :slight_smile:


#10

yea, I am using Pex 2.0 and haven't gotten any where with that either. its like no one has ever wanted to turn mob griefing off in a specific are before- which I refuse to believe...


#11

Uhm .. Pex is a Permissions-Plugin, not a Protection-Plugin, is it?


#12

Yes, it is a permissions program, I use it in combo with Grief Prevention. I will try Fox Guard in the next week or so if I cant get any help from the G.P. forums- which I anticipate no one will be able to offer any suggestions. The IRC channel is a joke...you can stay there all day and no one will reply. I asked the author of G.P. and haven't gotten a reply either.
So, this is the last week I will wait for an answer. After that, I remove it and forget it.