Spout overlay support is missing for the new relation coloring. Otherwise done.

This commit is contained in:
Olof Larsson 2011-10-21 20:08:54 +02:00
parent 89b53a577a
commit e6d45a6aa2
9 changed files with 63 additions and 52 deletions

View File

@ -212,7 +212,7 @@ public class Board
if (factionHere.isNone()) { if (factionHere.isNone()) {
row += ChatColor.GRAY+"-"; row += ChatColor.GRAY+"-";
} else if (factionHere.isSafeZone()) { } else if (factionHere.isSafeZone()) {
row += ChatColor.GOLD+"+"; row += Conf.colorPeaceful+"+";
} else if (factionHere.isWarZone()) { } else if (factionHere.isWarZone()) {
row += ChatColor.DARK_RED+"+"; row += ChatColor.DARK_RED+"+";
} else if ( } else if (
@ -225,7 +225,7 @@ public class Board
if (!fList.containsKey(factionHere.getTag())) if (!fList.containsKey(factionHere.getTag()))
fList.put(factionHere.getTag(), Conf.mapKeyChrs[chrIdx++]); fList.put(factionHere.getTag(), Conf.mapKeyChrs[chrIdx++]);
char tag = fList.get(factionHere.getTag()); char tag = fList.get(factionHere.getTag());
row += factionHere.getRelationTo(faction).getColor() + "" + tag; row += factionHere.getColorTo(faction) + "" + tag;
} else { } else {
row += ChatColor.GRAY+"-"; row += ChatColor.GRAY+"-";
} }
@ -243,9 +243,11 @@ public class Board
ret.set(3, asciiCompass.get(2)+ret.get(3).substring(3*3)); ret.set(3, asciiCompass.get(2)+ret.get(3).substring(3*3));
// Add the faction key // Add the faction key
if (Conf.showMapFactionKey) { if (Conf.showMapFactionKey)
{
String fRow = ""; String fRow = "";
for(String key : fList.keySet()) { for(String key : fList.keySet())
{
fRow += String.format("%s%s: %s ", ChatColor.GRAY, fList.get(key), key); fRow += String.format("%s%s: %s ", ChatColor.GRAY, fList.get(key), key);
} }
ret.add(fRow); ret.add(fRow);

View File

@ -312,11 +312,11 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
public String getNameAndTitle(Faction faction) public String getNameAndTitle(Faction faction)
{ {
return this.getRelationColor(faction)+this.getNameAndTitle(); return this.getColorTo(faction)+this.getNameAndTitle();
} }
public String getNameAndTitle(FPlayer fplayer) public String getNameAndTitle(FPlayer fplayer)
{ {
return this.getRelationColor(fplayer)+this.getNameAndTitle(); return this.getColorTo(fplayer)+this.getNameAndTitle();
} }
/*public String getNameAndTag(Faction faction) /*public String getNameAndTag(Faction faction)
@ -372,11 +372,12 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
public String getChatTag(FPlayer fplayer) public String getChatTag(FPlayer fplayer)
{ {
if ( ! this.hasFaction()) { if ( ! this.hasFaction())
{
return ""; return "";
} }
return this.getRelationTo(fplayer).getColor()+getChatTag(); return this.getColorTo(fplayer)+getChatTag();
} }
// ------------------------------- // -------------------------------
@ -413,9 +414,9 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
} }
@Override @Override
public ChatColor getRelationColor(RelationParticipator rp) public ChatColor getColorTo(RelationParticipator rp)
{ {
return RelationUtil.getRelationColor(this, rp); return RelationUtil.getColorOfThatToMe(this, rp);
} }
//----------------------------------------------// //----------------------------------------------//

View File

@ -68,14 +68,14 @@ public class Faction extends Entity implements EconomyParticipator
{ {
return getTag(); return getTag();
} }
return this.getTag(otherFaction.getRelationColor(this).toString()); return this.getTag(otherFaction.getColorTo(this).toString());
} }
public String getTag(FPlayer otherFplayer) { public String getTag(FPlayer otherFplayer) {
if (otherFplayer == null) if (otherFplayer == null)
{ {
return getTag(); return getTag();
} }
return this.getTag(otherFplayer.getRelationColor(this).toString()); return this.getTag(this.getColorTo(otherFplayer).toString());
} }
public void setTag(String str) public void setTag(String str)
{ {
@ -216,9 +216,9 @@ public class Faction extends Entity implements EconomyParticipator
} }
@Override @Override
public ChatColor getRelationColor(RelationParticipator rp) public ChatColor getColorTo(RelationParticipator rp)
{ {
return RelationUtil.getRelationColor(this, rp); return RelationUtil.getColorOfThatToMe(this, rp);
} }
public Relation getRelationWish(Faction otherFaction) public Relation getRelationWish(Faction otherFaction)
@ -248,31 +248,38 @@ public class Faction extends Entity implements EconomyParticipator
public double getPower() public double getPower()
{ {
double ret = 0; double ret = 0;
for (FPlayer fplayer : this.getFPlayers()) { for (FPlayer fplayer : this.getFPlayers())
{
ret += fplayer.getPower(); ret += fplayer.getPower();
} }
if (Conf.powerFactionMax > 0 && ret > Conf.powerFactionMax) { if (Conf.powerFactionMax > 0 && ret > Conf.powerFactionMax)
{
ret = Conf.powerFactionMax; ret = Conf.powerFactionMax;
} }
return ret; return ret;
} }
public double getPowerMax() { public double getPowerMax()
{
double ret = 0; double ret = 0;
for (FPlayer fplayer : this.getFPlayers()) { for (FPlayer fplayer : this.getFPlayers())
{
ret += fplayer.getPowerMax(); ret += fplayer.getPowerMax();
} }
if (Conf.powerFactionMax > 0 && ret > Conf.powerFactionMax) { if (Conf.powerFactionMax > 0 && ret > Conf.powerFactionMax)
{
ret = Conf.powerFactionMax; ret = Conf.powerFactionMax;
} }
return ret; return ret;
} }
public int getPowerRounded() { public int getPowerRounded()
{
return (int) Math.round(this.getPower()); return (int) Math.round(this.getPower());
} }
public int getPowerMaxRounded() { public int getPowerMaxRounded()
{
return (int) Math.round(this.getPowerMax()); return (int) Math.round(this.getPowerMax());
} }
@ -280,11 +287,13 @@ public class Faction extends Entity implements EconomyParticipator
return Board.getFactionCoordCount(this); return Board.getFactionCoordCount(this);
} }
public int getLandRoundedInWorld(String worldName) { public int getLandRoundedInWorld(String worldName)
{
return Board.getFactionCoordCountInWorld(this, worldName); return Board.getFactionCoordCountInWorld(this, worldName);
} }
public boolean hasLandInflation() { public boolean hasLandInflation()
{
return this.getLandRounded() > this.getPowerRounded(); return this.getLandRounded() > this.getPowerRounded();
} }
@ -430,20 +439,6 @@ public class Faction extends Entity implements EconomyParticipator
} }
} }
//----------------------------------------------//
// Mudd TODO
//----------------------------------------------//
public ChatColor getRelationColor(Faction otherFaction)
{
return this.getRelationTo(otherFaction).getColor();
}
public ChatColor getRelationColor(FPlayer fplayer)
{
return this.getRelationTo(fplayer).getColor();
}
//----------------------------------------------// //----------------------------------------------//
// Ownership of specific claims // Ownership of specific claims
//----------------------------------------------// //----------------------------------------------//
@ -539,7 +534,8 @@ public class Faction extends Entity implements EconomyParticipator
public void removePlayerAsOwner(String playerName, FLocation loc) public void removePlayerAsOwner(String playerName, FLocation loc)
{ {
Set<String> ownerData = claimOwnership.get(loc); Set<String> ownerData = claimOwnership.get(loc);
if (ownerData == null) { if (ownerData == null)
{
return; return;
} }
ownerData.remove(playerName.toLowerCase()); ownerData.remove(playerName.toLowerCase());

View File

@ -53,7 +53,7 @@ public class CmdPeaceful extends FCommand
} }
else else
{ {
fplayer.msg((fme == null ? "A server admin" : fme.describeTo(fplayer, true))+"<i> has "+change+" the faction \"" + faction.getTag(fplayer) + "\"."); fplayer.msg((fme == null ? "A server admin" : fme.describeTo(fplayer, true))+"<i> has "+change+" the faction \"" + faction.getTag(fplayer) + "<i>\".");
} }
} }

View File

@ -62,7 +62,7 @@ public class CmdTag extends FCommand
{ {
continue; continue;
} }
faction.msg("<i>The faction %s<i> changed their name to %s.", fme.getRelationColor(faction)+oldtag, myFaction.getTag(faction)); faction.msg("<i>The faction %s<i> changed their name to %s.", fme.getColorTo(faction)+oldtag, myFaction.getTag(faction));
} }
if (Conf.spoutFactionTagsOverNames) if (Conf.spoutFactionTagsOverNames)

View File

@ -12,5 +12,5 @@ public interface RelationParticipator
public Relation getRelationTo(RelationParticipator that); public Relation getRelationTo(RelationParticipator that);
public Relation getRelationTo(RelationParticipator that, boolean ignorePeaceful); public Relation getRelationTo(RelationParticipator that, boolean ignorePeaceful);
public ChatColor getRelationColor(RelationParticipator to); public ChatColor getColorTo(RelationParticipator to);
} }

View File

@ -32,7 +32,6 @@ public class SpoutMainListener extends SpoutListener
updateTerritoryDisplay(me); updateTerritoryDisplay(me);
} }
//-----------------------------------------------------------------------------------------// //-----------------------------------------------------------------------------------------//
// Everything below this is handled in here to prevent errors on servers not running Spout // Everything below this is handled in here to prevent errors on servers not running Spout
//-----------------------------------------------------------------------------------------// //-----------------------------------------------------------------------------------------//

View File

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

View File

@ -2,6 +2,7 @@ package com.massivecraft.factions.util;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.Faction; import com.massivecraft.factions.Faction;
import com.massivecraft.factions.iface.RelationParticipator; import com.massivecraft.factions.iface.RelationParticipator;
@ -53,7 +54,7 @@ public class RelationUtil
ret = TextUtil.upperCaseFirst(ret); ret = TextUtil.upperCaseFirst(ret);
} }
return "" + getRelationColor(me, that) + ret; return "" + getColorOfThatToMe(that, me) + ret;
} }
public static String describeThatToMe(RelationParticipator that, RelationParticipator me) public static String describeThatToMe(RelationParticipator that, RelationParticipator me)
@ -113,8 +114,12 @@ public class RelationUtil
return null; return null;
} }
public static ChatColor getRelationColor(RelationParticipator me, RelationParticipator that) public static ChatColor getColorOfThatToMe(RelationParticipator that, RelationParticipator me)
{ {
if (getFaction(that) != null && getFaction(that).isPeaceful() && getFaction(that) != getFaction(me))
{
return Conf.colorPeaceful;
}
return getRelationTo(that, me).getColor(); return getRelationTo(that, me).getColor();
} }
} }