Added new "Ally" related protection options to complement the "Enemy" ones (added thanks to donation from BeTrayed)

This commit is contained in:
Brettflan 2011-08-23 17:12:17 -05:00
parent 83d1e52be3
commit 82db1624c9
4 changed files with 22 additions and 14 deletions

View File

@ -107,6 +107,12 @@ public class Conf {
public static boolean territoryEnemyPainBuildWhenOffline = false; public static boolean territoryEnemyPainBuildWhenOffline = false;
public static boolean territoryEnemyDenyUseage = true; public static boolean territoryEnemyDenyUseage = true;
public static boolean territoryEnemyProtectMaterials = true; public static boolean territoryEnemyProtectMaterials = true;
public static boolean territoryAllyDenyBuild = true;
public static boolean territoryAllyDenyBuildWhenOffline = true;
public static boolean territoryAllyPainBuild = false;
public static boolean territoryAllyPainBuildWhenOffline = false;
public static boolean territoryAllyDenyUseage = true;
public static boolean territoryAllyProtectMaterials = true;
public static boolean territoryBlockCreepers = false; public static boolean territoryBlockCreepers = false;
public static boolean territoryBlockCreepersWhenOffline = false; public static boolean territoryBlockCreepersWhenOffline = false;
public static boolean territoryBlockFireballs = false; public static boolean territoryBlockFireballs = false;

View File

@ -17,6 +17,7 @@ import com.massivecraft.factions.FLocation;
import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.Faction; import com.massivecraft.factions.Faction;
import com.massivecraft.factions.Factions; import com.massivecraft.factions.Factions;
import com.massivecraft.factions.struct.Relation;
public class FactionsBlockListener extends BlockListener { public class FactionsBlockListener extends BlockListener {
@ -134,12 +135,12 @@ public class FactionsBlockListener extends BlockListener {
return false; return false;
} }
boolean areEnemies = pistonFaction.getRelation(otherFaction).isEnemy(); Relation rel = pistonFaction.getRelation(otherFaction);
boolean online = otherFaction.hasPlayersOnline(); boolean online = otherFaction.hasPlayersOnline();
if ( if (
(online && (areEnemies ? Conf.territoryEnemyDenyBuild : Conf.territoryDenyBuild)) (online && (rel.isEnemy() ? Conf.territoryEnemyDenyBuild : (rel.isAlly() ? Conf.territoryAllyDenyBuild : Conf.territoryDenyBuild)))
|| (!online && (areEnemies ? Conf.territoryEnemyDenyBuildWhenOffline : Conf.territoryDenyBuildWhenOffline)) || (!online && (rel.isEnemy() ? Conf.territoryEnemyDenyBuildWhenOffline : (rel.isAlly() ? Conf.territoryAllyDenyBuildWhenOffline : Conf.territoryDenyBuildWhenOffline)))
) { ) {
return false; return false;
} }
@ -180,15 +181,15 @@ public class FactionsBlockListener extends BlockListener {
} }
Faction myFaction = me.getFaction(); Faction myFaction = me.getFaction();
boolean areEnemies = myFaction.getRelation(otherFaction).isEnemy(); Relation rel = myFaction.getRelation(otherFaction);
// Cancel if we are not in our own territory // Cancel if we are not in our own territory
if (myFaction != otherFaction) { if (myFaction != otherFaction) {
boolean online = otherFaction.hasPlayersOnline(); boolean online = otherFaction.hasPlayersOnline();
boolean pain = (online && (areEnemies ? Conf.territoryEnemyPainBuild : Conf.territoryPainBuild)) boolean pain = (online && (rel.isEnemy() ? Conf.territoryEnemyPainBuild : (rel.isAlly() ? Conf.territoryAllyPainBuild : Conf.territoryPainBuild)))
|| (!online && (areEnemies ? Conf.territoryEnemyPainBuildWhenOffline : Conf.territoryPainBuildWhenOffline)); || (!online && (rel.isEnemy() ? Conf.territoryEnemyPainBuildWhenOffline : (rel.isAlly() ? Conf.territoryAllyPainBuildWhenOffline : Conf.territoryPainBuildWhenOffline)));
boolean deny = (online && (areEnemies ? Conf.territoryEnemyDenyBuild : Conf.territoryDenyBuild)) boolean deny = (online && (rel.isEnemy() ? Conf.territoryEnemyDenyBuild : (rel.isAlly() ? Conf.territoryAllyDenyBuild : Conf.territoryDenyBuild)))
|| (!online && (areEnemies ? Conf.territoryEnemyDenyBuildWhenOffline : Conf.territoryDenyBuildWhenOffline)); || (!online && (rel.isEnemy() ? Conf.territoryEnemyDenyBuildWhenOffline : (rel.isAlly() ? Conf.territoryAllyDenyBuildWhenOffline : Conf.territoryDenyBuildWhenOffline)));
//added by Bladedpenguin@gmail.com //added by Bladedpenguin@gmail.com
//hurt the player for building/destroying? //hurt the player for building/destroying?
if (pain) { if (pain) {

View File

@ -371,14 +371,14 @@ public class FactionsEntityListener extends EntityListener {
} }
Faction myFaction = me.getFaction(); Faction myFaction = me.getFaction();
boolean areEnemies = myFaction.getRelation(otherFaction).isEnemy(); Relation rel = myFaction.getRelation(otherFaction);
// Cancel if we are not in our own territory // Cancel if we are not in our own territory
if (myFaction != otherFaction) { if (myFaction != otherFaction) {
boolean online = otherFaction.hasPlayersOnline(); boolean online = otherFaction.hasPlayersOnline();
if ( if (
(online && (areEnemies ? Conf.territoryEnemyDenyBuild : Conf.territoryDenyBuild)) (online && (rel.isEnemy() ? Conf.territoryEnemyDenyBuild : (rel.isAlly() ? Conf.territoryAllyDenyBuild : Conf.territoryDenyBuild)))
|| (!online && (areEnemies ? Conf.territoryEnemyDenyBuildWhenOffline : Conf.territoryDenyBuildWhenOffline)) || (!online && (rel.isEnemy() ? Conf.territoryEnemyDenyBuildWhenOffline : (rel.isAlly() ? Conf.territoryAllyDenyBuildWhenOffline : Conf.territoryDenyBuildWhenOffline)))
) { ) {
me.sendMessage("You can't "+action+" paintings in the territory of "+otherFaction.getTag(myFaction)); me.sendMessage("You can't "+action+" paintings in the territory of "+otherFaction.getTag(myFaction));
return false; return false;

View File

@ -321,11 +321,11 @@ public class FactionsPlayerListener extends PlayerListener{
} }
Faction myFaction = me.getFaction(); Faction myFaction = me.getFaction();
boolean areEnemies = myFaction.getRelation(otherFaction).isEnemy(); Relation rel = myFaction.getRelation(otherFaction);
// Cancel if we are not in our own territory // Cancel if we are not in our own territory
if (myFaction != otherFaction) { if (myFaction != otherFaction) {
if (areEnemies ? Conf.territoryEnemyDenyUseage : Conf.territoryDenyUseage) { if (rel.isEnemy() ? Conf.territoryEnemyDenyUseage : (rel.isAlly() ? Conf.territoryAllyDenyUseage : Conf.territoryDenyUseage)) {
me.sendMessage("You can't use "+TextUtil.getMaterialName(material)+" in the territory of "+otherFaction.getTag(myFaction)); me.sendMessage("You can't use "+TextUtil.getMaterialName(material)+" in the territory of "+otherFaction.getTag(myFaction));
return false; return false;
} }
@ -367,8 +367,9 @@ public class FactionsPlayerListener extends PlayerListener{
FPlayer me = FPlayer.get(player); FPlayer me = FPlayer.get(player);
Faction myFaction = me.getFaction(); Faction myFaction = me.getFaction();
Relation rel = myFaction.getRelation(otherFaction);
if (myFaction.getRelation(otherFaction).isEnemy() && !Conf.territoryEnemyProtectMaterials) { if ((rel.isEnemy() && !Conf.territoryEnemyProtectMaterials) || (rel.isAlly() && !Conf.territoryAllyProtectMaterials)) {
return true; return true;
} }