Allowing environmental damage to minecarts.
Still not TNT, creepers, or players (without permission).
This commit is contained in:
parent
c5fab8dcd9
commit
1e0830542d
|
|
@ -146,6 +146,7 @@ public abstract class DataStore
|
||||||
}
|
}
|
||||||
//if failed, world guard compat features will just be disabled.
|
//if failed, world guard compat features will just be disabled.
|
||||||
catch(ClassNotFoundException exception){ }
|
catch(ClassNotFoundException exception){ }
|
||||||
|
catch(NoClassDefFoundError exception){ }
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadSoftMutes()
|
private void loadSoftMutes()
|
||||||
|
|
|
||||||
|
|
@ -764,36 +764,29 @@ class EntityEventHandler implements Listener
|
||||||
//determine which player is attacking, if any
|
//determine which player is attacking, if any
|
||||||
Player attacker = null;
|
Player attacker = null;
|
||||||
Entity damageSource = event.getAttacker();
|
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 damage source is null or a creeper, don't allow the damage when the vehicle is in a land claim
|
||||||
if(damageSource == null)
|
if(damageSource != null)
|
||||||
{
|
{
|
||||||
Claim claim = this.dataStore.getClaimAt(event.getVehicle().getLocation(), false, null);
|
damageSourceType = damageSource.getType();
|
||||||
|
|
||||||
//if it's claimed
|
if(damageSource.getType() == EntityType.PLAYER)
|
||||||
if(claim != null)
|
{
|
||||||
{
|
attacker = (Player)damageSource;
|
||||||
event.setCancelled(true);
|
}
|
||||||
}
|
else if(damageSource instanceof Projectile)
|
||||||
|
{
|
||||||
return;
|
Projectile arrow = (Projectile)damageSource;
|
||||||
}
|
if(arrow.getShooter() instanceof Player)
|
||||||
|
{
|
||||||
if(damageSource.getType() == EntityType.PLAYER)
|
attacker = (Player)arrow.getShooter();
|
||||||
{
|
}
|
||||||
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 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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import com.sk89q.worldedit.BlockVector;
|
||||||
import com.sk89q.worldguard.LocalPlayer;
|
import com.sk89q.worldguard.LocalPlayer;
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
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.managers.RegionManager;
|
||||||
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
||||||
|
|
||||||
|
|
@ -32,7 +33,7 @@ class WorldGuardWrapper
|
||||||
new BlockVector(greaterCorner.getX(), world.getMaxHeight(), greaterCorner.getZ()));
|
new BlockVector(greaterCorner.getX(), world.getMaxHeight(), greaterCorner.getZ()));
|
||||||
ApplicableRegionSet overlaps = manager.getApplicableRegions(tempRegion);
|
ApplicableRegionSet overlaps = manager.getApplicableRegions(tempRegion);
|
||||||
LocalPlayer localPlayer = worldGuard.wrapPlayer(creatingPlayer);
|
LocalPlayer localPlayer = worldGuard.wrapPlayer(creatingPlayer);
|
||||||
return overlaps.canBuild(localPlayer);
|
return overlaps.testState(localPlayer, DefaultFlag.BUILD);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user