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
|
|
|
|
|
|
|
|
2011-10-08 22:03:44 +02: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)
|
|
|
|
{
|
2011-02-06 13:36:11 +01:00
|
|
|
this.value = value;
|
|
|
|
this.nicename = nicename;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2011-10-08 22:03:44 +02:00
|
|
|
public String toString()
|
|
|
|
{
|
2011-02-06 13:36:11 +01:00
|
|
|
return this.nicename;
|
|
|
|
}
|
|
|
|
|
2011-10-08 22:03:44 +02:00
|
|
|
public boolean isMember()
|
|
|
|
{
|
2011-10-12 17:25:01 +02:00
|
|
|
return this == MEMBER;
|
2011-07-09 08:36:18 +02:00
|
|
|
}
|
|
|
|
|
2011-10-08 22:03:44 +02:00
|
|
|
public boolean isAlly()
|
|
|
|
{
|
2011-10-12 17:25:01 +02:00
|
|
|
return this == ALLY;
|
2011-07-09 08:36:18 +02:00
|
|
|
}
|
|
|
|
|
2011-10-08 22:03:44 +02:00
|
|
|
public boolean isNeutral()
|
|
|
|
{
|
2011-10-12 17:25:01 +02:00
|
|
|
return this == NEUTRAL;
|
2011-07-09 08:36:18 +02:00
|
|
|
}
|
|
|
|
|
2011-10-08 22:03:44 +02:00
|
|
|
public boolean isEnemy()
|
|
|
|
{
|
2011-10-12 17:25:01 +02:00
|
|
|
return this == ENEMY;
|
2011-07-09 08:36:18 +02:00
|
|
|
}
|
|
|
|
|
2011-10-08 22:03:44 +02:00
|
|
|
public boolean isAtLeast(Relation relation)
|
|
|
|
{
|
2011-08-02 02:59:48 +02:00
|
|
|
return this.value >= relation.value;
|
|
|
|
}
|
|
|
|
|
2011-10-08 22:03:44 +02:00
|
|
|
public boolean isAtMost(Relation relation)
|
|
|
|
{
|
2011-08-02 02:59:48 +02:00
|
|
|
return this.value <= relation.value;
|
|
|
|
}
|
|
|
|
|
2011-10-08 22:03:44 +02:00
|
|
|
public ChatColor getColor()
|
|
|
|
{
|
2011-10-12 17:25:01 +02:00
|
|
|
if (this == MEMBER)
|
2011-02-12 18:05:05 +01:00
|
|
|
return Conf.colorMember;
|
2011-10-12 17:25:01 +02:00
|
|
|
else if (this == ALLY)
|
2011-02-12 18:05:05 +01:00
|
|
|
return Conf.colorAlly;
|
2011-10-12 17:25:01 +02:00
|
|
|
else if (this == NEUTRAL)
|
2011-02-12 18:05:05 +01:00
|
|
|
return Conf.colorNeutral;
|
2011-10-08 22:03:44 +02:00
|
|
|
else
|
2011-02-12 18:05:05 +01:00
|
|
|
return Conf.colorEnemy;
|
2011-02-06 13:36:11 +01:00
|
|
|
}
|
2011-09-06 23:35:43 +02:00
|
|
|
|
|
|
|
// return appropriate Conf setting for DenyBuild based on this relation and their online status
|
2011-10-08 22:03:44 +02:00
|
|
|
public boolean confDenyBuild(boolean online)
|
|
|
|
{
|
2011-10-12 03:14:59 +02:00
|
|
|
if (isMember())
|
|
|
|
return false;
|
|
|
|
|
2011-10-08 22:03:44 +02:00
|
|
|
if (online)
|
|
|
|
{
|
|
|
|
if (isEnemy())
|
2011-09-06 23:35:43 +02:00
|
|
|
return Conf.territoryEnemyDenyBuild;
|
2011-10-08 22:03:44 +02:00
|
|
|
else if (isAlly())
|
2011-09-06 23:35:43 +02:00
|
|
|
return Conf.territoryAllyDenyBuild;
|
2011-10-08 22:03:44 +02:00
|
|
|
else
|
2011-09-06 23:35:43 +02:00
|
|
|
return Conf.territoryDenyBuild;
|
|
|
|
}
|
2011-10-08 22:03:44 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (isEnemy())
|
2011-09-06 23:35:43 +02:00
|
|
|
return Conf.territoryEnemyDenyBuildWhenOffline;
|
2011-10-08 22:03:44 +02:00
|
|
|
else if (isAlly())
|
2011-09-06 23:35:43 +02:00
|
|
|
return Conf.territoryAllyDenyBuildWhenOffline;
|
2011-10-08 22:03:44 +02:00
|
|
|
else
|
2011-09-06 23:35:43 +02:00
|
|
|
return Conf.territoryDenyBuildWhenOffline;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// return appropriate Conf setting for PainBuild based on this relation and their online status
|
2011-10-08 22:03:44 +02:00
|
|
|
public boolean confPainBuild(boolean online)
|
|
|
|
{
|
2011-10-12 03:14:59 +02:00
|
|
|
if (isMember())
|
|
|
|
return false;
|
|
|
|
|
2011-10-08 22:03:44 +02:00
|
|
|
if (online)
|
|
|
|
{
|
|
|
|
if (isEnemy())
|
2011-09-06 23:35:43 +02:00
|
|
|
return Conf.territoryEnemyPainBuild;
|
2011-10-08 22:03:44 +02:00
|
|
|
else if (isAlly())
|
2011-09-06 23:35:43 +02:00
|
|
|
return Conf.territoryAllyPainBuild;
|
2011-10-08 22:03:44 +02:00
|
|
|
else
|
2011-09-06 23:35:43 +02:00
|
|
|
return Conf.territoryPainBuild;
|
|
|
|
}
|
2011-10-08 22:03:44 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (isEnemy())
|
2011-09-06 23:35:43 +02:00
|
|
|
return Conf.territoryEnemyPainBuildWhenOffline;
|
2011-10-08 22:03:44 +02:00
|
|
|
else if (isAlly())
|
2011-09-06 23:35:43 +02:00
|
|
|
return Conf.territoryAllyPainBuildWhenOffline;
|
2011-10-08 22:03:44 +02:00
|
|
|
else
|
2011-09-06 23:35:43 +02:00
|
|
|
return Conf.territoryPainBuildWhenOffline;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// return appropriate Conf setting for DenyUseage based on this relation
|
2011-10-08 22:03:44 +02:00
|
|
|
public boolean confDenyUseage()
|
|
|
|
{
|
2011-10-12 03:14:59 +02:00
|
|
|
if (isMember())
|
|
|
|
return false;
|
|
|
|
else if (isEnemy())
|
2011-09-06 23:35:43 +02:00
|
|
|
return Conf.territoryEnemyDenyUseage;
|
2011-10-08 22:03:44 +02:00
|
|
|
else if (isAlly())
|
2011-09-06 23:35:43 +02:00
|
|
|
return Conf.territoryAllyDenyUseage;
|
2011-10-08 22:03:44 +02:00
|
|
|
else
|
2011-09-06 23:35:43 +02:00
|
|
|
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
|
|
|
}
|