Remove spout, update pom for lwc. Still need lots of dependencies.

This commit is contained in:
drtshock 2014-04-04 14:35:35 -05:00
parent 814e439705
commit d9b7cf7058
18 changed files with 42 additions and 538 deletions

26
pom.xml
View File

@ -45,11 +45,37 @@
<artifactId>bukkit</artifactId>
<version>LATEST</version>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
<version>LATEST</version>
</dependency>
<dependency>
<groupId>net.daboross.vault</groupId>
<artifactId>vault-api</artifactId>
<version>1.2.27</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.griefcraft</groupId>
<artifactId>lwc</artifactId>
<version>4.4.0-SNAPSHOT</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>repo-daboross-net</id>
<url>http://repo.daboross.net/</url>
</repository>
<repository>
<id>bukkit-repo</id>
<url>http://repo.bukkit.org/content/groups/public/</url>
</repository>
<repository>
<id>mcstats.releases</id>
<name>mcstats.org releases</name>
<url>http://repo.mcstats.org/content/repositories/</url>
</repository>
</repositories>
</project>

BIN
src/main/.DS_Store vendored Normal file

Binary file not shown.

View File

@ -0,0 +1,16 @@
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>bin</id>
<includeBaseDirectory>false</includeBaseDirectory>
<formats>
<format>zip</format>
</formats>
<files>
<file>
<source>${project.build.directory}/${artifactId}.jar</source>
<outputDirectory>/</outputDirectory>
<destName>${artifactId}.jar</destName>
</file>
</files>
</assembly>

View File

