From d9b7cf70586d8913d1d797da4635ea60f1570a9a Mon Sep 17 00:00:00 2001 From: drtshock Date: Fri, 4 Apr 2014 14:35:35 -0500 Subject: [PATCH] Remove spout, update pom for lwc. Still need lots of dependencies. --- pom.xml | 26 ++ src/main/.DS_Store | Bin 0 -> 6148 bytes src/main/assembly/package.xml | 16 + .../com/massivecraft/factions/FPlayer.java | 11 - .../java/com/massivecraft/factions/P.java | 1 - .../massivecraft/factions/cmd/CmdConfig.java | 1 - .../massivecraft/factions/cmd/CmdDisband.java | 1 - .../massivecraft/factions/cmd/CmdOwner.java | 1 - .../factions/cmd/CmdPeaceful.java | 1 - .../com/massivecraft/factions/cmd/CmdTag.java | 1 - .../massivecraft/factions/cmd/CmdTitle.java | 1 - .../massivecraft/factions/cmd/CmdUnclaim.java | 1 - .../factions/cmd/CmdUnclaimall.java | 1 - .../factions/cmd/FRelationCommand.java | 1 - .../factions/integration/SpoutFeatures.java | 298 ------------------ .../integration/SpoutMainListener.java | 217 ------------- .../listeners/FactionsPlayerListener.java | 1 - .../listeners/FactionsServerListener.java | 1 - 18 files changed, 42 insertions(+), 538 deletions(-) create mode 100644 src/main/.DS_Store create mode 100644 src/main/assembly/package.xml delete mode 100644 src/main/java/com/massivecraft/factions/integration/SpoutFeatures.java delete mode 100644 src/main/java/com/massivecraft/factions/integration/SpoutMainListener.java diff --git a/pom.xml b/pom.xml index 2f7772bd..335f512e 100644 --- a/pom.xml +++ b/pom.xml @@ -45,11 +45,37 @@ bukkit LATEST + + org.bukkit + craftbukkit + LATEST + + + net.daboross.vault + vault-api + 1.2.27 + provided + + + com.griefcraft + lwc + 4.4.0-SNAPSHOT + + + + repo-daboross-net + http://repo.daboross.net/ + bukkit-repo http://repo.bukkit.org/content/groups/public/ + + mcstats.releases + mcstats.org releases + http://repo.mcstats.org/content/repositories/ + diff --git a/src/main/.DS_Store b/src/main/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..2b99efd68cc07f8531458207e8f4a968c00dc2c0 GIT binary patch literal 6148 zcmeHK!EVz)5S>j8*hT^)acFP8!6AnfsuoUIp;SU#kc{YoqGHz(F*4pNb{e4&$w#2& zA2=fT6+VCi|5D!UE>-1(TZMq`L^E%8c4nP@^6q+xNc6|qDp5d0E|k&nVHODYv(8D! zM7UF^FdT}RI;WwaD>o+ZAia+}!-7oU0?)AQl&XRNC z;w9Jfeb2vg)qfrjN5{3lWtCw`JX%?Fd+;QD=8)=6FtMyfc^ z21wc2&dW?r`f^-m)lRH~+j&+G)u1NedY} z1)n^3<;LxMk5c*e-TM!RM;||b(PRtkO-imA`~_d(xYU~aK|Cr8S-wOc*E#eG83&X+ zEaaZygg47A=uOT!K88J&$9vy7;qHW+7H1xf@Gey(X$)_V{T6%Qz!;e#6dQ%(`$dpZ(BwM9Y9>;2&pz_lFS57#VCds;vV?T>*d&!b;%t@yIoy!N_2v z5j_y0OM$vnm@9_R<%owSFEZF@)a4}1-~U@xwrLr#4E#?F2xl|i>|;jeY@M4MpS2 + bin + false + + zip + + + + ${project.build.directory}/${artifactId}.jar + / + ${artifactId}.jar + + + \ No newline at end of file diff --git a/src/main/java/com/massivecraft/factions/FPlayer.java b/src/main/java/com/massivecraft/factions/FPlayer.java index 087c680c..a4c2d431 100644 --- a/src/main/java/com/massivecraft/factions/FPlayer.java +++ b/src/main/java/com/massivecraft/factions/FPlayer.java @@ -6,7 +6,6 @@ import com.massivecraft.factions.iface.EconomyParticipator; import com.massivecraft.factions.iface.RelationParticipator; import com.massivecraft.factions.integration.Econ; import com.massivecraft.factions.integration.LWCFeatures; -import com.massivecraft.factions.integration.SpoutFeatures; import com.massivecraft.factions.integration.Worldguard; import com.massivecraft.factions.struct.ChatMode; import com.massivecraft.factions.struct.Permission; @@ -61,7 +60,6 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator { if (oldFaction != null) oldFaction.removeFPlayer(this); faction.addFPlayer(this); this.factionId = faction.getId(); - SpoutFeatures.updateAppearances(this.getPlayer()); } // FIELD: role @@ -73,7 +71,6 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator { public void setRole(Role role) { this.role = role; - SpoutFeatures.updateAppearances(this.getPlayer()); } // FIELD: title @@ -233,10 +230,6 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator { this.role = Role.NORMAL; this.title = ""; this.autoClaimFor = null; - - if (doSpoutUpdate) { - SpoutFeatures.updateAppearances(this.getPlayer()); - } } public void resetFactionData() { @@ -549,9 +542,6 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator { } public void sendFactionHereMessage() { - if (SpoutFeatures.updateTerritoryDisplay(this)) { - return; - } Faction factionHere = Board.getFactionAt(this.getLastStoodAt()); String msg = P.p.txt.parse("") + " ~ " + factionHere.getTag(this); if (factionHere.getDescription().length() > 0) { @@ -758,7 +748,6 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator { } Board.setFactionAt(forFaction, flocation); - SpoutFeatures.updateTerritoryDisplayLoc(flocation); if (Conf.logLandClaims) P.p.log(this.getName() + " claimed land at (" + flocation.getCoordString() + ") for the faction: " + forFaction.getTag()); diff --git a/src/main/java/com/massivecraft/factions/P.java b/src/main/java/com/massivecraft/factions/P.java index 1bbabdaf..d603278e 100644 --- a/src/main/java/com/massivecraft/factions/P.java +++ b/src/main/java/com/massivecraft/factions/P.java @@ -98,7 +98,6 @@ public class P extends MPlugin { this.getBaseCommands().add(cmdBase); EssentialsFeatures.setup(); - SpoutFeatures.setup(); Econ.setup(); CapiFeatures.setup(); LWCFeatures.setup(); diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdConfig.java b/src/main/java/com/massivecraft/factions/cmd/CmdConfig.java index 8b5eb9ba..89d5e7b4 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdConfig.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdConfig.java @@ -2,7 +2,6 @@ package com.massivecraft.factions.cmd; import com.massivecraft.factions.Conf; import com.massivecraft.factions.P; -import com.massivecraft.factions.integration.SpoutFeatures; import com.massivecraft.factions.struct.Permission; import org.bukkit.ChatColor; import org.bukkit.Material; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdDisband.java b/src/main/java/com/massivecraft/factions/cmd/CmdDisband.java index babd5453..c9a246a5 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdDisband.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdDisband.java @@ -4,7 +4,6 @@ import com.massivecraft.factions.*; import com.massivecraft.factions.event.FPlayerLeaveEvent; import com.massivecraft.factions.event.FactionDisbandEvent; import com.massivecraft.factions.integration.Econ; -import com.massivecraft.factions.integration.SpoutFeatures; import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Role; import org.bukkit.Bukkit; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdOwner.java b/src/main/java/com/massivecraft/factions/cmd/CmdOwner.java index bfedaade..9da63d12 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdOwner.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdOwner.java @@ -1,7 +1,6 @@ package com.massivecraft.factions.cmd; import com.massivecraft.factions.*; -import com.massivecraft.factions.integration.SpoutFeatures; import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Role; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdPeaceful.java b/src/main/java/com/massivecraft/factions/cmd/CmdPeaceful.java index 3ad738f1..6234058d 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdPeaceful.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdPeaceful.java @@ -3,7 +3,6 @@ package com.massivecraft.factions.cmd; import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayers; import com.massivecraft.factions.Faction; -import com.massivecraft.factions.integration.SpoutFeatures; import com.massivecraft.factions.struct.Permission; public class CmdPeaceful extends FCommand { diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdTag.java b/src/main/java/com/massivecraft/factions/cmd/CmdTag.java index 05446432..323cee5a 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdTag.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdTag.java @@ -4,7 +4,6 @@ import com.massivecraft.factions.Conf; import com.massivecraft.factions.Faction; import com.massivecraft.factions.Factions; import com.massivecraft.factions.event.FactionRenameEvent; -import com.massivecraft.factions.integration.SpoutFeatures; import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.util.MiscUtil; import org.bukkit.Bukkit; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdTitle.java b/src/main/java/com/massivecraft/factions/cmd/CmdTitle.java index 2541e64f..39d9df23 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdTitle.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdTitle.java @@ -2,7 +2,6 @@ package com.massivecraft.factions.cmd; import com.massivecraft.factions.Conf; import com.massivecraft.factions.FPlayer; -import com.massivecraft.factions.integration.SpoutFeatures; import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.zcore.util.TextUtil; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdUnclaim.java b/src/main/java/com/massivecraft/factions/cmd/CmdUnclaim.java index 73f55bd8..f29418fa 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdUnclaim.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdUnclaim.java @@ -3,7 +3,6 @@ package com.massivecraft.factions.cmd; import com.massivecraft.factions.*; import com.massivecraft.factions.event.LandUnclaimEvent; import com.massivecraft.factions.integration.Econ; -import com.massivecraft.factions.integration.SpoutFeatures; import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Role; import org.bukkit.Bukkit; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdUnclaimall.java b/src/main/java/com/massivecraft/factions/cmd/CmdUnclaimall.java index f1fbae66..a1365bd1 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdUnclaimall.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdUnclaimall.java @@ -5,7 +5,6 @@ import com.massivecraft.factions.Conf; import com.massivecraft.factions.P; import com.massivecraft.factions.event.LandUnclaimAllEvent; import com.massivecraft.factions.integration.Econ; -import com.massivecraft.factions.integration.SpoutFeatures; import com.massivecraft.factions.struct.Permission; import org.bukkit.Bukkit; diff --git a/src/main/java/com/massivecraft/factions/cmd/FRelationCommand.java b/src/main/java/com/massivecraft/factions/cmd/FRelationCommand.java index b0616376..0ddc0a96 100644 --- a/src/main/java/com/massivecraft/factions/cmd/FRelationCommand.java +++ b/src/main/java/com/massivecraft/factions/cmd/FRelationCommand.java @@ -3,7 +3,6 @@ package com.massivecraft.factions.cmd; import com.massivecraft.factions.Conf; import com.massivecraft.factions.Faction; import com.massivecraft.factions.event.FactionRelationEvent; -import com.massivecraft.factions.integration.SpoutFeatures; import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Relation; import org.bukkit.Bukkit; diff --git a/src/main/java/com/massivecraft/factions/integration/SpoutFeatures.java b/src/main/java/com/massivecraft/factions/integration/SpoutFeatures.java deleted file mode 100644 index 4c0d2ffc..00000000 --- a/src/main/java/com/massivecraft/factions/integration/SpoutFeatures.java +++ /dev/null @@ -1,298 +0,0 @@ -package com.massivecraft.factions.integration; - -import com.massivecraft.factions.*; -import com.massivecraft.factions.struct.Relation; -import com.massivecraft.factions.struct.Role; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.entity.Player; -import org.bukkit.plugin.Plugin; -import org.getspout.spoutapi.SpoutManager; -import org.getspout.spoutapi.gui.Color; -import org.getspout.spoutapi.player.SpoutPlayer; - -import java.util.Set; - - -public class SpoutFeatures { - private transient static boolean spoutMe = false; - private transient static SpoutMainListener mainListener; - private transient static boolean listenersHooked; - - public static void setup() { - Plugin test = Bukkit.getServer().getPluginManager().getPlugin("Spout"); - if (test == null || !test.isEnabled()) return; - - setAvailable(true, test.getDescription().getFullName()); - } - - // set integration availability - public static void setAvailable(boolean enable, String pluginName) { - spoutMe = enable; - if (!spoutMe) return; - - P.p.log("Found and will use features of " + pluginName); - - if (!listenersHooked) { - listenersHooked = true; - mainListener = new SpoutMainListener(); - Bukkit.getServer().getPluginManager().registerEvents(mainListener, P.p); - } - } - - // If we're successfully hooked into Spout - public static boolean enabled() { - return spoutMe; - } - - // If Spout is available and the specified Player is running the Spoutcraft client - public static boolean availableFor(Player player) { - return spoutMe && SpoutManager.getPlayer(player).isSpoutCraftEnabled(); - } - - - // 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 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, 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 players = FPlayers.i.getOnline(); - - for (FPlayer player : players) { - if (fLoc == null || player.getLastStoodAt().equals(fLoc)) - mainListener.updateOwnerList(player); - } - } - - // update owner list for specified player - public static void updateOwnerList(FPlayer player) { - if (!enabled()) - return; - - mainListener.updateOwnerList(player); - } - - public static void playerDisconnect(FPlayer player) { - if (!enabled()) - return; - - mainListener.removeTerritoryLabels(player.getName()); - } - - - // update all appearances between every player - public static void updateAppearances() { - if (!enabled()) - return; - - Set players = FPlayers.i.getOnline(); - - for (FPlayer playerA : players) { - for (FPlayer playerB : players) { - updateSingle(playerB, playerA); - } - } - } - - // update all appearances related to a specific player - public static void updateAppearances(Player player) { - if (!enabled() || player == null) - return; - - Set players = FPlayers.i.getOnline(); - FPlayer playerA = FPlayers.i.get(player); - - for (FPlayer playerB : players) { - 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 players = FPlayers.i.getOnline(); - Faction factionA; - - for (FPlayer playerA : players) { - factionA = playerA.getFaction(); - - for (FPlayer playerB : players) { - if (factionA != faction && playerB.getFaction() != faction) - continue; - - updateSingle(playerB, playerA); - } - } - } - - // update all appearances between two factions - 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)) { - updateSingle(playerB, playerA); - updateSingle(playerA, playerB); - } - } - } - - - // update a single appearance; internal use only by above public methods - private static void updateSingle(FPlayer viewer, FPlayer viewed) { - if (viewer == null || viewed == null) - return; - - Faction viewedFaction = viewed.getFaction(); - if (viewedFaction == null) - return; - - // these still end up returning null on occasion at this point, mucking up the SpoutManager.getPlayer() method - if (viewer.getPlayer() == null || viewed.getPlayer() == null) - return; - - SpoutPlayer pViewer = SpoutManager.getPlayer(viewer.getPlayer()); - SpoutPlayer pViewed = SpoutManager.getPlayer(viewed.getPlayer()); - if (pViewed == null || pViewer == null) - return; - - String viewedTitle = viewed.getTitle(); - Role viewedRole = viewed.getRole(); - - if ((Conf.spoutFactionTagsOverNames || Conf.spoutFactionTitlesOverNames) && viewer != viewed) { - if (viewedFaction.isNormal()) { - String addTag = ""; - if (Conf.spoutFactionTagsOverNames) - addTag += viewedFaction.getTag(viewed.getColorTo(viewer).toString() + "[") + "]"; - - String rolePrefix = viewedRole.getPrefix(); - if (Conf.spoutFactionTitlesOverNames && (!viewedTitle.isEmpty() || !rolePrefix.isEmpty())) - addTag += (addTag.isEmpty() ? "" : " ") + viewedRole.getPrefix() + viewedTitle; - - pViewed.setTitleFor(pViewer, addTag + "\n" + pViewed.getDisplayName()); - } else { - pViewed.setTitleFor(pViewer, pViewed.getDisplayName()); - } - } - - if - ( - ( - Conf.spoutFactionAdminCapes - && - viewedRole.equals(Role.ADMIN) - ) - || - ( - Conf.spoutFactionModeratorCapes - && - viewedRole.equals(Role.MODERATOR) - ) - ) { - 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()) - pViewed.resetCapeFor(pViewer); - else - pViewed.setCapeFor(pViewer, cape); - } else if (Conf.spoutFactionAdminCapes || Conf.spoutFactionModeratorCapes) { - pViewed.resetCapeFor(pViewer); - } - } - - - // 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.getChar()) { - case 0x1: - return SpoutFixedColor(0, 0, 191, alpha); - case 0x2: - return SpoutFixedColor(0, 191, 0, alpha); - case 0x3: - return SpoutFixedColor(0, 191, 191, alpha); - case 0x4: - return SpoutFixedColor(191, 0, 0, alpha); - case 0x5: - return SpoutFixedColor(191, 0, 191, alpha); - case 0x6: - return SpoutFixedColor(191, 191, 0, alpha); - case 0x7: - return SpoutFixedColor(191, 191, 191, alpha); - case 0x8: - return SpoutFixedColor(64, 64, 64, alpha); - case 0x9: - return SpoutFixedColor(64, 64, 255, alpha); - case 0xA: - return SpoutFixedColor(64, 255, 64, alpha); - case 0xB: - return SpoutFixedColor(64, 255, 255, alpha); - case 0xC: - return SpoutFixedColor(255, 64, 64, alpha); - case 0xD: - return SpoutFixedColor(255, 64, 255, alpha); - case 0xE: - return SpoutFixedColor(255, 255, 64, alpha); - case 0xF: - return SpoutFixedColor(255, 255, 255, alpha); - default: - return SpoutFixedColor(0, 0, 0, alpha); - } - } - - private static Color SpoutFixedColor(int r, int g, int b, int a) { - return new Color(r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f); - } -} diff --git a/src/main/java/com/massivecraft/factions/integration/SpoutMainListener.java b/src/main/java/com/massivecraft/factions/integration/SpoutMainListener.java deleted file mode 100644 index 4bde7b3f..00000000 --- a/src/main/java/com/massivecraft/factions/integration/SpoutMainListener.java +++ /dev/null @@ -1,217 +0,0 @@ -package com.massivecraft.factions.integration; - -import com.massivecraft.factions.*; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.getspout.spoutapi.SpoutManager; -import org.getspout.spoutapi.event.spout.SpoutCraftEnableEvent; -import org.getspout.spoutapi.gui.GenericLabel; -import org.getspout.spoutapi.player.SpoutPlayer; - -import java.util.HashMap; -import java.util.Map; - - -public class SpoutMainListener implements Listener { - @EventHandler(priority = EventPriority.NORMAL) - public void onSpoutCraftEnable(SpoutCraftEnableEvent event) { - final FPlayer me = FPlayers.i.get(event.getPlayer()); - - SpoutFeatures.updateAppearances(me.getPlayer()); - updateTerritoryDisplay(me, true); - } - - //-----------------------------------------------------------------------------------------// - // Everything below this is handled in here to prevent errors on servers not running Spout - //-----------------------------------------------------------------------------------------// - - private transient static Map territoryLabels = new HashMap(); - private transient static Map territoryChangeLabels = new HashMap(); - private transient static Map ownerLabels = new HashMap(); - private final static int SCREEN_WIDTH = 427; -// private final static int SCREEN_HEIGHT = 240; - - - public boolean updateTerritoryDisplay(FPlayer player, boolean notify) { - Player p = player.getPlayer(); - if (p == null) - return false; - - SpoutPlayer sPlayer = SpoutManager.getPlayer(p); - if (!sPlayer.isSpoutCraftEnabled() || (Conf.spoutTerritoryDisplaySize <= 0 && !Conf.spoutTerritoryNoticeShow)) - return false; - - doLabels(player, sPlayer, notify); - - return true; - } - - public void updateOwnerList(FPlayer player) { - SpoutPlayer sPlayer = SpoutManager.getPlayer(player.getPlayer()); - if (!sPlayer.isSpoutCraftEnabled() || (Conf.spoutTerritoryDisplaySize <= 0 && !Conf.spoutTerritoryNoticeShow)) - return; - - FLocation here = player.getLastStoodAt(); - Faction factionHere = Board.getFactionAt(here); - - doOwnerList(player, sPlayer, here, factionHere); - - return; - } - - public void removeTerritoryLabels(String playerName) { - territoryLabels.remove(playerName); - territoryChangeLabels.remove(playerName); - ownerLabels.remove(playerName); - } - - - private void doLabels(FPlayer player, SpoutPlayer sPlayer, boolean notify) { - FLocation here = player.getLastStoodAt(); - Faction factionHere = Board.getFactionAt(here); - String tag = factionHere.getColorTo(player).toString() + factionHere.getTag(); - - // ---------------------- - // Main territory display - // ---------------------- - if (Conf.spoutTerritoryDisplayPosition > 0 && Conf.spoutTerritoryDisplaySize > 0) { - GenericLabel label; - if (territoryLabels.containsKey(player.getName())) - label = territoryLabels.get(player.getName()); - else { - label = new GenericLabel(); - label.setWidth(1).setHeight(1); // prevent Spout's questionable new "no default size" warning - label.setScale(Conf.spoutTerritoryDisplaySize); - - sPlayer.getMainScreen().attachWidget(P.p, label); - territoryLabels.put(player.getName(), label); - } - - String msg = tag; - - if (Conf.spoutTerritoryDisplayShowDescription && !factionHere.getDescription().isEmpty()) - msg += " - " + factionHere.getDescription(); - - label.setText(msg); - alignLabel(label, msg); - label.setDirty(true); - } - - // ----------------------- - // Fading territory notice - // ----------------------- - if (notify && Conf.spoutTerritoryNoticeShow && Conf.spoutTerritoryNoticeSize > 0) { - NoticeLabel label; - if (territoryChangeLabels.containsKey(player.getName())) - label = territoryChangeLabels.get(player.getName()); - else { - label = new NoticeLabel(Conf.spoutTerritoryNoticeLeaveAfterSeconds); - label.setWidth(1).setHeight(1); // prevent Spout's questionable new "no default size" warning - label.setScale(Conf.spoutTerritoryNoticeSize); - label.setY(Conf.spoutTerritoryNoticeTop); - sPlayer.getMainScreen().attachWidget(P.p, label); - territoryChangeLabels.put(player.getName(), label); - } - - String msg = tag; - - if (Conf.spoutTerritoryNoticeShowDescription && !factionHere.getDescription().isEmpty()) - msg += " - " + factionHere.getDescription(); - - label.setText(msg); - alignLabel(label, msg, 2); - label.resetNotice(); - label.setDirty(true); - } - - // and owner list, of course - doOwnerList(player, sPlayer, here, factionHere); - } - - private void doOwnerList(FPlayer player, SpoutPlayer sPlayer, FLocation here, Faction factionHere) { - // ---------- - // Owner list - // ---------- - if (Conf.spoutTerritoryDisplayPosition > 0 && Conf.spoutTerritoryDisplaySize > 0 && Conf.spoutTerritoryOwnersShow && Conf.ownedAreasEnabled) { - GenericLabel label; - if (ownerLabels.containsKey(player.getName())) - label = ownerLabels.get(player.getName()); - else { - label = new GenericLabel(); - label.setWidth(1).setHeight(1); // prevent Spout's questionable new "no default size" warning - label.setScale(Conf.spoutTerritoryDisplaySize); - label.setY((int) (10 * Conf.spoutTerritoryDisplaySize)); - sPlayer.getMainScreen().attachWidget(P.p, label); - ownerLabels.put(player.getName(), label); - } - - String msg = ""; - - if (player.getFaction() == factionHere) { - msg = factionHere.getOwnerListString(here); - - if (!msg.isEmpty()) - msg = Conf.ownedLandMessage + msg; - } - - label.setText(msg); - alignLabel(label, msg); - label.setDirty(true); - } - } - - - // this is only necessary because Spout text size scaling is currently bugged and breaks their built-in alignment methods - public void alignLabel(GenericLabel label, String text) { - alignLabel(label, text, Conf.spoutTerritoryDisplayPosition); - } - - public void alignLabel(GenericLabel label, String text, int alignment) { - int labelWidth = (int) ((float) GenericLabel.getStringWidth(text) * Conf.spoutTerritoryDisplaySize); - if (labelWidth > SCREEN_WIDTH) { - label.setX(0); - return; - } - - switch (alignment) { - case 1: // left aligned - label.setX(0); - break; - case 2: // center aligned - label.setX((SCREEN_WIDTH - labelWidth) / 2); - break; - default: // right aligned - label.setX(SCREEN_WIDTH - labelWidth); - } - } - - - private static class NoticeLabel extends GenericLabel { - private int initial; - private int countdown; // current delay countdown - - public NoticeLabel(float secondsOfLife) { - initial = (int) (secondsOfLife * 20); - resetNotice(); - } - - public final void resetNotice() { - countdown = initial; - } - - @Override - public void onTick() { - if (countdown <= 0) - return; - - this.countdown -= 1; - - if (this.countdown <= 0) { - this.setText(""); - this.setDirty(true); - } - } - } -} \ No newline at end of file diff --git a/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java b/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java index f0a2dacb..418c07d9 100644 --- a/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java +++ b/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java @@ -1,7 +1,6 @@ package com.massivecraft.factions.listeners; import com.massivecraft.factions.*; -import com.massivecraft.factions.integration.SpoutFeatures; import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Relation; import com.massivecraft.factions.struct.Role; diff --git a/src/main/java/com/massivecraft/factions/listeners/FactionsServerListener.java b/src/main/java/com/massivecraft/factions/listeners/FactionsServerListener.java index bb82bc3c..7510a6e3 100644 --- a/src/main/java/com/massivecraft/factions/listeners/FactionsServerListener.java +++ b/src/main/java/com/massivecraft/factions/listeners/FactionsServerListener.java @@ -1,7 +1,6 @@ package com.massivecraft.factions.listeners; import com.massivecraft.factions.P; -import com.massivecraft.factions.integration.SpoutFeatures; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener;