CompassModule

Integrate with CombatLogModule
This commit is contained in:
samczsun 2016-10-06 23:51:26 -04:00
parent e8becf3819
commit 70ed2e4fbb
36 changed files with 651 additions and 484 deletions

View File

@ -8,7 +8,9 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
@ -1267,4 +1269,87 @@ public class UtilItem
}
}
public static boolean isSimilar(ItemStack a, ItemStack b, ItemAttribute... attributes)
{
for (ItemAttribute attr : attributes)
{
if (!attr.isEqual(a, b))
{
return false;
}
}
return true;
}
public enum ItemAttribute
{
MATERIAL
{
@Override
public boolean isEqual(ItemStack a, ItemStack b)
{
return a == null ? b == null : b != null && a.getType() == b.getType();
}
},
DATA
{
@Override
public boolean isEqual(ItemStack a, ItemStack b)
{
return a == null ? b == null : b != null && a.getData().getData() == b.getData().getData();
}
},
AMOUNT
{
@Override
public boolean isEqual(ItemStack a, ItemStack b)
{
return a == null ? b == null : b != null && a.getAmount() == b.getAmount();
}
},
NAME
{
@Override
public boolean isEqual(ItemStack a, ItemStack b)
{
if (a == null)
{
return b == null;
}
else
{
if (b == null)
{
return false;
}
}
ItemMeta ma = a.getItemMeta();
ItemMeta mb = b.getItemMeta();
if (ma == null)
{
return mb == null;
}
else
{
if (mb == null)
{
return false;
}
}
return Objects.equals(ma.getDisplayName(), mb.getDisplayName());
}
},
LORE
{
@Override
public boolean isEqual(ItemStack a, ItemStack b)
{
return a == null ? b == null : b != null && Objects.equals(a.getItemMeta().getLore(), b.getItemMeta().getLore());
}
};
public abstract boolean isEqual(ItemStack a, ItemStack b);
}
}

View File

@ -167,4 +167,17 @@ public class UtilServer
{
return getPlugin().getConfig().getString("serverstatus.group").equalsIgnoreCase("Lobby");
}
public static void raiseError(RuntimeException throwable)
{
if (isTestServer())
{
throw throwable;
}
else
{
System.out.println("ERROR WAS RAISED");
throwable.printStackTrace(System.out);
}
}
}

View File

@ -122,7 +122,6 @@ import mineplex.serverdata.Region;
import nautilus.game.arcade.addons.SoupAddon;
import nautilus.game.arcade.addons.TeamArmorAddon;
import nautilus.game.arcade.addons.compass.CompassAddon;
import nautilus.game.arcade.booster.GameBoosterManager;
import nautilus.game.arcade.command.CancelNextGameCommand;
import nautilus.game.arcade.command.GameCmdModeCommand;
@ -140,7 +139,6 @@ import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.GameTeam.PlayerState;
import nautilus.game.arcade.game.games.event.EventModule;
import nautilus.game.arcade.game.games.minecraftleague.MinecraftLeague;
import nautilus.game.arcade.game.games.uhc.UHC;
import nautilus.game.arcade.managers.GameAchievementManager;
import nautilus.game.arcade.managers.GameCreationManager;
import nautilus.game.arcade.managers.GameFlagManager;
@ -356,7 +354,6 @@ public class ArcadeManager extends MiniPlugin implements IRelation
new GameBoosterManager(plugin, boosterManager, hologramManager, npcManager, serverConfig.BoosterGroup);
// Game Addons
new CompassAddon(plugin, this);
new SoupAddon(plugin, this);
new TeamArmorAddon(plugin, this);

View File

