diff --git a/lib/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar b/lib/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar deleted file mode 100644 index 4a599645..00000000 Binary files a/lib/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar and /dev/null differ diff --git a/lib/SpoutPlugin.jar b/lib/SpoutPlugin.jar deleted file mode 100644 index f7a8dfc0..00000000 Binary files a/lib/SpoutPlugin.jar and /dev/null differ diff --git a/lib/junit/junit-3.8.2-api.zip b/lib/junit/junit-3.8.2-api.zip deleted file mode 100644 index 6d792fda..00000000 Binary files a/lib/junit/junit-3.8.2-api.zip and /dev/null differ diff --git a/lib/junit/junit-3.8.2.jar b/lib/junit/junit-3.8.2.jar deleted file mode 100644 index d8358726..00000000 Binary files a/lib/junit/junit-3.8.2.jar and /dev/null differ diff --git a/lib/junit_4/junit-4.5-api.zip b/lib/junit_4/junit-4.5-api.zip deleted file mode 100644 index 5748c444..00000000 Binary files a/lib/junit_4/junit-4.5-api.zip and /dev/null differ diff --git a/lib/junit_4/junit-4.5-src.jar b/lib/junit_4/junit-4.5-src.jar deleted file mode 100644 index 18774a57..00000000 Binary files a/lib/junit_4/junit-4.5-src.jar and /dev/null differ diff --git a/lib/junit_4/junit-4.5.jar b/lib/junit_4/junit-4.5.jar deleted file mode 100644 index 83f8bc79..00000000 Binary files a/lib/junit_4/junit-4.5.jar and /dev/null differ diff --git a/lib/nblibraries.properties b/lib/nblibraries.properties deleted file mode 100644 index 9137b06b..00000000 --- a/lib/nblibraries.properties +++ /dev/null @@ -1,12 +0,0 @@ -libs.CopyLibs.classpath=\ - ${base}/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar -libs.junit.classpath=\ - ${base}/junit/junit-3.8.2.jar -libs.junit.javadoc=\ - ${base}/junit/junit-3.8.2-api.zip -libs.junit_4.classpath=\ - ${base}/junit_4/junit-4.5.jar -libs.junit_4.javadoc=\ - ${base}/junit_4/junit-4.5-api.zip -libs.junit_4.src=\ - ${base}/junit_4/junit-4.5-src.jar diff --git a/src/com/massivecraft/factions/ConfServer.java b/src/com/massivecraft/factions/ConfServer.java index ef633b4f..34bd6145 100644 --- a/src/com/massivecraft/factions/ConfServer.java +++ b/src/com/massivecraft/factions/ConfServer.java @@ -88,42 +88,6 @@ public class ConfServer extends SimpleConfig public static boolean onUnclaimResetLwcLocks = false; public static boolean onCaptureResetLwcLocks = false; - // -------------------------------------------- // - // INTEGRATION: SPOUT - // -------------------------------------------- // - - public static boolean spoutFactionTagsOverNames = true; // show faction tags over names over player heads - public static boolean spoutFactionTitlesOverNames = true; // whether to include player's title in that - public static boolean spoutHealthBarUnderNames = true; // Show healthbar under player names. - public static String spoutHealthBarLeft = "{c}["; - public static String spoutHealthBarSolid = "|"; - public static String spoutHealthBarBetween = "&8"; - public static String spoutHealthBarEmpty = "|"; - public static String spoutHealthBarRight = "{c}]"; - public static double spoutHealthBarSolidsPerEmpty = 1d; - public static String spoutHealthBarColorTag = "{c}"; - public static int spoutHealthBarWidth = 30; - - public static Map spoutHealthBarColorUnderQuota = MUtil.map( - 1.0d, "&2", - 0.8d, "&a", - 0.5d, "&e", - 0.4d, "&6", - 0.3d, "&c", - 0.2d, "&4" - ); - - public static boolean spoutCapes = true; // Show faction capes - public static int spoutTerritoryDisplayPosition = 1; // permanent territory display, instead of by chat; 0 = disabled, 1 = top left, 2 = top center, 3+ = top right - public static float spoutTerritoryDisplaySize = 1.0f; // text scale (size) for territory display - public static boolean spoutTerritoryDisplayShowDescription = true; // whether to show the faction description, not just the faction tag - public static boolean spoutTerritoryAccessShow = true; // show occasional territory access info as well ("access granted" or "access restricted" if relevant) - public static boolean spoutTerritoryNoticeShow = true; // show additional brief territory notice near center of screen, to be sure player notices transition - public static int spoutTerritoryNoticeTop = 40; // how far down the screen to place the additional notice - public static boolean spoutTerritoryNoticeShowDescription = false; // whether to show the faction description in the notice, not just the faction tag - public static float spoutTerritoryNoticeSize = 1.5f; // text scale (size) for notice - public static float spoutTerritoryNoticeLeaveAfterSeconds = 2.00f; // how many seconds before the notice goes away - // -------------------------------------------- // // INTEGRATION: ECONOMY // -------------------------------------------- // diff --git a/src/com/massivecraft/factions/Factions.java b/src/com/massivecraft/factions/Factions.java index 997568a1..db3edb6f 100644 --- a/src/com/massivecraft/factions/Factions.java +++ b/src/com/massivecraft/factions/Factions.java @@ -25,14 +25,12 @@ import com.massivecraft.factions.entity.UPlayerColls; import com.massivecraft.factions.entity.FactionColls; import com.massivecraft.factions.entity.MConfColl; import com.massivecraft.factions.integration.LWCFeatures; -import com.massivecraft.factions.integration.SpoutFeatures; import com.massivecraft.factions.integration.Worldguard; import com.massivecraft.factions.integration.herochat.HerochatFeatures; import com.massivecraft.factions.listeners.FactionsListenerChat; import com.massivecraft.factions.listeners.FactionsListenerEcon; import com.massivecraft.factions.listeners.FactionsListenerExploit; import com.massivecraft.factions.listeners.FactionsListenerMain; -import com.massivecraft.factions.listeners.FactionsListenerSpout; import com.massivecraft.factions.listeners.TodoFactionsPlayerListener; import com.massivecraft.factions.task.AutoLeaveTask; import com.massivecraft.factions.task.EconLandRewardTask; @@ -125,9 +123,6 @@ public class Factions extends MPlugin // Right now only a few situations are handled through this listener. FactionsListenerEcon.get().setup(); - // TODO: The same goes for this one: - FactionsListenerSpout.get().setup(); - // TODO: Get rid of this one this.playerListener = new TodoFactionsPlayerListener(); getServer().getPluginManager().registerEvents(this.playerListener, this); @@ -155,7 +150,6 @@ public class Factions extends MPlugin // Integrate this.integrate(HerochatFeatures.get()); - SpoutFeatures.setup(); LWCFeatures.setup(); if (ConfServer.worldGuardChecking) diff --git a/src/com/massivecraft/factions/cmd/CmdFactions.java b/src/com/massivecraft/factions/cmd/CmdFactions.java index 399656c8..02d5bb12 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactions.java +++ b/src/com/massivecraft/factions/cmd/CmdFactions.java @@ -14,7 +14,6 @@ public class CmdFactions extends FCommand public CmdFactionsLeader cmdFactionsLeader = new CmdFactionsLeader(); public CmdFactionsAutoClaim cmdFactionsAutoClaim = new CmdFactionsAutoClaim(); public CmdFactionsAdmin cmdFactionsAdmin = new CmdFactionsAdmin(); - public CmdFactionsCape cmdFactionsCape = new CmdFactionsCape(); public CmdFactionsClaim cmdFactionsClaim = new CmdFactionsClaim(); public CmdFactionsCreate cmdFactionsCreate = new CmdFactionsCreate(); public CmdFactionsDemote cmdFactionsDemote = new CmdFactionsDemote(); @@ -72,7 +71,6 @@ public class CmdFactions extends FCommand this.addSubCommand(this.cmdFactionsTag); this.addSubCommand(this.cmdFactionsDemote); this.addSubCommand(this.cmdFactionsDescription); - this.addSubCommand(this.cmdFactionsCape); this.addSubCommand(this.cmdFactionsPerm); this.addSubCommand(this.cmdFactionsFlag); this.addSubCommand(this.cmdFactionsInvite); diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsAccess.java b/src/com/massivecraft/factions/cmd/CmdFactionsAccess.java index 31cfbcc2..dfb432ce 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsAccess.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsAccess.java @@ -8,7 +8,6 @@ import com.massivecraft.factions.cmd.arg.ARFaction; import com.massivecraft.factions.entity.BoardColls; import com.massivecraft.factions.entity.UPlayer; import com.massivecraft.factions.entity.Faction; -import com.massivecraft.factions.integration.SpoutFeatures; import com.massivecraft.mcore.cmd.req.ReqIsPlayer; import com.massivecraft.mcore.ps.PS; import com.massivecraft.mcore.util.Txt; @@ -87,7 +86,6 @@ public class CmdFactionsAccess extends FCommand } msg("%s has been %s the access list for this territory.", target, Txt.parse(added ? "added to" : "removed from")); - SpoutFeatures.updateAccessInfoLoc(chunk); showAccessList(territory, locFaction); } diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsCape.java b/src/com/massivecraft/factions/cmd/CmdFactionsCape.java deleted file mode 100644 index 0e73cfd6..00000000 --- a/src/com/massivecraft/factions/cmd/CmdFactionsCape.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.massivecraft.factions.cmd; - -import com.massivecraft.factions.Perm; -import com.massivecraft.mcore.cmd.HelpCommand; -import com.massivecraft.mcore.cmd.req.ReqHasPerm; - -public class CmdFactionsCape extends FCommand -{ - public CmdFactionsCapeGet cmdCapeGet = new CmdFactionsCapeGet(); - public CmdFactionsCapeSet cmdCapeSet = new CmdFactionsCapeSet(); - public CmdFactionsCapeRemove cmdCapeRemove = new CmdFactionsCapeRemove(); - - public CmdFactionsCape() - { - this.addAliases("cape"); - - this.addRequirements(ReqHasPerm.get(Perm.CAPE.node)); - - this.addSubCommand(this.cmdCapeGet); - this.addSubCommand(this.cmdCapeSet); - this.addSubCommand(this.cmdCapeRemove); - } - - @Override - public void perform() - { - this.getCommandChain().add(this); - HelpCommand.getInstance().execute(this.sender, this.args, this.commandChain); - } - -} diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsCapeAbstract.java b/src/com/massivecraft/factions/cmd/CmdFactionsCapeAbstract.java deleted file mode 100644 index 92612144..00000000 --- a/src/com/massivecraft/factions/cmd/CmdFactionsCapeAbstract.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.massivecraft.factions.cmd; - -import java.util.List; - -import org.bukkit.command.CommandSender; - -import com.massivecraft.factions.FPerm; -import com.massivecraft.factions.cmd.arg.ARFaction; -import com.massivecraft.factions.entity.Faction; - -public abstract class CmdFactionsCapeAbstract extends FCommand -{ - public Faction capeFaction; - public String currentCape; - - public CmdFactionsCapeAbstract() - { - this.addOptionalArg("faction", "you"); - } - - @Override - public boolean validCall(CommandSender sender, List args) - { - this.capeFaction = null; - this.currentCape = null; - - if (this.myFaction == null && ! this.argIsSet(this.requiredArgs.size())) - { - msg("You must specify a faction from console."); - return false; - } - - this.capeFaction = this.arg(this.requiredArgs.size(), ARFaction.get(myFaction), myFaction); - if (this.capeFaction == null) return false; - - // Do we have permission to manage the cape of that faction? - if (fme != null && ! FPerm.CAPE.has(fme, capeFaction)) return false; - - this.currentCape = this.capeFaction.getCape(); - - return true; - } -} diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsCapeGet.java b/src/com/massivecraft/factions/cmd/CmdFactionsCapeGet.java deleted file mode 100644 index 753ce9fa..00000000 --- a/src/com/massivecraft/factions/cmd/CmdFactionsCapeGet.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.massivecraft.factions.cmd; - -import com.massivecraft.factions.Perm; -import com.massivecraft.mcore.cmd.req.ReqHasPerm; - -public class CmdFactionsCapeGet extends CmdFactionsCapeAbstract -{ - public CmdFactionsCapeGet() - { - this.addAliases("get"); - - this.addRequirements(ReqHasPerm.get(Perm.CAPE_GET.node)); - } - - @Override - public void perform() - { - if (currentCape == null) - { - msg("%s has no cape set.", capeFaction.describeTo(fme, true)); - } - else - { - msg("The cape of %s is \"%s\".", capeFaction.describeTo(fme, true), currentCape); - } - } -} diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsCapeRemove.java b/src/com/massivecraft/factions/cmd/CmdFactionsCapeRemove.java deleted file mode 100644 index f9af3155..00000000 --- a/src/com/massivecraft/factions/cmd/CmdFactionsCapeRemove.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.massivecraft.factions.cmd; - -import com.massivecraft.factions.Perm; -import com.massivecraft.factions.integration.SpoutFeatures; -import com.massivecraft.factions.util.RelationUtil; -import com.massivecraft.mcore.cmd.req.ReqHasPerm; - -public class CmdFactionsCapeRemove extends CmdFactionsCapeAbstract -{ - public CmdFactionsCapeRemove() - { - this.addAliases("rm", "rem", "remove", "del", "delete"); - - this.addRequirements(ReqHasPerm.get(Perm.CAPE_REMOVE.node)); - } - - @Override - public void perform() - { - if (currentCape == null) - { - msg("%s has no cape set.", capeFaction.describeTo(fme, true)); - } - else - { - capeFaction.setCape(null); - SpoutFeatures.updateCape(capeFaction, null); - msg("%s removed the cape from %s.", RelationUtil.describeThatToMe(fme, fme, true), capeFaction.describeTo(fme)); - capeFaction.msg("%s removed the cape from %s.", RelationUtil.describeThatToMe(fme, capeFaction, true), capeFaction.describeTo(capeFaction)); - } - } -} diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsCapeSet.java b/src/com/massivecraft/factions/cmd/CmdFactionsCapeSet.java deleted file mode 100644 index 646a7e9f..00000000 --- a/src/com/massivecraft/factions/cmd/CmdFactionsCapeSet.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.massivecraft.factions.cmd; - -import java.net.URL; - -import com.massivecraft.factions.Perm; -import com.massivecraft.factions.integration.SpoutFeatures; -import com.massivecraft.factions.util.RelationUtil; -import com.massivecraft.mcore.cmd.req.ReqHasPerm; - -public class CmdFactionsCapeSet extends CmdFactionsCapeAbstract -{ - - public CmdFactionsCapeSet() - { - this.addAliases("set"); - - this.addRequiredArg("url"); - this.setErrorOnToManyArgs(false); - - this.addRequirements(ReqHasPerm.get(Perm.CAPE_SET.node)); - } - - @Override - public void perform() - { - String newCape = this.argConcatFrom(0); - - if (isUrlValid(newCape)) - { - capeFaction.setCape(newCape); - SpoutFeatures.updateCape(capeFaction, null); - msg("%s set the cape of %s to \"%s\".", RelationUtil.describeThatToMe(fme, fme, true), capeFaction.describeTo(fme), newCape); - capeFaction.msg("%s set the cape of %s to \"%s\".", RelationUtil.describeThatToMe(fme, capeFaction, true), capeFaction.describeTo(capeFaction), newCape); - } - else - { - msg("\"%s\" is not a valid URL.", newCape); - } - } - - public static boolean isUrlValid(String urlString) - { - try - { - new URL(urlString); - return true; - } - catch (Exception e) - { - return false; - } - } -} diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsDisband.java b/src/com/massivecraft/factions/cmd/CmdFactionsDisband.java index c49005cc..38fcbb3b 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsDisband.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsDisband.java @@ -14,7 +14,6 @@ import com.massivecraft.factions.FFlag; import com.massivecraft.factions.FPerm; import com.massivecraft.factions.Factions; import com.massivecraft.factions.Perm; -import com.massivecraft.factions.integration.SpoutFeatures; import com.massivecraft.mcore.cmd.req.ReqHasPerm; import com.massivecraft.mcore.money.Money; @@ -94,8 +93,5 @@ public class CmdFactionsDisband extends FCommand } faction.detach(); - - SpoutFeatures.updateTitle(null, null); - SpoutFeatures.updateCape(null, null); } } diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsRelationAbstract.java b/src/com/massivecraft/factions/cmd/CmdFactionsRelationAbstract.java index ba801b35..2e630a35 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsRelationAbstract.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsRelationAbstract.java @@ -8,7 +8,6 @@ import com.massivecraft.factions.cmd.arg.ARFaction; import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast; import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.event.FactionsEventRelationChange; -import com.massivecraft.factions.integration.SpoutFeatures; import com.massivecraft.mcore.cmd.req.ReqHasPerm; public abstract class CmdFactionsRelationAbstract extends FCommand @@ -89,9 +88,5 @@ public abstract class CmdFactionsRelationAbstract extends FCommand otherFaction.msg("This will have no effect while their faction is peaceful."); myFaction.msg("This will have no effect while your faction is peaceful."); } - - SpoutFeatures.updateTitle(myFaction, otherFaction); - SpoutFeatures.updateTitle(otherFaction, myFaction); - SpoutFeatures.updateTerritoryDisplayLoc(null); } } diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsTag.java b/src/com/massivecraft/factions/cmd/CmdFactionsTag.java index 8be0604f..3de13f71 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsTag.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsTag.java @@ -2,7 +2,6 @@ package com.massivecraft.factions.cmd; import java.util.ArrayList; -import com.massivecraft.factions.ConfServer; import com.massivecraft.factions.Perm; import com.massivecraft.factions.Rel; import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast; @@ -10,7 +9,6 @@ import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.FactionColl; import com.massivecraft.factions.entity.FactionColls; import com.massivecraft.factions.event.FactionsEventTagChange; -import com.massivecraft.factions.integration.SpoutFeatures; import com.massivecraft.factions.util.MiscUtil; import com.massivecraft.mcore.cmd.req.ReqHasPerm; @@ -70,11 +68,6 @@ public class CmdFactionsTag extends FCommand } faction.msg("The faction %s changed their name to %s.", fme.getColorTo(faction)+oldtag, myFaction.getTag(faction)); } - - if (ConfServer.spoutFactionTagsOverNames) - { - SpoutFeatures.updateTitle(myFaction, null); - } } } diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsTitle.java b/src/com/massivecraft/factions/cmd/CmdFactionsTitle.java index b9525231..c22c94b7 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsTitle.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsTitle.java @@ -1,13 +1,11 @@ package com.massivecraft.factions.cmd; -import com.massivecraft.factions.ConfServer; import com.massivecraft.factions.Perm; import com.massivecraft.factions.Rel; import com.massivecraft.factions.cmd.arg.ARUPlayer; import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast; import com.massivecraft.factions.entity.UPlayer; import com.massivecraft.factions.event.FactionsEventTitleChange; -import com.massivecraft.factions.integration.SpoutFeatures; import com.massivecraft.mcore.cmd.arg.ARString; import com.massivecraft.mcore.cmd.req.ReqHasPerm; @@ -48,11 +46,6 @@ public class CmdFactionsTitle extends FCommand // Inform myFaction.msg("%s changed a title: %s", fme.describeTo(myFaction, true), you.describeTo(myFaction, true)); - - if (ConfServer.spoutFactionTitlesOverNames) - { - SpoutFeatures.updateTitle(me, null); - } } } diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsUnclaim.java b/src/com/massivecraft/factions/cmd/CmdFactionsUnclaim.java index eac67369..4056bf0f 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsUnclaim.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsUnclaim.java @@ -6,7 +6,6 @@ import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.MConf; import com.massivecraft.factions.event.FactionsEventLandUnclaim; import com.massivecraft.factions.integration.Econ; -import com.massivecraft.factions.integration.SpoutFeatures; import com.massivecraft.factions.FPerm; import com.massivecraft.factions.Factions; import com.massivecraft.factions.Perm; @@ -55,7 +54,6 @@ public class CmdFactionsUnclaim extends FCommand } BoardColls.get().removeAt(chunk); - SpoutFeatures.updateTerritoryDisplayLoc(chunk); myFaction.msg("%s unclaimed some land.", fme.describeTo(myFaction, true)); if (MConf.get().logLandUnclaims) diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsUnclaimall.java b/src/com/massivecraft/factions/cmd/CmdFactionsUnclaimall.java index b5188aab..65976c0c 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsUnclaimall.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsUnclaimall.java @@ -9,7 +9,6 @@ import com.massivecraft.factions.entity.BoardColls; import com.massivecraft.factions.entity.MConf; import com.massivecraft.factions.event.FactionsEventLandUnclaimAll; import com.massivecraft.factions.integration.Econ; -import com.massivecraft.factions.integration.SpoutFeatures; import com.massivecraft.mcore.cmd.req.ReqHasPerm; public class CmdFactionsUnclaimall extends FCommand @@ -49,9 +48,6 @@ public class CmdFactionsUnclaimall extends FCommand // Inform myFaction.msg("%s unclaimed ALL of your faction's land.", fme.describeTo(myFaction, true)); - - // TODO: Move this to a listener instead. - SpoutFeatures.updateTerritoryDisplayLoc(null); if (MConf.get().logLandUnclaims) { diff --git a/src/com/massivecraft/factions/entity/Faction.java b/src/com/massivecraft/factions/entity/Faction.java index 2da68b7e..09e4bdb8 100644 --- a/src/com/massivecraft/factions/entity/Faction.java +++ b/src/com/massivecraft/factions/entity/Faction.java @@ -18,7 +18,6 @@ import com.massivecraft.factions.Factions; import com.massivecraft.factions.Lang; import com.massivecraft.factions.Rel; import com.massivecraft.factions.RelationParticipator; -import com.massivecraft.factions.integration.SpoutFeatures; import com.massivecraft.factions.util.*; import com.massivecraft.mcore.mixin.Mixin; import com.massivecraft.mcore.ps.PS; @@ -50,7 +49,6 @@ public class Faction extends Entity implements EconomyParticipator this.setDescription(that.description); this.home = that.home; this.setPowerBoost(that.powerBoost); - this.cape = that.cape; this.open = that.open; this.setInvitedPlayerIds(that.invitedPlayerIds); this.setRelationWishes(that.relationWish); @@ -83,10 +81,6 @@ public class Faction extends Entity implements EconomyParticipator // The powerBoost is a custom increase/decrease to default and maximum power. private Double powerBoost = null; - // The cape field is used by the Spout integration features. - // It's the URL to the faction cape. - private String cape = null; - // Can anyone join the Faction? // If the faction is open they can. // If the faction is closed an invite is required. @@ -280,21 +274,6 @@ public class Faction extends Entity implements EconomyParticipator return this.getPowerBoost() != 0D; } - // -------------------------------------------- // - // FIELD: cape - // -------------------------------------------- // - - public String getCape() - { - return cape; - } - - public void setCape(String cape) - { - this.cape = cape; - SpoutFeatures.updateCape(this, null); - } - // -------------------------------------------- // // FIELD: open // -------------------------------------------- // diff --git a/src/com/massivecraft/factions/entity/MPlayer.java b/src/com/massivecraft/factions/entity/MPlayer.java new file mode 100644 index 00000000..dd4d0c8b --- /dev/null +++ b/src/com/massivecraft/factions/entity/MPlayer.java @@ -0,0 +1,41 @@ +package com.massivecraft.factions.entity; + +import com.massivecraft.mcore.store.SenderEntity; + +public class MPlayer extends SenderEntity +{ + // -------------------------------------------- // + // META + // -------------------------------------------- // + + public static MPlayer get(Object oid) + { + return MPlayerColl.get().get(oid); + } + + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // + + @Override + public MPlayer load(MPlayer that) + { + // TODO + + return this; + } + + @Override + public boolean isDefault() + { + // TODO + //return false; + + return true; + } + + // -------------------------------------------- // + // FIELDS + // -------------------------------------------- // + +} diff --git a/src/com/massivecraft/factions/entity/MPlayerColl.java b/src/com/massivecraft/factions/entity/MPlayerColl.java new file mode 100644 index 00000000..d011666f --- /dev/null +++ b/src/com/massivecraft/factions/entity/MPlayerColl.java @@ -0,0 +1,22 @@ +package com.massivecraft.factions.entity; + +import com.massivecraft.factions.ConfServer; +import com.massivecraft.factions.Const; +import com.massivecraft.factions.Factions; +import com.massivecraft.mcore.store.MStore; +import com.massivecraft.mcore.store.SenderColl; + +public class MPlayerColl extends SenderColl +{ + // -------------------------------------------- // + // INSTANCE & CONSTRUCT + // -------------------------------------------- // + + private static MPlayerColl i = new MPlayerColl(); + public static MPlayerColl get() { return i; } + private MPlayerColl() + { + super(Const.COLLECTION_BASENAME_MPLAYER, MPlayer.class, MStore.getDb(ConfServer.dburi), Factions.get()); + } + +} diff --git a/src/com/massivecraft/factions/entity/UPlayer.java b/src/com/massivecraft/factions/entity/UPlayer.java index 351f0375..d6843ba9 100644 --- a/src/com/massivecraft/factions/entity/UPlayer.java +++ b/src/com/massivecraft/factions/entity/UPlayer.java @@ -22,7 +22,6 @@ import com.massivecraft.factions.event.FactionsEventPowerChange; import com.massivecraft.factions.event.FactionsEventPowerChange.PowerChangeReason; 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.util.RelationUtil; import com.massivecraft.mcore.mixin.Mixin; @@ -121,12 +120,8 @@ public class UPlayer extends SenderEntity implements EconomyParticipato // FIELDS: RAW TRANSIENT // -------------------------------------------- // - // Where did this player stand the last time we checked? - private transient PS currentChunk = null; - public PS getCurrentChunk() { return this.currentChunk; } - public void setCurrentChunk(PS currentChunk) { this.currentChunk = currentChunk.getChunk(true); } - // FIELD: mapAutoUpdating + // TODO: Move this to the MPlayer private transient boolean mapAutoUpdating = false; public void setMapAutoUpdating(boolean mapAutoUpdating) { this.mapAutoUpdating = mapAutoUpdating; } public boolean isMapAutoUpdating() { return mapAutoUpdating; } @@ -153,11 +148,11 @@ public class UPlayer extends SenderEntity implements EconomyParticipato // GSON need this noarg constructor. public UPlayer() { - this.resetFactionData(false); + this.resetFactionData(); //this.power = ConfServer.powerStarting; } - public void resetFactionData(boolean doSpoutUpdate) + public void resetFactionData() { // The default neutral faction this.setFactionId(null); @@ -165,18 +160,6 @@ public class UPlayer extends SenderEntity implements EconomyParticipato this.setTitle(null); this.autoClaimFor = null; - - if (doSpoutUpdate) - { - SpoutFeatures.updateTitle(this, null); - SpoutFeatures.updateTitle(null, this); - SpoutFeatures.updateCape(this.getPlayer(), null); - } - } - - public void resetFactionData() - { - this.resetFactionData(true); } // -------------------------------------------- // @@ -230,10 +213,6 @@ public class UPlayer extends SenderEntity implements EconomyParticipato if (!this.getColl().inited()) return; if (!Factions.get().isDatabaseInitialized()) return; - // Spout Derp - SpoutFeatures.updateTitle(this, null); - SpoutFeatures.updateTitle(null, this); - // Update index Faction oldFaction = FactionColls.get().get(this).get(oldFactionId); Faction faction = FactionColls.get().get(this).get(factionId); @@ -270,7 +249,6 @@ public class UPlayer extends SenderEntity implements EconomyParticipato { this.role = role; } - SpoutFeatures.updateTitle(this, null); this.changed(); } @@ -638,21 +616,6 @@ public class UPlayer extends SenderEntity implements EconomyParticipato // TODO: Use Mixin to get this PS instead return BoardColls.get().getFactionAt(Mixin.getSenderPs(this.getId())).getRelationTo(this) == Rel.ENEMY; } - - public void sendFactionHereMessage() - { - if (SpoutFeatures.updateTerritoryDisplay(this)) - { - return; - } - Faction factionHere = BoardColls.get().getFactionAt(this.getCurrentChunk()); - String msg = Txt.parse("")+" ~ "+factionHere.getTag(this); - if (factionHere.hasDescription()) - { - msg += " - "+factionHere.getDescription(); - } - this.sendMessage(msg); - } // -------------------------------------------- // // ACTIONS @@ -846,7 +809,6 @@ public class UPlayer extends SenderEntity implements EconomyParticipato } BoardColls.get().setFactionAt(psChunk, forFaction); - SpoutFeatures.updateTerritoryDisplayLoc(psChunk); if (MConf.get().logLandClaims) { diff --git a/src/com/massivecraft/factions/entity/UPlayerColl.java b/src/com/massivecraft/factions/entity/UPlayerColl.java index c9835713..e0daa851 100644 --- a/src/com/massivecraft/factions/entity/UPlayerColl.java +++ b/src/com/massivecraft/factions/entity/UPlayerColl.java @@ -66,7 +66,6 @@ public class UPlayerColl extends SenderColl if (FactionColls.get().get(this).containsId(uplayer.getFactionId())) continue; Factions.get().log("Reset faction data (invalid faction) for player "+uplayer.getName()); - uplayer.resetFactionData(false); } } diff --git a/src/com/massivecraft/factions/integration/SpoutFeatures.java b/src/com/massivecraft/factions/integration/SpoutFeatures.java deleted file mode 100644 index a749e9c7..00000000 --- a/src/com/massivecraft/factions/integration/SpoutFeatures.java +++ /dev/null @@ -1,303 +0,0 @@ -package com.massivecraft.factions.integration; - -import java.util.Arrays; -import java.util.HashSet; -import java.util.Set; - -import com.massivecraft.factions.ConfServer; -import com.massivecraft.factions.Factions; - -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.plugin.Plugin; -import org.bukkit.entity.Player; - -import com.massivecraft.factions.entity.UPlayer; -import com.massivecraft.factions.entity.Faction; -import com.massivecraft.factions.util.HealthBarUtil; -import com.massivecraft.mcore.ps.PS; - -import org.getspout.spoutapi.player.SpoutPlayer; -import org.getspout.spoutapi.SpoutManager; - - -public class SpoutFeatures -{ - // -------------------------------------------- // - // FIELDS - // -------------------------------------------- // - - private static SpoutMainListener mainListener; - - private static boolean enabled = false; - public static boolean isEnabled() { return enabled; } - - // -------------------------------------------- // - // SETUP AND AVAILABILITY - // -------------------------------------------- // - - public static boolean setup() - { - Plugin plugin = Bukkit.getPluginManager().getPlugin("Spout"); - if (plugin == null || ! plugin.isEnabled()) - { - if (enabled == false) return false; - enabled = false; - return false; - } - - if (enabled == true) return true; - enabled = true; - - Factions.get().log("Found and will use features of "+plugin.getDescription().getFullName()); - mainListener = new SpoutMainListener(); - Bukkit.getPluginManager().registerEvents(mainListener, Factions.get()); - - return true; - } - - // -------------------------------------------- // - // CAPES - // -------------------------------------------- // - // Capes look the same to everyone. - - public static void updateCape(final Object ofrom, final Object oto, boolean onlyIfDifferent) - { - // Enabled and non-null? - if ( ! isEnabled()) return; - if ( ! ConfServer.spoutCapes) return; - - Set fromPlayers = getPlayersFromObject(ofrom); - Set toPlayers = getPlayersFromObject(oto); - - for (Player player : fromPlayers) - { - UPlayer uplayer = UPlayer.get(player); - SpoutPlayer splayer = SpoutManager.getPlayer(player); - Faction faction = uplayer.getFaction(); - - String cape = faction.getCape(); - if (cape == null) - { - // TODO: This URL is outdated? - cape = "http://s3.amazonaws.com/MinecraftCloaks/" + player.getName() + ".png"; - } - - for (Player playerTo : toPlayers) - { - SpoutPlayer splayerTo = SpoutManager.getPlayer(playerTo); - - boolean skip = onlyIfDifferent && cape.equals(splayer.getCape(splayerTo)); - //Bukkit.getConsoleSender().sendMessage(P.p.txt.parse("CAPE SKIP:%s FROM %s TO %s URL %s", String.valueOf(skip), player.getDisplayName(), playerTo.getDisplayName(), cape)); - if (skip) continue; - //Bukkit.getConsoleSender().sendMessage(P.p.txt.parse("CAPE FROM %s TO %s URL %s", player.getDisplayName(), playerTo.getDisplayName(), cape)); - - // Set the cape - try - { - splayer.setCapeFor(splayerTo, cape); - } - catch (Exception e) - { - - } - } - } - } - - public static void updateCape(final Object ofrom, final Object oto) - { - updateCape(ofrom, oto, true); - } - - public static void updateCapeShortly(final Object ofrom, final Object oto) - { - Factions.get().getServer().getScheduler().scheduleSyncDelayedTask(Factions.get(), new Runnable() - { - @Override - public void run() - { - updateCape(ofrom, oto, false); - } - }, 5); - } - - // -------------------------------------------- // - // TITLE - // -------------------------------------------- // - - public static void updateTitle(final Object ofrom, final Object oto, boolean onlyIfDifferent) - { - // Enabled and non-null? - if ( ! isEnabled()) return; - if ( ! (ConfServer.spoutFactionTagsOverNames || ConfServer.spoutFactionTitlesOverNames || ConfServer.spoutHealthBarUnderNames)) return; - - Set fromPlayers = getPlayersFromObject(ofrom); - Set toPlayers = getPlayersFromObject(oto); - - for (Player player : fromPlayers) - { - UPlayer uplayer = UPlayer.get(player); - SpoutPlayer splayer = SpoutManager.getPlayer(player); - Faction faction = uplayer.getFaction(); - - for (Player playerTo : toPlayers) - { - UPlayer uplayerTo = UPlayer.get(playerTo); - SpoutPlayer splayerTo = SpoutManager.getPlayer(playerTo); - Faction factionTo = uplayerTo.getFaction(); - - ChatColor relationColor = faction.getRelationTo(factionTo).getColor(); - - String title = generateTitle(player, uplayer, faction, relationColor); - - boolean skip = onlyIfDifferent && title.equals(splayer.getTitleFor(splayerTo)); - //Bukkit.getConsoleSender().sendMessage(P.p.txt.parse("TITLE SKIP:%s FROM %s TO %s TITLE %s", String.valueOf(skip), player.getDisplayName(), playerTo.getDisplayName(), title)); - if (skip) continue; - //Bukkit.getConsoleSender().sendMessage(P.p.txt.parse("TITLE FROM %s TO %s TITLE %s", player.getDisplayName(), playerTo.getDisplayName(), title)); - - splayer.setTitleFor(splayerTo, title); - } - } - } - - public static void updateTitle(final Object ofrom, final Object oto) - { - updateTitle(ofrom, oto, true); - } - - public static void updateTitleShortly(final Object ofrom, final Object oto) - { - Factions.get().getServer().getScheduler().scheduleSyncDelayedTask(Factions.get(), new Runnable() - { - @Override - public void run() - { - updateTitle(ofrom, oto, false); - } - }, 5); - } - - public static String generateTitle(Player player, UPlayer uplayer, Faction faction, ChatColor relationColor) - { - String ret = null; - - ret = player.getDisplayName(); - - if (faction.isNormal()) - { - String addTag = ""; - if (ConfServer.spoutFactionTagsOverNames) - { - addTag += relationColor.toString() + uplayer.getRole().getPrefix() + faction.getTag(); - } - - if (ConfServer.spoutFactionTitlesOverNames && uplayer.hasTitle()) - { - addTag += (addTag.isEmpty() ? "" : " ") + uplayer.getTitle(); - } - - ret = addTag + "\n" + ret; - } - - if (ConfServer.spoutHealthBarUnderNames) - { - ret += "\n"; - ret += HealthBarUtil.getHealthbar(player.getHealth() / 20d); - } - - return ret; - } - - // -------------------------------------------- // - // UTIL - // -------------------------------------------- // - - public static Set getPlayersFromObject(Object o) - { - Set ret = new HashSet(); - if (o instanceof Player) - { - ret.add((Player)o); - } - else if (o instanceof UPlayer) - { - UPlayer uplayer = (UPlayer)o; - Player player = uplayer.getPlayer(); - if (player != null) - { - ret.add(player); - } - } - else if (o instanceof Faction) - { - ret.addAll(((Faction)o).getOnlinePlayers()); - } - else - { - ret.addAll(Arrays.asList(Bukkit.getOnlinePlayers())); - } - - return ret; - } - - // -------------------------------------------- // - // TERRITORY DISPLAY - // -------------------------------------------- // - - // 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(PS chunk) - { - if ( ! isEnabled()) return; - - for (Player player : Bukkit.getOnlinePlayers()) - { - UPlayer uplayer = UPlayer.get(player); - if (chunk == null) - { - mainListener.updateTerritoryDisplay(uplayer, false); - } - else if (uplayer.getCurrentChunk().equals(chunk)) - { - mainListener.updateTerritoryDisplay(uplayer, true); - } - } - } - - // update displayed current territory for specified player; returns false if unsuccessful - public static boolean updateTerritoryDisplay(UPlayer player) - { - if ( ! isEnabled()) return false; - return mainListener.updateTerritoryDisplay(player, true); - } - - // update access info for all players inside a specified chunk; if specified chunk is null, then simply update everyone online - public static void updateAccessInfoLoc(PS chunk) - { - if ( ! isEnabled()) return; - - chunk = chunk.getChunk(true); - - for (Player player : Bukkit.getOnlinePlayers()) - { - UPlayer uplayer = UPlayer.get(player); - if (chunk == null || uplayer.getCurrentChunk().equals(chunk)) - { - mainListener.updateAccessInfo(uplayer); - } - } - } - - // update owner list for specified player - public static boolean updateAccessInfo(UPlayer player) - { - if ( ! isEnabled()) return false; - return mainListener.updateAccessInfo(player); - } - - public static void playerDisconnect(UPlayer player) - { - if ( ! isEnabled()) return; - mainListener.removeTerritoryLabels(player.getName()); - } -} diff --git a/src/com/massivecraft/factions/integration/SpoutMainListener.java b/src/com/massivecraft/factions/integration/SpoutMainListener.java deleted file mode 100644 index 75a2f976..00000000 --- a/src/com/massivecraft/factions/integration/SpoutMainListener.java +++ /dev/null @@ -1,263 +0,0 @@ -package com.massivecraft.factions.integration; - -import java.util.HashMap; -import java.util.Map; - -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; - -import com.massivecraft.factions.ConfServer; -import com.massivecraft.factions.Factions; -import com.massivecraft.factions.TerritoryAccess; -import com.massivecraft.factions.entity.BoardColls; -import com.massivecraft.factions.entity.UPlayer; -import com.massivecraft.factions.entity.Faction; -import com.massivecraft.mcore.ps.PS; - -import org.getspout.spoutapi.event.spout.SpoutCraftEnableEvent; -import org.getspout.spoutapi.gui.Color; -import org.getspout.spoutapi.gui.GenericLabel; -import org.getspout.spoutapi.player.SpoutPlayer; -import org.getspout.spoutapi.SpoutManager; - - -public class SpoutMainListener implements Listener -{ - @EventHandler(priority = EventPriority.NORMAL) - public void onSpoutCraftEnable(SpoutCraftEnableEvent event) - { - final UPlayer me = UPlayer.get(event.getPlayer()); - - SpoutFeatures.updateTitle(me, null); - SpoutFeatures.updateTitle(null, me); - 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 accessLabels = new HashMap(); - private final static int SCREEN_WIDTH = 427; -// private final static int SCREEN_HEIGHT = 240; - - - public boolean updateTerritoryDisplay(UPlayer player, boolean notify) - { - Player p = player.getPlayer(); - if (p == null) - return false; - - SpoutPlayer sPlayer = SpoutManager.getPlayer(p); - if (!sPlayer.isSpoutCraftEnabled() || (ConfServer.spoutTerritoryDisplaySize <= 0 && ! ConfServer.spoutTerritoryNoticeShow)) - return false; - - doLabels(player, sPlayer, notify); - - return true; - } - - public boolean updateAccessInfo(UPlayer player) - { - Player p = player.getPlayer(); - if (p == null) - return false; - - SpoutPlayer sPlayer = SpoutManager.getPlayer(p); - if (!sPlayer.isSpoutCraftEnabled() || (ConfServer.spoutTerritoryDisplaySize <= 0 && ! ConfServer.spoutTerritoryNoticeShow)) - return false; - - PS here = player.getCurrentChunk(); - - this.doAccessInfo(player, sPlayer, here); - - return true; - } - - public void removeTerritoryLabels(String playerName) - { - territoryLabels.remove(playerName); - territoryChangeLabels.remove(playerName); - accessLabels.remove(playerName); - } - - - private void doLabels(UPlayer player, SpoutPlayer sPlayer, boolean notify) - { - PS here = player.getCurrentChunk(); - Faction factionHere = BoardColls.get().getFactionAt(here); - String tag = factionHere.getColorTo(player).toString() + factionHere.getTag(); - - // ---------------------- - // Main territory display - // ---------------------- - if (ConfServer.spoutTerritoryDisplayPosition > 0 && ConfServer.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(ConfServer.spoutTerritoryDisplaySize); - - sPlayer.getMainScreen().attachWidget(Factions.get(), label); - territoryLabels.put(player.getName(), label); - } - - String msg = tag; - - if (ConfServer.spoutTerritoryDisplayShowDescription && factionHere.hasDescription()) - { - msg += " - " + factionHere.getDescription(); - } - - label.setText(msg); - alignLabel(label, msg); - label.setDirty(true); - } - - // ----------------------- - // Fading territory notice - // ----------------------- - if (notify && ConfServer.spoutTerritoryNoticeShow && ConfServer.spoutTerritoryNoticeSize > 0) - { - NoticeLabel label; - if (territoryChangeLabels.containsKey(player.getName())) - label = territoryChangeLabels.get(player.getName()); - else - { - label = new NoticeLabel(ConfServer.spoutTerritoryNoticeLeaveAfterSeconds); - label.setWidth(1).setHeight(1); // prevent Spout's questionable new "no default size" warning - label.setScale(ConfServer.spoutTerritoryNoticeSize); - label.setY(ConfServer.spoutTerritoryNoticeTop); - sPlayer.getMainScreen().attachWidget(Factions.get(), label); - territoryChangeLabels.put(player.getName(), label); - } - - String msg = tag; - - if (ConfServer.spoutTerritoryNoticeShowDescription && factionHere.hasDescription()) - { - msg += " - " + factionHere.getDescription(); - } - - label.setText(msg); - alignLabel(label, msg, 2); - label.resetNotice(); - label.setDirty(true); - } - - // and access info, of course - doAccessInfo(player, sPlayer, here); - } - - private static final Color accessGrantedColor = new Color(0.2f, 1.0f, 0.2f); - private static final Color accessDeniedColor = new Color(1.0f, 0.2f, 0.2f); - private void doAccessInfo(UPlayer player, SpoutPlayer sPlayer, PS here) - { - if (ConfServer.spoutTerritoryDisplayPosition <= 0 || ConfServer.spoutTerritoryDisplaySize <= 0 || ! ConfServer.spoutTerritoryAccessShow) return; - - // ----------- - // Access Info - // ----------- - GenericLabel label; - if (accessLabels.containsKey(player.getName())) - label = accessLabels.get(player.getName()); - else - { - label = new GenericLabel(); - label.setWidth(1).setHeight(1); // prevent Spout's questionable new "no default size" warning - label.setScale(ConfServer.spoutTerritoryDisplaySize); - label.setY((int)(10 * ConfServer.spoutTerritoryDisplaySize)); - sPlayer.getMainScreen().attachWidget(Factions.get(), label); - accessLabels.put(player.getName(), label); - } - - String msg = ""; - TerritoryAccess access = BoardColls.get().getTerritoryAccessAt(here); - - if ( ! access.isDefault()) - { - if (access.subjectHasAccess(player)) - { - msg = "access granted"; - label.setTextColor(accessGrantedColor); - } - else if (access.subjectAccessIsRestricted(player)) - { - msg = "access restricted"; - label.setTextColor(accessDeniedColor); - } - } - - 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, ConfServer.spoutTerritoryDisplayPosition); - } - public void alignLabel(GenericLabel label, String text, int alignment) - { - int labelWidth = (int)((float)GenericLabel.getStringWidth(text) * ConfServer.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/com/massivecraft/factions/listeners/FactionsListenerMain.java b/src/com/massivecraft/factions/listeners/FactionsListenerMain.java index dac067c6..eddd92ed 100644 --- a/src/com/massivecraft/factions/listeners/FactionsListenerMain.java +++ b/src/com/massivecraft/factions/listeners/FactionsListenerMain.java @@ -350,7 +350,8 @@ public class FactionsListenerMain implements Listener } Rel rel = uplayer.getRelationToLocation(); - if (BoardColls.get().getFactionAt(uplayer.getCurrentChunk()).isNone()) return; + PS ps = PS.valueOf(player).getChunk(true); + if (BoardColls.get().getFactionAt(ps).isNone()) return; if (rel == Rel.NEUTRAL && containsCommand(command, ConfServer.territoryNeutralDenyCommands)) { diff --git a/src/com/massivecraft/factions/listeners/FactionsListenerSpout.java b/src/com/massivecraft/factions/listeners/FactionsListenerSpout.java deleted file mode 100644 index 31d9cebb..00000000 --- a/src/com/massivecraft/factions/listeners/FactionsListenerSpout.java +++ /dev/null @@ -1,116 +0,0 @@ -package com.massivecraft.factions.listeners; - -import org.bukkit.Bukkit; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.entity.EntityDamageEvent; -import org.bukkit.event.entity.EntityRegainHealthEvent; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerRespawnEvent; -import org.bukkit.event.player.PlayerTeleportEvent; -import org.bukkit.event.server.PluginDisableEvent; -import org.bukkit.event.server.PluginEnableEvent; - -import com.massivecraft.factions.ConfServer; -import com.massivecraft.factions.Factions; -import com.massivecraft.factions.integration.SpoutFeatures; - -public class FactionsListenerSpout implements Listener -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static FactionsListenerSpout i = new FactionsListenerSpout(); - public static FactionsListenerSpout get() { return i; } - public FactionsListenerSpout() {} - - // -------------------------------------------- // - // SETUP - // -------------------------------------------- // - - public void setup() - { - Bukkit.getPluginManager().registerEvents(this, Factions.get()); - } - - // TODO: These spout related methods should not be in here. - // The spout integration needs to be moved elsewhere. - // NOTE: Also the spout integration should not have method calls from within FactionsCore code, - // we should instead listen to FactionsCore events. And send client updates upon non-cancelled monitor. - - // Setup - - @EventHandler(priority = EventPriority.MONITOR) - public void spoutSetup(PluginDisableEvent event) - { - SpoutFeatures.setup(); - } - - @EventHandler(priority = EventPriority.MONITOR) - public void spoutSetup(PluginEnableEvent event) - { - SpoutFeatures.setup(); - } - - // Standard - - public static void spoutStandard(Player player) - { - SpoutFeatures.updateTitleShortly(player, null); - SpoutFeatures.updateTitleShortly(null, player); - SpoutFeatures.updateCapeShortly(player, null); - SpoutFeatures.updateCapeShortly(null, player); - } - - @EventHandler(priority = EventPriority.MONITOR) - public void spoutStandard(PlayerJoinEvent event) - { - spoutStandard(event.getPlayer()); - } - - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - public void spoutStandard(PlayerTeleportEvent event) - { - if (event.getFrom().getWorld().equals(event.getTo().getWorld())) return; - spoutStandard(event.getPlayer()); - } - - @EventHandler(priority = EventPriority.MONITOR) - public void spoutStandard(PlayerRespawnEvent event) - { - spoutStandard(event.getPlayer()); - } - - // Health Bar - - public static void spoutHealthBar(Entity entity) - { - if ( ! ConfServer.spoutHealthBarUnderNames) return; - if ( ! (entity instanceof Player)) return; - Player player = (Player)entity; - SpoutFeatures.updateTitle(player, null); - } - - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - public void spoutHealthBar(EntityDamageEvent event) - { - spoutHealthBar(event.getEntity()); - } - - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - public void spoutHealthBar(EntityRegainHealthEvent event) - { - spoutHealthBar(event.getEntity()); - } - - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - public void spoutHealthBar(PlayerRespawnEvent event) - { - spoutHealthBar(event.getPlayer()); - } - -} diff --git a/src/com/massivecraft/factions/listeners/TodoFactionsPlayerListener.java b/src/com/massivecraft/factions/listeners/TodoFactionsPlayerListener.java index 46622198..d874b006 100644 --- a/src/com/massivecraft/factions/listeners/TodoFactionsPlayerListener.java +++ b/src/com/massivecraft/factions/listeners/TodoFactionsPlayerListener.java @@ -17,12 +17,14 @@ import com.massivecraft.factions.Const; import com.massivecraft.factions.FPerm; import com.massivecraft.factions.TerritoryAccess; import com.massivecraft.factions.entity.BoardColls; +import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.UPlayer; import com.massivecraft.factions.entity.MConf; -import com.massivecraft.factions.integration.SpoutFeatures; +import com.massivecraft.factions.entity.UPlayerColls; import com.massivecraft.mcore.event.MCorePlayerLeaveEvent; import com.massivecraft.mcore.ps.PS; import com.massivecraft.mcore.util.MUtil; +import com.massivecraft.mcore.util.Txt; public class TodoFactionsPlayerListener implements Listener @@ -34,17 +36,10 @@ public class TodoFactionsPlayerListener implements Listener Player player = event.getPlayer(); UPlayer uplayer = UPlayer.get(player); - // ... recalculate their power as if they were offline since last recalculation ... + // ... recalculate their power as if they were offline since last recalculation. uplayer.recalculatePower(false); - - // ... update the current chunk ... - uplayer.setCurrentChunk(PS.valueOf(event.getPlayer())); - - // ... notify the player about where they are ... - if ( ! SpoutFeatures.updateTerritoryDisplay(uplayer)) - { - uplayer.sendFactionHereMessage(); - } + // TODO: What about the other universes? + // TODO: Track world --> world travel as logging on and off. } @EventHandler(priority = EventPriority.NORMAL) @@ -57,8 +52,6 @@ public class TodoFactionsPlayerListener implements Listener // This is required since we recalculate as if the player were offline when they log back in. // TODO: When I setup universes I must do this for all universe instance of the player that logs off! uplayer.recalculatePower(true); - - SpoutFeatures.playerDisconnect(uplayer); } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @@ -66,47 +59,49 @@ public class TodoFactionsPlayerListener implements Listener { // If the player is moving from one chunk to another ... if (MUtil.isSameChunk(event)) return; - - // ... update the stored current chunk ... - Player player = event.getPlayer(); - UPlayer uplayer = UPlayer.get(player); - PS chunkFrom = uplayer.getCurrentChunk(); + // ... gather info on the player and the move ... + Player player = event.getPlayer(); + UPlayer uplayerTo = UPlayerColls.get().get(event.getTo()).get(player); + + PS chunkFrom = PS.valueOf(event.getFrom()).getChunk(true); PS chunkTo = PS.valueOf(event.getTo()).getChunk(true); - uplayer.setCurrentChunk(chunkTo); + Faction factionFrom = BoardColls.get().getFactionAt(chunkFrom); + Faction factionTo = BoardColls.get().getFactionAt(chunkTo); - // ... TODO: assorted and uncleaned code below ... - - TerritoryAccess access = BoardColls.get().getTerritoryAccessAt(chunkTo); - - // Did we change "host"(faction)? - boolean changedFaction = (BoardColls.get().getFactionAt(chunkFrom) != BoardColls.get().getFactionAt(chunkTo)); - - // let Spout handle most of this if it's available - boolean handledBySpout = changedFaction && SpoutFeatures.updateTerritoryDisplay(uplayer); - - if (uplayer.isMapAutoUpdating()) + // ... send host faction info updates ... + if (uplayerTo.isMapAutoUpdating()) { - uplayer.sendMessage(BoardColls.get().getMap(uplayer.getFaction(), chunkTo, player.getLocation().getYaw())); + uplayerTo.sendMessage(BoardColls.get().getMap(uplayerTo.getFaction(), chunkTo, player.getLocation().getYaw())); } - else if (changedFaction && ! handledBySpout) + else if (factionFrom != factionTo) { - uplayer.sendFactionHereMessage(); + String msg = Txt.parse("") + " ~ " + factionTo.getTag(uplayerTo); + if (factionTo.hasDescription()) + { + msg += " - " + factionTo.getDescription(); + } + player.sendMessage(msg); } // show access info message if needed - if ( ! handledBySpout && ! SpoutFeatures.updateAccessInfo(uplayer) && ! access.isDefault()) + TerritoryAccess accessTo = BoardColls.get().getTerritoryAccessAt(chunkTo); + if (!accessTo.isDefault()) { - if (access.subjectHasAccess(uplayer)) - uplayer.msg("You have access to this area."); - else if (access.subjectAccessIsRestricted(uplayer)) - uplayer.msg("This area has restricted access."); + if (accessTo.subjectHasAccess(uplayerTo)) + { + uplayerTo.msg("You have access to this area."); + } + else if (accessTo.subjectAccessIsRestricted(uplayerTo)) + { + uplayerTo.msg("This area has restricted access."); + } } - if (uplayer.getAutoClaimFor() != null) + if (uplayerTo.getAutoClaimFor() != null) { - uplayer.attemptClaim(uplayer.getAutoClaimFor(), PS.valueOf(event.getTo()), true); + uplayerTo.attemptClaim(uplayerTo.getAutoClaimFor(), PS.valueOf(event.getTo()), true); } } diff --git a/src/com/massivecraft/factions/util/HealthBarUtil.java b/src/com/massivecraft/factions/util/HealthBarUtil.java deleted file mode 100644 index b2a4da98..00000000 --- a/src/com/massivecraft/factions/util/HealthBarUtil.java +++ /dev/null @@ -1,70 +0,0 @@ -package com.massivecraft.factions.util; - -import java.util.Map.Entry; - -import com.massivecraft.factions.ConfServer; -import com.massivecraft.mcore.util.Txt; - -public class HealthBarUtil -{ - public static String getHealthbar(double healthQuota, int barLength) - { - // Ensure between 0 and 1; - healthQuota = fixQuota(healthQuota); - - // What color is the health bar? - String color = getColorFromHealthQuota(healthQuota); - - // how much solid should there be? - int solidCount = (int) Math.ceil(barLength * healthQuota); - - // The rest is empty - int emptyCount = (int) ((barLength - solidCount) / ConfServer.spoutHealthBarSolidsPerEmpty); - - // Create the non-parsed bar - String ret = ConfServer.spoutHealthBarLeft + Txt.repeat(ConfServer.spoutHealthBarSolid, solidCount) + ConfServer.spoutHealthBarBetween + Txt.repeat(ConfServer.spoutHealthBarEmpty, emptyCount) + ConfServer.spoutHealthBarRight; - - // Replace color tag - ret = ret.replace("{c}", color); - - // Parse amp color codes - ret = Txt.parse(ret); - - return ret; - } - - public static String getHealthbar(double healthQuota) - { - return getHealthbar(healthQuota, ConfServer.spoutHealthBarWidth); - } - - public static double fixQuota(double healthQuota) - { - if (healthQuota > 1) - { - return 1d; - } - else if (healthQuota < 0) - { - return 0d; - } - return healthQuota; - } - - public static String getColorFromHealthQuota(double healthQuota) - { - Double currentRoof = null; - String ret = null; - for (Entry entry : ConfServer.spoutHealthBarColorUnderQuota.entrySet()) - { - double roof = entry.getKey(); - String color = entry.getValue(); - if (healthQuota <= roof && (currentRoof == null || roof <= currentRoof)) - { - currentRoof = roof; - ret = color; - } - } - return ret; - } -} \ No newline at end of file