Four new conf.json settings to prevent Endermen from removing or placing blocks.

"territoryDenyEndermanBlocks" (default true) for claimed territory.
"safeZoneDenyEndermanBlocks" (default true) for Safe Zones.
"warZoneDenyEndermanBlocks" (default true) for War Zones.
"wildernessDenyEndermanBlocks" (default false) for unclaimed wilderness areas.
This commit is contained in:
Brettflan 2011-09-22 06:22:01 -05:00
parent 492d983464
commit 34e4afee2c
3 changed files with 62 additions and 0 deletions

View File

@ -126,11 +126,13 @@ public class Conf {
public static boolean territoryBlockFireballsWhenOffline = false;
public static boolean territoryBlockTNT = false;
public static boolean territoryBlockTNTWhenOffline = false;
public static boolean territoryDenyEndermanBlocks = true;
public static boolean safeZoneDenyBuild = true;
public static boolean safeZoneDenyUseage = true;
public static boolean safeZoneBlockTNT = true;
public static boolean safeZonePreventAllDamageToPlayers = false;
public static boolean safeZoneDenyEndermanBlocks = true;
public static boolean warZoneDenyBuild = true;
public static boolean warZoneDenyUseage = true;
@ -139,6 +141,7 @@ public class Conf {
public static boolean warZoneBlockTNT = true;
public static boolean warZonePowerLoss = true;
public static boolean warZoneFriendlyFire = false;
public static boolean warZoneDenyEndermanBlocks = true;
public static boolean wildernessDenyBuild = false;
public static boolean wildernessDenyUseage = false;
@ -146,6 +149,7 @@ public class Conf {
public static boolean wildernessBlockFireballs = false;
public static boolean wildernessBlockTNT = false;
public static boolean wildernessPowerLoss = true;
public static boolean wildernessDenyEndermanBlocks = false;
// for claimed areas where further faction-member ownership can be defined
public static boolean ownedAreasEnabled = true;

View File

@ -168,6 +168,8 @@ public class Factions extends JavaPlugin {
pm.registerEvent(Event.Type.PLAYER_RESPAWN, this.playerListener, Event.Priority.High, this);
pm.registerEvent(Event.Type.PLAYER_BUCKET_EMPTY, this.playerListener, Event.Priority.Normal, this);
pm.registerEvent(Event.Type.PLAYER_BUCKET_FILL, this.playerListener, Event.Priority.Normal, this);
pm.registerEvent(Event.Type.ENDERMAN_PICKUP, this.entityListener, Event.Priority.Normal, this);
pm.registerEvent(Event.Type.ENDERMAN_PLACE, this.entityListener, Event.Priority.Normal, this);
pm.registerEvent(Event.Type.ENTITY_DEATH, this.entityListener, Event.Priority.Normal, this);
pm.registerEvent(Event.Type.ENTITY_DAMAGE, this.entityListener, Event.Priority.Normal, this);
pm.registerEvent(Event.Type.ENTITY_EXPLODE, this.entityListener, Event.Priority.Normal, this);

View File

@ -10,6 +10,8 @@ import org.bukkit.entity.Fireball;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.entity.EndermanPickupEvent;
import org.bukkit.event.entity.EndermanPlaceEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDeathEvent;
@ -389,4 +391,58 @@ public class FactionsEntityListener extends EntityListener {
return true;
}
@Override
public void onEndermanPickup(EndermanPickupEvent event) {
if (event.isCancelled()) {
return;
}
if (stopEndermanBlockManipulation(event.getBlock().getLocation())) {
event.setCancelled(true);
}
}
@Override
public void onEndermanPlace(EndermanPlaceEvent event) {
if (event.isCancelled()) {
return;
}
if (stopEndermanBlockManipulation(event.getLocation())) {
event.setCancelled(true);
}
}
private boolean stopEndermanBlockManipulation(Location loc) {
if (loc == null) {
return false;
}
// quick check to see if all Enderman deny options are enabled; if so, no need to check location
if ( Conf.wildernessDenyEndermanBlocks
&& Conf.territoryDenyEndermanBlocks
&& Conf.safeZoneDenyEndermanBlocks
&& Conf.warZoneDenyEndermanBlocks
) {
return true;
}
FLocation fLoc = new FLocation(loc);
Faction claimFaction = Board.getFactionAt(fLoc);
if (claimFaction.isNone()) {
return Conf.wildernessDenyEndermanBlocks;
}
else if (claimFaction.isNormal()) {
return Conf.territoryDenyEndermanBlocks;
}
else if (claimFaction.isSafeZone()) {
return Conf.safeZoneDenyEndermanBlocks;
}
else if (claimFaction.isWarZone()) {
return Conf.warZoneDenyEndermanBlocks;
}
return false;
}
}