@ -1,257 +0,0 @@
package nautilus.game.arcade.addons.compass;
import java.util.HashSet;
import mineplex.core.MiniPlugin;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextBottom;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.gui.spectatorMenu.SpectatorShop;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.Action;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.plugin.java.JavaPlugin;
public class CompassAddon extends MiniPlugin
{
public ArcadeManager Manager;
private SpectatorShop _spectatorShop;
public CompassAddon(JavaPlugin plugin, ArcadeManager manager)
{
super("Compass Addon", plugin);
Manager = manager;
_spectatorShop = new SpectatorShop(this, manager, manager.GetClients(), manager.GetDonation());
}
@EventHandler
public void Update(UpdateEvent event)
{
if (event.getType() != UpdateType.FASTER)
return;
if (Manager.GetGame() == null)
return;
if (!Manager.GetGame().IsLive())
return;
for (Player player : UtilServer.getPlayers())
{
if (!Manager.GetGame().CompassEnabled && Manager.GetGame().IsAlive(player))
continue;
GameTeam team = Manager.GetGame().GetTeam(player);
Player target = null;
GameTeam targetTeam = null;
double bestDist = 0;
for (Player other : Manager.GetGame().GetPlayers(true))
{
if (other.equals(player))
continue;
GameTeam otherTeam = Manager.GetGame().GetTeam(other);
//Same Team (Not Solo Game) && Alive
if (Manager.GetGame().GetTeamList().size() > 1 && (team != null && team.equals(otherTeam)) && Manager.GetGame().IsAlive(player))
continue;
double dist = UtilMath.offset(player, other);
if (target == null || dist < bestDist)
{
CompassAttemptTargetEvent tE = new CompassAttemptTargetEvent(player, other);
Bukkit.getServer().getPluginManager().callEvent(tE);
if (tE.isCancelled())
continue;
target = other;
targetTeam = otherTeam;
bestDist = dist;
}
}
if (target != null)
{
if (Manager.GetGame().CompassGiveItem || (Manager.GetGame().CompassGiveItemSpectators && Manager.isSpectator(player)))
if (!player.getInventory().contains(Material.COMPASS))
{
if (player.getOpenInventory() == null || player.getOpenInventory().getCursor() == null || player.getOpenInventory().getCursor().getType() != Material.COMPASS)
{
ItemStack stack = new ItemStack(Material.COMPASS);
ItemMeta itemMeta = stack.getItemMeta();
itemMeta.setDisplayName(C.cGreen + C.Bold + "Tracking Compass");
stack.setItemMeta(itemMeta);
player.getInventory().addItem(stack);
}
}
player.setCompassTarget(target.getLocation());
double heightDiff = target.getLocation().getY() - player.getLocation().getY();
//Action Bar
if (UtilGear.isMat(player.getItemInHand(), Material.COMPASS))
{
UtilTextBottom.display(
" " + C.cWhite + C.Bold + "Nearest Player: " + targetTeam.GetColor() + target.getName() +
" " + C.cWhite + C.Bold + "Distance: " + targetTeam.GetColor() + UtilMath.trim(1, bestDist) +
" " + C.cWhite + C.Bold + "Height: " + targetTeam.GetColor() + UtilMath.trim(1, heightDiff), player);
}
}
}
}
@EventHandler
public void DropItem(PlayerDropItemEvent event)
{
if (Manager.GetGame() == null || !Manager.GetGame().CompassEnabled)
return;
if (!UtilInv.IsItem(event.getItemDrop().getItemStack(), Material.COMPASS, (byte)0))
return;
//Cancel
event.setCancelled(true);
//Inform
UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot drop " + F.item("Target Compass") + "."));
}
@EventHandler
public void DeathRemove(PlayerDeathEvent event)
{
if (Manager.GetGame() == null || !Manager.GetGame().CompassEnabled)
return;
HashSet<org.bukkit.inventory.ItemStack> remove = new HashSet<org.bukkit.inventory.ItemStack>();
for (org.bukkit.inventory.ItemStack item : event.getDrops())
if (UtilInv.IsItem(item, Material.COMPASS, (byte)0))
remove.add(item);
for (org.bukkit.inventory.ItemStack item : remove)
event.getDrops().remove(item);
}
@EventHandler
public void SpectatorTeleport(PlayerInteractEvent event)
{
if (Manager.GetGame() == null)
return;
if (event.getAction() == Action.PHYSICAL)
return;
Player player = event.getPlayer();
if (!UtilGear.isMat(player.getItemInHand(), Material.COMPASS))
return;
if (Manager.GetGame().IsAlive(player))
return;
event.setCancelled(true);
if (event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK)
{
// Teleport to nearest player when you left click compass
if (!Recharge.Instance.use(player, "Spectate", 3000, true, false))
{
return;
}
spectateNearestPlayer(player);
}
else
{
// Right click - open spectator menu
_spectatorShop.attemptShopOpen(player);
}
}
private void spectateNearestPlayer(Player spectator)
{
GameTeam team = Manager.GetGame().GetTeam(spectator);
Player target = null;
double bestDist = 0;
for (Player other : Manager.GetGame().GetPlayers(true))
{
GameTeam otherTeam = Manager.GetGame().GetTeam(other);
//Same Team (Not Solo Game) && Alive
if (Manager.GetGame().GetTeamList().size() > 1 && (team != null && team.equals(otherTeam)) && Manager.GetGame().IsAlive(spectator))
continue;
double dist = UtilMath.offset(spectator, other);
if (target == null || dist < bestDist)
{
target = other;
bestDist = dist;
}
}
if (target != null)
{
spectator.teleport(target.getLocation().add(0, 1, 0));
}
}
@EventHandler
public void closeShop(GameStateChangeEvent event)
{
// Close shop when a game ends
if (event.GetState().equals(Game.GameState.End))
{
for (Player player : UtilServer.getPlayers())
{
if (_spectatorShop.isPlayerInShop(player))
player.closeInventory();
}
}
}
@EventHandler
public void updateShop(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC)
return;
_spectatorShop.update();
}
}

View File

@ -283,10 +283,6 @@ public abstract class Game implements Listener
public boolean DontAllowOverfill = false;
// Addons
public boolean CompassEnabled = false;
public boolean CompassGiveItem = true;
public boolean CompassGiveItemSpectators = true;
public boolean SoupEnabled = true;
public boolean TeamArmor = false;
public boolean TeamArmorHotbar = false;

View File

@ -14,6 +14,7 @@ import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.game.SoloGame;
import nautilus.game.arcade.game.games.barbarians.kits.*;
import nautilus.game.arcade.game.modules.compass.CompassModule;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.managers.chat.ChatStatData;
import nautilus.game.arcade.stats.BlockBreakStatTracker;
@ -40,7 +41,8 @@ public class Barbarians extends SoloGame
});
this.DamageTeamSelf = true;
this.CompassEnabled = true;
new CompassModule().register(this);
this.BlockBreakAllow.add(5);
this.BlockBreakAllow.add(17);

View File

@ -18,6 +18,7 @@ import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.TeamGame;
import nautilus.game.arcade.game.games.bridge.kits.*;
import nautilus.game.arcade.game.modules.compass.CompassModule;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.ore.OreHider;
import nautilus.game.arcade.ore.OreObsfucation;
@ -202,7 +203,7 @@ public class Bridge extends TeamGame implements OreObsfucation
WorldWaterDamage = 0;
WorldBoundaryKill = false;
CompassEnabled = true;
new CompassModule().register(this);
DeathDropItems = true;

View File

@ -22,6 +22,7 @@ import nautilus.game.arcade.game.GameTeam.PlayerState;
import nautilus.game.arcade.game.TeamGame;
import nautilus.game.arcade.game.games.common.dominate_data.CapturePointTDM;
import nautilus.game.arcade.game.games.common.dominate_data.Resupply;
import nautilus.game.arcade.game.modules.compass.CompassModule;
import nautilus.game.arcade.kit.Kit;
import org.bukkit.Location;
@ -63,8 +64,9 @@ public class TeamDeathmatch extends TeamGame
this.DeathOut = true;
this.HungerSet = 20;
this.WorldTimeSet = 2000;
this.CompassEnabled = true;
this.WorldTimeSet = 2000;
new CompassModule().register(this);
//this.EloRanking = true;
//this.EloSetting.setEloSetting(2);

View File

