Merge branch 'master' into seven

This commit is contained in:
Olof Larsson 2011-10-23 17:31:30 +02:00
commit e6ff84ad9a
9 changed files with 122 additions and 70 deletions

View File

@ -770,6 +770,7 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
} }
Board.setFactionAt(forFaction, flocation); Board.setFactionAt(forFaction, flocation);
SpoutFeatures.updateTerritoryDisplayLoc(flocation);
return true; return true;
} }

View File

@ -58,6 +58,13 @@ public class Factions extends EntityCollection<Faction>
faction.setTag("SafeZone"); faction.setTag("SafeZone");
faction.setDescription("Free from PVP and monsters"); faction.setDescription("Free from PVP and monsters");
} }
else
{
// if SafeZone has old pre-1.6.0 name, rename it to remove troublesome " "
Faction faction = this.getSafeZone();
if (faction.getTag().contains(" "))
faction.setTag("SafeZone");
}
// Make sure the war zone faction exists // Make sure the war zone faction exists
if ( ! this.exists("-2")) if ( ! this.exists("-2"))
@ -66,6 +73,13 @@ public class Factions extends EntityCollection<Faction>
faction.setTag("WarZone"); faction.setTag("WarZone");
faction.setDescription("Not the safest place to be"); faction.setDescription("Not the safest place to be");
} }
else
{
// if WarZone has old pre-1.6.0 name, rename it to remove troublesome " "
Faction faction = this.getWarZone();
if (faction.getTag().contains(" "))
faction.setTag("WarZone");
}
return true; return true;
} }

View File

@ -5,6 +5,7 @@ import com.massivecraft.factions.Conf;
import com.massivecraft.factions.FLocation; import com.massivecraft.factions.FLocation;
import com.massivecraft.factions.Faction; import com.massivecraft.factions.Faction;
import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.integration.SpoutFeatures;
import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Rel; import com.massivecraft.factions.struct.Rel;
@ -90,6 +91,7 @@ public class CmdOwner extends FCommand
if (args.isEmpty() && myFaction.doesLocationHaveOwnersSet(flocation)) if (args.isEmpty() && myFaction.doesLocationHaveOwnersSet(flocation))
{ {
myFaction.clearClaimOwnership(flocation); myFaction.clearClaimOwnership(flocation);
SpoutFeatures.updateOwnerListLoc(flocation);
fme.msg("<i>You have cleared ownership for this claimed area."); fme.msg("<i>You have cleared ownership for this claimed area.");
return; return;
} }
@ -97,6 +99,7 @@ public class CmdOwner extends FCommand
if (myFaction.isPlayerInOwnerList(playerName, flocation)) if (myFaction.isPlayerInOwnerList(playerName, flocation))
{ {
myFaction.removePlayerAsOwner(playerName, flocation); myFaction.removePlayerAsOwner(playerName, flocation);
SpoutFeatures.updateOwnerListLoc(flocation);
fme.msg("<i>You have removed ownership of this claimed land from %s<i>.", playerName); fme.msg("<i>You have removed ownership of this claimed land from %s<i>.", playerName);
return; return;
} }
@ -105,6 +108,8 @@ public class CmdOwner extends FCommand
if ( ! payForCommand(Conf.econCostOwner, "to set ownership of claimed land", "for setting ownership of claimed land")) return; if ( ! payForCommand(Conf.econCostOwner, "to set ownership of claimed land", "for setting ownership of claimed land")) return;
myFaction.setPlayerAsOwner(playerName, flocation); myFaction.setPlayerAsOwner(playerName, flocation);
SpoutFeatures.updateOwnerListLoc(flocation);
fme.msg("<i>You have added %s<i> to the owner list for this claimed land.", playerName); fme.msg("<i>You have added %s<i> to the owner list for this claimed land.", playerName);
} }
} }

View File

