mirror of
https://github.com/MassiveCraft/Factions.git
synced 2024-10-31 07:39:54 +01:00
Updated SpoutAPI, handled deprecated Spout AppearanceManager code, updated Spout event listener to new Bukkit event system
This commit is contained in:
parent
e918bc0d91
commit
c8d6d06f90
BIN
lib/SpoutAPI.jar
BIN
lib/SpoutAPI.jar
Binary file not shown.
@ -9,21 +9,19 @@ import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.FLocation;
|
||||
import com.massivecraft.factions.P;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
|
||||
import com.massivecraft.factions.struct.Rel;
|
||||
|
||||
import org.getspout.spoutapi.gui.Color;
|
||||
import org.getspout.spoutapi.player.AppearanceManager;
|
||||
import org.getspout.spoutapi.player.SpoutPlayer;
|
||||
import org.getspout.spoutapi.SpoutManager;
|
||||
|
||||
|
||||
public class SpoutFeatures
|
||||
{
|
||||
private transient static AppearanceManager spoutApp;
|
||||
private transient static boolean spoutMe = false;
|
||||
private transient static SpoutMainListener mainListener;
|
||||
private transient static boolean listenersHooked;
|
||||
@ -32,21 +30,15 @@ public class SpoutFeatures
|
||||
public static void setAvailable(boolean enable, String pluginName)
|
||||
{
|
||||
spoutMe = enable;
|
||||
if (spoutMe)
|
||||
{
|
||||
spoutApp = SpoutManager.getAppearanceManager();
|
||||
P.p.log("Found and will use features of "+pluginName);
|
||||
if (!spoutMe) return;
|
||||
|
||||
if (!listenersHooked)
|
||||
{
|
||||
listenersHooked = true;
|
||||
mainListener = new SpoutMainListener();
|
||||
P.p.registerEvent(Event.Type.CUSTOM_EVENT, mainListener, Event.Priority.Normal);
|
||||
}
|
||||
}
|
||||
else
|
||||
P.p.log("Found and will use features of "+pluginName);
|
||||
|
||||
if (!listenersHooked)
|
||||
{
|
||||
spoutApp = null;
|
||||
listenersHooked = true;
|
||||
mainListener = new SpoutMainListener();
|
||||
Bukkit.getServer().getPluginManager().registerEvents(mainListener, P.p);
|
||||
}
|
||||
}
|
||||
|
||||
@ -194,12 +186,11 @@ public class SpoutFeatures
|
||||
if (viewedFaction == null)
|
||||
return;
|
||||
|
||||
Player pViewed = viewed.getPlayer();
|
||||
Player pViewer = viewer.getPlayer();
|
||||
SpoutPlayer pViewer = SpoutManager.getPlayer(viewer.getPlayer());
|
||||
SpoutPlayer pViewed = SpoutManager.getPlayer(viewed.getPlayer());
|
||||
if (pViewed == null || pViewer == null)
|
||||
return;
|
||||
|
||||
SpoutPlayer sPlayer = SpoutManager.getPlayer(pViewer);
|
||||
String viewedTitle = viewed.getTitle();
|
||||
Rel viewedRole = viewed.getRole();
|
||||
|
||||
@ -215,11 +206,11 @@ public class SpoutFeatures
|
||||
if (Conf.spoutFactionTitlesOverNames && (!viewedTitle.isEmpty() || !rolePrefix.isEmpty()))
|
||||
addTag += (addTag.isEmpty() ? "" : " ") + viewedRole.getPrefix() + viewedTitle;
|
||||
|
||||
spoutApp.setPlayerTitle(sPlayer, pViewed, addTag + "\n" + pViewed.getDisplayName());
|
||||
pViewed.setTitleFor(pViewer, addTag + "\n" + pViewed.getDisplayName());
|
||||
}
|
||||
else
|
||||
{
|
||||
spoutApp.setPlayerTitle(sPlayer, pViewed, pViewed.getDisplayName());
|
||||
pViewed.setTitleFor(pViewer, pViewed.getDisplayName());
|
||||
}
|
||||
}
|
||||
|
||||
@ -256,13 +247,13 @@ public class SpoutFeatures
|
||||
cape = Conf.capeAlly;
|
||||
|
||||
if (cape.isEmpty())
|
||||
spoutApp.resetPlayerCloak(sPlayer, pViewed);
|
||||
pViewed.resetCapeFor(pViewer);
|
||||
else
|
||||
spoutApp.setPlayerCloak(sPlayer, pViewed, cape);
|
||||
pViewed.setCapeFor(pViewer, cape);
|
||||
}
|
||||
else if (Conf.spoutFactionLeaderCapes || Conf.spoutFactionOfficerCapes)
|
||||
{
|
||||
spoutApp.resetPlayerCloak(sPlayer, pViewed);
|
||||
pViewed.resetCapeFor(pViewer);
|
||||
}
|
||||
}
|
||||
|
||||
@ -273,7 +264,7 @@ public class SpoutFeatures
|
||||
if (inColor == null)
|
||||
return SpoutFixedColor(191, 191, 191, alpha);
|
||||
|
||||
switch (inColor.getCode())
|
||||
switch (inColor.getChar())
|
||||
{
|
||||
case 0x1: return SpoutFixedColor(0, 0, 191, alpha);
|
||||
case 0x2: return SpoutFixedColor(0, 191, 0, alpha);
|
||||
|
@ -4,6 +4,9 @@ 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.Board;
|
||||
import com.massivecraft.factions.Conf;
|
||||
@ -14,16 +17,14 @@ import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.P;
|
||||
|
||||
import org.getspout.spoutapi.event.spout.SpoutCraftEnableEvent;
|
||||
import org.getspout.spoutapi.event.spout.SpoutListener;
|
||||
import org.getspout.spoutapi.gui.GenericLabel;
|
||||
import org.getspout.spoutapi.player.SpoutPlayer;
|
||||
import org.getspout.spoutapi.SpoutManager;
|
||||
//import org.getspout.spoutapi.gui.WidgetAnchor;
|
||||
|
||||
|
||||
public class SpoutMainListener extends SpoutListener
|
||||
public class SpoutMainListener implements Listener
|
||||
{
|
||||
@Override
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onSpoutCraftEnable(SpoutCraftEnableEvent event)
|
||||
{
|
||||
final FPlayer me = FPlayers.i.get(event.getPlayer());
|
||||
@ -85,13 +86,7 @@ public class SpoutMainListener extends SpoutListener
|
||||
label = new GenericLabel();
|
||||
label.setWidth(1).setHeight(1); // prevent Spout's questionable new "no default size" warning
|
||||
label.setScale(Conf.spoutTerritoryDisplaySize);
|
||||
/* // this should work once the Spout team fix it to account for text scaling; we can then get rid of alignLabel method added below
|
||||
switch (Conf.spoutTerritoryDisplayPosition) {
|
||||
case 1: label.setAlign(WidgetAnchor.TOP_LEFT).setAnchor(WidgetAnchor.TOP_LEFT); break;
|
||||
case 2: label.setAlign(WidgetAnchor.TOP_CENTER).setAnchor(WidgetAnchor.TOP_CENTER); break;
|
||||
default: label.setAlign(WidgetAnchor.TOP_RIGHT).setAnchor(WidgetAnchor.TOP_RIGHT);
|
||||
}
|
||||
*/
|
||||
|
||||
sPlayer.getMainScreen().attachWidget(P.p, label);
|
||||
territoryLabels.put(player.getName(), label);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user