@ -6,7 +6,6 @@ import com.massivecraft.factions.iface.EconomyParticipator;
import com.massivecraft.factions.iface.RelationParticipator;
import com.massivecraft.factions.integration.Econ;
import com.massivecraft.factions.integration.LWCFeatures;
import com.massivecraft.factions.integration.SpoutFeatures;
import com.massivecraft.factions.integration.Worldguard;
import com.massivecraft.factions.struct.ChatMode;
import com.massivecraft.factions.struct.Permission;
@ -61,7 +60,6 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator {
if (oldFaction != null) oldFaction.removeFPlayer(this);
faction.addFPlayer(this);
this.factionId = faction.getId();
SpoutFeatures.updateAppearances(this.getPlayer());
}
// FIELD: role
@ -73,7 +71,6 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator {
public void setRole(Role role) {
this.role = role;
SpoutFeatures.updateAppearances(this.getPlayer());
}
// FIELD: title
@ -233,10 +230,6 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator {
this.role = Role.NORMAL;
this.title = "";
this.autoClaimFor = null;
if (doSpoutUpdate) {
SpoutFeatures.updateAppearances(this.getPlayer());
}
}
public void resetFactionData() {
@ -549,9 +542,6 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator {
}
public void sendFactionHereMessage() {
if (SpoutFeatures.updateTerritoryDisplay(this)) {
return;
}
Faction factionHere = Board.getFactionAt(this.getLastStoodAt());
String msg = P.p.txt.parse("<i>") + " ~ " + factionHere.getTag(this);
if (factionHere.getDescription().length() > 0) {
@ -758,7 +748,6 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator {
}
Board.setFactionAt(forFaction, flocation);
SpoutFeatures.updateTerritoryDisplayLoc(flocation);
if (Conf.logLandClaims)
P.p.log(this.getName() + " claimed land at (" + flocation.getCoordString() + ") for the faction: " + forFaction.getTag());

View File

@ -98,7 +98,6 @@ public class P extends MPlugin {
this.getBaseCommands().add(cmdBase);
EssentialsFeatures.setup();
SpoutFeatures.setup();
Econ.setup();
CapiFeatures.setup();
LWCFeatures.setup();

View File

@ -2,7 +2,6 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.P;
import com.massivecraft.factions.integration.SpoutFeatures;
import com.massivecraft.factions.struct.Permission;
import org.bukkit.ChatColor;
import org.bukkit.Material;

View File

@ -4,7 +4,6 @@ import com.massivecraft.factions.*;
import com.massivecraft.factions.event.FPlayerLeaveEvent;
import com.massivecraft.factions.event.FactionDisbandEvent;
import com.massivecraft.factions.integration.Econ;
import com.massivecraft.factions.integration.SpoutFeatures;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Role;
import org.bukkit.Bukkit;

View File

@ -1,7 +1,6 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.*;
import com.massivecraft.factions.integration.SpoutFeatures;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Role;

View File

@ -3,7 +3,6 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.FPlayers;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.integration.SpoutFeatures;
import com.massivecraft.factions.struct.Permission;
public class CmdPeaceful extends FCommand {

View File

@ -4,7 +4,6 @@ import com.massivecraft.factions.Conf;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.event.FactionRenameEvent;
import com.massivecraft.factions.integration.SpoutFeatures;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.util.MiscUtil;
import org.bukkit.Bukkit;

View File

@ -2,7 +2,6 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.integration.SpoutFeatures;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TextUtil;

View File

@ -3,7 +3,6 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.*;
import com.massivecraft.factions.event.LandUnclaimEvent;
import com.massivecraft.factions.integration.Econ;
import com.massivecraft.factions.integration.SpoutFeatures;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Role;
import org.bukkit.Bukkit;

View File

@ -5,7 +5,6 @@ import com.massivecraft.factions.Conf;
import com.massivecraft.factions.P;
import com.massivecraft.factions.event.LandUnclaimAllEvent;
import com.massivecraft.factions.integration.Econ;
import com.massivecraft.factions.integration.SpoutFeatures;
import com.massivecraft.factions.struct.Permission;
import org.bukkit.Bukkit;

View File

@ -3,7 +3,6 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.event.FactionRelationEvent;
import com.massivecraft.factions.integration.SpoutFeatures;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Relation;
import org.bukkit.Bukkit;

View File

@ -1,298 +0,0 @@
package com.massivecraft.factions.integration;
import com.massivecraft.factions.*;
import com.massivecraft.factions.struct.Relation;
import com.massivecraft.factions.struct.Role;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.getspout.spoutapi.SpoutManager;
import org.getspout.spoutapi.gui.Color;
import org.getspout.spoutapi.player.SpoutPlayer;
import java.util.Set;
public class SpoutFeatures {
private transient static boolean spoutMe = false;
private transient static SpoutMainListener mainListener;
private transient static boolean listenersHooked;
public static void setup() {
Plugin test = Bukkit.getServer().getPluginManager().getPlugin("Spout");
if (test == null || !test.isEnabled()) return;
setAvailable(true, test.getDescription().getFullName());
}
// set integration availability
public static void setAvailable(boolean enable, String pluginName) {
spoutMe = enable;
if (!spoutMe) return;
P.p.log("Found and will use features of " + pluginName);
if (!listenersHooked) {
listenersHooked = true;
mainListener = new SpoutMainListener();
Bukkit.getServer().getPluginManager().registerEvents(mainListener, P.p);
}
}
// If we're successfully hooked into Spout
public static boolean enabled() {
return spoutMe;
}
// If Spout is available and the specified Player is running the Spoutcraft client
public static boolean availableFor(Player player) {
return spoutMe && SpoutManager.getPlayer(player).isSpoutCraftEnabled();
}
// update displayed current territory for all players inside a specified chunk; if specified chunk is null, then simply update everyone online
public static void updateTerritoryDisplayLoc(FLocation fLoc) {
if (!enabled())
return;
Set<FPlayer> players = FPlayers.i.getOnline();
for (FPlayer player : players) {
if (fLoc == null)
mainListener.updateTerritoryDisplay(player, false);
else if (player.getLastStoodAt().equals(fLoc))
mainListener.updateTerritoryDisplay(player, true);
}
}
// update displayed current territory for specified player; returns false if unsuccessful
public static boolean updateTerritoryDisplay(FPlayer player) {
if (!enabled())
return false;
return mainListener.updateTerritoryDisplay(player, true);
}
// update owner list for all players inside a specified chunk; if specified chunk is null, then simply update everyone online
public static void updateOwnerListLoc(FLocation fLoc) {
if (!enabled())
return;
Set<FPlayer> players = FPlayers.i.getOnline();
for (FPlayer player : players) {
if (fLoc == null || player.getLastStoodAt().equals(fLoc))
mainListener.updateOwnerList(player);
}
}
// update owner list for specified player
public static void updateOwnerList(FPlayer player) {
if (!enabled())
return;
mainListener.updateOwnerList(player);
}
public static void playerDisconnect(FPlayer player) {
if (!enabled())
return;
mainListener.removeTerritoryLabels(player.getName());
}
// update all appearances between every player
public static void updateAppearances() {
if (!enabled())
return;
Set<FPlayer> players = FPlayers.i.getOnline();
for (FPlayer playerA : players) {
for (FPlayer playerB : players) {
updateSingle(playerB, playerA);
}
}
}
// update all appearances related to a specific player
public static void updateAppearances(Player player) {
if (!enabled() || player == null)
return;
Set<FPlayer> players = FPlayers.i.getOnline();
FPlayer playerA = FPlayers.i.get(player);
for (FPlayer playerB : players) {
updateSingle(playerB, playerA);
updateSingle(playerA, playerB);
}
}
// as above method, but with a delay added; useful for after-login update which doesn't always propagate if done immediately
public static void updateAppearancesShortly(final Player player) {
P.p.getServer().getScheduler().scheduleSyncDelayedTask(P.p, new Runnable() {
@Override
public void run() {
updateAppearances(player);
}
}, 100);
}
// update all appearances related to a single faction
public static void updateAppearances(Faction faction) {
if (!enabled() || faction == null)
return;
Set<FPlayer> players = FPlayers.i.getOnline();
Faction factionA;
for (FPlayer playerA : players) {
factionA = playerA.getFaction();
for (FPlayer playerB : players) {
if (factionA != faction && playerB.getFaction() != faction)
continue;
updateSingle(playerB, playerA);
}
}
}
// update all appearances between two factions
public static void updateAppearances(Faction factionA, Faction factionB) {
if (!enabled() || factionA == null || factionB == null)
return;
for (FPlayer playerA : factionA.getFPlayersWhereOnline(true)) {
for (FPlayer playerB : factionB.getFPlayersWhereOnline(true)) {
updateSingle(playerB, playerA);
updateSingle(playerA, playerB);
}
}
}
// update a single appearance; internal use only by above public methods
private static void updateSingle(FPlayer viewer, FPlayer viewed) {
if (viewer == null || viewed == null)
return;
Faction viewedFaction = viewed.getFaction();
if (viewedFaction == null)
return;
// these still end up returning null on occasion at this point, mucking up the SpoutManager.getPlayer() method
if (viewer.getPlayer() == null || viewed.getPlayer() == null)
return;
SpoutPlayer pViewer = SpoutManager.getPlayer(viewer.getPlayer());
SpoutPlayer pViewed = SpoutManager.getPlayer(viewed.getPlayer());
if (pViewed == null || pViewer == null)
return;
String viewedTitle = viewed.getTitle();
Role viewedRole = viewed.getRole();
if ((Conf.spoutFactionTagsOverNames || Conf.spoutFactionTitlesOverNames) && viewer != viewed) {
if (viewedFaction.isNormal()) {
String addTag = "";
if (Conf.spoutFactionTagsOverNames)
addTag += viewedFaction.getTag(viewed.getColorTo(viewer).toString() + "[") + "]";
String rolePrefix = viewedRole.getPrefix();
if (Conf.spoutFactionTitlesOverNames && (!viewedTitle.isEmpty() || !rolePrefix.isEmpty()))
addTag += (addTag.isEmpty() ? "" : " ") + viewedRole.getPrefix() + viewedTitle;
pViewed.setTitleFor(pViewer, addTag + "\n" + pViewed.getDisplayName());
} else {
pViewed.setTitleFor(pViewer, pViewed.getDisplayName());
}
}
if
(
(
Conf.spoutFactionAdminCapes
&&
viewedRole.equals(Role.ADMIN)
)
||
(
Conf.spoutFactionModeratorCapes
&&
viewedRole.equals(Role.MODERATOR)
)
) {
Relation relation = viewer.getRelationTo(viewed);
String cape = "";
if (!viewedFaction.isNormal()) {
// yeah, no cape if no faction
} else if (viewedFaction.isPeaceful())
cape = Conf.capePeaceful;
else if (relation.isNeutral())
cape = Conf.capeNeutral;
else if (relation.isMember())
cape = Conf.capeMember;
else if (relation.isEnemy())
cape = Conf.capeEnemy;
else if (relation.isAlly())
cape = Conf.capeAlly;
if (cape.isEmpty())
pViewed.resetCapeFor(pViewer);
else
pViewed.setCapeFor(pViewer, cape);
} else if (Conf.spoutFactionAdminCapes || Conf.spoutFactionModeratorCapes) {
pViewed.resetCapeFor(pViewer);
}
}
// method to convert a Bukkit ChatColor to a Spout Color
protected static Color getSpoutColor(ChatColor inColor, int alpha) {
if (inColor == null)
return SpoutFixedColor(191, 191, 191, alpha);
switch (inColor.getChar()) {
case 0x1:
return SpoutFixedColor(0, 0, 191, alpha);
case 0x2:
return SpoutFixedColor(0, 191, 0, alpha);
case 0x3:
return SpoutFixedColor(0, 191, 191, alpha);
case 0x4:
return SpoutFixedColor(191, 0, 0, alpha);
case 0x5:
return SpoutFixedColor(191, 0, 191, alpha);
case 0x6:
return SpoutFixedColor(191, 191, 0, alpha);
case 0x7:
return SpoutFixedColor(191, 191, 191, alpha);
case 0x8:
return SpoutFixedColor(64, 64, 64, alpha);
case 0x9:
return SpoutFixedColor(64, 64, 255, alpha);
case 0xA:
return SpoutFixedColor(64, 255, 64, alpha);
case 0xB:
return SpoutFixedColor(64, 255, 255, alpha);
case 0xC:
return SpoutFixedColor(255, 64, 64, alpha);
case 0xD:
return SpoutFixedColor(255, 64, 255, alpha);
case 0xE:
return SpoutFixedColor(255, 255, 64, alpha);
case 0xF:
return SpoutFixedColor(255, 255, 255, alpha);
default:
return SpoutFixedColor(0, 0, 0, alpha);
}
}
private static Color SpoutFixedColor(int r, int g, int b, int a) {
return new Color(r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f);
}
}

View File

@ -1,217 +0,0 @@
package com.massivecraft.factions.integration;
import com.massivecraft.factions.*;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.getspout.spoutapi.SpoutManager;
import org.getspout.spoutapi.event.spout.SpoutCraftEnableEvent;
import org.getspout.spoutapi.gui.GenericLabel;
import org.getspout.spoutapi.player.SpoutPlayer;
import java.util.HashMap;
import java.util.Map;
public class SpoutMainListener implements Listener {
@EventHandler(priority = EventPriority.NORMAL)
public void onSpoutCraftEnable(SpoutCraftEnableEvent event) {
final FPlayer me = FPlayers.i.get(event.getPlayer());
SpoutFeatures.updateAppearances(me.getPlayer());
updateTerritoryDisplay(me, true);
}
//-----------------------------------------------------------------------------------------//
// Everything below this is handled in here to prevent errors on servers not running Spout
//-----------------------------------------------------------------------------------------//
private transient static Map<String, GenericLabel> territoryLabels = new HashMap<String, GenericLabel>();
private transient static Map<String, NoticeLabel> territoryChangeLabels = new HashMap<String, NoticeLabel>();
private transient static Map<String, GenericLabel> ownerLabels = new HashMap<String, GenericLabel>();
private final static int SCREEN_WIDTH = 427;
// private final static int SCREEN_HEIGHT = 240;
public boolean updateTerritoryDisplay(FPlayer player, boolean notify) {
Player p = player.getPlayer();
if (p == null)
return false;
SpoutPlayer sPlayer = SpoutManager.getPlayer(p);
if (!sPlayer.isSpoutCraftEnabled() || (Conf.spoutTerritoryDisplaySize <= 0 && !Conf.spoutTerritoryNoticeShow))
return false;
doLabels(player, sPlayer, notify);
return true;
}
public void updateOwnerList(FPlayer player) {
SpoutPlayer sPlayer = SpoutManager.getPlayer(player.getPlayer());
if (!sPlayer.isSpoutCraftEnabled() || (Conf.spoutTerritoryDisplaySize <= 0 && !Conf.spoutTerritoryNoticeShow))
return;
FLocation here = player.getLastStoodAt();
Faction factionHere = Board.getFactionAt(here);
doOwnerList(player, sPlayer, here, factionHere);
return;
}
public void removeTerritoryLabels(String playerName) {
territoryLabels.remove(playerName);
territoryChangeLabels.remove(playerName);
ownerLabels.remove(playerName);
}
private void doLabels(FPlayer player, SpoutPlayer sPlayer, boolean notify) {
FLocation here = player.getLastStoodAt();
Faction factionHere = Board.getFactionAt(here);
String tag = factionHere.getColorTo(player).toString() + factionHere.getTag();
// ----------------------
// Main territory display
// ----------------------
if (Conf.spoutTerritoryDisplayPosition > 0 && Conf.spoutTerritoryDisplaySize > 0) {
GenericLabel label;
if (territoryLabels.containsKey(player.getName()))
label = territoryLabels.get(player.getName());
else {
label = new GenericLabel();
label.setWidth(1).setHeight(1); // prevent Spout's questionable new "no default size" warning
label.setScale(Conf.spoutTerritoryDisplaySize);
sPlayer.getMainScreen().attachWidget(P.p, label);
territoryLabels.put(player.getName(), label);
}
String msg = tag;
if (Conf.spoutTerritoryDisplayShowDescription && !factionHere.getDescription().isEmpty())
msg += " - " + factionHere.getDescription();
label.setText(msg);
alignLabel(label, msg);
label.setDirty(true);
}
// -----------------------
// Fading territory notice
// -----------------------
if (notify && Conf.spoutTerritoryNoticeShow && Conf.spoutTerritoryNoticeSize > 0) {
NoticeLabel label;
if (territoryChangeLabels.containsKey(player.getName()))
label = territoryChangeLabels.get(player.getName());
else {
label = new NoticeLabel(Conf.spoutTerritoryNoticeLeaveAfterSeconds);
label.setWidth(1).setHeight(1); // prevent Spout's questionable new "no default size" warning
label.setScale(Conf.spoutTerritoryNoticeSize);
label.setY(Conf.spoutTerritoryNoticeTop);
sPlayer.getMainScreen().attachWidget(P.p, label);
territoryChangeLabels.put(player.getName(), label);
}
String msg = tag;
if (Conf.spoutTerritoryNoticeShowDescription && !factionHere.getDescription().isEmpty())
msg += " - " + factionHere.getDescription();
label.setText(msg);
alignLabel(label, msg, 2);
label.resetNotice();
label.setDirty(true);
}
// and owner list, of course
doOwnerList(player, sPlayer, here, factionHere);
}
private void doOwnerList(FPlayer player, SpoutPlayer sPlayer, FLocation here, Faction factionHere) {
// ----------
// Owner list
// ----------
if (Conf.spoutTerritoryDisplayPosition > 0 && Conf.spoutTerritoryDisplaySize > 0 && Conf.spoutTerritoryOwnersShow && Conf.ownedAreasEnabled) {
GenericLabel label;
if (ownerLabels.containsKey(player.getName()))
label = ownerLabels.get(player.getName());
else {
label = new GenericLabel();
label.setWidth(1).setHeight(1); // prevent Spout's questionable new "no default size" warning
label.setScale(Conf.spoutTerritoryDisplaySize);
label.setY((int) (10 * Conf.spoutTerritoryDisplaySize));
sPlayer.getMainScreen().attachWidget(P.p, label);
ownerLabels.put(player.getName(), label);
}
String msg = "";
if (player.getFaction() == factionHere) {
msg = factionHere.getOwnerListString(here);
if (!msg.isEmpty())
msg = Conf.ownedLandMessage + msg;
}
label.setText(msg);
alignLabel(label, msg);
label.setDirty(true);
}
}
// this is only necessary because Spout text size scaling is currently bugged and breaks their built-in alignment methods
public void alignLabel(GenericLabel label, String text) {
alignLabel(label, text, Conf.spoutTerritoryDisplayPosition);
}
public void alignLabel(GenericLabel label, String text, int alignment) {
int labelWidth = (int) ((float) GenericLabel.getStringWidth(text) * Conf.spoutTerritoryDisplaySize);
if (labelWidth > SCREEN_WIDTH) {
label.setX(0);
return;
}
switch (alignment) {
case 1: // left aligned
label.setX(0);
break;
case 2: // center aligned
label.setX((SCREEN_WIDTH - labelWidth) / 2);
break;
default: // right aligned
label.setX(SCREEN_WIDTH - labelWidth);
}
}
private static class NoticeLabel extends GenericLabel {
private int initial;
private int countdown; // current delay countdown
public NoticeLabel(float secondsOfLife) {
initial = (int) (secondsOfLife * 20);
resetNotice();
}
public final void resetNotice() {
countdown = initial;
}
@Override
public void onTick() {
if (countdown <= 0)
return;
this.countdown -= 1;
if (this.countdown <= 0) {
this.setText("");
this.setDirty(true);
}
}
}
}

View File

@ -1,7 +1,6 @@
package com.massivecraft.factions.listeners;
import com.massivecraft.factions.*;
import com.massivecraft.factions.integration.SpoutFeatures;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Relation;
import com.massivecraft.factions.struct.Role;

View File

@ -1,7 +1,6 @@
package com.massivecraft.factions.listeners;
import com.massivecraft.factions.P;
import com.massivecraft.factions.integration.SpoutFeatures;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;