Protect against fishing rod usage in regions.

Fixes WORLDGUARD-3696.
Also be more explicit with some dependencies so IntelliJ stops complaining.
This commit is contained in:
wizjany 2016-06-11 01:22:40 -04:00
parent 5bd2125963
commit 6c3dd4234d
2 changed files with 21 additions and 5 deletions

View File

@ -12,11 +12,14 @@
dependencies {
compile 'org.khelekore:prtree:1.5.0'
compile 'org.bukkit:bukkit:1.9.4-R0.1-SNAPSHOT'
compile 'com.sk89q.worldedit:worldedit-bukkit:6.1.1-SNAPSHOT'
compile 'com.sk89q.worldedit:worldedit-bukkit:6.1.3-SNAPSHOT'
compile 'com.sk89q:squirrelid:0.1.0'
compile 'com.sk89q:guavabackport:1.1'
compile 'org.flywaydb:flyway-core:3.0'
compile 'com.sk89q:commandbook:2.3'
compile ('com.sk89q:commandbook:2.3') {
exclude group: 'com.sk89q', module: 'worldedit'
exclude group: 'com.zachsthings.libcomponents'
}
compile 'net.sf.opencsv:opencsv:2.0'
compile 'com.googlecode.json-simple:json-simple:1.1.1'
compile 'com.google.code.findbugs:jsr305:1.3.9'
@ -44,7 +47,7 @@
include(dependency('com.googlecode.json-simple:json-simple:1.1.1'))
include(dependency('net.sf.opencsv:opencsv:2.0'))
}
relocate('com.sk89q.guavabackport', 'com.sk89q.worldguard.internal.guava')
relocate('org.flywaydb', 'com.sk89q.worldguard.internal.flywaydb')
relocate('com.sk89q.squirrelid', 'com.sk89q.worldguard.util.profile')

View File

@ -40,6 +40,7 @@
import com.sk89q.worldguard.bukkit.listener.debounce.legacy.EntityEntityEventDebounce;
import com.sk89q.worldguard.bukkit.listener.debounce.legacy.InventoryMoveItemEventDebounce;
import com.sk89q.worldguard.bukkit.util.Blocks;
import com.sk89q.worldguard.bukkit.util.Entities;
import com.sk89q.worldguard.bukkit.util.Events;
import com.sk89q.worldguard.bukkit.util.Materials;
import com.sk89q.worldguard.protection.flags.DefaultFlag;
@ -622,8 +623,20 @@ public void onBlockExp(BlockExpEvent event) {
@EventHandler(ignoreCancelled = true)
public void onPlayerFish(PlayerFishEvent event) {
if (Events.fireAndTestCancel(new SpawnEntityEvent(event, create(event.getPlayer(), event.getHook()), event.getHook().getLocation(), EntityType.EXPERIENCE_ORB))) {
event.setExpToDrop(0);
if (event.getState() == PlayerFishEvent.State.CAUGHT_FISH) {
if (Events.fireAndTestCancel(new SpawnEntityEvent(event, create(event.getPlayer(), event.getHook()), event.getHook().getLocation(), EntityType.EXPERIENCE_ORB))) {
event.setExpToDrop(0);
}
} else if (event.getState() == PlayerFishEvent.State.CAUGHT_ENTITY) {
Entity caught = event.getCaught();
if (caught == null) return;
if (caught instanceof Item) {
Events.fireToCancel(event, new DestroyEntityEvent(event, create(event.getPlayer(), event.getHook()), caught));
} else if (Entities.isConsideredBuildingIfUsed(caught)) {
Events.fireToCancel(event, new UseEntityEvent(event, create(event.getPlayer(), event.getHook()), caught));
} else if (Entities.isNonHostile(caught)) {
Events.fireToCancel(event, new DamageEntityEvent(event, create(event.getPlayer(), event.getHook()), caught));
}
}
}