mirror of
https://github.com/MassiveCraft/Factions.git
synced 2024-11-26 20:26:23 +01:00
Allergy reaction kicked in. This commit removes the Spout features. I have nothing against spout but if we are going to have them we should do them properly. They should be coded in such a way that they could be in an external plugin alltogether. Also removed netbeans stuff from IDE that should not be in the github repo.
This commit is contained in:
parent
bc194efc9b
commit
90d819ab18
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -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
|
|
@ -88,42 +88,6 @@ public class ConfServer extends SimpleConfig
|
|||||||
public static boolean onUnclaimResetLwcLocks = false;
|
public static boolean onUnclaimResetLwcLocks = false;
|
||||||
public static boolean onCaptureResetLwcLocks = 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<Double, String> 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
|
// INTEGRATION: ECONOMY
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
@ -25,14 +25,12 @@ import com.massivecraft.factions.entity.UPlayerColls;
|
|||||||
import com.massivecraft.factions.entity.FactionColls;
|
import com.massivecraft.factions.entity.FactionColls;
|
||||||
import com.massivecraft.factions.entity.MConfColl;
|
import com.massivecraft.factions.entity.MConfColl;
|
||||||
import com.massivecraft.factions.integration.LWCFeatures;
|
import com.massivecraft.factions.integration.LWCFeatures;
|
||||||
import com.massivecraft.factions.integration.SpoutFeatures;
|
|
||||||
import com.massivecraft.factions.integration.Worldguard;
|
import com.massivecraft.factions.integration.Worldguard;
|
||||||
import com.massivecraft.factions.integration.herochat.HerochatFeatures;
|
import com.massivecraft.factions.integration.herochat.HerochatFeatures;
|
||||||
import com.massivecraft.factions.listeners.FactionsListenerChat;
|
import com.massivecraft.factions.listeners.FactionsListenerChat;
|
||||||
import com.massivecraft.factions.listeners.FactionsListenerEcon;
|
import com.massivecraft.factions.listeners.FactionsListenerEcon;
|
||||||
import com.massivecraft.factions.listeners.FactionsListenerExploit;
|
import com.massivecraft.factions.listeners.FactionsListenerExploit;
|
||||||
import com.massivecraft.factions.listeners.FactionsListenerMain;
|
import com.massivecraft.factions.listeners.FactionsListenerMain;
|
||||||
import com.massivecraft.factions.listeners.FactionsListenerSpout;
|
|
||||||
import com.massivecraft.factions.listeners.TodoFactionsPlayerListener;
|
import com.massivecraft.factions.listeners.TodoFactionsPlayerListener;
|
||||||
import com.massivecraft.factions.task.AutoLeaveTask;
|
import com.massivecraft.factions.task.AutoLeaveTask;
|
||||||
import com.massivecraft.factions.task.EconLandRewardTask;
|
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.
|
// Right now only a few situations are handled through this listener.
|
||||||
FactionsListenerEcon.get().setup();
|
FactionsListenerEcon.get().setup();
|
||||||
|
|
||||||
// TODO: The same goes for this one:
|
|
||||||
FactionsListenerSpout.get().setup();
|
|
||||||
|
|
||||||
// TODO: Get rid of this one
|
// TODO: Get rid of this one
|
||||||
this.playerListener = new TodoFactionsPlayerListener();
|
this.playerListener = new TodoFactionsPlayerListener();
|
||||||
getServer().getPluginManager().registerEvents(this.playerListener, this);
|
getServer().getPluginManager().registerEvents(this.playerListener, this);
|
||||||
@ -155,7 +150,6 @@ public class Factions extends MPlugin
|
|||||||
// Integrate
|
// Integrate
|
||||||
this.integrate(HerochatFeatures.get());
|
this.integrate(HerochatFeatures.get());
|
||||||
|
|
||||||
SpoutFeatures.setup();
|
|
||||||
LWCFeatures.setup();
|
LWCFeatures.setup();
|
||||||
|
|
||||||
if (ConfServer.worldGuardChecking)
|
if (ConfServer.worldGuardChecking)
|
||||||
|
@ -14,7 +14,6 @@ public class CmdFactions extends FCommand
|
|||||||
public CmdFactionsLeader cmdFactionsLeader = new CmdFactionsLeader();
|
public CmdFactionsLeader cmdFactionsLeader = new CmdFactionsLeader();
|
||||||
public CmdFactionsAutoClaim cmdFactionsAutoClaim = new CmdFactionsAutoClaim();
|
public CmdFactionsAutoClaim cmdFactionsAutoClaim = new CmdFactionsAutoClaim();
|
||||||
public CmdFactionsAdmin cmdFactionsAdmin = new CmdFactionsAdmin();
|
public CmdFactionsAdmin cmdFactionsAdmin = new CmdFactionsAdmin();
|
||||||
public CmdFactionsCape cmdFactionsCape = new CmdFactionsCape();
|
|
||||||
public CmdFactionsClaim cmdFactionsClaim = new CmdFactionsClaim();
|
public CmdFactionsClaim cmdFactionsClaim = new CmdFactionsClaim();
|
||||||
public CmdFactionsCreate cmdFactionsCreate = new CmdFactionsCreate();
|
public CmdFactionsCreate cmdFactionsCreate = new CmdFactionsCreate();
|
||||||
public CmdFactionsDemote cmdFactionsDemote = new CmdFactionsDemote();
|
public CmdFactionsDemote cmdFactionsDemote = new CmdFactionsDemote();
|
||||||
@ -72,7 +71,6 @@ public class CmdFactions extends FCommand
|
|||||||
this.addSubCommand(this.cmdFactionsTag);
|
this.addSubCommand(this.cmdFactionsTag);
|
||||||
this.addSubCommand(this.cmdFactionsDemote);
|
this.addSubCommand(this.cmdFactionsDemote);
|
||||||
this.addSubCommand(this.cmdFactionsDescription);
|
this.addSubCommand(this.cmdFactionsDescription);
|
||||||
this.addSubCommand(this.cmdFactionsCape);
|
|
||||||
this.addSubCommand(this.cmdFactionsPerm);
|
this.addSubCommand(this.cmdFactionsPerm);
|
||||||
this.addSubCommand(this.cmdFactionsFlag);
|
this.addSubCommand(this.cmdFactionsFlag);
|
||||||
this.addSubCommand(this.cmdFactionsInvite);
|
this.addSubCommand(this.cmdFactionsInvite);
|
||||||
|
@ -8,7 +8,6 @@ import com.massivecraft.factions.cmd.arg.ARFaction;
|
|||||||
import com.massivecraft.factions.entity.BoardColls;
|
import com.massivecraft.factions.entity.BoardColls;
|
||||||
import com.massivecraft.factions.entity.UPlayer;
|
import com.massivecraft.factions.entity.UPlayer;
|
||||||
import com.massivecraft.factions.entity.Faction;
|
import com.massivecraft.factions.entity.Faction;
|
||||||
import com.massivecraft.factions.integration.SpoutFeatures;
|
|
||||||
import com.massivecraft.mcore.cmd.req.ReqIsPlayer;
|
import com.massivecraft.mcore.cmd.req.ReqIsPlayer;
|
||||||
import com.massivecraft.mcore.ps.PS;
|
import com.massivecraft.mcore.ps.PS;
|
||||||
import com.massivecraft.mcore.util.Txt;
|
import com.massivecraft.mcore.util.Txt;
|
||||||
@ -87,7 +86,6 @@ public class CmdFactionsAccess extends FCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
msg("<i>%s has been %s<i> the access list for this territory.", target, Txt.parse(added ? "<lime>added to" : "<rose>removed from"));
|
msg("<i>%s has been %s<i> the access list for this territory.", target, Txt.parse(added ? "<lime>added to" : "<rose>removed from"));
|
||||||
SpoutFeatures.updateAccessInfoLoc(chunk);
|
|
||||||
showAccessList(territory, locFaction);
|
showAccessList(territory, locFaction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -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<String> args)
|
|
||||||
{
|
|
||||||
this.capeFaction = null;
|
|
||||||
this.currentCape = null;
|
|
||||||
|
|
||||||
if (this.myFaction == null && ! this.argIsSet(this.requiredArgs.size()))
|
|
||||||
{
|
|
||||||
msg("<b>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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -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("<h>%s <i>has no cape set.", capeFaction.describeTo(fme, true));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
msg("<i>The cape of <h>%s <i>is \"<h>%s<i>\".", capeFaction.describeTo(fme, true), currentCape);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -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("<h>%s <i>has no cape set.", capeFaction.describeTo(fme, true));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
capeFaction.setCape(null);
|
|
||||||
SpoutFeatures.updateCape(capeFaction, null);
|
|
||||||
msg("<h>%s <i>removed the cape from <h>%s<i>.", RelationUtil.describeThatToMe(fme, fme, true), capeFaction.describeTo(fme));
|
|
||||||
capeFaction.msg("<h>%s <i>removed the cape from <h>%s<i>.", RelationUtil.describeThatToMe(fme, capeFaction, true), capeFaction.describeTo(capeFaction));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -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("<h>%s <i>set the cape of <h>%s<i> to \"<h>%s<i>\".", RelationUtil.describeThatToMe(fme, fme, true), capeFaction.describeTo(fme), newCape);
|
|
||||||
capeFaction.msg("<h>%s <i>set the cape of <h>%s<i> to \"<h>%s<i>\".", RelationUtil.describeThatToMe(fme, capeFaction, true), capeFaction.describeTo(capeFaction), newCape);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
msg("<i>\"<h>%s<i>\" is not a valid URL.", newCape);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isUrlValid(String urlString)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
new URL(urlString);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -14,7 +14,6 @@ import com.massivecraft.factions.FFlag;
|
|||||||
import com.massivecraft.factions.FPerm;
|
import com.massivecraft.factions.FPerm;
|
||||||
import com.massivecraft.factions.Factions;
|
import com.massivecraft.factions.Factions;
|
||||||
import com.massivecraft.factions.Perm;
|
import com.massivecraft.factions.Perm;
|
||||||
import com.massivecraft.factions.integration.SpoutFeatures;
|
|
||||||
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
|
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
|
||||||
import com.massivecraft.mcore.money.Money;
|
import com.massivecraft.mcore.money.Money;
|
||||||
|
|
||||||
@ -94,8 +93,5 @@ public class CmdFactionsDisband extends FCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
faction.detach();
|
faction.detach();
|
||||||
|
|
||||||
SpoutFeatures.updateTitle(null, null);
|
|
||||||
SpoutFeatures.updateCape(null, null);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,6 @@ import com.massivecraft.factions.cmd.arg.ARFaction;
|
|||||||
import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast;
|
import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast;
|
||||||
import com.massivecraft.factions.entity.Faction;
|
import com.massivecraft.factions.entity.Faction;
|
||||||
import com.massivecraft.factions.event.FactionsEventRelationChange;
|
import com.massivecraft.factions.event.FactionsEventRelationChange;
|
||||||
import com.massivecraft.factions.integration.SpoutFeatures;
|
|
||||||
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
|
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
|
||||||
|
|
||||||
public abstract class CmdFactionsRelationAbstract extends FCommand
|
public abstract class CmdFactionsRelationAbstract extends FCommand
|
||||||
@ -89,9 +88,5 @@ public abstract class CmdFactionsRelationAbstract extends FCommand
|
|||||||
otherFaction.msg("<i>This will have no effect while their faction is peaceful.");
|
otherFaction.msg("<i>This will have no effect while their faction is peaceful.");
|
||||||
myFaction.msg("<i>This will have no effect while your faction is peaceful.");
|
myFaction.msg("<i>This will have no effect while your faction is peaceful.");
|
||||||
}
|
}
|
||||||
|
|
||||||
SpoutFeatures.updateTitle(myFaction, otherFaction);
|
|
||||||
SpoutFeatures.updateTitle(otherFaction, myFaction);
|
|
||||||
SpoutFeatures.updateTerritoryDisplayLoc(null);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@ package com.massivecraft.factions.cmd;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import com.massivecraft.factions.ConfServer;
|
|
||||||
import com.massivecraft.factions.Perm;
|
import com.massivecraft.factions.Perm;
|
||||||
import com.massivecraft.factions.Rel;
|
import com.massivecraft.factions.Rel;
|
||||||
import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast;
|
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.FactionColl;
|
||||||
import com.massivecraft.factions.entity.FactionColls;
|
import com.massivecraft.factions.entity.FactionColls;
|
||||||
import com.massivecraft.factions.event.FactionsEventTagChange;
|
import com.massivecraft.factions.event.FactionsEventTagChange;
|
||||||
import com.massivecraft.factions.integration.SpoutFeatures;
|
|
||||||
import com.massivecraft.factions.util.MiscUtil;
|
import com.massivecraft.factions.util.MiscUtil;
|
||||||
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
|
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
|
||||||
|
|
||||||
@ -70,11 +68,6 @@ public class CmdFactionsTag extends FCommand
|
|||||||
}
|
}
|
||||||
faction.msg("<i>The faction %s<i> changed their name to %s.", fme.getColorTo(faction)+oldtag, myFaction.getTag(faction));
|
faction.msg("<i>The faction %s<i> changed their name to %s.", fme.getColorTo(faction)+oldtag, myFaction.getTag(faction));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ConfServer.spoutFactionTagsOverNames)
|
|
||||||
{
|
|
||||||
SpoutFeatures.updateTitle(myFaction, null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
package com.massivecraft.factions.cmd;
|
package com.massivecraft.factions.cmd;
|
||||||
|
|
||||||
import com.massivecraft.factions.ConfServer;
|
|
||||||
import com.massivecraft.factions.Perm;
|
import com.massivecraft.factions.Perm;
|
||||||
import com.massivecraft.factions.Rel;
|
import com.massivecraft.factions.Rel;
|
||||||
import com.massivecraft.factions.cmd.arg.ARUPlayer;
|
import com.massivecraft.factions.cmd.arg.ARUPlayer;
|
||||||
import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast;
|
import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast;
|
||||||
import com.massivecraft.factions.entity.UPlayer;
|
import com.massivecraft.factions.entity.UPlayer;
|
||||||
import com.massivecraft.factions.event.FactionsEventTitleChange;
|
import com.massivecraft.factions.event.FactionsEventTitleChange;
|
||||||
import com.massivecraft.factions.integration.SpoutFeatures;
|
|
||||||
import com.massivecraft.mcore.cmd.arg.ARString;
|
import com.massivecraft.mcore.cmd.arg.ARString;
|
||||||
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
|
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
|
||||||
|
|
||||||
@ -48,11 +46,6 @@ public class CmdFactionsTitle extends FCommand
|
|||||||
|
|
||||||
// Inform
|
// Inform
|
||||||
myFaction.msg("%s<i> changed a title: %s", fme.describeTo(myFaction, true), you.describeTo(myFaction, true));
|
myFaction.msg("%s<i> changed a title: %s", fme.describeTo(myFaction, true), you.describeTo(myFaction, true));
|
||||||
|
|
||||||
if (ConfServer.spoutFactionTitlesOverNames)
|
|
||||||
{
|
|
||||||
SpoutFeatures.updateTitle(me, null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,6 @@ import com.massivecraft.factions.entity.Faction;
|
|||||||
import com.massivecraft.factions.entity.MConf;
|
import com.massivecraft.factions.entity.MConf;
|
||||||
import com.massivecraft.factions.event.FactionsEventLandUnclaim;
|
import com.massivecraft.factions.event.FactionsEventLandUnclaim;
|
||||||
import com.massivecraft.factions.integration.Econ;
|
import com.massivecraft.factions.integration.Econ;
|
||||||
import com.massivecraft.factions.integration.SpoutFeatures;
|
|
||||||
import com.massivecraft.factions.FPerm;
|
import com.massivecraft.factions.FPerm;
|
||||||
import com.massivecraft.factions.Factions;
|
import com.massivecraft.factions.Factions;
|
||||||
import com.massivecraft.factions.Perm;
|
import com.massivecraft.factions.Perm;
|
||||||
@ -55,7 +54,6 @@ public class CmdFactionsUnclaim extends FCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
BoardColls.get().removeAt(chunk);
|
BoardColls.get().removeAt(chunk);
|
||||||
SpoutFeatures.updateTerritoryDisplayLoc(chunk);
|
|
||||||
myFaction.msg("%s<i> unclaimed some land.", fme.describeTo(myFaction, true));
|
myFaction.msg("%s<i> unclaimed some land.", fme.describeTo(myFaction, true));
|
||||||
|
|
||||||
if (MConf.get().logLandUnclaims)
|
if (MConf.get().logLandUnclaims)
|
||||||
|
@ -9,7 +9,6 @@ import com.massivecraft.factions.entity.BoardColls;
|
|||||||
import com.massivecraft.factions.entity.MConf;
|
import com.massivecraft.factions.entity.MConf;
|
||||||
import com.massivecraft.factions.event.FactionsEventLandUnclaimAll;
|
import com.massivecraft.factions.event.FactionsEventLandUnclaimAll;
|
||||||
import com.massivecraft.factions.integration.Econ;
|
import com.massivecraft.factions.integration.Econ;
|
||||||
import com.massivecraft.factions.integration.SpoutFeatures;
|
|
||||||
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
|
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
|
||||||
|
|
||||||
public class CmdFactionsUnclaimall extends FCommand
|
public class CmdFactionsUnclaimall extends FCommand
|
||||||
@ -50,9 +49,6 @@ public class CmdFactionsUnclaimall extends FCommand
|
|||||||
// Inform
|
// Inform
|
||||||
myFaction.msg("%s<i> unclaimed ALL of your faction's land.", fme.describeTo(myFaction, true));
|
myFaction.msg("%s<i> unclaimed ALL of your faction's land.", fme.describeTo(myFaction, true));
|
||||||
|
|
||||||
// TODO: Move this to a listener instead.
|
|
||||||
SpoutFeatures.updateTerritoryDisplayLoc(null);
|
|
||||||
|
|
||||||
if (MConf.get().logLandUnclaims)
|
if (MConf.get().logLandUnclaims)
|
||||||
{
|
{
|
||||||
Factions.get().log(fme.getName()+" unclaimed everything for the faction: "+myFaction.getTag());
|
Factions.get().log(fme.getName()+" unclaimed everything for the faction: "+myFaction.getTag());
|
||||||
|
@ -18,7 +18,6 @@ import com.massivecraft.factions.Factions;
|
|||||||
import com.massivecraft.factions.Lang;
|
import com.massivecraft.factions.Lang;
|
||||||
import com.massivecraft.factions.Rel;
|
import com.massivecraft.factions.Rel;
|
||||||
import com.massivecraft.factions.RelationParticipator;
|
import com.massivecraft.factions.RelationParticipator;
|
||||||
import com.massivecraft.factions.integration.SpoutFeatures;
|
|
||||||
import com.massivecraft.factions.util.*;
|
import com.massivecraft.factions.util.*;
|
||||||
import com.massivecraft.mcore.mixin.Mixin;
|
import com.massivecraft.mcore.mixin.Mixin;
|
||||||
import com.massivecraft.mcore.ps.PS;
|
import com.massivecraft.mcore.ps.PS;
|
||||||
@ -50,7 +49,6 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
|
|||||||
this.setDescription(that.description);
|
this.setDescription(that.description);
|
||||||
this.home = that.home;
|
this.home = that.home;
|
||||||
this.setPowerBoost(that.powerBoost);
|
this.setPowerBoost(that.powerBoost);
|
||||||
this.cape = that.cape;
|
|
||||||
this.open = that.open;
|
this.open = that.open;
|
||||||
this.setInvitedPlayerIds(that.invitedPlayerIds);
|
this.setInvitedPlayerIds(that.invitedPlayerIds);
|
||||||
this.setRelationWishes(that.relationWish);
|
this.setRelationWishes(that.relationWish);
|
||||||
@ -83,10 +81,6 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
|
|||||||
// The powerBoost is a custom increase/decrease to default and maximum power.
|
// The powerBoost is a custom increase/decrease to default and maximum power.
|
||||||
private Double powerBoost = null;
|
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?
|
// Can anyone join the Faction?
|
||||||
// If the faction is open they can.
|
// If the faction is open they can.
|
||||||
// If the faction is closed an invite is required.
|
// If the faction is closed an invite is required.
|
||||||
@ -280,21 +274,6 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
|
|||||||
return this.getPowerBoost() != 0D;
|
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
|
// FIELD: open
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
41
src/com/massivecraft/factions/entity/MPlayer.java
Normal file
41
src/com/massivecraft/factions/entity/MPlayer.java
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
package com.massivecraft.factions.entity;
|
||||||
|
|
||||||
|
import com.massivecraft.mcore.store.SenderEntity;
|
||||||
|
|
||||||
|
public class MPlayer extends SenderEntity<MPlayer>
|
||||||
|
{
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// 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
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
}
|
22
src/com/massivecraft/factions/entity/MPlayerColl.java
Normal file
22
src/com/massivecraft/factions/entity/MPlayerColl.java
Normal file
@ -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<MPlayer>
|
||||||
|
{
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// 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());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -22,7 +22,6 @@ import com.massivecraft.factions.event.FactionsEventPowerChange;
|
|||||||
import com.massivecraft.factions.event.FactionsEventPowerChange.PowerChangeReason;
|
import com.massivecraft.factions.event.FactionsEventPowerChange.PowerChangeReason;
|
||||||
import com.massivecraft.factions.integration.Econ;
|
import com.massivecraft.factions.integration.Econ;
|
||||||
import com.massivecraft.factions.integration.LWCFeatures;
|
import com.massivecraft.factions.integration.LWCFeatures;
|
||||||
import com.massivecraft.factions.integration.SpoutFeatures;
|
|
||||||
import com.massivecraft.factions.integration.Worldguard;
|
import com.massivecraft.factions.integration.Worldguard;
|
||||||
import com.massivecraft.factions.util.RelationUtil;
|
import com.massivecraft.factions.util.RelationUtil;
|
||||||
import com.massivecraft.mcore.mixin.Mixin;
|
import com.massivecraft.mcore.mixin.Mixin;
|
||||||
@ -121,12 +120,8 @@ public class UPlayer extends SenderEntity<UPlayer> implements EconomyParticipato
|
|||||||
// FIELDS: RAW TRANSIENT
|
// 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
|
// FIELD: mapAutoUpdating
|
||||||
|
// TODO: Move this to the MPlayer
|
||||||
private transient boolean mapAutoUpdating = false;
|
private transient boolean mapAutoUpdating = false;
|
||||||
public void setMapAutoUpdating(boolean mapAutoUpdating) { this.mapAutoUpdating = mapAutoUpdating; }
|
public void setMapAutoUpdating(boolean mapAutoUpdating) { this.mapAutoUpdating = mapAutoUpdating; }
|
||||||
public boolean isMapAutoUpdating() { return mapAutoUpdating; }
|
public boolean isMapAutoUpdating() { return mapAutoUpdating; }
|
||||||
@ -153,11 +148,11 @@ public class UPlayer extends SenderEntity<UPlayer> implements EconomyParticipato
|
|||||||
// GSON need this noarg constructor.
|
// GSON need this noarg constructor.
|
||||||
public UPlayer()
|
public UPlayer()
|
||||||
{
|
{
|
||||||
this.resetFactionData(false);
|
this.resetFactionData();
|
||||||
//this.power = ConfServer.powerStarting;
|
//this.power = ConfServer.powerStarting;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resetFactionData(boolean doSpoutUpdate)
|
public void resetFactionData()
|
||||||
{
|
{
|
||||||
// The default neutral faction
|
// The default neutral faction
|
||||||
this.setFactionId(null);
|
this.setFactionId(null);
|
||||||
@ -165,18 +160,6 @@ public class UPlayer extends SenderEntity<UPlayer> implements EconomyParticipato
|
|||||||
this.setTitle(null);
|
this.setTitle(null);
|
||||||
|
|
||||||
this.autoClaimFor = 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<UPlayer> implements EconomyParticipato
|
|||||||
if (!this.getColl().inited()) return;
|
if (!this.getColl().inited()) return;
|
||||||
if (!Factions.get().isDatabaseInitialized()) return;
|
if (!Factions.get().isDatabaseInitialized()) return;
|
||||||
|
|
||||||
// Spout Derp
|
|
||||||
SpoutFeatures.updateTitle(this, null);
|
|
||||||
SpoutFeatures.updateTitle(null, this);
|
|
||||||
|
|
||||||
// Update index
|
// Update index
|
||||||
Faction oldFaction = FactionColls.get().get(this).get(oldFactionId);
|
Faction oldFaction = FactionColls.get().get(this).get(oldFactionId);
|
||||||
Faction faction = FactionColls.get().get(this).get(factionId);
|
Faction faction = FactionColls.get().get(this).get(factionId);
|
||||||
@ -270,7 +249,6 @@ public class UPlayer extends SenderEntity<UPlayer> implements EconomyParticipato
|
|||||||
{
|
{
|
||||||
this.role = role;
|
this.role = role;
|
||||||
}
|
}
|
||||||
SpoutFeatures.updateTitle(this, null);
|
|
||||||
this.changed();
|
this.changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -639,21 +617,6 @@ public class UPlayer extends SenderEntity<UPlayer> implements EconomyParticipato
|
|||||||
return BoardColls.get().getFactionAt(Mixin.getSenderPs(this.getId())).getRelationTo(this) == Rel.ENEMY;
|
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("<i>")+" ~ "+factionHere.getTag(this);
|
|
||||||
if (factionHere.hasDescription())
|
|
||||||
{
|
|
||||||
msg += " - "+factionHere.getDescription();
|
|
||||||
}
|
|
||||||
this.sendMessage(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// ACTIONS
|
// ACTIONS
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
@ -846,7 +809,6 @@ public class UPlayer extends SenderEntity<UPlayer> implements EconomyParticipato
|
|||||||
}
|
}
|
||||||
|
|
||||||
BoardColls.get().setFactionAt(psChunk, forFaction);
|
BoardColls.get().setFactionAt(psChunk, forFaction);
|
||||||
SpoutFeatures.updateTerritoryDisplayLoc(psChunk);
|
|
||||||
|
|
||||||
if (MConf.get().logLandClaims)
|
if (MConf.get().logLandClaims)
|
||||||
{
|
{
|
||||||
|
@ -66,7 +66,6 @@ public class UPlayerColl extends SenderColl<UPlayer>
|
|||||||
if (FactionColls.get().get(this).containsId(uplayer.getFactionId())) continue;
|
if (FactionColls.get().get(this).containsId(uplayer.getFactionId())) continue;
|
||||||
|
|
||||||
Factions.get().log("Reset faction data (invalid faction) for player "+uplayer.getName());
|
Factions.get().log("Reset faction data (invalid faction) for player "+uplayer.getName());
|
||||||
uplayer.resetFactionData(false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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<Player> fromPlayers = getPlayersFromObject(ofrom);
|
|
||||||
Set<Player> 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("<i>CAPE SKIP:<h>%s <i>FROM <h>%s <i>TO <h>%s <i>URL <h>%s", String.valueOf(skip), player.getDisplayName(), playerTo.getDisplayName(), cape));
|
|
||||||
if (skip) continue;
|
|
||||||
//Bukkit.getConsoleSender().sendMessage(P.p.txt.parse("<i>CAPE FROM <h>%s <i>TO <h>%s <i>URL <h>%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<Player> fromPlayers = getPlayersFromObject(ofrom);
|
|
||||||
Set<Player> 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("<i>TITLE SKIP:<h>%s <i>FROM <h>%s <i>TO <h>%s <i>TITLE <h>%s", String.valueOf(skip), player.getDisplayName(), playerTo.getDisplayName(), title));
|
|
||||||
if (skip) continue;
|
|
||||||
//Bukkit.getConsoleSender().sendMessage(P.p.txt.parse("<i>TITLE FROM <h>%s <i>TO <h>%s <i>TITLE <h>%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<Player> getPlayersFromObject(Object o)
|
|
||||||
{
|
|
||||||
Set<Player> ret = new HashSet<Player>();
|
|
||||||
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());
|
|
||||||
}
|
|
||||||
}
|
|
@ -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<String, GenericLabel> territoryLabels = new HashMap<String, GenericLabel>();
|
|
||||||
private transient static Map<String, NoticeLabel> territoryChangeLabels = new HashMap<String, NoticeLabel>();
|
|
||||||
private transient static Map<String, GenericLabel> accessLabels = new HashMap<String, GenericLabel>();
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -350,7 +350,8 @@ public class FactionsListenerMain implements Listener
|
|||||||
}
|
}
|
||||||
|
|
||||||
Rel rel = uplayer.getRelationToLocation();
|
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))
|
if (rel == Rel.NEUTRAL && containsCommand(command, ConfServer.territoryNeutralDenyCommands))
|
||||||
{
|
{
|
||||||
|
@ -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());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -17,12 +17,14 @@ import com.massivecraft.factions.Const;
|
|||||||
import com.massivecraft.factions.FPerm;
|
import com.massivecraft.factions.FPerm;
|
||||||
import com.massivecraft.factions.TerritoryAccess;
|
import com.massivecraft.factions.TerritoryAccess;
|
||||||
import com.massivecraft.factions.entity.BoardColls;
|
import com.massivecraft.factions.entity.BoardColls;
|
||||||
|
import com.massivecraft.factions.entity.Faction;
|
||||||
import com.massivecraft.factions.entity.UPlayer;
|
import com.massivecraft.factions.entity.UPlayer;
|
||||||
import com.massivecraft.factions.entity.MConf;
|
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.event.MCorePlayerLeaveEvent;
|
||||||
import com.massivecraft.mcore.ps.PS;
|
import com.massivecraft.mcore.ps.PS;
|
||||||
import com.massivecraft.mcore.util.MUtil;
|
import com.massivecraft.mcore.util.MUtil;
|
||||||
|
import com.massivecraft.mcore.util.Txt;
|
||||||
|
|
||||||
|
|
||||||
public class TodoFactionsPlayerListener implements Listener
|
public class TodoFactionsPlayerListener implements Listener
|
||||||
@ -34,17 +36,10 @@ public class TodoFactionsPlayerListener implements Listener
|
|||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
UPlayer uplayer = UPlayer.get(player);
|
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);
|
uplayer.recalculatePower(false);
|
||||||
|
// TODO: What about the other universes?
|
||||||
// ... update the current chunk ...
|
// TODO: Track world --> world travel as logging on and off.
|
||||||
uplayer.setCurrentChunk(PS.valueOf(event.getPlayer()));
|
|
||||||
|
|
||||||
// ... notify the player about where they are ...
|
|
||||||
if ( ! SpoutFeatures.updateTerritoryDisplay(uplayer))
|
|
||||||
{
|
|
||||||
uplayer.sendFactionHereMessage();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@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.
|
// 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!
|
// TODO: When I setup universes I must do this for all universe instance of the player that logs off!
|
||||||
uplayer.recalculatePower(true);
|
uplayer.recalculatePower(true);
|
||||||
|
|
||||||
SpoutFeatures.playerDisconnect(uplayer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
@ -67,46 +60,48 @@ public class TodoFactionsPlayerListener implements Listener
|
|||||||
// If the player is moving from one chunk to another ...
|
// If the player is moving from one chunk to another ...
|
||||||
if (MUtil.isSameChunk(event)) return;
|
if (MUtil.isSameChunk(event)) return;
|
||||||
|
|
||||||
// ... update the stored current chunk ...
|
// ... gather info on the player and the move ...
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
UPlayer uplayer = UPlayer.get(player);
|
UPlayer uplayerTo = UPlayerColls.get().get(event.getTo()).get(player);
|
||||||
|
|
||||||
PS chunkFrom = uplayer.getCurrentChunk();
|
PS chunkFrom = PS.valueOf(event.getFrom()).getChunk(true);
|
||||||
PS chunkTo = PS.valueOf(event.getTo()).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 ...
|
// ... send host faction info updates ...
|
||||||
|
if (uplayerTo.isMapAutoUpdating())
|
||||||
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())
|
|
||||||
{
|
{
|
||||||
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("<i>") + " ~ " + factionTo.getTag(uplayerTo);
|
||||||
|
if (factionTo.hasDescription())
|
||||||
|
{
|
||||||
|
msg += " - " + factionTo.getDescription();
|
||||||
|
}
|
||||||
|
player.sendMessage(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
// show access info message if needed
|
// 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))
|
if (accessTo.subjectHasAccess(uplayerTo))
|
||||||
uplayer.msg("<g>You have access to this area.");
|
{
|
||||||
else if (access.subjectAccessIsRestricted(uplayer))
|
uplayerTo.msg("<g>You have access to this area.");
|
||||||
uplayer.msg("<b>This area has restricted access.");
|
}
|
||||||
|
else if (accessTo.subjectAccessIsRestricted(uplayerTo))
|
||||||
|
{
|
||||||
|
uplayerTo.msg("<b>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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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<Double, String> 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;
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user