New options in conf.json which will now treat enemy factions differently: "territoryEnemyDenyBuild", "territoryEnemyDenyBuildWhenOffline","territoryEnemyDenyUseage", and "territoryEnemyProtectMaterials" (all default to true). If someone in an enemy faction tries any of those (builsing/destroying, using certain inventory items, or interacting with certain blocks such as doors), these new values will be checked; otherwise, for neutral and allied factions the existing values will be used.
Also slightly simplified the code used for checking relations.
This commit is contained in:
parent
787e6b867a
commit
d69b278728
@ -78,6 +78,10 @@ public class Conf {
|
|||||||
public static boolean territoryDenyBuild = true;
|
public static boolean territoryDenyBuild = true;
|
||||||
public static boolean territoryDenyBuildWhenOffline = true;
|
public static boolean territoryDenyBuildWhenOffline = true;
|
||||||
public static boolean territoryDenyUseage = true;
|
public static boolean territoryDenyUseage = true;
|
||||||
|
public static boolean territoryEnemyDenyBuild = true;
|
||||||
|
public static boolean territoryEnemyDenyBuildWhenOffline = true;
|
||||||
|
public static boolean territoryEnemyDenyUseage = true;
|
||||||
|
public static boolean territoryEnemyProtectMaterials = 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;
|
||||||
|
@ -7,7 +7,6 @@ import org.bukkit.entity.Player;
|
|||||||
import org.mcteam.factions.Conf;
|
import org.mcteam.factions.Conf;
|
||||||
import org.mcteam.factions.FPlayer;
|
import org.mcteam.factions.FPlayer;
|
||||||
import org.mcteam.factions.Faction;
|
import org.mcteam.factions.Faction;
|
||||||
import org.mcteam.factions.struct.Relation;
|
|
||||||
import org.mcteam.factions.struct.Role;
|
import org.mcteam.factions.struct.Role;
|
||||||
import org.mcteam.factions.util.TextUtil;
|
import org.mcteam.factions.util.TextUtil;
|
||||||
|
|
||||||
@ -73,9 +72,9 @@ public class FCommandShow extends FBaseCommand {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
listpart = otherFaction.getTag(me)+Conf.colorSystem+", ";
|
listpart = otherFaction.getTag(me)+Conf.colorSystem+", ";
|
||||||
if (otherFaction.getRelation(faction) == Relation.ALLY) {
|
if (otherFaction.getRelation(faction).isAlly()) {
|
||||||
allyList += listpart;
|
allyList += listpart;
|
||||||
} else if (otherFaction.getRelation(faction) == Relation.ENEMY) {
|
} else if (otherFaction.getRelation(faction).isEnemy()) {
|
||||||
enemyList += listpart;
|
enemyList += listpart;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -90,11 +90,15 @@ public class FactionsBlockListener extends BlockListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Faction myFaction = me.getFaction();
|
Faction myFaction = me.getFaction();
|
||||||
|
boolean areEnemies = myFaction.getRelation(otherFaction).isEnemy();
|
||||||
|
|
||||||
// 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 ((online && Conf.territoryDenyBuild) || (!online && Conf.territoryDenyBuildWhenOffline)) {
|
if (
|
||||||
|
(online && (areEnemies ? Conf.territoryEnemyDenyBuild : Conf.territoryDenyBuild))
|
||||||
|
|| (!online && (areEnemies ? Conf.territoryEnemyDenyBuildWhenOffline : Conf.territoryDenyBuildWhenOffline))
|
||||||
|
) {
|
||||||
me.sendMessage("You can't "+action+" in the territory of "+otherFaction.getTag(myFaction));
|
me.sendMessage("You can't "+action+" in the territory of "+otherFaction.getTag(myFaction));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -193,13 +193,13 @@ public class FactionsEntityListener extends EntityListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// You can never hurt faction members or allies
|
// You can never hurt faction members or allies
|
||||||
if (relation == Relation.MEMBER || relation == Relation.ALLY) {
|
if (relation.isMember() || relation.isAlly()) {
|
||||||
attacker.sendMessage(Conf.colorSystem+"You can't hurt "+defender.getNameAndRelevant(attacker));
|
attacker.sendMessage(Conf.colorSystem+"You can't hurt "+defender.getNameAndRelevant(attacker));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// You can not hurt neutrals in their own territory.
|
// You can not hurt neutrals in their own territory.
|
||||||
if (relation == Relation.NEUTRAL && defender.isInOwnTerritory()) {
|
if (relation.isNeutral() && defender.isInOwnTerritory()) {
|
||||||
attacker.sendMessage(Conf.colorSystem+"You can't hurt "+relation.getColor()+defender.getNameAndRelevant(attacker)+Conf.colorSystem+" in their own territory.");
|
attacker.sendMessage(Conf.colorSystem+"You can't hurt "+relation.getColor()+defender.getNameAndRelevant(attacker)+Conf.colorSystem+" in their own territory.");
|
||||||
defender.sendMessage(attacker.getNameAndRelevant(defender)+Conf.colorSystem+" tried to hurt you.");
|
defender.sendMessage(attacker.getNameAndRelevant(defender)+Conf.colorSystem+" tried to hurt you.");
|
||||||
return false;
|
return false;
|
||||||
@ -319,11 +319,15 @@ public class FactionsEntityListener extends EntityListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Faction myFaction = me.getFaction();
|
Faction myFaction = me.getFaction();
|
||||||
|
boolean areEnemies = myFaction.getRelation(otherFaction).isEnemy();
|
||||||
|
|
||||||
// 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 ((online && Conf.territoryDenyBuild) || (!online && Conf.territoryDenyBuildWhenOffline)) {
|
if (
|
||||||
|
(online && (areEnemies ? Conf.territoryEnemyDenyBuild : Conf.territoryDenyBuild))
|
||||||
|
|| (!online && (areEnemies ? Conf.territoryEnemyDenyBuildWhenOffline : 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;
|
||||||
}
|
}
|
||||||
|
@ -287,9 +287,10 @@ public class FactionsPlayerListener extends PlayerListener{
|
|||||||
}
|
}
|
||||||
|
|
||||||
Faction myFaction = me.getFaction();
|
Faction myFaction = me.getFaction();
|
||||||
|
boolean areEnemies = myFaction.getRelation(otherFaction).isEnemy();
|
||||||
|
|
||||||
// Cancel if we are not in our own territory
|
// Cancel if we are not in our own territory
|
||||||
if (myFaction != otherFaction && Conf.territoryDenyUseage) {
|
if (myFaction != otherFaction && (areEnemies ? Conf.territoryEnemyDenyUseage : 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;
|
||||||
}
|
}
|
||||||
@ -321,6 +322,10 @@ public class FactionsPlayerListener extends PlayerListener{
|
|||||||
FPlayer me = FPlayer.get(player);
|
FPlayer me = FPlayer.get(player);
|
||||||
Faction myFaction = me.getFaction();
|
Faction myFaction = me.getFaction();
|
||||||
|
|
||||||
|
if (myFaction.getRelation(otherFaction).isEnemy() && !Conf.territoryEnemyProtectMaterials) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// You may use any block unless it is another faction's territory...
|
// You may use any block unless it is another faction's territory...
|
||||||
if (otherFaction.isNormal() && myFaction != otherFaction) {
|
if (otherFaction.isNormal() && myFaction != otherFaction) {
|
||||||
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));
|
||||||
|
@ -23,6 +23,22 @@ public enum Relation {
|
|||||||
return this.nicename;
|
return this.nicename;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isMember() {
|
||||||
|
return this == Relation.MEMBER;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAlly() {
|
||||||
|
return this == Relation.ALLY;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isNeutral() {
|
||||||
|
return this == Relation.NEUTRAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEnemy() {
|
||||||
|
return this == Relation.ENEMY;
|
||||||
|
}
|
||||||
|
|
||||||
public ChatColor getColor() {
|
public ChatColor getColor() {
|
||||||
if (this == Relation.MEMBER) {
|
if (this == Relation.MEMBER) {
|
||||||
return Conf.colorMember;
|
return Conf.colorMember;
|
||||||
|
Loading…
Reference in New Issue
Block a user