@ -3,6 +3,7 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Board; import com.massivecraft.factions.Board;
import com.massivecraft.factions.Conf; import com.massivecraft.factions.Conf;
import com.massivecraft.factions.integration.Econ; import com.massivecraft.factions.integration.Econ;
import com.massivecraft.factions.integration.SpoutFeatures;
import com.massivecraft.factions.FLocation; import com.massivecraft.factions.FLocation;
import com.massivecraft.factions.Faction; import com.massivecraft.factions.Faction;
import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Permission;
@ -38,6 +39,7 @@ public class CmdUnclaim extends FCommand
if (Permission.MANAGE_SAFE_ZONE.has(sender)) if (Permission.MANAGE_SAFE_ZONE.has(sender))
{ {
Board.removeAt(flocation); Board.removeAt(flocation);
SpoutFeatures.updateTerritoryDisplayLoc(flocation);
msg("<i>Safe zone was unclaimed."); msg("<i>Safe zone was unclaimed.");
} }
else else
@ -51,6 +53,7 @@ public class CmdUnclaim extends FCommand
if (Permission.MANAGE_WAR_ZONE.has(sender)) if (Permission.MANAGE_WAR_ZONE.has(sender))
{ {
Board.removeAt(flocation); Board.removeAt(flocation);
SpoutFeatures.updateTerritoryDisplayLoc(flocation);
msg("<i>War zone was unclaimed."); msg("<i>War zone was unclaimed.");
} }
else else
@ -63,6 +66,7 @@ public class CmdUnclaim extends FCommand
if (fme.isAdminBypassing()) if (fme.isAdminBypassing())
{ {
Board.removeAt(flocation); Board.removeAt(flocation);
SpoutFeatures.updateTerritoryDisplayLoc(flocation);
otherFaction.msg("%s<i> unclaimed some of your land.", fme.describeTo(otherFaction, true)); otherFaction.msg("%s<i> unclaimed some of your land.", fme.describeTo(otherFaction, true));
msg("<i>You unclaimed this land."); msg("<i>You unclaimed this land.");
@ -148,6 +152,7 @@ public class CmdUnclaim extends FCommand
} }
Board.removeAt(flocation); Board.removeAt(flocation);
SpoutFeatures.updateTerritoryDisplayLoc(flocation);
myFaction.msg("%s<i> unclaimed some land.", fme.describeTo(myFaction, true)); myFaction.msg("%s<i> unclaimed some land.", fme.describeTo(myFaction, true));
} }

View File

@ -3,6 +3,7 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Board; import com.massivecraft.factions.Board;
import com.massivecraft.factions.Conf; import com.massivecraft.factions.Conf;
import com.massivecraft.factions.integration.Econ; import com.massivecraft.factions.integration.Econ;
import com.massivecraft.factions.integration.SpoutFeatures;
import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Permission;
public class CmdUnclaimall extends FCommand public class CmdUnclaimall extends FCommand
@ -26,6 +27,8 @@ public class CmdUnclaimall extends FCommand
@Override @Override
public void perform() public void perform()
{
if (Econ.shouldBeUsed())
{ {
double refund = Econ.calculateTotalLandRefund(myFaction.getLandRounded()); double refund = Econ.calculateTotalLandRefund(myFaction.getLandRounded());
if(Conf.bankFactionPaysLandCosts) if(Conf.bankFactionPaysLandCosts)
@ -36,9 +39,11 @@ public class CmdUnclaimall extends FCommand
{ {
if ( ! Econ.modifyMoney(fme , refund, "to unclaim all faction land", "for unclaiming all faction land")) return; if ( ! Econ.modifyMoney(fme , refund, "to unclaim all faction land", "for unclaiming all faction land")) return;
} }
}
Board.unclaimAll(myFaction.getId()); Board.unclaimAll(myFaction.getId());
myFaction.msg("%s<i> unclaimed ALL of your faction's land.", fme.describeTo(myFaction, true)); myFaction.msg("%s<i> unclaimed ALL of your faction's land.", fme.describeTo(myFaction, true));
SpoutFeatures.updateTerritoryDisplayLoc(null);
} }
} }

View File

@ -76,6 +76,6 @@ public abstract class FRelationCommand extends FCommand
} }
SpoutFeatures.updateAppearances(myFaction, them); SpoutFeatures.updateAppearances(myFaction, them);
SpoutFeatures.updateTerritoryDisplayLoc(null);
} }
} }

View File

