Updated SpoutAPI, handled deprecated Spout AppearanceManager code, updated Spout event listener to new Bukkit event system
This commit is contained in:
parent
639dc16bf5
commit
11a4162981
BIN
lib/SpoutAPI.jar
BIN
lib/SpoutAPI.jar
Binary file not shown.
@ -9,22 +9,20 @@ import com.massivecraft.factions.Faction;
|
|||||||
import com.massivecraft.factions.FLocation;
|
import com.massivecraft.factions.FLocation;
|
||||||
import com.massivecraft.factions.P;
|
import com.massivecraft.factions.P;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Event;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.struct.Relation;
|
import com.massivecraft.factions.struct.Relation;
|
||||||
import com.massivecraft.factions.struct.Role;
|
import com.massivecraft.factions.struct.Role;
|
||||||
|
|
||||||
import org.getspout.spoutapi.gui.Color;
|
import org.getspout.spoutapi.gui.Color;
|
||||||
import org.getspout.spoutapi.player.AppearanceManager;
|
|
||||||
import org.getspout.spoutapi.player.SpoutPlayer;
|
import org.getspout.spoutapi.player.SpoutPlayer;
|
||||||
import org.getspout.spoutapi.SpoutManager;
|
import org.getspout.spoutapi.SpoutManager;
|
||||||
|
|
||||||
|
|
||||||
public class SpoutFeatures
|
public class SpoutFeatures
|
||||||
{
|
{
|
||||||
private transient static AppearanceManager spoutApp;
|
|
||||||
private transient static boolean spoutMe = false;
|
private transient static boolean spoutMe = false;
|
||||||
private transient static SpoutMainListener mainListener;
|
private transient static SpoutMainListener mainListener;
|
||||||
private transient static boolean listenersHooked;
|
private transient static boolean listenersHooked;
|
||||||
@ -33,21 +31,15 @@ public class SpoutFeatures
|
|||||||
public static void setAvailable(boolean enable, String pluginName)
|
public static void setAvailable(boolean enable, String pluginName)
|
||||||
{
|
{
|
||||||
spoutMe = enable;
|
spoutMe = enable;
|
||||||
if (spoutMe)
|
if (!spoutMe) return;
|
||||||
{
|
|
||||||
spoutApp = SpoutManager.getAppearanceManager();
|
|
||||||
P.p.log("Found and will use features of "+pluginName);
|
|
||||||
|
|
||||||
if (!listenersHooked)
|
P.p.log("Found and will use features of "+pluginName);
|
||||||
{
|
|
||||||
listenersHooked = true;
|
if (!listenersHooked)
|
||||||
mainListener = new SpoutMainListener();
|
|
||||||
P.p.registerEvent(Event.Type.CUSTOM_EVENT, mainListener, Event.Priority.Normal);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
spoutApp = null;
|
listenersHooked = true;
|
||||||
|
mainListener = new SpoutMainListener();
|
||||||
|
Bukkit.getServer().getPluginManager().registerEvents(mainListener, P.p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -219,12 +211,11 @@ public class SpoutFeatures
|
|||||||
if (viewedFaction == null)
|
if (viewedFaction == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Player pViewed = viewed.getPlayer();
|
SpoutPlayer pViewer = SpoutManager.getPlayer(viewer.getPlayer());
|
||||||
Player pViewer = viewer.getPlayer();
|
SpoutPlayer pViewed = SpoutManager.getPlayer(viewed.getPlayer());
|
||||||
if (pViewed == null || pViewer == null)
|
if (pViewed == null || pViewer == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
SpoutPlayer sPlayer = SpoutManager.getPlayer(pViewer);
|
|
||||||
String viewedTitle = viewed.getTitle();
|
String viewedTitle = viewed.getTitle();
|
||||||
Role viewedRole = viewed.getRole();
|
Role viewedRole = viewed.getRole();
|
||||||
|
|
||||||
@ -240,11 +231,11 @@ public class SpoutFeatures
|
|||||||
if (Conf.spoutFactionTitlesOverNames && (!viewedTitle.isEmpty() || !rolePrefix.isEmpty()))
|
if (Conf.spoutFactionTitlesOverNames && (!viewedTitle.isEmpty() || !rolePrefix.isEmpty()))
|
||||||
addTag += (addTag.isEmpty() ? "" : " ") + viewedRole.getPrefix() + viewedTitle;
|
addTag += (addTag.isEmpty() ? "" : " ") + viewedRole.getPrefix() + viewedTitle;
|
||||||
|
|
||||||
spoutApp.setPlayerTitle(sPlayer, pViewed, addTag + "\n" + pViewed.getDisplayName());
|
pViewed.setTitleFor(pViewer, addTag + "\n" + pViewed.getDisplayName());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
spoutApp.setPlayerTitle(sPlayer, pViewed, pViewed.getDisplayName());
|
pViewed.setTitleFor(pViewer, pViewed.getDisplayName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -281,13 +272,13 @@ public class SpoutFeatures
|
|||||||
cape = Conf.capeAlly;
|
cape = Conf.capeAlly;
|
||||||
|
|
||||||
if (cape.isEmpty())
|
if (cape.isEmpty())
|
||||||
spoutApp.resetPlayerCloak(sPlayer, pViewed);
|
pViewed.resetCapeFor(pViewer);
|
||||||
else
|
else
|
||||||
spoutApp.setPlayerCloak(sPlayer, pViewed, cape);
|
pViewed.setCapeFor(pViewer, cape);
|
||||||
}
|
}
|
||||||
else if (Conf.spoutFactionAdminCapes || Conf.spoutFactionModeratorCapes)
|
else if (Conf.spoutFactionAdminCapes || Conf.spoutFactionModeratorCapes)
|
||||||
{
|
{
|
||||||
spoutApp.resetPlayerCloak(sPlayer, pViewed);
|
pViewed.resetCapeFor(pViewer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -298,7 +289,7 @@ public class SpoutFeatures
|
|||||||
if (inColor == null)
|
if (inColor == null)
|
||||||
return SpoutFixedColor(191, 191, 191, alpha);
|
return SpoutFixedColor(191, 191, 191, alpha);
|
||||||
|
|
||||||
switch (inColor.getCode())
|
switch (inColor.getChar())
|
||||||
{
|
{
|
||||||
case 0x1: return SpoutFixedColor(0, 0, 191, alpha);
|
case 0x1: return SpoutFixedColor(0, 0, 191, alpha);
|
||||||
case 0x2: return SpoutFixedColor(0, 191, 0, alpha);
|
case 0x2: return SpoutFixedColor(0, 191, 0, alpha);
|
||||||
|
@ -4,6 +4,9 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
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.Board;
|
||||||
import com.massivecraft.factions.Conf;
|
import com.massivecraft.factions.Conf;
|
||||||
@ -14,16 +17,14 @@ import com.massivecraft.factions.Faction;
|
|||||||
import com.massivecraft.factions.P;
|
import com.massivecraft.factions.P;
|
||||||
|
|
||||||
import org.getspout.spoutapi.event.spout.SpoutCraftEnableEvent;
|
import org.getspout.spoutapi.event.spout.SpoutCraftEnableEvent;
|
||||||
import org.getspout.spoutapi.event.spout.SpoutListener;
|
|
||||||
import org.getspout.spoutapi.gui.GenericLabel;
|
import org.getspout.spoutapi.gui.GenericLabel;
|
||||||
import org.getspout.spoutapi.player.SpoutPlayer;
|
import org.getspout.spoutapi.player.SpoutPlayer;
|
||||||
import org.getspout.spoutapi.SpoutManager;
|
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)
|
public void onSpoutCraftEnable(SpoutCraftEnableEvent event)
|
||||||
{
|
{
|
||||||
final FPlayer me = FPlayers.i.get(event.getPlayer());
|
final FPlayer me = FPlayers.i.get(event.getPlayer());
|
||||||
@ -99,13 +100,7 @@ public class SpoutMainListener extends SpoutListener
|
|||||||
label = new GenericLabel();
|
label = new GenericLabel();
|
||||||
label.setWidth(1).setHeight(1); // prevent Spout's questionable new "no default size" warning
|
label.setWidth(1).setHeight(1); // prevent Spout's questionable new "no default size" warning
|
||||||
label.setScale(Conf.spoutTerritoryDisplaySize);
|
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);
|
sPlayer.getMainScreen().attachWidget(P.p, label);
|
||||||
territoryLabels.put(player.getName(), label);
|
territoryLabels.put(player.getName(), label);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user