Allowing environmental damage to minecarts.

Still not TNT, creepers, or players (without permission).
This commit is contained in:
ryanhamshire 2015-01-07 20:08:04 -08:00
parent c5fab8dcd9
commit 1e0830542d
3 changed files with 22 additions and 27 deletions

View File

@ -146,6 +146,7 @@ public abstract class DataStore
}
//if failed, world guard compat features will just be disabled.
catch(ClassNotFoundException exception){ }
catch(NoClassDefFoundError exception){ }
}
private void loadSoftMutes()

View File

@ -764,36 +764,29 @@ class EntityEventHandler implements Listener
//determine which player is attacking, if any
Player attacker = null;
Entity damageSource = event.getAttacker();
EntityType damageSourceType = null;
//if damage source is null, don't allow the damage when the vehicle is in a land claim
if(damageSource == null)
//if damage source is null or a creeper, don't allow the damage when the vehicle is in a land claim
if(damageSource != null)
{
Claim claim = this.dataStore.getClaimAt(event.getVehicle().getLocation(), false, null);
damageSourceType = damageSource.getType();
//if it's claimed
if(claim != null)
{
event.setCancelled(true);
}
return;
}
if(damageSource.getType() == EntityType.PLAYER)
{
attacker = (Player)damageSource;
}
else if(damageSource instanceof Projectile)
{
Projectile arrow = (Projectile)damageSource;
if(arrow.getShooter() instanceof Player)
{
attacker = (Player)arrow.getShooter();
}
if(damageSource.getType() == EntityType.PLAYER)
{
attacker = (Player)damageSource;
}
else if(damageSource instanceof Projectile)
{
Projectile arrow = (Projectile)damageSource;
if(arrow.getShooter() instanceof Player)
{
attacker = (Player)arrow.getShooter();
}
}
}
//if not a player and not an explosion, always allow
if(attacker == null && !(damageSource instanceof Explosive))
if(attacker == null && damageSourceType != EntityType.CREEPER && damageSourceType != EntityType.PRIMED_TNT)
{
return;
}

View File

@ -8,6 +8,7 @@ import com.sk89q.worldedit.BlockVector;
import com.sk89q.worldguard.LocalPlayer;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.protection.ApplicableRegionSet;
import com.sk89q.worldguard.protection.flags.DefaultFlag;
import com.sk89q.worldguard.protection.managers.RegionManager;
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
@ -32,7 +33,7 @@ class WorldGuardWrapper
new BlockVector(greaterCorner.getX(), world.getMaxHeight(), greaterCorner.getZ()));
ApplicableRegionSet overlaps = manager.getApplicableRegions(tempRegion);
LocalPlayer localPlayer = worldGuard.wrapPlayer(creatingPlayer);
return overlaps.canBuild(localPlayer);
return overlaps.testState(localPlayer, DefaultFlag.BUILD);
}
return true;