2011-07-18 22:06:02 +02:00
|
|
|
package com.massivecraft.factions.struct;
|
2011-02-06 13:36:11 +01:00
|
|
|
|
2014-04-04 20:55:21 +02:00
|
|
|
import com.massivecraft.factions.Conf;
|
2014-12-08 00:12:52 +01:00
|
|
|
import com.massivecraft.factions.zcore.util.TL;
|
2011-02-06 13:36:11 +01:00
|
|
|
import org.bukkit.ChatColor;
|
2011-07-18 22:06:02 +02:00
|
|
|
|
2011-02-06 13:36:11 +01:00
|
|
|
|
2014-04-04 20:55:21 +02:00
|
|
|
public enum Relation {
|
2015-01-23 03:30:40 +01:00
|
|
|
MEMBER(4, "member"),
|
|
|
|
ALLY(3, "ally"),
|
|
|
|
TRUCE(2, "truce"),
|
2014-04-04 20:55:21 +02:00
|
|
|
NEUTRAL(1, "neutral"),
|
|
|
|
ENEMY(0, "enemy");
|
|
|
|
|
|
|
|
public final int value;
|
|
|
|
public final String nicename;
|
|
|
|
|
|
|
|
private Relation(final int value, final String nicename) {
|
2014-07-01 22:10:18 +02:00
|
|
|
this.value = value;
|
|
|
|
this.nicename = nicename;
|
2014-04-04 20:55:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String toString() {
|
|
|
|
return this.nicename;
|
|
|
|
}
|
2014-12-09 23:01:20 +01:00
|
|
|
|
|
|
|
public static Relation fromString(String s) {
|
|
|
|
// Because Java 6 doesn't allow String switches :(
|
|
|
|
if (s.equalsIgnoreCase("member")) {
|
2015-01-23 03:30:40 +01:00
|
|
|
return MEMBER;
|
2014-12-09 23:01:20 +01:00
|
|
|
} else if (s.equalsIgnoreCase("ally")) {
|
2015-01-23 03:30:40 +01:00
|
|
|
return ALLY;
|
|
|
|
} else if(s.equalsIgnoreCase("truce")) {
|
|
|
|
return TRUCE;
|
2014-12-09 23:01:20 +01:00
|
|
|
} else if (s.equalsIgnoreCase("enemy")) {
|
2015-01-23 03:30:40 +01:00
|
|
|
return ENEMY;
|
2014-12-09 23:01:20 +01:00
|
|
|
} else {
|
2015-01-23 03:30:40 +01:00
|
|
|
return NEUTRAL; // If they somehow mess things up, go back to default behavior.
|
2014-12-09 23:01:20 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getTranslation() {
|
|
|
|
for (TL t : TL.values()) {
|
|
|
|
if (t.name().equals("RELATION_" + name())) {
|
|
|
|
return t.toString();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return toString();
|
2014-12-08 00:12:52 +01:00
|
|
|
}
|
2014-04-04 20:55:21 +02:00
|
|
|
|
|
|
|
public boolean isMember() {
|
|
|
|
return this == MEMBER;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isAlly() {
|
|
|
|
return this == ALLY;
|
|
|
|
}
|
|
|
|
|
2015-01-23 03:30:40 +01:00
|
|
|
public boolean isTruce() {
|
|
|
|
return this == TRUCE;
|
|
|
|
}
|
|
|
|
|
2014-04-04 20:55:21 +02:00
|
|
|
public boolean isNeutral() {
|
|
|
|
return this == NEUTRAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isEnemy() {
|
|
|
|
return this == ENEMY;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isAtLeast(Relation relation) {
|
|
|
|
return this.value >= relation.value;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isAtMost(Relation relation) {
|
|
|
|
return this.value <= relation.value;
|
|
|
|
}
|
|
|
|
|
|
|
|
public ChatColor getColor() {
|
2014-07-01 22:10:18 +02:00
|
|
|
if (this == MEMBER) {
|
|
|
|
return Conf.colorMember;
|
|
|
|
} else if (this == ALLY) {
|
2014-07-01 21:52:40 +02:00
|
|
|
return Conf.colorAlly;
|
2014-07-01 22:10:18 +02:00
|
|
|
} else if (this == NEUTRAL) {
|
|
|
|
return Conf.colorNeutral;
|
2015-01-23 03:30:40 +01:00
|
|
|
} else if (this == TRUCE) {
|
|
|
|
return Conf.colorTruce;
|
2014-07-01 22:10:18 +02:00
|
|
|
} else {
|
|
|
|
return Conf.colorEnemy;
|
|
|
|
}
|
2014-04-04 20:55:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// return appropriate Conf setting for DenyBuild based on this relation and their online status
|
|
|
|
public boolean confDenyBuild(boolean online) {
|
2014-07-01 22:10:18 +02:00
|
|
|
if (isMember()) {
|
|
|
|
return false;
|
|
|
|
}
|
2014-04-04 20:55:21 +02:00
|
|
|
|
|
|
|
if (online) {
|
2014-07-01 22:10:18 +02:00
|
|
|
if (isEnemy()) {
|
|
|
|
return Conf.territoryEnemyDenyBuild;
|
|
|
|
} else if (isAlly()) {
|
2014-07-01 21:52:40 +02:00
|
|
|
return Conf.territoryAllyDenyBuild;
|
2015-01-23 03:30:40 +01:00
|
|
|
} else if (isTruce()) {
|
|
|
|
return Conf.territoryTruceDenyBuild;
|
2014-07-01 22:10:18 +02:00
|
|
|
} else {
|
|
|
|
return Conf.territoryDenyBuild;
|
|
|
|
}
|
2014-07-01 21:52:40 +02:00
|
|
|
} else {
|
2014-07-01 22:10:18 +02:00
|
|
|
if (isEnemy()) {
|
|
|
|
return Conf.territoryEnemyDenyBuildWhenOffline;
|
|
|
|
} else if (isAlly()) {
|
2014-07-01 21:52:40 +02:00
|
|
|
return Conf.territoryAllyDenyBuildWhenOffline;
|
2015-01-23 03:30:40 +01:00
|
|
|
} else if (isTruce()) {
|
|
|
|
return Conf.territoryTruceDenyBuildWhenOffline;
|
2014-07-01 22:10:18 +02:00
|
|
|
} else {
|
|
|
|
return Conf.territoryDenyBuildWhenOffline;
|
|
|
|
}
|
2014-04-04 20:55:21 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// return appropriate Conf setting for PainBuild based on this relation and their online status
|
|
|
|
public boolean confPainBuild(boolean online) {
|
2014-07-01 22:10:18 +02:00
|
|
|
if (isMember()) {
|
|
|
|
return false;
|
|
|
|
}
|
2014-04-04 20:55:21 +02:00
|
|
|
|
|
|
|
if (online) {
|
2014-07-01 22:10:18 +02:00
|
|
|
if (isEnemy()) {
|
|
|
|
return Conf.territoryEnemyPainBuild;
|
|
|
|
} else if (isAlly()) {
|
2014-07-01 21:52:40 +02:00
|
|
|
return Conf.territoryAllyPainBuild;
|
2015-01-23 03:30:40 +01:00
|
|
|
} else if (isTruce()) {
|
|
|
|
return Conf.territoryTrucePainBuild;
|
2014-07-01 22:10:18 +02:00
|
|
|
} else {
|
|
|
|
return Conf.territoryPainBuild;
|
|
|
|
}
|
2014-07-01 21:52:40 +02:00
|
|
|
} else {
|
2014-07-01 22:10:18 +02:00
|
|
|
if (isEnemy()) {
|
|
|
|
return Conf.territoryEnemyPainBuildWhenOffline;
|
|
|
|
} else if (isAlly()) {
|
2014-07-01 21:52:40 +02:00
|
|
|
return Conf.territoryAllyPainBuildWhenOffline;
|
2015-01-23 03:30:40 +01:00
|
|
|
} else if (isTruce()) {
|
|
|
|
return Conf.territoryTrucePainBuildWhenOffline;
|
2014-07-01 22:10:18 +02:00
|
|
|
} else {
|
|
|
|
return Conf.territoryPainBuildWhenOffline;
|
|
|
|
}
|
2014-04-04 20:55:21 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// return appropriate Conf setting for DenyUseage based on this relation
|
|
|
|
public boolean confDenyUseage() {
|
2014-07-01 22:10:18 +02:00
|
|
|
if (isMember()) {
|
|
|
|
return false;
|
|
|
|
} else if (isEnemy()) {
|
2014-07-01 21:52:40 +02:00
|
|
|
return Conf.territoryEnemyDenyUseage;
|
2014-07-01 22:10:18 +02:00
|
|
|
} else if (isAlly()) {
|
|
|
|
return Conf.territoryAllyDenyUseage;
|
2015-01-23 03:30:40 +01:00
|
|
|
} else if (isTruce()) {
|
|
|
|
return Conf.territoryTruceDenyUseage;
|
2014-07-01 22:10:18 +02:00
|
|
|
} else {
|
|
|
|
return Conf.territoryDenyUseage;
|
|
|
|
}
|
2014-04-04 20:55:21 +02:00
|
|
|
}
|
2011-02-06 13:36:11 +01:00
|
|
|
|
2014-04-04 20:55:21 +02:00
|
|
|
public double getRelationCost() {
|
2014-07-01 22:10:18 +02:00
|
|
|
if (isEnemy()) {
|
|
|
|
return Conf.econCostEnemy;
|
|
|
|
} else if (isAlly()) {
|
|
|
|
return Conf.econCostAlly;
|
2015-01-23 03:30:40 +01:00
|
|
|
} else if (isTruce()) {
|
|
|
|
return Conf.econCostTruce;
|
2014-07-01 22:10:18 +02:00
|
|
|
} else {
|
2014-07-01 21:52:40 +02:00
|
|
|
return Conf.econCostNeutral;
|
|
|
|
}
|
2014-04-04 20:55:21 +02:00
|
|
|
}
|
2011-02-06 13:36:11 +01:00
|
|
|
}
|