Added new "Ally" related protection options to complement the "Enemy" ones (added thanks to donation from BeTrayed)
This commit is contained in:
parent
83d1e52be3
commit
82db1624c9
@ -107,6 +107,12 @@ public class Conf {
|
||||
public static boolean territoryEnemyPainBuildWhenOffline = false;
|
||||
public static boolean territoryEnemyDenyUseage = 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 territoryBlockCreepersWhenOffline = false;
|
||||
public static boolean territoryBlockFireballs = false;
|
||||
|
@ -17,6 +17,7 @@ import com.massivecraft.factions.FLocation;
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.Factions;
|
||||
import com.massivecraft.factions.struct.Relation;
|
||||
|
||||
|
||||
public class FactionsBlockListener extends BlockListener {
|
||||
@ -134,12 +135,12 @@ public class FactionsBlockListener extends BlockListener {
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean areEnemies = pistonFaction.getRelation(otherFaction).isEnemy();
|
||||
Relation rel = pistonFaction.getRelation(otherFaction);
|
||||
boolean online = otherFaction.hasPlayersOnline();
|
||||
|
||||
if (
|
||||
(online && (areEnemies ? Conf.territoryEnemyDenyBuild : Conf.territoryDenyBuild))
|
||||
|| (!online && (areEnemies ? Conf.territoryEnemyDenyBuildWhenOffline : Conf.territoryDenyBuildWhenOffline))
|
||||
(online && (rel.isEnemy() ? Conf.territoryEnemyDenyBuild : (rel.isAlly() ? Conf.territoryAllyDenyBuild : Conf.territoryDenyBuild)))
|
||||
|| (!online && (rel.isEnemy() ? Conf.territoryEnemyDenyBuildWhenOffline : (rel.isAlly() ? Conf.territoryAllyDenyBuildWhenOffline : Conf.territoryDenyBuildWhenOffline)))
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
@ -180,15 +181,15 @@ public class FactionsBlockListener extends BlockListener {
|
||||
}
|
||||
|
||||
Faction myFaction = me.getFaction();
|
||||
boolean areEnemies = myFaction.getRelation(otherFaction).isEnemy();
|
||||
Relation rel = myFaction.getRelation(otherFaction);
|
||||
|
||||
// Cancel if we are not in our own territory
|
||||
if (myFaction != otherFaction) {
|
||||
boolean online = otherFaction.hasPlayersOnline();
|
||||
boolean pain = (online && (areEnemies ? Conf.territoryEnemyPainBuild : Conf.territoryPainBuild))
|
||||
|| (!online && (areEnemies ? Conf.territoryEnemyPainBuildWhenOffline : Conf.territoryPainBuildWhenOffline));
|
||||
boolean deny = (online && (areEnemies ? Conf.territoryEnemyDenyBuild : Conf.territoryDenyBuild))
|
||||
|| (!online && (areEnemies ? Conf.territoryEnemyDenyBuildWhenOffline : Conf.territoryDenyBuildWhenOffline));
|
||||
boolean pain = (online && (rel.isEnemy() ? Conf.territoryEnemyPainBuild : (rel.isAlly() ? Conf.territoryAllyPainBuild : Conf.territoryPainBuild)))
|
||||
|| (!online && (rel.isEnemy() ? Conf.territoryEnemyPainBuildWhenOffline : (rel.isAlly() ? Conf.territoryAllyPainBuildWhenOffline : Conf.territoryPainBuildWhenOffline)));
|
||||
boolean deny = (online && (rel.isEnemy() ? Conf.territoryEnemyDenyBuild : (rel.isAlly() ? Conf.territoryAllyDenyBuild : Conf.territoryDenyBuild)))
|
||||
|| (!online && (rel.isEnemy() ? Conf.territoryEnemyDenyBuildWhenOffline : (rel.isAlly() ? Conf.territoryAllyDenyBuildWhenOffline : Conf.territoryDenyBuildWhenOffline)));
|
||||
//added by Bladedpenguin@gmail.com
|
||||
//hurt the player for building/destroying?
|
||||
if (pain) {
|
||||
|
@ -371,14 +371,14 @@ public class FactionsEntityListener extends EntityListener {
|
||||
}
|
||||
|
||||
Faction myFaction = me.getFaction();
|
||||
boolean areEnemies = myFaction.getRelation(otherFaction).isEnemy();
|
||||
Relation rel = myFaction.getRelation(otherFaction);
|
||||
|
||||
// Cancel if we are not in our own territory
|
||||
if (myFaction != otherFaction) {
|
||||
boolean online = otherFaction.hasPlayersOnline();
|
||||
if (
|
||||
(online && (areEnemies ? Conf.territoryEnemyDenyBuild : Conf.territoryDenyBuild))
|
||||
|| (!online && (areEnemies ? Conf.territoryEnemyDenyBuildWhenOffline : Conf.territoryDenyBuildWhenOffline))
|
||||
(online && (rel.isEnemy() ? Conf.territoryEnemyDenyBuild : (rel.isAlly() ? Conf.territoryAllyDenyBuild : Conf.territoryDenyBuild)))
|
||||
|| (!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));
|
||||
return false;
|
||||
|
@ -321,11 +321,11 @@ public class FactionsPlayerListener extends PlayerListener{
|
||||
}
|
||||
|
||||
Faction myFaction = me.getFaction();
|
||||
boolean areEnemies = myFaction.getRelation(otherFaction).isEnemy();
|
||||
Relation rel = myFaction.getRelation(otherFaction);
|
||||
|
||||
// Cancel if we are not in our own territory
|
||||
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));
|
||||
return false;
|
||||
}
|
||||
@ -367,8 +367,9 @@ public class FactionsPlayerListener extends PlayerListener{
|
||||
|
||||
FPlayer me = FPlayer.get(player);
|
||||
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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user