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);
SpoutFeatures.updateTerritoryDisplayLoc(flocation);
return true;
}

View File

@ -58,6 +58,13 @@ public class Factions extends EntityCollection<Faction>
faction.setTag("SafeZone");
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
if ( ! this.exists("-2"))
@ -66,6 +73,13 @@ public class Factions extends EntityCollection<Faction>
faction.setTag("WarZone");
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;
}

View File

@ -5,6 +5,7 @@ import com.massivecraft.factions.Conf;
import com.massivecraft.factions.FLocation;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.integration.SpoutFeatures;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Rel;
@ -90,6 +91,7 @@ public class CmdOwner extends FCommand
if (args.isEmpty() && myFaction.doesLocationHaveOwnersSet(flocation))
{
myFaction.clearClaimOwnership(flocation);
SpoutFeatures.updateOwnerListLoc(flocation);
fme.msg("<i>You have cleared ownership for this claimed area.");
return;
}
@ -97,6 +99,7 @@ public class CmdOwner extends FCommand
if (myFaction.isPlayerInOwnerList(playerName, flocation))
{
myFaction.removePlayerAsOwner(playerName, flocation);
SpoutFeatures.updateOwnerListLoc(flocation);
fme.msg("<i>You have removed ownership of this claimed land from %s<i>.", playerName);
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;
myFaction.setPlayerAsOwner(playerName, flocation);
SpoutFeatures.updateOwnerListLoc(flocation);
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.Conf;
import com.massivecraft.factions.integration.Econ;
import com.massivecraft.factions.integration.SpoutFeatures;
import com.massivecraft.factions.FLocation;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.struct.Permission;
@ -38,6 +39,7 @@ public class CmdUnclaim extends FCommand
if (Permission.MANAGE_SAFE_ZONE.has(sender))
{
Board.removeAt(flocation);
SpoutFeatures.updateTerritoryDisplayLoc(flocation);
msg("<i>Safe zone was unclaimed.");
}
else
@ -51,6 +53,7 @@ public class CmdUnclaim extends FCommand
if (Permission.MANAGE_WAR_ZONE.has(sender))
{
Board.removeAt(flocation);
SpoutFeatures.updateTerritoryDisplayLoc(flocation);
msg("<i>War zone was unclaimed.");
}
else
@ -63,6 +66,7 @@ public class CmdUnclaim extends FCommand
if (fme.isAdminBypassing())
{
Board.removeAt(flocation);
SpoutFeatures.updateTerritoryDisplayLoc(flocation);
otherFaction.msg("%s<i> unclaimed some of your land.", fme.describeTo(otherFaction, true));
msg("<i>You unclaimed this land.");
@ -148,6 +152,7 @@ public class CmdUnclaim extends FCommand
}
Board.removeAt(flocation);
SpoutFeatures.updateTerritoryDisplayLoc(flocation);
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.Conf;
import com.massivecraft.factions.integration.Econ;
import com.massivecraft.factions.integration.SpoutFeatures;
import com.massivecraft.factions.struct.Permission;
public class CmdUnclaimall extends FCommand
@ -27,18 +28,22 @@ public class CmdUnclaimall extends FCommand
@Override
public void perform()
{
double refund = Econ.calculateTotalLandRefund(myFaction.getLandRounded());
if(Conf.bankFactionPaysLandCosts)
if (Econ.shouldBeUsed())
{
if ( ! Econ.modifyMoney(myFaction, refund, "to unclaim all faction land", "for unclaiming all faction land")) return;
}
else
{
if ( ! Econ.modifyMoney(fme , refund, "to unclaim all faction land", "for unclaiming all faction land")) return;
double refund = Econ.calculateTotalLandRefund(myFaction.getLandRounded());
if(Conf.bankFactionPaysLandCosts)
{
if ( ! Econ.modifyMoney(myFaction, refund, "to unclaim all faction land", "for unclaiming all faction land")) return;
}
else
{
if ( ! Econ.modifyMoney(fme , refund, "to unclaim all faction land", "for unclaiming all faction land")) return;
}
}
Board.unclaimAll(myFaction.getId());
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.updateTerritoryDisplayLoc(null);
}
}

View File