@ -20,6 +20,7 @@ import nautilus.game.arcade.game.games.deathtag.kits.KitChaser;
import nautilus.game.arcade.game.games.deathtag.kits.KitRunnerArcher;
import nautilus.game.arcade.game.games.deathtag.kits.KitRunnerBasher;
import nautilus.game.arcade.game.games.deathtag.kits.KitRunnerTraitor;
import nautilus.game.arcade.game.modules.compass.CompassModule;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.NullKit;
import nautilus.game.arcade.stats.ComeAtMeBroStatTracker;
@ -73,7 +74,7 @@ public class DeathTag extends SoloGame
this.DeathOut = false;
this.HungerSet = 20;
this.CompassEnabled = true;
new CompassModule().register(this);
this.PrepareFreeze = false;

View File

@ -29,6 +29,7 @@ import nautilus.game.arcade.game.games.evolution.kits.KitEvolveSpeed;
import nautilus.game.arcade.game.games.evolution.kits.KitHealth;
import nautilus.game.arcade.game.games.evolution.mobs.*;
import nautilus.game.arcade.game.games.evolution.trackers.*;
import nautilus.game.arcade.game.modules.compass.CompassModule;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.ProgressingKit;
import nautilus.game.arcade.stats.KillFastStatTracker;
@ -117,8 +118,9 @@ public class Evolution extends SoloGame
GemKillDeathRespawn = 2;
GemAssistDeathRespawn = .5;
CompassEnabled = true;
CompassGiveItem = false;
new CompassModule()
.setGiveCompass(false)
.register(this);
AutomaticRespawn = false;
DeathSpectateSecs = 4.0;

View File

@ -12,7 +12,7 @@ import mineplex.core.hologram.HologramManager;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.addons.compass.CompassAttemptTargetEvent;
import nautilus.game.arcade.game.modules.compass.CompassAttemptTargetEvent;
import nautilus.game.arcade.game.games.evolution.EvoKit;
import nautilus.game.arcade.game.games.evolution.Evolution;
import nautilus.game.arcade.game.games.evolution.events.EvolutionAbilityUseEvent;
@ -182,8 +182,11 @@ public class EvolveManager implements Listener
{
if (!Host.IsLive())
return;
if (isEvolving(event.getTarget()))
if (!(event.getTarget() instanceof Player))
return;
if (isEvolving((Player) event.getTarget()))
event.setCancelled(true);
}

View File

@ -61,6 +61,7 @@ import nautilus.game.arcade.game.games.gravity.objects.GravityBomb;
import nautilus.game.arcade.game.games.gravity.objects.GravityDebris;
import nautilus.game.arcade.game.games.gravity.objects.GravityHook;
import nautilus.game.arcade.game.games.gravity.objects.GravityPlayer;
import nautilus.game.arcade.game.modules.compass.CompassModule;
import nautilus.game.arcade.kit.Kit;
public class Gravity extends SoloGame
@ -112,7 +113,7 @@ public class Gravity extends SoloGame
this.WorldTimeSet = 18000;
this.CompassEnabled = true;
new CompassModule().register(this);
this.WorldBoundaryKill = false;

View File

@ -27,6 +27,7 @@ import nautilus.game.arcade.game.games.milkcow.MilkRemoveEvent.RemoveType;
import nautilus.game.arcade.game.games.milkcow.kits.KitCow;
import nautilus.game.arcade.game.games.milkcow.kits.KitFarmerJump;
import nautilus.game.arcade.game.games.milkcow.kits.KitSturdyFarmhand;
import nautilus.game.arcade.game.modules.compass.CompassModule;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.NullKit;
import net.minecraft.server.v1_8_R3.EntityCreature;
@ -92,7 +93,7 @@ public class MilkCow extends SoloGame
"First player to 15 points wins!"
});
this.CompassEnabled = true;
new CompassModule().register(this);
this.DeathOut = false;
_scoreObj = Scoreboard.getScoreboard().registerNewObjective("Milk", "dummy");

View File

@ -246,10 +246,6 @@ public class BawkBawkBattles extends TeamGame implements IThrown
TeleportsDisqualify = false;
GiveClock = false;
CompassEnabled = false;
CompassGiveItem = false;
CompassGiveItemSpectators = false;
Manager.GetCreature().SetDisableCustomDrops(true);
populateChallenges();

View File

@ -96,8 +96,6 @@ public class MonsterMaze extends SoloGame
PrepareFreeze = false;
HungerSet = 20;
CompassEnabled = false;
registerStatTrackers(
new SnowmanHitTracker(this),

View File

@ -74,6 +74,7 @@ import nautilus.game.arcade.game.games.skyfall.stats.AeronaughtStatTracker;
import nautilus.game.arcade.game.games.skyfall.stats.RingStatTracker;
import nautilus.game.arcade.game.games.survivalgames.SupplyChestOpenEvent;
import nautilus.game.arcade.game.modules.VersionModule;
import nautilus.game.arcade.game.modules.compass.CompassModule;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.stats.FirstSupplyDropOpenStatTracker;
import nautilus.game.arcade.stats.KillsWithinTimeLimitStatTracker;
@ -214,7 +215,8 @@ public class Skyfall extends SoloGame
SoupEnabled = true;
ReplaceTeamsWithKits = true;
StrictAntiHack = false;
CompassEnabled = true;
new CompassModule().register(this);
SpeedMeasurement = true;

View File

@ -85,6 +85,7 @@ import nautilus.game.arcade.game.games.skywars.kits.KitEarth;
import nautilus.game.arcade.game.games.skywars.kits.KitFire;
import nautilus.game.arcade.game.games.skywars.kits.KitIce;
import nautilus.game.arcade.game.games.skywars.kits.KitMetal;
import nautilus.game.arcade.game.modules.compass.CompassModule;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.ore.OreHider;
@ -164,7 +165,7 @@ public abstract class Skywars extends Game
HideTeamSheep = true;
CompassEnabled = true;
new CompassModule().register(this);
StrictAntiHack = true;

View File

@ -79,6 +79,7 @@ import nautilus.game.arcade.game.games.smash.kits.KitWitherSkeleton;
import nautilus.game.arcade.game.games.smash.kits.KitWolf;
import nautilus.game.arcade.game.games.smash.kits.KitZombie;
import nautilus.game.arcade.game.games.smash.perks.SmashUltimate;
import nautilus.game.arcade.game.modules.compass.CompassModule;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.Perk;
@ -120,11 +121,11 @@ public abstract class SuperSmash extends Game
super(manager, type, kits, description);
DeathOut = false;
CompassEnabled = true;
DeathSpectateSecs = 4;
WorldWaterDamage = 1000;
HideTeamSheep = true;
ReplaceTeamsWithKits = true;
new CompassModule().register(this);
}
@EventHandler(priority = EventPriority.HIGH)

