Saber-Factions/src/main/java/com/massivecraft/factions/struct/Relation.java

147 lines
2.7 KiB
Java
Raw Normal View History

2011-07-18 22:06:02 +02:00
package com.massivecraft.factions.struct;
2011-02-06 13:36:11 +01:00
import org.bukkit.ChatColor;
2011-07-18 22:06:02 +02:00
import com.massivecraft.factions.Conf;
2011-02-06 13:36:11 +01:00
public enum Relation
{
2011-02-06 13:36:11 +01:00
MEMBER(3, "member"),
ALLY(2, "ally"),
NEUTRAL(1, "neutral"),
ENEMY(0, "enemy");
public final int value;
public final String nicename;
2011-10-12 17:25:01 +02:00
private Relation(final int value, final String nicename)
{
this.value = value;
this.nicename = nicename;
}
2011-02-06 13:36:11 +01:00
@Override
public String toString()
{
2011-02-06 13:36:11 +01:00
return this.nicename;
}
public boolean isMember()
{
2011-10-12 17:25:01 +02:00
return this == MEMBER;
}
public boolean isAlly()
{
2011-10-12 17:25:01 +02:00
return this == ALLY;
}
public boolean isNeutral()
{
2011-10-12 17:25:01 +02:00
return this == NEUTRAL;
}
public boolean isEnemy()
{
2011-10-12 17:25:01 +02:00
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()
{
2011-10-12 17:25:01 +02:00
if (this == MEMBER)
return Conf.colorMember;
2011-10-12 17:25:01 +02:00
else if (this == ALLY)
return Conf.colorAlly;
2011-10-12 17:25:01 +02:00
else if (this == NEUTRAL)
return Conf.colorNeutral;
else
return Conf.colorEnemy;
2011-02-06 13:36:11 +01:00
}
// return appropriate Conf setting for DenyBuild based on this relation and their online status
public boolean confDenyBuild(boolean online)
{
if (isMember())
return false;
if (online)
{
if (isEnemy())
return Conf.territoryEnemyDenyBuild;
else if (isAlly())
return Conf.territoryAllyDenyBuild;
else
return Conf.territoryDenyBuild;
}
else
{
if (isEnemy())
return Conf.territoryEnemyDenyBuildWhenOffline;
else if (isAlly())
return Conf.territoryAllyDenyBuildWhenOffline;
else
return Conf.territoryDenyBuildWhenOffline;
}
}
// return appropriate Conf setting for PainBuild based on this relation and their online status
public boolean confPainBuild(boolean online)
{
if (isMember())
return false;
if (online)
{
if (isEnemy())
return Conf.territoryEnemyPainBuild;
else if (isAlly())
return Conf.territoryAllyPainBuild;
else
return Conf.territoryPainBuild;
}
else
{
if (isEnemy())
return Conf.territoryEnemyPainBuildWhenOffline;
else if (isAlly())
return Conf.territoryAllyPainBuildWhenOffline;
else
return Conf.territoryPainBuildWhenOffline;
}
}
// return appropriate Conf setting for DenyUseage based on this relation
public boolean confDenyUseage()
{
if (isMember())
return false;
else if (isEnemy())
return Conf.territoryEnemyDenyUseage;
else if (isAlly())
return Conf.territoryAllyDenyUseage;
else
return Conf.territoryDenyUseage;
}
2011-10-09 18:35:39 +02:00
public double getRelationCost()
{
if (isEnemy())
return Conf.econCostEnemy;
else if (isAlly())
return Conf.econCostAlly;
else
return Conf.econCostNeutral;
}
2011-02-06 13:36:11 +01:00
}