Fixing a few apperance bugs and stopped updating apparance if it was the same.
This commit is contained in:
parent
2c5438bf70
commit
67e5aa8464
@ -32,7 +32,7 @@ import com.massivecraft.factions.listeners.FactionsBlockListener;
|
|||||||
import com.massivecraft.factions.listeners.FactionsChatListener;
|
import com.massivecraft.factions.listeners.FactionsChatListener;
|
||||||
import com.massivecraft.factions.listeners.FactionsEntityListener;
|
import com.massivecraft.factions.listeners.FactionsEntityListener;
|
||||||
import com.massivecraft.factions.listeners.FactionsExploitListener;
|
import com.massivecraft.factions.listeners.FactionsExploitListener;
|
||||||
import com.massivecraft.factions.listeners.FactionsHealthBarListener;
|
import com.massivecraft.factions.listeners.FactionsAppearanceListener;
|
||||||
import com.massivecraft.factions.listeners.FactionsPlayerListener;
|
import com.massivecraft.factions.listeners.FactionsPlayerListener;
|
||||||
import com.massivecraft.factions.listeners.FactionsServerListener;
|
import com.massivecraft.factions.listeners.FactionsServerListener;
|
||||||
import com.massivecraft.factions.struct.FFlag;
|
import com.massivecraft.factions.struct.FFlag;
|
||||||
@ -59,7 +59,7 @@ public class P extends MPlugin
|
|||||||
public final FactionsExploitListener exploitListener;
|
public final FactionsExploitListener exploitListener;
|
||||||
public final FactionsBlockListener blockListener;
|
public final FactionsBlockListener blockListener;
|
||||||
public final FactionsServerListener serverListener;
|
public final FactionsServerListener serverListener;
|
||||||
public final FactionsHealthBarListener healthBarListener;
|
public final FactionsAppearanceListener appearanceListener;
|
||||||
|
|
||||||
// Persistance related
|
// Persistance related
|
||||||
private boolean locked = false;
|
private boolean locked = false;
|
||||||
@ -80,7 +80,7 @@ public class P extends MPlugin
|
|||||||
this.exploitListener = new FactionsExploitListener();
|
this.exploitListener = new FactionsExploitListener();
|
||||||
this.blockListener = new FactionsBlockListener(this);
|
this.blockListener = new FactionsBlockListener(this);
|
||||||
this.serverListener = new FactionsServerListener(this);
|
this.serverListener = new FactionsServerListener(this);
|
||||||
this.healthBarListener = new FactionsHealthBarListener(this);
|
this.appearanceListener = new FactionsAppearanceListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -117,12 +117,13 @@ public class P extends MPlugin
|
|||||||
startAutoLeaveTask(false);
|
startAutoLeaveTask(false);
|
||||||
|
|
||||||
// Register Event Handlers
|
// Register Event Handlers
|
||||||
getServer().getPluginManager().registerEvents(playerListener, this);
|
getServer().getPluginManager().registerEvents(this.playerListener, this);
|
||||||
getServer().getPluginManager().registerEvents(chatListener, this);
|
getServer().getPluginManager().registerEvents(this.chatListener, this);
|
||||||
getServer().getPluginManager().registerEvents(entityListener, this);
|
getServer().getPluginManager().registerEvents(this.entityListener, this);
|
||||||
getServer().getPluginManager().registerEvents(exploitListener, this);
|
getServer().getPluginManager().registerEvents(this.exploitListener, this);
|
||||||
getServer().getPluginManager().registerEvents(blockListener, this);
|
getServer().getPluginManager().registerEvents(this.blockListener, this);
|
||||||
getServer().getPluginManager().registerEvents(serverListener, this);
|
getServer().getPluginManager().registerEvents(this.serverListener, this);
|
||||||
|
getServer().getPluginManager().registerEvents(this.appearanceListener, this);
|
||||||
|
|
||||||
// since some other plugins execute commands directly through this command interface, provide it
|
// since some other plugins execute commands directly through this command interface, provide it
|
||||||
this.getCommand(this.refCommand).setExecutor(this);
|
this.getCommand(this.refCommand).setExecutor(this);
|
||||||
|
@ -94,6 +94,7 @@ public abstract class FRelationCommand extends FCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
SpoutFeatures.updateTitle(myFaction, them);
|
SpoutFeatures.updateTitle(myFaction, them);
|
||||||
|
SpoutFeatures.updateTitle(them, myFaction);
|
||||||
SpoutFeatures.updateTerritoryDisplayLoc(null);
|
SpoutFeatures.updateTerritoryDisplayLoc(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ public class SpoutFeatures
|
|||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// Capes look the same to everyone.
|
// Capes look the same to everyone.
|
||||||
|
|
||||||
public static void updateCape(final Object ofrom, final Object oto)
|
public static void updateCape(final Object ofrom, final Object oto, boolean onlyIfDifferent)
|
||||||
{
|
{
|
||||||
// Enabled and non-null?
|
// Enabled and non-null?
|
||||||
if ( ! isEnabled()) return;
|
if ( ! isEnabled()) return;
|
||||||
@ -78,31 +78,38 @@ public class SpoutFeatures
|
|||||||
Faction faction = fplayer.getFaction();
|
Faction faction = fplayer.getFaction();
|
||||||
|
|
||||||
String cape = faction.getCape();
|
String cape = faction.getCape();
|
||||||
|
if (cape == null)
|
||||||
|
{
|
||||||
|
cape = "http://s3.amazonaws.com/MinecraftCloaks/" + player.getName() + ".png";
|
||||||
|
}
|
||||||
|
|
||||||
for (Player playerTo : toPlayers)
|
for (Player playerTo : toPlayers)
|
||||||
{
|
{
|
||||||
SpoutPlayer splayerTo = SpoutManager.getPlayer(playerTo);
|
SpoutPlayer splayerTo = SpoutManager.getPlayer(playerTo);
|
||||||
|
|
||||||
// Set the cape
|
boolean skip = onlyIfDifferent && cape.equals(splayer.getCape(splayerTo));
|
||||||
if (cape != null)
|
//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;
|
||||||
try
|
//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));
|
||||||
{
|
|
||||||
splayer.setCapeFor(splayerTo, cape);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
// Set the cape
|
||||||
}
|
try
|
||||||
else
|
|
||||||
{
|
{
|
||||||
splayer.resetCapeFor(splayerTo);
|
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)
|
public static void updateCapeShortly(final Object ofrom, final Object oto)
|
||||||
{
|
{
|
||||||
P.p.getServer().getScheduler().scheduleSyncDelayedTask(P.p, new Runnable()
|
P.p.getServer().getScheduler().scheduleSyncDelayedTask(P.p, new Runnable()
|
||||||
@ -110,16 +117,16 @@ public class SpoutFeatures
|
|||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
updateCape(ofrom, oto);
|
updateCape(ofrom, oto, false);
|
||||||
}
|
}
|
||||||
}, 10);
|
}, 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// TITLE
|
// TITLE
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
public static void updateTitle(final Object ofrom, final Object oto)
|
public static void updateTitle(final Object ofrom, final Object oto, boolean onlyIfDifferent)
|
||||||
{
|
{
|
||||||
// Enabled and non-null?
|
// Enabled and non-null?
|
||||||
if ( ! isEnabled()) return;
|
if ( ! isEnabled()) return;
|
||||||
@ -143,11 +150,22 @@ public class SpoutFeatures
|
|||||||
ChatColor relationColor = faction.getRelationTo(factionTo).getColor();
|
ChatColor relationColor = faction.getRelationTo(factionTo).getColor();
|
||||||
|
|
||||||
String title = generateTitle(player, fplayer, faction, relationColor);
|
String title = generateTitle(player, fplayer, 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);
|
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)
|
public static void updateTitleShortly(final Object ofrom, final Object oto)
|
||||||
{
|
{
|
||||||
P.p.getServer().getScheduler().scheduleSyncDelayedTask(P.p, new Runnable()
|
P.p.getServer().getScheduler().scheduleSyncDelayedTask(P.p, new Runnable()
|
||||||
@ -155,9 +173,9 @@ public class SpoutFeatures
|
|||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
updateTitle(ofrom, oto);
|
updateTitle(ofrom, oto, false);
|
||||||
}
|
}
|
||||||
}, 10);
|
}, 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String generateTitle(Player player, FPlayer fplayer, Faction faction, ChatColor relationColor)
|
public static String generateTitle(Player player, FPlayer fplayer, Faction faction, ChatColor relationColor)
|
||||||
@ -171,7 +189,7 @@ public class SpoutFeatures
|
|||||||
String addTag = "";
|
String addTag = "";
|
||||||
if (Conf.spoutFactionTagsOverNames)
|
if (Conf.spoutFactionTagsOverNames)
|
||||||
{
|
{
|
||||||
addTag += relationColor.toString() + "[" + fplayer.getRole().getPrefix() + faction.getTag() + "]";
|
addTag += relationColor.toString() + fplayer.getRole().getPrefix() + faction.getTag();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Conf.spoutFactionTitlesOverNames && ! fplayer.getTitle().isEmpty())
|
if (Conf.spoutFactionTitlesOverNames && ! fplayer.getTitle().isEmpty())
|
||||||
@ -204,7 +222,12 @@ public class SpoutFeatures
|
|||||||
}
|
}
|
||||||
else if (o instanceof FPlayer)
|
else if (o instanceof FPlayer)
|
||||||
{
|
{
|
||||||
ret.add(((FPlayer)o).getPlayer());
|
FPlayer fplayer = (FPlayer)o;
|
||||||
|
Player player = fplayer.getPlayer();
|
||||||
|
if (player != null)
|
||||||
|
{
|
||||||
|
ret.add(player);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (o instanceof Faction)
|
else if (o instanceof Faction)
|
||||||
{
|
{
|
||||||
|
@ -0,0 +1,88 @@
|
|||||||
|
package com.massivecraft.factions.listeners;
|
||||||
|
|
||||||
|
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 com.massivecraft.factions.Conf;
|
||||||
|
import com.massivecraft.factions.P;
|
||||||
|
import com.massivecraft.factions.integration.SpoutFeatures;
|
||||||
|
|
||||||
|
|
||||||
|
public class FactionsAppearanceListener implements Listener
|
||||||
|
{
|
||||||
|
public P p;
|
||||||
|
public FactionsAppearanceListener(P p)
|
||||||
|
{
|
||||||
|
this.p = p;
|
||||||
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// FULL TWO-WAYS
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
public void fullTwoWay(Player player)
|
||||||
|
{
|
||||||
|
SpoutFeatures.updateTitleShortly(player, null);
|
||||||
|
SpoutFeatures.updateTitleShortly(null, player);
|
||||||
|
SpoutFeatures.updateCapeShortly(player, null);
|
||||||
|
SpoutFeatures.updateCapeShortly(null, player);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
|
public void onPlayerJoin(PlayerJoinEvent event)
|
||||||
|
{
|
||||||
|
fullTwoWay(event.getPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
|
public void onPlayerTeleport(PlayerTeleportEvent event)
|
||||||
|
{
|
||||||
|
if (event.getFrom().getWorld().equals(event.getTo().getWorld())) return;
|
||||||
|
fullTwoWay(event.getPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
|
public void onPlayerRespawn(PlayerRespawnEvent event)
|
||||||
|
{
|
||||||
|
fullTwoWay(event.getPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// HEALTH BAR
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
public static void possiblyUpdateHealthBar(Entity entity)
|
||||||
|
{
|
||||||
|
if ( ! Conf.spoutHealthBarUnderNames) return;
|
||||||
|
if ( ! (entity instanceof Player)) return;
|
||||||
|
Player player = (Player)entity;
|
||||||
|
SpoutFeatures.updateTitle(player, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
|
public void monitorEntityDamageEvent(EntityDamageEvent event)
|
||||||
|
{
|
||||||
|
possiblyUpdateHealthBar(event.getEntity());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
|
public void monitorEntityRegainHealthEvent(EntityRegainHealthEvent event)
|
||||||
|
{
|
||||||
|
possiblyUpdateHealthBar(event.getEntity());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
|
public void monitorPlayerRespawnEvent(PlayerRespawnEvent event)
|
||||||
|
{
|
||||||
|
possiblyUpdateHealthBar(event.getPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,57 +0,0 @@
|
|||||||
package com.massivecraft.factions.listeners;
|
|
||||||
|
|
||||||
import org.bukkit.entity.Entity;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.Cancellable;
|
|
||||||
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.PlayerRespawnEvent;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.Conf;
|
|
||||||
import com.massivecraft.factions.P;
|
|
||||||
import com.massivecraft.factions.integration.SpoutFeatures;
|
|
||||||
|
|
||||||
|
|
||||||
public class FactionsHealthBarListener implements Listener
|
|
||||||
{
|
|
||||||
public P p;
|
|
||||||
public FactionsHealthBarListener(P p)
|
|
||||||
{
|
|
||||||
this.p = p;
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// HEALTH BAR
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
public static void possiblyUpdateHealthBar(Entity entity, Cancellable event)
|
|
||||||
{
|
|
||||||
if (event != null && event.isCancelled()) return;
|
|
||||||
if ( ! Conf.spoutHealthBarUnderNames) return;
|
|
||||||
if ( ! (entity instanceof Player)) return;
|
|
||||||
Player player = (Player)entity;
|
|
||||||
SpoutFeatures.updateTitle(player, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
|
||||||
public void monitorEntityDamageEvent(EntityDamageEvent event)
|
|
||||||
{
|
|
||||||
possiblyUpdateHealthBar(event.getEntity(), event);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
|
||||||
public void monitorEntityRegainHealthEvent(EntityRegainHealthEvent event)
|
|
||||||
{
|
|
||||||
possiblyUpdateHealthBar(event.getEntity(), event);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
|
||||||
public void monitorPlayerRespawnEvent(PlayerRespawnEvent event)
|
|
||||||
{
|
|
||||||
possiblyUpdateHealthBar(event.getPlayer(), null);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -52,11 +52,6 @@ public class FactionsPlayerListener implements Listener
|
|||||||
|
|
||||||
// Update the lastLoginTime for this fplayer
|
// Update the lastLoginTime for this fplayer
|
||||||
me.setLastLoginTime(System.currentTimeMillis());
|
me.setLastLoginTime(System.currentTimeMillis());
|
||||||
|
|
||||||
SpoutFeatures.updateTitleShortly(event.getPlayer(), null);
|
|
||||||
SpoutFeatures.updateTitleShortly(null, event.getPlayer());
|
|
||||||
SpoutFeatures.updateCapeShortly(event.getPlayer(), null);
|
|
||||||
SpoutFeatures.updateCapeShortly(null, event.getPlayer());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
|
Loading…
Reference in New Issue
Block a user