@ -6,6 +6,7 @@ import com.massivecraft.factions.Conf;
import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.FPlayers; import com.massivecraft.factions.FPlayers;
import com.massivecraft.factions.Faction; import com.massivecraft.factions.Faction;
import com.massivecraft.factions.FLocation;
import com.massivecraft.factions.P; import com.massivecraft.factions.P;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -63,13 +64,45 @@ public class SpoutFeatures
} }
// update displayed current territory for all players inside a specified chunk; if specified chunk is null, then simply update everyone online
public static void updateTerritoryDisplayLoc(FLocation fLoc)
{
if (!enabled())
return;
Set<FPlayer> players = FPlayers.i.getOnline();
for (FPlayer player : players)
{
if (fLoc == null)
mainListener.updateTerritoryDisplay(player, false);
else if (player.getLastStoodAt().equals(fLoc))
mainListener.updateTerritoryDisplay(player, true);
}
}
// update displayed current territory for specified player; returns false if unsuccessful // update displayed current territory for specified player; returns false if unsuccessful
public static boolean updateTerritoryDisplay(FPlayer player) public static boolean updateTerritoryDisplay(FPlayer player)
{ {
if (!enabled()) if (!enabled())
return false; return false;
return mainListener.updateTerritoryDisplay(player); return mainListener.updateTerritoryDisplay(player, true);
}
// update owner list for all players inside a specified chunk; if specified chunk is null, then simply update everyone online
public static void updateOwnerListLoc(FLocation fLoc)
{
if (!enabled())
return;
Set<FPlayer> players = FPlayers.i.getOnline();
for (FPlayer player : players)
{
if (fLoc == null || player.getLastStoodAt().equals(fLoc))
mainListener.updateOwnerList(player);
}
} }
// update owner list for specified player // update owner list for specified player
@ -94,19 +127,15 @@ public class SpoutFeatures
public static void updateAppearances() public static void updateAppearances()
{ {
if (!enabled()) if (!enabled())
{
return; return;
}
Set<FPlayer> players = FPlayers.i.getOnline(); Set<FPlayer> players = FPlayers.i.getOnline();
Faction factionA;
for (FPlayer playerA : players) for (FPlayer playerA : players)
{ {
factionA = playerA.getFaction();
for (FPlayer playerB : players) for (FPlayer playerB : players)
{ {
updateSingle(playerB.getPlayer(), playerA.getPlayer(), factionA.getRelationTo(playerB), factionA, playerA.getTitle(), playerA.getRole()); updateSingle(playerB, playerA);
} }
} }
} }
@ -115,33 +144,39 @@ public class SpoutFeatures
public static void updateAppearances(Player player) public static void updateAppearances(Player player)
{ {
if (!enabled() || player == null) if (!enabled() || player == null)
{
return; return;
}
Set<FPlayer> players = FPlayers.i.getOnline(); Set<FPlayer> players = FPlayers.i.getOnline();
FPlayer playerA = FPlayers.i.get(player); FPlayer playerA = FPlayers.i.get(player);
Faction factionA = playerA.getFaction();
for (FPlayer playerB : players) for (FPlayer playerB : players)
{ {
Player player2 = playerB.getPlayer(); updateSingle(playerB, playerA);
Relation rel = factionA.getRelationTo(playerB); updateSingle(playerA, playerB);
updateSingle(player2, player, rel, factionA, playerA.getTitle(), playerA.getRole());
updateSingle(player, player2, rel, playerB.getFaction(), playerB.getTitle(), playerB.getRole());
} }
} }
// as above method, but with a delay added; useful for after-login update which doesn't always propagate if done immediately
public static void updateAppearancesShortly(final Player player)
{
P.p.getServer().getScheduler().scheduleSyncDelayedTask(P.p, new Runnable()
{
@Override
public void run()
{
updateAppearances(player);
}
}, 100);
}
// update all appearances related to a single faction // update all appearances related to a single faction
public static void updateAppearances(Faction faction) public static void updateAppearances(Faction faction)
{ {
if (!enabled() || faction == null) if (!enabled() || faction == null)
{
return; return;
}
Set<FPlayer> players = FPlayers.i.getOnline(); Set<FPlayer> players = FPlayers.i.getOnline();
Faction factionA, factionB; Faction factionA;
for (FPlayer playerA : players) for (FPlayer playerA : players)
{ {
@ -149,12 +184,10 @@ public class SpoutFeatures
for (FPlayer playerB : players) for (FPlayer playerB : players)
{ {
factionB = playerB.getFaction(); if (factionA != faction && playerB.getFaction() != faction)
if (factionA != faction && factionB != faction)
{
continue; continue;
}
updateSingle(playerB.getPlayer(), playerA.getPlayer(), factionA.getRelationTo(factionB), factionA, playerA.getTitle(), playerA.getRole()); updateSingle(playerB, playerA);
} }
} }
} }
@ -163,31 +196,33 @@ public class SpoutFeatures
public static void updateAppearances(Faction factionA, Faction factionB) public static void updateAppearances(Faction factionA, Faction factionB)
{ {
if (!enabled() || factionA == null || factionB == null) if (!enabled() || factionA == null || factionB == null)
{
return; return;
}
for (FPlayer playerA : factionA.getFPlayersWhereOnline(true)) for (FPlayer playerA : factionA.getFPlayersWhereOnline(true))
{ {
for (FPlayer playerB : factionB.getFPlayersWhereOnline(true)) for (FPlayer playerB : factionB.getFPlayersWhereOnline(true))
{ {
Player player1 = playerA.getPlayer(); updateSingle(playerB, playerA);
Player player2 = playerB.getPlayer(); updateSingle(playerA, playerB);
Relation rel = factionA.getRelationTo(factionB);
updateSingle(player2, player1, rel, factionA, playerA.getTitle(), playerA.getRole());
updateSingle(player1, player2, rel, factionB, playerB.getTitle(), playerB.getRole());
} }
} }
} }
// update a single appearance; internal use only by above public methods // update a single appearance; internal use only by above public methods
private static void updateSingle(Player viewer, Player viewed, Relation relation, Faction viewedFaction, String viewedTitle, Role viewedRole) private static void updateSingle(FPlayer viewer, FPlayer viewed)
{ {
if (viewer == null || viewed == null) if (viewer == null || viewed == null)
return; return;
SpoutPlayer sPlayer = SpoutManager.getPlayer(viewer); Faction viewedFaction = viewed.getFaction();
if (viewedFaction == null)
return;
SpoutPlayer sPlayer = SpoutManager.getPlayer(viewer.getPlayer());
Player pViewed = viewed.getPlayer();
String viewedTitle = viewed.getTitle();
Role viewedRole = viewed.getRole();
if ((Conf.spoutFactionTagsOverNames || Conf.spoutFactionTitlesOverNames) && viewer != viewed) if ((Conf.spoutFactionTagsOverNames || Conf.spoutFactionTitlesOverNames) && viewer != viewed)
{ {
@ -195,19 +230,17 @@ public class SpoutFeatures
{ {
String addTag = ""; String addTag = "";
if (Conf.spoutFactionTagsOverNames) if (Conf.spoutFactionTagsOverNames)
{ addTag += viewedFaction.getTag(viewed.getColorTo(viewer).toString() + "[") + "]";
addTag += viewedFaction.getTag(relation.getColor().toString() + "[") + "]";
}
String rolePrefix = viewedRole.getPrefix(); String rolePrefix = viewedRole.getPrefix();
if (Conf.spoutFactionTitlesOverNames && (!viewedTitle.isEmpty() || !rolePrefix.isEmpty())) if (Conf.spoutFactionTitlesOverNames && (!viewedTitle.isEmpty() || !rolePrefix.isEmpty()))
{
addTag += (addTag.isEmpty() ? "" : " ") + viewedRole.getPrefix() + viewedTitle; addTag += (addTag.isEmpty() ? "" : " ") + viewedRole.getPrefix() + viewedTitle;
}
spoutApp.setPlayerTitle(sPlayer, viewed, addTag + "\n" + viewed.getDisplayName()); spoutApp.setPlayerTitle(sPlayer, pViewed, addTag + "\n" + pViewed.getDisplayName());
} }
else else
{ {
spoutApp.setPlayerTitle(sPlayer, viewed, viewed.getDisplayName()); spoutApp.setPlayerTitle(sPlayer, pViewed, pViewed.getDisplayName());
} }
} }
@ -226,54 +259,41 @@ public class SpoutFeatures
) )
) )
{ {
Relation relation = viewer.getRelationTo(viewed);
String cape = ""; String cape = "";
if (!viewedFaction.isNormal()) if (!viewedFaction.isNormal())
{ {
// yeah, no cape if no faction // yeah, no cape if no faction
} }
else if (viewedFaction.isPeaceful()) else if (viewedFaction.isPeaceful())
{
cape = Conf.capePeaceful; cape = Conf.capePeaceful;
}
else if (relation.isNeutral()) else if (relation.isNeutral())
{
cape = Conf.capeNeutral; cape = Conf.capeNeutral;
}
else if (relation.isMember()) else if (relation.isMember())
{
cape = Conf.capeMember; cape = Conf.capeMember;
}
else if (relation.isEnemy()) else if (relation.isEnemy())
{
cape = Conf.capeEnemy; cape = Conf.capeEnemy;
}
else if (relation.isAlly()) else if (relation.isAlly())
{
cape = Conf.capeAlly; cape = Conf.capeAlly;
}
if (cape.isEmpty()) if (cape.isEmpty())
{ spoutApp.resetPlayerCloak(sPlayer, pViewed);
spoutApp.resetPlayerCloak(sPlayer, viewed);
}
else else
{ spoutApp.setPlayerCloak(sPlayer, pViewed, cape);
spoutApp.setPlayerCloak(sPlayer, viewed, cape);
}
} }
else if (Conf.spoutFactionAdminCapes || Conf.spoutFactionModeratorCapes) else if (Conf.spoutFactionAdminCapes || Conf.spoutFactionModeratorCapes)
{ {
spoutApp.resetPlayerCloak(sPlayer, viewed); spoutApp.resetPlayerCloak(sPlayer, pViewed);
} }
} }
// method to convert a Bukkit ChatColor to a Spout Color // method to convert a Bukkit ChatColor to a Spout Color
protected static Color getSpoutColor(ChatColor inColor, int alpha) protected static Color getSpoutColor(ChatColor inColor, int alpha)
{ {
if (inColor == null) if (inColor == null)
{
return SpoutFixedColor(191, 191, 191, alpha); return SpoutFixedColor(191, 191, 191, alpha);
}
switch (inColor.getCode()) switch (inColor.getCode())
{ {
case 0x1: return SpoutFixedColor(0, 0, 191, alpha); case 0x1: return SpoutFixedColor(0, 0, 191, alpha);

View File

@ -29,7 +29,7 @@ public class SpoutMainListener extends SpoutListener
final FPlayer me = FPlayers.i.get(event.getPlayer()); final FPlayer me = FPlayers.i.get(event.getPlayer());
SpoutFeatures.updateAppearances(me.getPlayer()); SpoutFeatures.updateAppearances(me.getPlayer());
updateTerritoryDisplay(me); updateTerritoryDisplay(me, true);
} }
//-----------------------------------------------------------------------------------------// //-----------------------------------------------------------------------------------------//
@ -43,7 +43,7 @@ public class SpoutMainListener extends SpoutListener
// private final static int SCREEN_HEIGHT = 240; // private final static int SCREEN_HEIGHT = 240;
public boolean updateTerritoryDisplay(FPlayer player) public boolean updateTerritoryDisplay(FPlayer player, boolean notify)
{ {
Player p = player.getPlayer(); Player p = player.getPlayer();
if (p == null) if (p == null)
@ -53,7 +53,7 @@ public class SpoutMainListener extends SpoutListener
if (!sPlayer.isSpoutCraftEnabled() || (Conf.spoutTerritoryDisplaySize <= 0 && ! Conf.spoutTerritoryNoticeShow)) if (!sPlayer.isSpoutCraftEnabled() || (Conf.spoutTerritoryDisplaySize <= 0 && ! Conf.spoutTerritoryNoticeShow))
return false; return false;
doLabels(player, sPlayer); doLabels(player, sPlayer, notify);
return true; return true;
} }
@ -80,11 +80,11 @@ public class SpoutMainListener extends SpoutListener
} }
private void doLabels(FPlayer player, SpoutPlayer sPlayer) private void doLabels(FPlayer player, SpoutPlayer sPlayer, boolean notify)
{ {
FLocation here = new FLocation(player); FLocation here = new FLocation(player);
Faction factionHere = Board.getFactionAt(here); Faction factionHere = Board.getFactionAt(here);
String tag = factionHere.getTag(player); String tag = factionHere.getColorTo(player).toString() + factionHere.getTag();
// ---------------------- // ----------------------
// Main territory display // Main territory display
@ -122,7 +122,7 @@ public class SpoutMainListener extends SpoutListener
// ----------------------- // -----------------------
// Fading territory notice // Fading territory notice
// ----------------------- // -----------------------
if (Conf.spoutTerritoryNoticeShow && Conf.spoutTerritoryNoticeSize > 0) if (notify && Conf.spoutTerritoryNoticeShow && Conf.spoutTerritoryNoticeSize > 0)
{ {
NoticeLabel label; NoticeLabel label;
if (territoryChangeLabels.containsKey(player.getName())) if (territoryChangeLabels.containsKey(player.getName()))

View File

@ -154,6 +154,8 @@ public class FactionsPlayerListener extends PlayerListener
// Run the member auto kick routine. Twice to get to the admins... // Run the member auto kick routine. Twice to get to the admins...
FPlayers.i.autoLeaveOnInactivityRoutine(); FPlayers.i.autoLeaveOnInactivityRoutine();
FPlayers.i.autoLeaveOnInactivityRoutine(); FPlayers.i.autoLeaveOnInactivityRoutine();
SpoutFeatures.updateAppearancesShortly(event.getPlayer());
} }
@Override @Override