This commit is contained in:
drtshock
2014-04-04 13:53:42 -05:00
parent 10f9c16461
commit c3983d3b96
157 changed files with 92 additions and 15 deletions

View File

@@ -0,0 +1,40 @@
package com.massivecraft.factions.struct;
public enum ChatMode
{
FACTION(2, "faction chat"),
ALLIANCE(1, "alliance chat"),
PUBLIC(0, "public chat");
public final int value;
public final String nicename;
private ChatMode(final int value, final String nicename)
{
this.value = value;
this.nicename = nicename;
}
public boolean isAtLeast(ChatMode role)
{
return this.value >= role.value;
}
public boolean isAtMost(ChatMode role)
{
return this.value <= role.value;
}
@Override
public String toString()
{
return this.nicename;
}
public ChatMode getNext()
{
if (this == PUBLIC) return ALLIANCE;
if (this == ALLIANCE)return FACTION;
return PUBLIC;
}
}

View File

@@ -0,0 +1,87 @@
package com.massivecraft.factions.struct;
import org.bukkit.command.CommandSender;
import com.massivecraft.factions.P;
public enum Permission
{
MANAGE_SAFE_ZONE("managesafezone"),
MANAGE_WAR_ZONE("managewarzone"),
OWNERSHIP_BYPASS("ownershipbypass"),
ADMIN("admin"),
ADMIN_ANY("admin.any"),
AUTOCLAIM("autoclaim"),
BYPASS("bypass"),
CHAT("chat"),
CHATSPY("chatspy"),
CLAIM("claim"),
CLAIM_RADIUS("claim.radius"),
CONFIG("config"),
CREATE("create"),
DEINVITE("deinvite"),
DESCRIPTION("description"),
DISBAND("disband"),
DISBAND_ANY("disband.any"),
HELP("help"),
HOME("home"),
INVITE("invite"),
JOIN("join"),
JOIN_ANY("join.any"),
JOIN_OTHERS("join.others"),
KICK("kick"),
KICK_ANY("kick.any"),
LEAVE("leave"),
LIST("list"),
LOCK("lock"),
MAP("map"),
MOD("mod"),
MOD_ANY("mod.any"),
MONEY_BALANCE("money.balance"),
MONEY_BALANCE_ANY("money.balance.any"),
MONEY_DEPOSIT("money.deposit"),
MONEY_WITHDRAW("money.withdraw"),
MONEY_WITHDRAW_ANY("money.withdraw.any"),
MONEY_F2F("money.f2f"),
MONEY_F2P("money.f2p"),
MONEY_P2F("money.p2f"),
NO_BOOM("noboom"),
OPEN("open"),
OWNER("owner"),
OWNERLIST("ownerlist"),
SET_PEACEFUL("setpeaceful"),
SET_PERMANENT("setpermanent"),
SET_PERMANENTPOWER("setpermanentpower"),
POWERBOOST("powerboost"),
POWER("power"),
POWER_ANY("power.any"),
RELATION("relation"),
RELOAD("reload"),
SAVE("save"),
SETHOME("sethome"),
SETHOME_ANY("sethome.any"),
SHOW("show"),
TAG("tag"),
TITLE("title"),
UNCLAIM("unclaim"),
UNCLAIM_ALL("unclaimall"),
VERSION("version"),
;
public final String node;
Permission(final String node)
{
this.node = "factions."+node;
}
public boolean has(CommandSender sender, boolean informSenderIfNot)
{
return P.p.perm.has(sender, this.node, informSenderIfNot);
}
public boolean has(CommandSender sender)
{
return has(sender, false);
}
}

View File

@@ -0,0 +1,146 @@
package com.massivecraft.factions.struct;
import org.bukkit.ChatColor;
import com.massivecraft.factions.Conf;
public enum Relation
{
MEMBER(3, "member"),
ALLY(2, "ally"),
NEUTRAL(1, "neutral"),
ENEMY(0, "enemy");
public final int value;
public final String nicename;
private Relation(final int value, final String nicename)
{
this.value = value;
this.nicename = nicename;
}
@Override
public String toString()
{
return this.nicename;
}
public boolean isMember()
{
return this == MEMBER;
}
public boolean isAlly()
{
return this == ALLY;
}
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()
{
if (this == MEMBER)
return Conf.colorMember;
else if (this == ALLY)
return Conf.colorAlly;
else if (this == NEUTRAL)
return Conf.colorNeutral;
else
return Conf.colorEnemy;
}
// 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;
}
public double getRelationCost()
{
if (isEnemy())
return Conf.econCostEnemy;
else if (isAlly())
return Conf.econCostAlly;
else
return Conf.econCostNeutral;
}
}

View File

@@ -0,0 +1,50 @@
package com.massivecraft.factions.struct;
import com.massivecraft.factions.Conf;
public enum Role
{
ADMIN(2, "admin"),
MODERATOR(1, "moderator"),
NORMAL(0, "normal member");
public final int value;
public final String nicename;
private Role(final int value, final String nicename)
{
this.value = value;
this.nicename = nicename;
}
public boolean isAtLeast(Role role)
{
return this.value >= role.value;
}
public boolean isAtMost(Role role)
{
return this.value <= role.value;
}
@Override
public String toString()
{
return this.nicename;
}
public String getPrefix()
{
if (this == Role.ADMIN)
{
return Conf.prefixAdmin;
}
if (this == Role.MODERATOR)
{
return Conf.prefixMod;
}
return "";
}
}