View File

@ -16,6 +16,7 @@ import nautilus.game.arcade.game.*;
import nautilus.game.arcade.game.games.sneakyassassins.kits.*;
import nautilus.game.arcade.game.games.sneakyassassins.npc.*;
import nautilus.game.arcade.game.games.sneakyassassins.powerups.*;
import nautilus.game.arcade.game.modules.compass.CompassModule;
import nautilus.game.arcade.kit.*;
import nautilus.game.arcade.stats.KillEntityStatTracker;
import nautilus.game.arcade.stats.MasterAssassinStatTracker;
@ -79,9 +80,10 @@ public class SneakyAssassins extends SoloGame
this.PrepareFreeze = false;
this.HungerSet = 20;
this.CompassEnabled = true;
this.CompassGiveItem = false;
new CompassModule()
.setGiveCompass(false)
.register(this);
Manager.getCosmeticManager().setHideParticles(true);

View File

@ -30,6 +30,7 @@ import nautilus.game.arcade.game.TeamGame;
import nautilus.game.arcade.game.games.snowfight.kits.KitTactician;
import nautilus.game.arcade.game.games.snowfight.kits.KitMedic;
import nautilus.game.arcade.game.games.snowfight.kits.KitSportsman;
import nautilus.game.arcade.game.modules.compass.CompassModule;
import nautilus.game.arcade.kit.Kit;
import org.bukkit.Bukkit;
@ -84,9 +85,10 @@ public class SnowFight extends TeamGame
this.PrepareFreeze = false;
this.HungerSet = 20;
this.CompassEnabled = true;
this.CompassGiveItem = false;
new CompassModule()
.setGiveCompass(false)
.register(this);
this.TeamArmor = true;
this.TeamArmorHotbar = true;

View File

@ -17,6 +17,7 @@ import nautilus.game.arcade.GameType;
import nautilus.game.arcade.game.SoloGame;
import nautilus.game.arcade.game.games.quiver.QuiverScore;
import nautilus.game.arcade.game.games.squidshooter.kits.*;
import nautilus.game.arcade.game.modules.compass.CompassModule;
import nautilus.game.arcade.kit.Kit;
public class SquidShooter extends SoloGame
@ -46,7 +47,7 @@ public class SquidShooter extends SoloGame
this.DamageSelf = false;
this.DamageTeamSelf = true;
this.PrepareFreeze = false;
this.CompassEnabled = true;
new CompassModule().register(this);
this.KitRegisterState = GameState.Prepare;
registerChatStats();

View File

@ -187,8 +187,6 @@ public class SurvivalGamesTeams extends TeamGame
this.ItemDrop = true;
this.ItemPickup = true;
this.CompassEnabled = false; //XXX
this.InventoryClick = true;
this.InventoryOpenBlock = true;

View File

@ -121,7 +121,7 @@ public class TypeWars extends TeamGame
this.DeathSpectateSecs = 0;
this.HungerSet = 20;
this.WorldBoundaryKill = true;
this.CompassEnabled = false;
this.TeamArmor = true;
this.TeamArmorHotbar = false;
this.WorldTimeSet = 6000;

View File

