Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
96b0f5f25d | ||
|
|
4422d536b7 | ||
|
|
1f40908c04 |
No files matched your search
@@ -2,7 +2,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.sk89q</groupId>
|
||||
<artifactId>worldguard</artifactId>
|
||||
<version>5.9</version>
|
||||
<version>5.9.1-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<!-- Project information -->
|
||||
@@ -31,7 +31,7 @@
|
||||
<connection>scm:git:git://github.com/sk89q/worldguard.git</connection>
|
||||
<developerConnection>scm:git:git@github.com:sk89q/worldguard.git</developerConnection>
|
||||
<url>https://github.com/sk89q/worldguard</url>
|
||||
<tag>5.9</tag>
|
||||
<tag>master</tag>
|
||||
</scm>
|
||||
|
||||
<mailingLists>
|
||||
|
||||
@@ -70,6 +70,7 @@ import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.entity.PotionSplashEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.projectiles.ProjectileSource;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.blocks.BlockID;
|
||||
@@ -330,7 +331,7 @@ public class WorldGuardEntityListener implements Listener {
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(player.getWorld());
|
||||
ApplicableRegionSet set = mgr.getApplicableRegions(pt);
|
||||
if (fireball.getShooter() instanceof Player) {
|
||||
Vector pt2 = toVector(fireball.getShooter().getLocation());
|
||||
Vector pt2 = toVector(((Player) fireball.getShooter()).getLocation());
|
||||
if (!mgr.getApplicableRegions(pt2).allows(DefaultFlag.PVP, plugin.wrapPlayer((Player) fireball.getShooter()))) {
|
||||
tryCancelPVPEvent((Player) fireball.getShooter(), player, event, true);
|
||||
} else if (!set.allows(DefaultFlag.PVP, localPlayer)) {
|
||||
@@ -399,7 +400,13 @@ public class WorldGuardEntityListener implements Listener {
|
||||
|
||||
private void onEntityDamageByProjectile(EntityDamageByEntityEvent event) {
|
||||
Entity defender = event.getEntity();
|
||||
Entity attacker = ((Projectile) event.getDamager()).getShooter();
|
||||
Entity attacker;
|
||||
ProjectileSource source = ((Projectile) event.getDamager()).getShooter();
|
||||
if (source instanceof LivingEntity) {
|
||||
attacker = (LivingEntity) source;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
if (defender instanceof Player) {
|
||||
Player player = (Player) defender;
|
||||
|
||||
@@ -28,6 +28,7 @@ import org.bukkit.entity.Creeper;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Hanging;
|
||||
import org.bukkit.entity.ItemFrame;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Painting;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Projectile;
|
||||
@@ -39,6 +40,7 @@ import org.bukkit.event.hanging.HangingBreakEvent;
|
||||
import org.bukkit.event.hanging.HangingBreakEvent.RemoveCause;
|
||||
import org.bukkit.event.hanging.HangingPlaceEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.projectiles.ProjectileSource;
|
||||
|
||||
import com.sk89q.worldedit.blocks.ItemID;
|
||||
import com.sk89q.worldguard.blacklist.events.BlockBreakBlacklistEvent;
|
||||
@@ -81,8 +83,9 @@ public class WorldGuardHangingListener implements Listener {
|
||||
HangingBreakByEntityEvent entityEvent = (HangingBreakByEntityEvent) event;
|
||||
Entity removerEntity = entityEvent.getRemover();
|
||||
if (removerEntity instanceof Projectile) {
|
||||
Projectile projectile = (Projectile) removerEntity;
|
||||
removerEntity = projectile.getShooter() != null ? projectile.getShooter() : removerEntity;
|
||||
Projectile projectile = (Projectile) removerEntity;
|
||||
ProjectileSource remover = projectile.getShooter();
|
||||
removerEntity = (remover instanceof LivingEntity ? (LivingEntity) remover : null);
|
||||
}
|
||||
|
||||
if (removerEntity instanceof Player) {
|
||||
@@ -123,6 +126,8 @@ public class WorldGuardHangingListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
// this now covers dispensers as well, if removerEntity is null above,
|
||||
// due to a non-LivingEntity ProjectileSource
|
||||
if (hanging instanceof Painting
|
||||
&& (wcfg.blockEntityPaintingDestroy
|
||||
|| (wcfg.useRegions
|
||||
|
||||
@@ -129,30 +129,14 @@ public class ProtectedCuboidRegion extends ProtectedRegion {
|
||||
*/
|
||||
|
||||
@Override
|
||||
public List<ProtectedRegion> getIntersectingRegions(List<ProtectedRegion> regions) throws UnsupportedIntersectionException {
|
||||
List<ProtectedRegion> intersectingRegions = new ArrayList<ProtectedRegion>();
|
||||
|
||||
for (ProtectedRegion region : regions) {
|
||||
if (!intersectsBoundingBox(region)) continue;
|
||||
|
||||
// If both regions are Cuboids and their bounding boxes intersect, they intersect
|
||||
if (region instanceof ProtectedCuboidRegion) {
|
||||
intersectingRegions.add(region);
|
||||
continue;
|
||||
} else if (region instanceof ProtectedPolygonalRegion) {
|
||||
// If either region contains the points of the other,
|
||||
// or if any edges intersect, the regions intersect
|
||||
if (containsAny(region.getPoints())
|
||||
|| region.containsAny(getPoints())
|
||||
|| intersectsEdges(region)) {
|
||||
intersectingRegions.add(region);
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
public boolean intersectsRegion(ProtectedRegion region) {
|
||||
if (region instanceof ProtectedPolygonalRegion) {
|
||||
return intersectsRegionHelper(region);
|
||||
} else if (region instanceof ProtectedCuboidRegion) {
|
||||
return intersectsBoundingBox(region);
|
||||
} else {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
return intersectingRegions;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -23,7 +23,6 @@ import java.util.List;
|
||||
|
||||
import com.sk89q.worldedit.BlockVector2D;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldguard.protection.UnsupportedIntersectionException;
|
||||
|
||||
public class ProtectedPolygonalRegion extends ProtectedRegion {
|
||||
|
||||
@@ -122,30 +121,6 @@ public class ProtectedPolygonalRegion extends ProtectedRegion {
|
||||
return inside;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ProtectedRegion> getIntersectingRegions(List<ProtectedRegion> regions) throws UnsupportedIntersectionException {
|
||||
List<ProtectedRegion> intersectingRegions = new ArrayList<ProtectedRegion>();
|
||||
|
||||
for (ProtectedRegion region : regions) {
|
||||
if (!intersectsBoundingBox(region)) continue;
|
||||
|
||||
if (region instanceof ProtectedPolygonalRegion || region instanceof ProtectedCuboidRegion) {
|
||||
// If either region contains the points of the other,
|
||||
// or if any edges intersect, the regions intersect
|
||||
if (containsAny(region.getPoints())
|
||||
|| region.containsAny(getPoints())
|
||||
|| intersectsEdges(region)) {
|
||||
intersectingRegions.add(region);
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
}
|
||||
return intersectingRegions;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the type of region as a user-friendly name.
|
||||
*
|
||||
|
||||
@@ -28,6 +28,7 @@ import com.sk89q.worldguard.protection.UnsupportedIntersectionException;
|
||||
import com.sk89q.worldguard.protection.flags.Flag;
|
||||
|
||||
import java.awt.geom.Line2D;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -487,6 +488,24 @@ public abstract class ProtectedRegion implements Comparable<ProtectedRegion> {
|
||||
return id.compareTo(other.id);
|
||||
}
|
||||
|
||||
protected boolean intersectsRegionHelper(ProtectedRegion region) {
|
||||
if (!intersectsBoundingBox(region)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If either region contains the points of the other,
|
||||
// or if any edges intersect, the regions intersect
|
||||
return containsAny(region.getPoints()) || region.containsAny(getPoints()) || intersectsEdges(region);
|
||||
}
|
||||
|
||||
public boolean intersectsRegion(ProtectedRegion region) {
|
||||
if (!(region instanceof ProtectedPolygonalRegion) && (!(region instanceof ProtectedCuboidRegion))) {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
return intersectsRegionHelper(region);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the type of region as a user-friendly, lowercase name.
|
||||
*
|
||||
@@ -501,9 +520,16 @@ public abstract class ProtectedRegion implements Comparable<ProtectedRegion> {
|
||||
* @return The elements of {@code regions} that intersect with this region
|
||||
* @throws UnsupportedIntersectionException if an invalid intersection is detected
|
||||
*/
|
||||
public abstract List<ProtectedRegion> getIntersectingRegions(
|
||||
List<ProtectedRegion> regions)
|
||||
throws UnsupportedIntersectionException;
|
||||
public List<ProtectedRegion> getIntersectingRegions(List<ProtectedRegion> regions) throws UnsupportedIntersectionException {
|
||||
List<ProtectedRegion> intersectingRegions = new ArrayList<ProtectedRegion>();
|
||||
|
||||
for (ProtectedRegion region : regions) {
|
||||
if (intersectsRegion(region)) {
|
||||
intersectingRegions.add(region);
|
||||
}
|
||||
}
|
||||
return intersectingRegions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the bounding box of a region intersects with with the bounding
|
||||
|
||||
Reference in new issue
Block a user