@ -6,6 +6,7 @@ import com.massivecraft.factions.Conf;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.FPlayers;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.FLocation;
import com.massivecraft.factions.P;
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
public static boolean updateTerritoryDisplay(FPlayer player)
{
if (!enabled())
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
@ -94,19 +127,15 @@ public class SpoutFeatures
public static void updateAppearances()
{
if (!enabled())
{
return;
}
Set<FPlayer> players = FPlayers.i.getOnline();
Faction factionA;
for (FPlayer playerA : players)
{
factionA = playerA.getFaction();
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)
{
if (!enabled() || player == null)
{
return;
}
Set<FPlayer> players = FPlayers.i.getOnline();
FPlayer playerA = FPlayers.i.get(player);
Faction factionA = playerA.getFaction();
for (FPlayer playerB : players)
{
Player player2 = playerB.getPlayer();
Relation rel = factionA.getRelationTo(playerB);
updateSingle(player2, player, rel, factionA, playerA.getTitle(), playerA.getRole());
updateSingle(player, player2, rel, playerB.getFaction(), playerB.getTitle(), playerB.getRole());
updateSingle(playerB, playerA);
updateSingle(playerA, playerB);
}
}
// 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
public static void updateAppearances(Faction faction)
{
if (!enabled() || faction == null)
{
return;
}
Set<FPlayer> players = FPlayers.i.getOnline();
Faction factionA, factionB;
Faction factionA;
for (FPlayer playerA : players)
{
@ -149,12 +184,10 @@ public class SpoutFeatures
for (FPlayer playerB : players)
{
factionB = playerB.getFaction();
if (factionA != faction && factionB != faction)
{
if (factionA != faction && playerB.getFaction() != faction)
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)
{
if (!enabled() || factionA == null || factionB == null)
{
return;
}
for (FPlayer playerA : factionA.getFPlayersWhereOnline(true))
{
for (FPlayer playerB : factionB.getFPlayersWhereOnline(true))
{
Player player1 = playerA.getPlayer();
Player player2 = playerB.getPlayer();
Relation rel = factionA.getRelationTo(factionB);
updateSingle(player2, player1, rel, factionA, playerA.getTitle(), playerA.getRole());
updateSingle(player1, player2, rel, factionB, playerB.getTitle(), playerB.getRole());
updateSingle(playerB, playerA);
updateSingle(playerA, playerB);
}
}
}
// 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)
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)
{
@ -195,19 +230,17 @@ public class SpoutFeatures
{
String addTag = "";
if (Conf.spoutFactionTagsOverNames)
{
addTag += viewedFaction.getTag(relation.getColor().toString() + "[") + "]";
}
addTag += viewedFaction.getTag(viewed.getColorTo(viewer).toString() + "[") + "]";
String rolePrefix = viewedRole.getPrefix();
if (Conf.spoutFactionTitlesOverNames && (!viewedTitle.isEmpty() || !rolePrefix.isEmpty()))
{
addTag += (addTag.isEmpty() ? "" : " ") + viewedRole.getPrefix() + viewedTitle;
}
spoutApp.setPlayerTitle(sPlayer, viewed, addTag + "\n" + viewed.getDisplayName());
spoutApp.setPlayerTitle(sPlayer, pViewed, addTag + "\n" + pViewed.getDisplayName());
}
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 = "";
if (!viewedFaction.isNormal())
{
// yeah, no cape if no faction
}
else if (viewedFaction.isPeaceful())
{
cape = Conf.capePeaceful;
}
else if (relation.isNeutral())
{
cape = Conf.capeNeutral;
}
else if (relation.isMember())
{
cape = Conf.capeMember;
}
else if (relation.isEnemy())
{
cape = Conf.capeEnemy;
}
else if (relation.isAlly())
{
cape = Conf.capeAlly;
}
if (cape.isEmpty())
{
spoutApp.resetPlayerCloak(sPlayer, viewed);
}
spoutApp.resetPlayerCloak(sPlayer, pViewed);
else
{
spoutApp.setPlayerCloak(sPlayer, viewed, cape);
}
spoutApp.setPlayerCloak(sPlayer, pViewed, cape);
}
else if (Conf.spoutFactionAdminCapes || Conf.spoutFactionModeratorCapes)
{
spoutApp.resetPlayerCloak(sPlayer, viewed);
spoutApp.resetPlayerCloak(sPlayer, pViewed);
}
}
// method to convert a Bukkit ChatColor to a Spout Color
protected static Color getSpoutColor(ChatColor inColor, int alpha)
{
if (inColor == null)
{
return SpoutFixedColor(191, 191, 191, alpha);
}
switch (inColor.getCode())
{
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());
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;
public boolean updateTerritoryDisplay(FPlayer player)
public boolean updateTerritoryDisplay(FPlayer player, boolean notify)
{
Player p = player.getPlayer();
if (p == null)
@ -53,7 +53,7 @@ public class SpoutMainListener extends SpoutListener
if (!sPlayer.isSpoutCraftEnabled() || (Conf.spoutTerritoryDisplaySize <= 0 && ! Conf.spoutTerritoryNoticeShow))
return false;
doLabels(player, sPlayer);
doLabels(player, sPlayer, notify);
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);
Faction factionHere = Board.getFactionAt(here);
String tag = factionHere.getTag(player);
String tag = factionHere.getColorTo(player).toString() + factionHere.getTag();
// ----------------------
// Main territory display
@ -122,7 +122,7 @@ public class SpoutMainListener extends SpoutListener
// -----------------------
// Fading territory notice
// -----------------------
if (Conf.spoutTerritoryNoticeShow && Conf.spoutTerritoryNoticeSize > 0)
if (notify && Conf.spoutTerritoryNoticeShow && Conf.spoutTerritoryNoticeSize > 0)
{
NoticeLabel label;
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...
FPlayers.i.autoLeaveOnInactivityRoutine();
FPlayers.i.autoLeaveOnInactivityRoutine();
SpoutFeatures.updateAppearancesShortly(event.getPlayer());
}
@Override