@ -41,6 +41,8 @@ import nautilus.game.arcade.game.modules.SafezoneModule;
import nautilus.game.arcade.game.modules.TeamModule;
import nautilus.game.arcade.game.modules.combatlog.CombatLogModule;
import nautilus.game.arcade.game.modules.combatlog.CombatLogNPC;
import nautilus.game.arcade.game.modules.compass.CompassEntry;
import nautilus.game.arcade.game.modules.compass.CompassModule;
import nautilus.game.arcade.kit.Kit;
import net.minecraft.server.v1_8_R3.MinecraftServer;
@ -209,9 +211,6 @@ public class UHC extends TeamGame
this.SoupEnabled = false;
this.CompassEnabled = true;
this.CompassGiveItem = false;
this.WorldBoundaryKill = false;
this.GemBoosterEnabled = false;
@ -253,6 +252,9 @@ public class UHC extends TeamGame
location.getX() <= SAFE_REGION && location.getX() >= -SAFE_REGION &&
location.getZ() <= SAFE_REGION && location.getZ() >= -SAFE_REGION)
.register(this);
new CompassModule()
.setGiveCompass(false)
.register(this);
registerDebugCommand(new DebugCommand("startpvp", Rank.ADMIN)
{
@ -721,7 +723,8 @@ public class UHC extends TeamGame
this.DamagePvP = true;
this.RejoinTime = 300000; // 5 minutes
this.CompassGiveItem = true;
getModule(CompassModule.class)
.setGiveCompass(true);
new CombatLogModule()
.setSpawnForCreative(false)
.setCombatLogTime(300000)

View File

@ -122,7 +122,6 @@ public class WitherGame extends TeamGame implements IBlockRestorer
this.DeathSpectateSecs = 4;
this.HungerSet = 20;
this.WorldBoundaryKill = false;
this.CompassEnabled = false;
//Customizing for the Editor kit
this.BlockBreak = true;

View File

@ -32,6 +32,7 @@ import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.SoloGame;
import nautilus.game.arcade.game.GameTeam.PlayerState;
import nautilus.game.arcade.game.games.zombiesurvival.kits.*;
import nautilus.game.arcade.game.modules.compass.CompassModule;
import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.NullKit;
import net.minecraft.server.v1_8_R3.EntityCreature;
@ -68,8 +69,8 @@ public class ZombieSurvival extends SoloGame
this.DeathOut = false;
this.HungerSet = 20;
this.CompassEnabled = true;
new CompassModule().register(this);
registerChatStats(
Kills,

View File

@ -11,6 +11,8 @@ import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.TeamGame;
import nautilus.game.arcade.game.modules.Module;
import nautilus.game.arcade.game.modules.compass.CompassEntry;
import nautilus.game.arcade.game.modules.compass.CompassModule;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
@ -30,8 +32,10 @@ import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Objects;
import java.util.UUID;
import java.util.function.Consumer;
import java.util.stream.Collectors;
/*
* This module will spawn combat log NPCs for players who disconnect
@ -61,6 +65,8 @@ public class CombatLogModule extends Module
};
private boolean _integrateWithCompassModule = true;
private int _locationTaskId = -1;
protected void setup()
@ -72,6 +78,30 @@ public class CombatLogModule extends Module
getGame().GetLocationStore().put(npc.getPlayerInfo().getName(), npc.getNPC().getLocation());
}
}, 0L, 1L).getTaskId();
if (this._integrateWithCompassModule)
{
CompassModule compassModule = getGame().getModule(CompassModule.class);
if (compassModule != null)
{
compassModule.addSupplier(() ->
getAllNPCs()
.stream()
.map(npc -> new CompassEntry(npc.getNPC(), npc.getPlayerInfo().getName(), npc.getPlayerInfo().getName() + " (Disconnected)", npc.getPlayerInfo().getTeam(), npc.getPlayerInfo().getKit()))
.collect(Collectors.toList())
);
}
else
{
UtilServer.raiseError(new RuntimeException("CompassModule was null but integration was not disabled"));
}
}
}
public CombatLogModule disableCompassModuleIntegration()
{
this._integrateWithCompassModule = false;
return this;
}
public CombatLogModule setNotifyPlayer(boolean notifyPlayer)

View File

@ -3,6 +3,8 @@ package nautilus.game.arcade.game.modules.combatlog;
import mineplex.core.common.util.UtilInv;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.kit.Kit;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
@ -24,6 +26,7 @@ public class PlayerInfo
private List<ItemStack> _items;
private ChatColor _teamColor = ChatColor.GRAY;
private GameTeam _team;
private Kit _kit;
public PlayerInfo(Player player, ArcadeManager arcadeManager)
{
@ -35,6 +38,7 @@ public class PlayerInfo
{
_teamColor = _team.GetColor();
}
_kit = arcadeManager.GetGame().GetKit(player);
}
public String getName()
@ -66,4 +70,9 @@ public class PlayerInfo
{
return this._items;
}
public Kit getKit()
{
return this._kit;
}
}

View File

@ -1,5 +1,6 @@
package nautilus.game.arcade.addons.compass;
package nautilus.game.arcade.game.modules.compass;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
@ -9,26 +10,26 @@ public class CompassAttemptTargetEvent extends PlayerEvent implements Cancellabl
{
private static HandlerList _handlers = new HandlerList();
private boolean _cancelled = false;
private Player _target;
public CompassAttemptTargetEvent(Player player, Player target)
private Entity _target;
CompassAttemptTargetEvent(Player player, Entity target)
{
super(player);
_target = target;
}
public Player getTarget()
public Entity getTarget()
{
return _target;
}
public static HandlerList getHandlerList()
{
return _handlers;
}
@Override
public HandlerList getHandlers()
{

View File

@ -0,0 +1,49 @@
package nautilus.game.arcade.game.modules.compass;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.kit.Kit;
import org.bukkit.entity.Entity;
public class CompassEntry
{
private Entity _entity;
private String _name;
private String _displayName;
private GameTeam _team;
private Kit _kit;
public CompassEntry(Entity entity, String name, String displayName, GameTeam team, Kit kit)
{
_entity = entity;
_name = name;
_displayName = displayName;
_team = team;
_kit = kit;
}
public Entity getEntity()
{
return _entity;
}
public GameTeam getTeam()
{
return _team;
}
public String getDisplayName()
{
return _displayName;
}
public String getName()
{
return _name;
}
public Kit getKit()
{
return _kit;
}
}

View File

@ -0,0 +1,237 @@
package nautilus.game.arcade.game.modules.compass;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList;
import org.bukkit.event.block.Action;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilItem;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextBottom;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.game.modules.Module;
import nautilus.game.arcade.game.modules.compass.menu.CompassMenu;
public class CompassModule extends Module
{
private static final ItemStack COMPASS_ITEM =
new ItemBuilder(Material.COMPASS)
.setAmount(1)
.setTitle(C.cGreen + C.Bold + "Tracking Compass")
.build();
private List<Supplier<Collection<CompassEntry>>> _suppliers = new ArrayList<>();
private CompassMenu _compassMenu;
private boolean _giveCompassItem = true;
private boolean _giveCompassItemToSpectators = true;
public CompassModule addSupplier(Supplier<Collection<CompassEntry>> supplier)
{
_suppliers.add(supplier);
return this;
}
public CompassModule setGiveCompass(boolean b)
{
_giveCompassItem = b;
return this;
}
public CompassModule setGiveCompassToSpecs(boolean b)
{
_giveCompassItemToSpectators = b;
return this;
}
@Override
public void cleanup()
{
HandlerList.unregisterAll(_compassMenu);
_compassMenu = null;
_suppliers = null;
}
@Override
protected void setup()
{
_compassMenu = new CompassMenu(this);
_suppliers.add(() ->
getGame()
.GetPlayers(true)
.stream()
.map(player -> new CompassEntry(player, player.getName(), player.getName(), getGame().GetTeam(player), getGame().GetKit(player)))
.collect(Collectors.toList()));
}
@EventHandler
public void update(UpdateEvent event)
{
if (event.getType() != UpdateType.FASTER)
return;
for (Player player : UtilServer.getPlayers())
{
GameTeam team = getGame().GetTeam(player);
stream()
.filter(entry -> entry.getEntity() != player)
.filter(entry -> getGame().GetTeamList().size() <= 1 || team == null || !team.equals(entry.getTeam()))
.filter(entry -> !UtilServer.CallEvent(new CompassAttemptTargetEvent(player, entry.getEntity())).isCancelled())
.min((a, b) -> Double.compare(UtilMath.offset(player, a.getEntity()), UtilMath.offset(player, b.getEntity())))
.ifPresent(target ->
{
Entity targetEntity = target.getEntity();
GameTeam targetTeam = target.getTeam();
if (_giveCompassItem || (_giveCompassItemToSpectators && getGame().getArcadeManager().isSpectator(player)))
{
long count = UtilInv.getItems(player, true, true, true)
.stream()
.filter(this::isCompassItem)
.count();
if (count == 0)
{
player.getInventory().addItem(COMPASS_ITEM);
}
}
player.setCompassTarget(targetEntity.getLocation());
double heightDiff = targetEntity.getLocation().getY() - player.getLocation().getY();
//Action Bar
if (isCompassItem(player.getItemInHand()))
{
UtilTextBottom.display(
" " + C.cWhite + C.Bold + "Nearest Target: " + targetTeam.GetColor() + target.getDisplayName() +
" " + C.cWhite + C.Bold + "Distance: " + targetTeam.GetColor() + UtilMath.trim(1, UtilMath.offset(player, targetEntity)) +
" " + C.cWhite + C.Bold + "Height: " + targetTeam.GetColor() + UtilMath.trim(1, heightDiff), player
);
}
});
}
}
@EventHandler
public void onDrop(PlayerDropItemEvent event)
{
if (!isCompassItem(event.getItemDrop().getItemStack()))
return;
event.setCancelled(true);
UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot drop " + F.item("Target Compass") + "."));
}
@EventHandler
public void DeathRemove(PlayerDeathEvent event)
{
for (Iterator<ItemStack> it = event.getDrops().iterator(); it.hasNext(); )
{
ItemStack item = it.next();
if (isCompassItem(item))
it.remove();
}
}
@EventHandler
public void SpectatorTeleport(PlayerInteractEvent event)
{
if (event.getAction() == Action.PHYSICAL)
return;
Player player = event.getPlayer();
if (getGame().IsAlive(player))
return;
if (!isCompassItem(player.getItemInHand()))
return;
if (player.getGameMode() == GameMode.SPECTATOR)
return;
event.setCancelled(true);
if (event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK)
{
if (!Recharge.Instance.use(player, "Spectate", 3000, true, false))
{
return;
}
spectateNearestPlayer(player);
}
else
{
_compassMenu.attemptShopOpen(player);
}
}
private void spectateNearestPlayer(Player spectator)
{
stream()
.min((a, b) -> Double.compare(UtilMath.offset(spectator, a.getEntity()), UtilMath.offset(spectator, b.getEntity())))
.map(CompassEntry::getEntity)
.ifPresent(target -> spectator.teleport(target.getLocation().add(0, 1, 0)));
}
@EventHandler
public void closeShop(GameStateChangeEvent event)
{
if (event.GetState().equals(Game.GameState.End))
{
UtilServer.getPlayersCollection().stream().filter(_compassMenu::isPlayerInShop).forEach(Player::closeInventory);
}
}
@EventHandler
public void updateShop(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC)
return;
_compassMenu.update();
}
public Stream<CompassEntry> stream()
{
return _suppliers.stream().map(Supplier::get).flatMap(Collection::stream);
}
// Defined here to make modifying definitions easier
public boolean isCompassItem(ItemStack item)
{
return UtilItem.isSimilar(COMPASS_ITEM, item, UtilItem.ItemAttribute.NAME, UtilItem.ItemAttribute.MATERIAL);
}
}

View File

@ -0,0 +1,36 @@
package nautilus.game.arcade.game.modules.compass.menu;
import org.bukkit.entity.Player;
import mineplex.core.shop.ShopBase;
import mineplex.core.shop.page.ShopPageBase;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.game.modules.compass.CompassModule;
import nautilus.game.arcade.game.modules.compass.menu.page.CompassPage;
public class CompassMenu extends ShopBase<ArcadeManager>
{
private CompassModule _compassModule;
public CompassMenu(CompassModule module)
{
super(module.getGame().getArcadeManager(), module.getGame().getArcadeManager().GetClients(), module.getGame().getArcadeManager().GetDonation(), "Spectate Menu");
this._compassModule = module;
}
@Override
protected ShopPageBase<ArcadeManager, ? extends ShopBase<ArcadeManager>> buildPagesFor(Player player)
{
return new CompassPage(this, _compassModule, player);
}
public void update()
{
for (ShopPageBase<ArcadeManager, ? extends ShopBase<ArcadeManager>> shopPage : getPlayerPageMap().values())
{
shopPage.refresh();
}
}
}

View File

@ -0,0 +1,78 @@
package nautilus.game.arcade.game.modules.compass.menu.button;
import java.lang.ref.WeakReference;
import mineplex.core.common.util.F;
import mineplex.core.shop.item.IButton;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.game.modules.compass.CompassEntry;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
/**
* Created by shaun on 14-09-26.
*/
public class CompassButton implements IButton
{
private ArcadeManager _arcadeManager;
private Player _player;
private WeakReference<Entity> _target;
public CompassButton(ArcadeManager arcadeManager, Player player, CompassEntry target)
{
_arcadeManager = arcadeManager;
_player = player;
_target = new WeakReference<>(target.getEntity());
}
@Override
public void onClick(Player player, ClickType clickType)
{
// Make sure this player is still a spectator
if (!((CraftPlayer) player).getHandle().spectating)
return;
if (_target.get() == null)
{
_player.sendMessage(F.main("Spectate", "That target does not exist anymore"));
return;
}
Entity entity = _target.get();
if (entity instanceof Player)
{
if (_arcadeManager.IsAlive((Player) entity))
{
if (clickType == ClickType.RIGHT)
{
_player.closeInventory();
_arcadeManager.getGameSpectatorManager().setSpectating(_player, entity);
}
else
{
_player.teleport(entity.getLocation().add(0, 1, 0));
}
}
else
{
_player.sendMessage(F.main("Spectate", F.name(entity.getName()) + " is no longer alive."));
}
}
else
{
if (clickType == ClickType.RIGHT)
{
_player.closeInventory();
_arcadeManager.getGameSpectatorManager().setSpectating(_player, entity);
}
else
{
_player.teleport(entity.getLocation().add(0, 1, 0));
}
}
}
}

View File

@ -1,10 +1,10 @@
package nautilus.game.arcade.gui.spectatorMenu.page;
package nautilus.game.arcade.game.modules.compass.menu.page;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
import org.bukkit.ChatColor;
import org.bukkit.Material;
@ -13,39 +13,36 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.SkullMeta;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilColor;
import mineplex.core.common.util.UtilMath;
import mineplex.core.donation.DonationManager;
import mineplex.core.shop.item.IButton;
import mineplex.core.shop.item.ShopItem;
import mineplex.core.shop.page.ShopPageInventory;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.addons.compass.CompassAddon;
import nautilus.game.arcade.game.GameTeam;
import nautilus.game.arcade.gui.spectatorMenu.SpectatorShop;
import nautilus.game.arcade.gui.spectatorMenu.button.SpectatorButton;
import nautilus.game.arcade.game.modules.compass.CompassEntry;
import nautilus.game.arcade.game.modules.compass.CompassModule;
import nautilus.game.arcade.game.modules.compass.menu.CompassMenu;
import nautilus.game.arcade.game.modules.compass.menu.button.CompassButton;
/**
* Created by shaun on 14-09-24.
*/
public class SpectatorPage extends
ShopPageInventory<CompassAddon, SpectatorShop>
public class CompassPage extends
ShopPageInventory<ArcadeManager, CompassMenu>
{
private ArcadeManager _arcadeManager;
private CompassModule _compassModule;
private IButton[] _buttons;
private ItemStack[] _items;
public SpectatorPage(CompassAddon plugin, ArcadeManager arcadeManager,
SpectatorShop shop, CoreClientManager clientManager,
DonationManager donationManager, Player player)
public CompassPage(CompassMenu menu, CompassModule compassModule, Player player)
{
super(plugin, shop, clientManager, donationManager, "Spectator Menu",
super(compassModule.getGame().getArcadeManager(),
menu,
compassModule.getGame().getArcadeManager().GetClients(),
compassModule.getGame().getArcadeManager().GetDonation(),
"Spectator Menu",
player);
_arcadeManager = arcadeManager;
_compassModule = compassModule;
buildPage();
}
@ -55,43 +52,31 @@ public class SpectatorPage extends
_buttons = new IButton[54];
_items = new ItemStack[54];
List<GameTeam> teamList = new ArrayList<GameTeam>(_arcadeManager.GetGame().GetTeamList());
List<GameTeam> teamList = new ArrayList<>(_compassModule.getGame().GetTeamList());
List<CompassEntry> entries = _compassModule.stream().collect(Collectors.toList());
int playerCount = _arcadeManager.GetGame().GetPlayers(true).size();
if (teamList.size() == 1 && playerCount < 28)
if (teamList.size() == 1 && entries.size() < 28)
{
buildSingleTeam(teamList.get(0), playerCount);
buildSingleTeam(teamList.get(0), entries);
}
else
{
buildMultipleTeams(teamList, playerCount);
buildMultipleTeams(teamList, entries);
}
}
private void buildSingleTeam(GameTeam team, int playerCount)
private void buildSingleTeam(GameTeam team, List<CompassEntry> entries)
{
ArrayList<Player> players = team.GetPlayers(true);
Collections.sort(entries, (o1, o2) -> o1.getDisplayName().compareToIgnoreCase(o2.getDisplayName()));
Collections.sort(players, new Comparator<Player>()
{
@Override
public int compare(Player o1, Player o2)
{
return o1.getName().compareToIgnoreCase(o2.getName());
}
});
_buttons = new IButton[19 + players.size()];
_buttons = new IButton[19 + entries.size()];
_items = new ItemStack[_buttons.length];
_items[13] = getTeamItem(team, playerCount);
_items[13] = getTeamItem(team, entries.size());
int slot = 19;
for (Player other : players)
for (CompassEntry other : entries)
{
addPlayerItem(slot, team, other);
@ -109,26 +94,20 @@ public class SpectatorPage extends
}
}
private void buildMultipleTeams(List<GameTeam> teamList, int playerCount)
private void buildMultipleTeams(List<GameTeam> teamList, List<CompassEntry> entries)
{
Collections.sort(teamList, new Comparator<GameTeam>()
Collections.sort(teamList, (o1, o2) ->
{
int returns = o1.getDisplayName().compareToIgnoreCase(
o2.getDisplayName());
@Override
public int compare(GameTeam o1, GameTeam o2)
if (returns == 0)
{
int returns = o1.getDisplayName().compareToIgnoreCase(
o2.getDisplayName());
if (returns == 0)
{
return Long.compare(o1.getCreatedTime(),
o2.getCreatedTime());
}
return returns;
return Long.compare(o1.getCreatedTime(),
o2.getCreatedTime());
}
return returns;
});
_buttons = new IButton[0];
@ -138,16 +117,9 @@ public class SpectatorPage extends
for (GameTeam team : teamList)
{
ArrayList<Player> teamPlayers = team.GetPlayers(true);
List<CompassEntry> teamPlayers = entries.stream().filter(ent -> ent.getTeam() == team).collect(Collectors.toList());
Collections.sort(teamPlayers, new Comparator<Player>()
{
@Override
public int compare(Player o1, Player o2)
{
return o1.getName().compareToIgnoreCase(o2.getName());
}
});
Collections.sort(teamPlayers, (o1, o2) -> o1.getDisplayName().compareToIgnoreCase(o2.getDisplayName()));
int rowsNeeded = (int) Math.ceil(teamPlayers.size() / 8.0);
@ -163,7 +135,7 @@ public class SpectatorPage extends
int playerIndex = row * 8;
for (int i = 0; i < 8 && playerIndex < teamPlayers.size(); i++, playerIndex++)
{
Player other = teamPlayers.get(playerIndex);
CompassEntry other = teamPlayers.get(playerIndex);
int slot = woolSlot + 1 + i;
addPlayerItem(slot, team, other);
@ -172,7 +144,7 @@ public class SpectatorPage extends
// Add a line in between teams if the player count is low enough and
// there are less than 4 teams
if (rowsNeeded == 1 && teamList.size() < 4 && playerCount <= 26)
if (rowsNeeded == 1 && teamList.size() < 4 && entries.size() <= 26)
{
currentRow += 2;
@ -186,15 +158,15 @@ public class SpectatorPage extends
}
}
private void addPlayerItem(int slot, GameTeam team, Player other)
private void addPlayerItem(int slot, GameTeam team, CompassEntry other)
{
ItemStack playerItem = getPlayerItem(team, other);
ShopItem shopItem = new ShopItem(playerItem, other.getName(),
other.getName(), 1, false, false);
ShopItem shopItem = new ShopItem(playerItem, other.getDisplayName(),
other.getDisplayName(), 1, false, false);
_items[slot] = shopItem;
_buttons[slot] = new SpectatorButton(_arcadeManager, getPlayer(), other);
_buttons[slot] = new CompassButton(_compassModule.getGame().getArcadeManager(), getPlayer(), other);
}
private ItemStack getTeamItem(GameTeam team, int playerCount)
@ -211,18 +183,18 @@ public class SpectatorPage extends
return item;
}
private ItemStack getPlayerItem(GameTeam team, Player other)
private ItemStack getPlayerItem(GameTeam team, CompassEntry other)
{
ItemStack item = new ItemStack(Material.SKULL_ITEM, 1, (byte) 3);
double distance = UtilMath.offset(getPlayer(), other);
double heightDifference = other.getLocation().getY()
double distance = UtilMath.offset(getPlayer(), other.getEntity());
double heightDifference = other.getEntity().getLocation().getY()
- getPlayer().getLocation().getY();
ArrayList<String> lore = new ArrayList<String>();
lore.add(" ");
lore.add(ChatColor.RESET + C.cYellow + "Kit: " + C.cWhite
+ _arcadeManager.GetGame().GetKit(other).GetName());
+ other.getKit().GetName());
lore.add(ChatColor.RESET + C.cYellow + "Distance: " + C.cWhite
+ UtilMath.trim(1, distance));
lore.add(ChatColor.RESET + C.cYellow + "Height Difference: " + C.cWhite
@ -232,7 +204,7 @@ public class SpectatorPage extends
lore.add(ChatColor.YELLOW + "Right Click" + ChatColor.RESET + " Spectate");
SkullMeta skullMeta = ((SkullMeta) item.getItemMeta());
skullMeta.setOwner(other.getName());
skullMeta.setDisplayName(team.GetColor() + other.getName());
skullMeta.setDisplayName(team.GetColor() + other.getDisplayName());
skullMeta.setLore(lore);
item.setItemMeta(skullMeta);

View File

@ -1,40 +0,0 @@
package nautilus.game.arcade.gui.spectatorMenu;
import mineplex.core.account.CoreClientManager;
import mineplex.core.donation.DonationManager;
import mineplex.core.shop.ShopBase;
import mineplex.core.shop.page.ShopPageBase;
import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.addons.compass.CompassAddon;
import nautilus.game.arcade.gui.spectatorMenu.page.SpectatorPage;
import org.bukkit.entity.Player;
/**
* Created by shaun on 14-09-24.
*/
public class SpectatorShop extends ShopBase<CompassAddon>
{
private ArcadeManager _arcadeManager;
public SpectatorShop(CompassAddon plugin, ArcadeManager arcadeManager, CoreClientManager clientManager, DonationManager donationManager)
{
super(plugin, clientManager, donationManager, "Spectate Menu");
_arcadeManager = arcadeManager;
}
@Override
protected ShopPageBase<CompassAddon, ? extends ShopBase<CompassAddon>> buildPagesFor(Player player)
{
return new SpectatorPage(getPlugin(), _arcadeManager, this, getClientManager(), getDonationManager(), player);
}
public void update()
{
for (ShopPageBase<CompassAddon, ? extends ShopBase<CompassAddon>> shopPage : getPlayerPageMap().values())
{
shopPage.refresh();
}
}
}

View File

@ -1,56 +0,0 @@
package nautilus.game.arcade.gui.spectatorMenu.button;
import org.bukkit.GameMode;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTextBottom;
import mineplex.core.shop.item.IButton;
import nautilus.game.arcade.ArcadeManager;
/**
* Created by shaun on 14-09-26.
*/
public class SpectatorButton implements IButton
{
private ArcadeManager _arcadeManager;
private Player _player;
private Player _target;
public SpectatorButton(ArcadeManager arcadeManager, Player player, Player target)
{
_arcadeManager = arcadeManager;
_player = player;
_target = target;
}
@Override
public void onClick(Player player, ClickType clickType)
{
// Make sure this player is still a spectator
if (!((CraftPlayer) player).getHandle().spectating)
return;
if (_arcadeManager.IsAlive(_target))
{
if(clickType == ClickType.RIGHT)
{
_player.closeInventory();
_arcadeManager.getGameSpectatorManager().setSpectating(_player, _target);
}
else
{
_player.teleport(_target.getLocation().add(0, 1, 0));
}
}
else
{
_player.sendMessage(F.main("Spectate", F.name(_target.getName()) + " is no longer alive."));
}
}
}