Converted spec away from CREATIVE

This commit is contained in:
Cheese 2015-03-12 15:31:40 +11:00
parent bf901b2280
commit 3ceb0ff678
60 changed files with 2560 additions and 2527 deletions

View File

@ -381,7 +381,7 @@ public class UtilEnt
for (Entity cur : loc.getWorld().getEntities())
{
if (!(cur instanceof LivingEntity) || (cur instanceof Player && ((Player)cur).getGameMode() == GameMode.CREATIVE))
if (!(cur instanceof LivingEntity) || UtilPlayer.isSpectator(cur))
continue;
LivingEntity ent = (LivingEntity)cur;

View File

@ -123,7 +123,7 @@ public class UtilPlayer
for (Entity entity : p.getNearbyEntities(range, range, range))
{
if (entity == p || (entity instanceof Player && ((Player) entity).getGameMode() == GameMode.CREATIVE))
if (entity == p || UtilPlayer.isSpectator(entity))
continue;
double theirDist = p.getEyeLocation().distance(entity.getLocation());
@ -164,7 +164,7 @@ public class UtilPlayer
for (Entity entity : player.getNearbyEntities(rangeToScan, rangeToScan, rangeToScan))
{
if (entity == player || (entity instanceof Player && ((Player) entity).getGameMode() == GameMode.CREATIVE))
if (entity == player || UtilPlayer.isSpectator(entity))
continue;
if (avoidNonLiving && !(entity instanceof LivingEntity))
@ -393,7 +393,7 @@ public class UtilPlayer
for (Player cur : loc.getWorld().getPlayers())
{
if (cur.getGameMode() == GameMode.CREATIVE)
if (UtilPlayer.isSpectator(cur))
continue;
if (cur.isDead())
@ -427,7 +427,7 @@ public class UtilPlayer
for (Player cur : loc.getWorld().getPlayers())
{
if (cur.getGameMode() == GameMode.CREATIVE)
if (UtilPlayer.isSpectator(cur))
continue;
if (cur.isDead())
@ -455,7 +455,7 @@ public class UtilPlayer
for (Player cur : loc.getWorld().getPlayers())
{
if (cur.getGameMode() == GameMode.CREATIVE)
if (UtilPlayer.isSpectator(cur))
continue;
if (cur.isDead())
@ -500,7 +500,7 @@ public class UtilPlayer
for (Player cur : loc.getWorld().getPlayers())
{
if (cur.getGameMode() == GameMode.CREATIVE)
if (UtilPlayer.isSpectator(cur))
continue;
double offset = UtilMath.offset(loc, cur.getLocation());
@ -575,6 +575,13 @@ public class UtilPlayer
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
}
public static boolean isSpectator(Entity player)
{
if (player instanceof Player)
return ((CraftPlayer) player).getHandle().spectating;
return false;
}
/*
public void setListName(Player player, CoreClient client)
{

View File

@ -192,7 +192,7 @@ public class AntiHack extends MiniPlugin
if (player.equals(other))
continue;
if (other.getGameMode() != GameMode.SURVIVAL)
if (other.getGameMode() != GameMode.SURVIVAL || UtilPlayer.isSpectator(player))
continue;
if (other.getVehicle() != null)
@ -202,7 +202,7 @@ public class AntiHack extends MiniPlugin
return true;
}
if (player.isFlying() || player.isInsideVehicle() || player.getGameMode() != GameMode.SURVIVAL)
if (player.isFlying() || player.isInsideVehicle() || player.getGameMode() != GameMode.SURVIVAL || UtilPlayer.isSpectator(player))
{
return true;
}

View File

@ -8,6 +8,7 @@ import mineplex.core.antihack.AntiHack;
import mineplex.core.antihack.Detector;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
@ -44,7 +45,7 @@ public class Reach extends MiniPlugin implements Detector
for (Player player : UtilServer.getPlayers())
{
if (player.getGameMode() != GameMode.SURVIVAL)
if (player.getGameMode() != GameMode.SURVIVAL || UtilPlayer.isSpectator(player))
continue;
if (!_history.containsKey(player))

View File

@ -160,7 +160,7 @@ public class MorphWither extends MorphGadget
for (Player player : GetActive())
{
if (player.getGameMode() == GameMode.CREATIVE)
if (UtilPlayer.isSpectator(player))
continue;
player.setAllowFlight(true);

View File

@ -63,7 +63,7 @@ public class ParticleHeart extends ParticleGadget {
if (other.equals(player))
continue;
if (other.getGameMode() != GameMode.SURVIVAL)
if (!UtilPlayer.isSpectator(other))
continue;
if (_target.get(player).containsKey(other))

View File

@ -34,7 +34,7 @@ public abstract class ParticleGadget extends Gadget
public boolean shouldDisplay(Player player)
{
if (player.getGameMode() != GameMode.SURVIVAL)
if (UtilPlayer.isSpectator(player))
return false;
if (Manager.hideParticles())

View File

@ -4,6 +4,7 @@ import mineplex.core.updater.event.UpdateEvent;
import mineplex.core.updater.UpdateType;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.disguise.DisguiseManager;
import mineplex.core.disguise.disguises.DisguiseSquid;
@ -133,8 +134,9 @@ public class ProjectileUser
if (ent.equals(_thrower))
continue;
//Creative or Spec
if (ent instanceof Player)
if (((Player)ent).getGameMode() == GameMode.CREATIVE)
if (((Player)ent).getGameMode() == GameMode.CREATIVE || UtilPlayer.isSpectator(ent))
continue;
EntityType disguise = null;

View File

@ -150,7 +150,7 @@ public class DwarfToss extends SkillActive
if (target instanceof Player)
{
if (((Player)target).getGameMode() != GameMode.SURVIVAL)
if (UtilPlayer.isSpectator(target))
{
UtilPlayer.message(player, F.main(GetClassType().name(), F.name(((Player)target).getName()) + " is not attackable."));
return;

View File

@ -116,7 +116,7 @@ public class Takedown extends SkillActive
for (Player player : GetUsers())
if (_live.containsKey(player))
for (Player other : player.getWorld().getPlayers())
if (other.getGameMode() == GameMode.SURVIVAL)
if (!UtilPlayer.isSpectator(other))
if (!other.equals(player))
if (Factory.Relation().canHurt(player, other))
if (UtilMath.offset(player, other) < 2)

View File

@ -103,7 +103,7 @@ public class Taunt extends SkillActive
for (Player player : GetUsers())
if (_live.containsKey(player))
for (Player other : player.getWorld().getPlayers())
if (other.getGameMode() == GameMode.SURVIVAL)
if (!UtilPlayer.isSpectator(other))
if (!other.equals(player))
if (Factory.Relation().canHurt(player, other))
if (UtilMath.offset(player, other) < 7 && UtilMath.offset(player, other) > 2)

View File

@ -188,7 +188,7 @@ public class ArcticArmor extends Skill
for (Player cur : UtilServer.getPlayers())
{
if (cur.getGameMode() != GameMode.SURVIVAL)
if (UtilPlayer.isSpectator(cur))
continue;
if (cur.getEyeLocation().getBlock().getType() == Material.ICE)

View File

@ -102,7 +102,7 @@ public class WolfsPounce extends SkillChargeSword
for (Player other : player.getWorld().getPlayers())
{
if (other.getGameMode() != GameMode.SURVIVAL)
if (UtilPlayer.isSpectator(other))
continue;
if (other.equals(player))

View File

@ -90,7 +90,7 @@ public class ProximityExplosive extends ItemUsable
@EventHandler(priority = EventPriority.LOW)
public void Pickup(PlayerPickupItemEvent event)
{
if (event.getPlayer().getGameMode() != GameMode.SURVIVAL)
if (UtilPlayer.isSpectator(event.getPlayer()))
return;
if (((CraftPlayer)event.getPlayer()).getHandle().spectating)

View File

@ -87,7 +87,7 @@ public class ProximityZapper extends ItemUsable
@EventHandler(priority = EventPriority.LOW)
public void Pickup(PlayerPickupItemEvent event)
{
if (event.getPlayer().getGameMode() != GameMode.SURVIVAL)
if (UtilPlayer.isSpectator(event.getPlayer()))
return;
if (((CraftPlayer)event.getPlayer()).getHandle().spectating)

View File

@ -182,6 +182,12 @@ public class DamageManager extends MiniPlugin
event.SetCancelled("Damagee in Creative");
return;
}
if (UtilPlayer.isSpectator(damagee))
{
event.SetCancelled("Damagee in Spectator");
return;
}
//Limit Mob/World Damage Rate
if (!event.IgnoreRate())

View File

@ -11,6 +11,7 @@ import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -27,6 +28,7 @@ import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.server.ServerListPingEvent;
import org.bukkit.util.Vector;
import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager;
@ -1182,4 +1184,35 @@ public class ArcadeManager extends MiniPlugin implements IRelation
{
return _partyManager;
}
public void addSpectator(Player player, boolean teleport)
{
if (GetGame() == null)
return;
Clear(player);
if (teleport)
player.teleport(GetGame().GetSpectatorLocation());
//Set Spec State
player.setVelocity(new Vector(0,1,0));
player.setAllowFlight(true);
player.setFlying(true);
player.setFlySpeed(0.1f);
((CraftPlayer) player).getHandle().spectating = true;
((CraftPlayer) player).getHandle().k = false;
GetCondition().Factory().Cloak("Spectator", player, player, 7777, true, true);
//Game Team
GetGame().GetScoreboard().SetPlayerTeam(player, "SPEC");
}
public boolean isSpectator(Entity player)
{
if (player instanceof Player)
return UtilPlayer.isSpectator((Player)player);
return false;
}
}

View File

@ -44,7 +44,6 @@ import nautilus.game.arcade.game.games.spleef.Spleef;
import nautilus.game.arcade.game.games.spleef.SpleefTeams;
import nautilus.game.arcade.game.games.squidshooter.SquidShooter;
import nautilus.game.arcade.game.games.stacker.Stacker;
import nautilus.game.arcade.game.games.survivalgames.SurvivalGames;
import nautilus.game.arcade.game.games.survivalgames.SurvivalGamesTeams;
import nautilus.game.arcade.game.games.paintball.Paintball;
import nautilus.game.arcade.game.games.tug.Tug;
@ -104,7 +103,7 @@ public class GameFactory
else if (gameType == GameType.SpleefTeams) return new SpleefTeams(_manager);
else if (gameType == GameType.SquidShooter) return new SquidShooter(_manager);
else if (gameType == GameType.Stacker) return new Stacker(_manager);
else if (gameType == GameType.SurvivalGames) return new SurvivalGames(_manager);
//else if (gameType == GameType.SurvivalGames) return new SurvivalGames(_manager);
else if (gameType == GameType.SurvivalGamesTeams) return new SurvivalGamesTeams(_manager);
else if (gameType == GameType.Tug) return new Tug(_manager);
else if (gameType == GameType.TurfWars) return new TurfForts(_manager);

View File

@ -95,7 +95,7 @@ public class CompassAddon extends MiniPlugin
if (target != null)
{
if (Manager.GetGame().CompassGiveItem || player.getGameMode() != GameMode.SURVIVAL)
if (Manager.GetGame().CompassGiveItem || Manager.isSpectator(player))
if (!player.getInventory().contains(Material.COMPASS))
{
if (player.getOpenInventory() == null || player.getOpenInventory().getCursor() == null || player.getOpenInventory().getCursor().getType() != Material.COMPASS)
@ -198,7 +198,7 @@ public class CompassAddon extends MiniPlugin
event.setCancelled(true);
if (event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK || !Manager.GetGame().CompassSpectatorMenu)
if (event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK)
{
// Teleport to nearest player when you left click compass
@ -274,7 +274,7 @@ public class CompassAddon extends MiniPlugin
@EventHandler(priority = EventPriority.HIGH)
public void onInventoryClick(InventoryClickEvent event)
{
if (event.getClickedInventory() != null && event.getWhoClicked() != null && event.getWhoClicked().getGameMode() == GameMode.CREATIVE && event.getClickedInventory().getTitle().equals("Spectator Menu"))
if (event.getClickedInventory() != null && event.getWhoClicked() != null && Manager.isSpectator(event.getWhoClicked()) && event.getClickedInventory().getTitle().equals("Spectator Menu"))
{
event.setCancelled(false);
}

View File

@ -235,7 +235,6 @@ public abstract class Game implements Listener
//Addons
public boolean CompassEnabled = false;
public boolean CompassGiveItem = true;
public boolean CompassSpectatorMenu = true;
public boolean SoupEnabled = true;
public boolean TeamArmor = false;
@ -851,24 +850,6 @@ public abstract class Game implements Listener
return SpectatorSpawn;
}
public void SetSpectator(Player player, boolean teleport)
{
Manager.Clear(player);
if (teleport)
player.teleport(GetSpectatorLocation());
player.setGameMode(GameMode.CREATIVE);
player.setFlying(true);
player.setFlySpeed(0.1f);
((CraftPlayer) player).getHandle().spectating = true;
((CraftPlayer) player).getHandle().k = false;
Manager.GetCondition().Factory().Cloak("Spectator", player, player, 7777, true, true);
Scoreboard.SetPlayerTeam(player, "SPEC");
}
@EventHandler
public void eloStart(PlayerLoginEvent event)
{

View File

@ -143,8 +143,6 @@ public class Bridge extends TeamGame implements OreObsfucation
"Special loot is located in the center.",
"The last team alive wins!"
});
this.CompassSpectatorMenu = false;
_ore = new OreHider();

View File

@ -195,8 +195,6 @@ public class CastleSiege extends TeamGame
this.WorldTimeSet = 14000; //14000
this.BlockPlaceAllow.add(85);
this.CompassSpectatorMenu = false;
_kingName = C.cYellow + C.Bold + "King Sparklez";
GameTeam notRedTeam = null;

View File

@ -131,7 +131,7 @@ public class CapturePoint
{
for (Player player : team.GetPlayers(true))
{
if (player.getGameMode() != GameMode.SURVIVAL)
if (Host.Manager.isSpectator(player))
continue;
if (Math.abs(_loc.getX() - player.getLocation().getX()) > 2.5)

View File

@ -106,7 +106,7 @@ public class CapturePointTDM
{
for (Player player : team.GetPlayers(true))
{
if (player.getGameMode() != GameMode.SURVIVAL)
if (Host.Manager.isSpectator(player))
continue;
if (Math.abs(_loc.getX() - player.getLocation().getX()) > 2.5)

View File

@ -77,7 +77,7 @@ public class Emerald
if (!Host.IsAlive(player))
return;
if (player.getGameMode() != GameMode.SURVIVAL)
if (Host.Manager.isSpectator(player))
return;
GameTeam team = Host.GetTeam(player);

View File

@ -77,7 +77,7 @@ public class Resupply
if (!Host.IsAlive(player))
return;
if (player.getGameMode() != GameMode.SURVIVAL)
if (Host.Manager.isSpectator(player))
return;
GameTeam team = Host.GetTeam(player);

View File

@ -260,8 +260,6 @@ public class MineStrike extends TeamGame
this.InventoryClick = true;
this.JoinInProgress = true;
this.CompassSpectatorMenu = false;
_scoreObj = Scoreboard.GetScoreboard().registerNewObjective("HP", "dummy");
_scoreObj.setDisplaySlot(DisplaySlot.BELOW_NAME);
@ -2665,23 +2663,6 @@ public class MineStrike extends TeamGame
event.AddMod(this.GetName(), "Fire", 3, false);
}
@Override
public void SetSpectator(Player player, boolean teleport)
{
Manager.Clear(player);
player.setVelocity(new Vector(0,1,0));
player.setGameMode(GameMode.CREATIVE);
player.setFlying(true);
player.setFlySpeed(0.1f);
((CraftPlayer)player).getHandle().spectating = true;
((CraftPlayer)player).getHandle().k = false;
Manager.GetCondition().Factory().Cloak("Spectator", player, player, 7777, true, true);
Scoreboard.SetPlayerTeam(player, "SPEC");
}
@EventHandler
public void teleportCancel(PlayerTeleportEvent event)
{

View File

@ -309,12 +309,12 @@ public class ShopManager
}
//Leave Shop
if (_inShop.contains(player) && (!nearShop || !isBuyTime()) || player.getGameMode() != GameMode.SURVIVAL)
if (_inShop.contains(player) && (!nearShop || !isBuyTime()) || Host.Manager.isSpectator(player))
{
leaveShop(player, true, false);
}
//Enter Shop
else if (!_inShop.contains(player) && (nearShop && isBuyTime()) && player.getGameMode() == GameMode.SURVIVAL)
else if (!_inShop.contains(player) && (nearShop && isBuyTime()) && !Host.Manager.isSpectator(player))
{
enterShop(player);
}

View File

@ -318,7 +318,7 @@ public class Paintball extends TeamGame
Manager.GetCondition().Factory().Cloak("Hit", player, player, 9999, false, false);
//Settings
player.setGameMode(GameMode.CREATIVE);
player.setAllowFlight(true);
player.setFlying(true);
((CraftPlayer)player).getHandle().spectating = true;
((CraftPlayer)player).getHandle().k = false;
@ -429,7 +429,7 @@ public class Paintball extends TeamGame
}
//Settings
player.setGameMode(GameMode.SURVIVAL);
player.setAllowFlight(false);
player.setFlying(false);
((CraftPlayer)player).getHandle().spectating = false;
((CraftPlayer)player).getHandle().k = true;

View File

@ -200,7 +200,7 @@ public class SearchAndDestroy extends TeamGame
true, "Bomb", "Bomb");
if (IsAlive(player))
{
this.SetSpectator(player, true);
Manager.addSpectator(player, true);
}
}
}

View File

@ -284,7 +284,7 @@ public class SheepGame extends TeamGame
if (player.getItemInHand() != null && player.getItemInHand().getType() != Material.SADDLE)
return true;
if (player.getGameMode() != GameMode.SURVIVAL)
if (Manager.isSpectator(player))
return true;
if (!IsAlive(player))
@ -373,7 +373,7 @@ public class SheepGame extends TeamGame
if (player.getItemInHand() != null && player.getItemInHand().getType() != Material.SADDLE)
return;
if (event.getPlayer().getGameMode() != GameMode.SURVIVAL)
if (Manager.isSpectator(event.getPlayer()))
return;
if (!IsAlive(event.getPlayer()))

View File

@ -181,7 +181,7 @@ public class KitSlime extends SmashKit
if (player.equals(other))
continue;
if (other.getGameMode() != GameMode.SURVIVAL)
if (Manager.isSpectator(other))
continue;
if (UtilMath.offset(player.getLocation().add(0, 3, 0), other.getLocation()) < 5)

View File

@ -160,9 +160,6 @@ public class UHC extends TeamGame
this.GemDoubleEnabled = false;
this.GemHunterEnabled = false;
// TODO design a better way to handle spectator gui for UHC
this.CompassSpectatorMenu = false;
WorldTimeSet = -1;
CraftRecipes();

View File

@ -528,7 +528,7 @@ public class WitherGame extends TeamGame implements IBlockRestorer
Manager.GetCondition().Factory().Cloak("Hit", player, player, 9999, false, false);
//Settings
player.setGameMode(GameMode.CREATIVE);
player.setAllowFlight(true);
player.setFlying(true);
((CraftPlayer)player).getHandle().spectating = true;
((CraftPlayer)player).getHandle().k = false;
@ -555,7 +555,7 @@ public class WitherGame extends TeamGame implements IBlockRestorer
}
//Settings
player.setGameMode(GameMode.SURVIVAL);
player.setAllowFlight(false);
player.setFlying(false);
((CraftPlayer)player).getHandle().spectating = false;
((CraftPlayer)player).getHandle().k = true;

View File

@ -3,6 +3,7 @@ package nautilus.game.arcade.game.games.wizards.spells;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilPlayer;
import nautilus.game.arcade.game.games.wizards.Spell;
import nautilus.game.arcade.game.games.wizards.spellinterfaces.SpellClick;
@ -38,7 +39,7 @@ public class SpellMagicMissile extends Spell implements SpellClick
{
if (cur == player || !(cur instanceof LivingEntity)
|| (cur instanceof Player && ((Player) cur).getGameMode() == GameMode.CREATIVE))
|| (cur instanceof Player && UtilPlayer.isSpectator(cur)))
continue;
LivingEntity entity = (LivingEntity) cur;
@ -125,7 +126,7 @@ public class SpellMagicMissile extends Spell implements SpellClick
{
if (cur == player || !(cur instanceof LivingEntity)
|| (cur instanceof Player && ((Player) cur).getGameMode() == GameMode.CREATIVE))
|| (cur instanceof Player && UtilPlayer.isSpectator(cur)))
continue;
LivingEntity ent = (LivingEntity) cur;

View File

@ -6,6 +6,7 @@ import java.util.List;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilShapes;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
@ -36,7 +37,7 @@ public class SpellTrapRune extends Spell implements SpellClick
while (itel.hasNext())
{
TrapRune rune = itel.next();
if (!rune.RuneCaster.isOnline() || rune.RuneCaster.getGameMode() == GameMode.CREATIVE)
if (!rune.RuneCaster.isOnline() || UtilPlayer.isSpectator(rune.RuneCaster))
{
itel.remove();
}

View File

@ -4,6 +4,7 @@ import java.util.ArrayList;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilShapes;
@ -31,7 +32,7 @@ public class HealingRune
{
for (Player player : Bukkit.getOnlinePlayers())
{
if (player.getGameMode() == GameMode.CREATIVE)
if (UtilPlayer.isSpectator(player))
{
continue;
}

View File

@ -4,6 +4,7 @@ import java.util.HashMap;
import java.util.UUID;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilShapes;
import mineplex.core.common.util.UtilParticle.ParticleType;
import nautilus.game.arcade.game.games.wizards.Wizards;
@ -35,7 +36,7 @@ public class LaunchRune
for (LivingEntity entity : _runeLocation.getWorld().getEntitiesByClass(LivingEntity.class))
{
if (!(entity instanceof Player) || ((Player) entity).getGameMode() != GameMode.CREATIVE)
if (!(entity instanceof Player) || !UtilPlayer.isSpectator(entity))
{
UUID uuid = entity.getUniqueId();

View File

@ -2,6 +2,7 @@ package nautilus.game.arcade.game.games.wizards.spells.subclasses;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilShapes;
import org.bukkit.GameMode;
@ -48,7 +49,7 @@ public class TeleportRune
for (LivingEntity entity : _firstLoc.getWorld().getEntitiesByClass(LivingEntity.class))
{
if (entity instanceof Player && ((Player) entity).getGameMode() == GameMode.CREATIVE)
if (entity instanceof Player && UtilPlayer.isSpectator(entity))
{
continue;
}

View File

@ -149,7 +149,7 @@ public class PerkBatForm extends SmashPerk
//Proxy Boom
for (Player player : Manager.GetGame().GetPlayers(true))
{
if (player.getGameMode() != GameMode.SURVIVAL)
if (Manager.isSpectator(player))
continue;
if (player.equals(data.Shooter))
@ -193,11 +193,14 @@ public class PerkBatForm extends SmashPerk
{
Player player = event.getPlayer();
if (player.getGameMode() == GameMode.CREATIVE)
if (Manager.isSpectator(player))
return;
if (!isSuperActive(player))
return;
if (player.getGameMode() == GameMode.CREATIVE)
return;
event.setCancelled(true);
player.setFlying(false);
@ -223,7 +226,7 @@ public class PerkBatForm extends SmashPerk
for (Player player : ((SmashKit)Kit).getSuperActive())
{
if (player.getGameMode() == GameMode.CREATIVE)
if (Manager.isSpectator(player))
continue;
if (UtilEnt.isGrounded(player) || UtilBlock.solid(player.getLocation().getBlock().getRelative(BlockFace.DOWN)))

View File

@ -87,7 +87,7 @@ public class PerkBodySlam extends Perk
for (Player player : Manager.GetGame().GetPlayers(true))
if (_live.containsKey(player))
for (Player other : Manager.GetGame().GetPlayers(true))
if (other.getGameMode() == GameMode.SURVIVAL)
if (!Manager.isSpectator(other))
if (!other.equals(player))
if (UtilMath.offset(player, other) < 2)
{

View File

@ -62,7 +62,7 @@ public class PerkConstructor extends Perk
if (!Manager.GetGame().IsAlive(cur))
continue;
if (cur.getGameMode() != GameMode.SURVIVAL)
if (Manager.isSpectator(cur))
continue;
if (!Recharge.Instance.use(cur, GetName(), (long) (_time * 1000), false, false))

View File

@ -92,7 +92,7 @@ public class PerkDeathsGrasp extends Perk
for (Player player : Manager.GetGame().GetPlayers(true))
if (_live.containsKey(player))
for (Player other : Manager.GetGame().GetPlayers(true))
if (other.getGameMode() == GameMode.SURVIVAL)
if (!Manager.isSpectator(other))
if (!other.equals(player))
if (UtilMath.offset(player, other) < 2)
{

View File

@ -66,6 +66,9 @@ public class PerkDoubleJump extends Perk
if (!Kit.HasKit(player))
return;
if (Manager.isSpectator(player))
return;
if (player.getGameMode() == GameMode.CREATIVE)
return;
@ -108,7 +111,7 @@ public class PerkDoubleJump extends Perk
for (Player player : UtilServer.getPlayers())
{
if (player.getGameMode() == GameMode.CREATIVE)
if (Manager.isSpectator(player))
continue;
if (!Kit.HasKit(player))

View File

@ -34,6 +34,9 @@ public class PerkDoubleJumpHorse extends Perk
if (!Kit.HasKit(player))
return;
if (Manager.isSpectator(player))
return;
if (player.getGameMode() == GameMode.CREATIVE)
return;
@ -61,14 +64,12 @@ public class PerkDoubleJumpHorse extends Perk
for (Player player : UtilServer.getPlayers())
{
if (player.getGameMode() == GameMode.CREATIVE)
if (Manager.isSpectator(player))
continue;
if (!Kit.HasKit(player))
continue;
if (player.getVehicle() == null)
{
if (UtilEnt.isGrounded(player) || UtilBlock.solid(player.getLocation().getBlock().getRelative(BlockFace.DOWN)))

View File

@ -39,12 +39,15 @@ public class PerkFlap extends SmashPerk
{
Player player = event.getPlayer();
if (player.getGameMode() == GameMode.CREATIVE)
if (Manager.isSpectator(player))
return;
if (!Kit.HasKit(player))
return;
if (player.getGameMode() == GameMode.CREATIVE)
return;
event.setCancelled(true);
player.setFlying(false);

View File

@ -100,7 +100,7 @@ public class PerkFletcher extends Perk
for (Player cur : UtilServer.getPlayers())
{
if (cur.getGameMode() != GameMode.SURVIVAL)
if (Manager.isSpectator(cur))
continue;
if (!Kit.HasKit(cur))

View File

@ -81,7 +81,7 @@ public class PerkLeapTackleHG extends Perk
for (Player player : Manager.GetGame().GetPlayers(true))
if (_live.containsKey(player))
for (Player other : Manager.GetGame().GetPlayers(true))
if (other.getGameMode() == GameMode.SURVIVAL)
if (!Manager.isSpectator(other))
if (!other.equals(player))
if (UtilMath.offset(player, other) < 2)
{

View File

@ -85,7 +85,7 @@ public class PerkSlimeSlam extends SmashPerk
for (Player player : Manager.GetGame().GetPlayers(true))
if (_live.containsKey(player))
for (Player other : Manager.GetGame().GetPlayers(true))
if (other.getGameMode() == GameMode.SURVIVAL)
if (!Manager.isSpectator(other))
if (!other.equals(player))
if (UtilMath.offset(player, other) < 2)
{

View File

@ -103,7 +103,7 @@ public class PerkSmokebomb extends Perk
continue;
if (other instanceof Player)
if (((Player)other).getGameMode() != GameMode.SURVIVAL)
if (Manager.isSpectator((Player)other))
continue;
LivingEntity living = (LivingEntity) other;

View File

@ -44,7 +44,7 @@ public class PerkSpiderLeap extends Perk
for (Player player : UtilServer.getPlayers())
{
if (player.getGameMode() == GameMode.CREATIVE)
if (Manager.isSpectator(player))
continue;
if (!Kit.HasKit(player))
@ -95,6 +95,9 @@ public class PerkSpiderLeap extends Perk
if (!Kit.HasKit(player))
return;
if (Manager.isSpectator(player))
return;
if (player.getGameMode() == GameMode.CREATIVE)
return;
@ -121,7 +124,7 @@ public class PerkSpiderLeap extends Perk
for (Player player : UtilServer.getPlayers())
{
if (player.getGameMode() == GameMode.CREATIVE)
if (Manager.isSpectator(player))
continue;
if (!Kit.HasKit(player))

View File

@ -80,7 +80,7 @@ public class PerkTakedown extends Perk
for (Player player : Manager.GetGame().GetPlayers(true))
if (_live.containsKey(player))
for (Player other : Manager.GetGame().GetPlayers(true))
if (other.getGameMode() == GameMode.SURVIVAL)
if (!Manager.isSpectator(other))
if (!other.equals(player))
if (UtilMath.offset(player, other) < 2)
{

View File

@ -125,7 +125,7 @@ public class PerkWolf extends SmashPerk
//Hit Player
for (Player other : Manager.GetGame().GetPlayers(true))
if (other.getGameMode() == GameMode.SURVIVAL)
if (!Manager.isSpectator(other))
if (UtilEnt.hitBox(wolf.getLocation(), other, 2, null))
{
if (other.equals(TackleGetOwner(wolf)))
@ -285,7 +285,7 @@ public class PerkWolf extends SmashPerk
for (Player other : Manager.GetGame().GetPlayers(true))
if (!player.equals(other))
if (other.getGameMode() == GameMode.SURVIVAL)
if (!Manager.isSpectator(other))
if (UtilEnt.hitBox(player.getLocation().add(0, 1, 0), other, 2, null))
{
StrikeHit(player, other);

View File

@ -97,7 +97,7 @@ public class PerkWolfPack extends Perk
if (!Kit.HasKit(player))
return;
if (player.getGameMode() == GameMode.CREATIVE)
if (Manager.isSpectator(player))
return;
event.setCancelled(true);
@ -149,7 +149,7 @@ public class PerkWolfPack extends Perk
for (Player player : UtilServer.getPlayers())
{
if (player.getGameMode() == GameMode.CREATIVE)
if (Manager.isSpectator(player))
continue;
if (!Kit.HasKit(player))
@ -396,7 +396,7 @@ public class PerkWolfPack extends Perk
Wolf wolf = wolfIterator.next();
for (Player other : Manager.GetGame().GetPlayers(true))
if (other.getGameMode() == GameMode.SURVIVAL)
if (Manager.isSpectator(other))
if (UtilEnt.hitBox(wolf.getLocation(), other, 2, null))
{
if (other.equals(GetOwner(wolf)))
@ -518,7 +518,7 @@ public class PerkWolfPack extends Perk
for (Player other : Manager.GetGame().GetPlayers(true))
if (!player.equals(other))
if (other.getGameMode() == GameMode.SURVIVAL)
if (!Manager.isSpectator(other))
if (UtilEnt.hitBox(player.getLocation(), other, 2, null))
{
TackleHit(player, other);

View File

@ -246,7 +246,7 @@ public class PerkWolfPet extends Perk
Wolf wolf = wolfIterator.next();
for (Player other : Manager.GetGame().GetPlayers(true))
if (other.getGameMode() == GameMode.SURVIVAL)
if (!Manager.isSpectator(other))
if (UtilEnt.hitBox(wolf.getLocation(), other, 2, null))
{
if (other.equals(wolf.getOwner()))

View File

@ -2,6 +2,7 @@ package nautilus.game.arcade.kit.perks.data;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import org.bukkit.DyeColor;
import org.bukkit.GameMode;
@ -26,7 +27,7 @@ public class HomingSheepData
public boolean update()
{
if (!Sheep.isValid() || !Target.isValid() || Target.getGameMode() != GameMode.SURVIVAL)
if (!Sheep.isValid() || !Target.isValid() || UtilPlayer.isSpectator(Target))
return true;
if (Sheep.getTicksLived() > 300)

View File

@ -90,6 +90,20 @@ public class GameFlagManager implements Listener
return;
}
//Damagee Spec
if (damagee != null && Manager.isSpectator(damagee))
{
event.SetCancelled("Damagee Spectator");
return;
}
//Damager Spec
if (damager != null && Manager.isSpectator(damager))
{
event.SetCancelled("Damager Spectator");
return;
}
if (!game.Damage)
{
@ -216,6 +230,7 @@ public class GameFlagManager implements Listener
Game game = Manager.GetGame();
if (game == null || !game.IsAlive(player) || game.GetState() != GameState.Live)
{
//Only allow ops in creative
if (!player.isOp() || player.getGameMode() != GameMode.CREATIVE)
{
event.setCancelled(true);
@ -315,6 +330,7 @@ public class GameFlagManager implements Listener
Game game = Manager.GetGame();
if (game == null)
{
//Only allow ops in creative
if (!player.isOp() || player.getGameMode() != GameMode.CREATIVE)
event.setCancelled(true);
}
@ -322,10 +338,12 @@ public class GameFlagManager implements Listener
{
if (!game.IsAlive(player))
{
//Only allow ops in creative
if (!player.isOp() || player.getGameMode() != GameMode.CREATIVE)
event.setCancelled(true);
}
else if (game.BlockPlaceCreative && player.getGameMode() == GameMode.CREATIVE) // Event Server Allowance
// Event Server Allowance
else if (game.BlockPlaceCreative && player.getGameMode() == GameMode.CREATIVE)
{
return;
}
@ -357,6 +375,7 @@ public class GameFlagManager implements Listener
Game game = Manager.GetGame();
if (game == null)
{
//Only allow ops in creative
if (!player.isOp() || player.getGameMode() != GameMode.CREATIVE)
event.setCancelled(true);
}
@ -366,7 +385,8 @@ public class GameFlagManager implements Listener
{
event.setCancelled(true);
}
else if (game.BlockBreakCreative && player.getGameMode() == GameMode.CREATIVE) // Event Server Allowance
// Event Server Allowance
else if (game.BlockBreakCreative && player.getGameMode() == GameMode.CREATIVE)
{
return;
}
@ -658,7 +678,7 @@ public class GameFlagManager implements Listener
}
else
{
game.SetSpectator(player, true);
Manager.addSpectator(player, true);
}
Manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable()
@ -681,7 +701,7 @@ public class GameFlagManager implements Listener
UtilInv.Clear(player);
Manager.GetCondition().Factory().Blind("Ghost", player, player, 1.5, 0, false, false, false);
Manager.GetCondition().Factory().Cloak("Ghost", player, player, time, false, false);
player.setGameMode(GameMode.CREATIVE);
player.setAllowFlight(true);
player.setFlying(true);
((CraftPlayer)player).getHandle().spectating = true;
((CraftPlayer)player).getHandle().k = false;
@ -704,7 +724,7 @@ public class GameFlagManager implements Listener
}
else
{
game.SetSpectator(player, true);
Manager.addSpectator(player, true);
}
player.setFireTicks(0);
@ -907,7 +927,7 @@ public class GameFlagManager implements Listener
team.RemovePlayer(event.getPlayer());
}
game.SetSpectator(event.getPlayer(), false);
Manager.addSpectator(event.getPlayer(), false);
}
@EventHandler

View File

@ -540,9 +540,6 @@ public class GameManager implements Listener
game.SetPlayerTeam(player, team, true);
//Game Mode
player.setGameMode(GameMode.SURVIVAL);
return true;
}
@ -605,7 +602,7 @@ public class GameManager implements Listener
if (Manager.GetGame().IsAlive(player))
continue;
Manager.GetGame().SetSpectator(player, true);
Manager.addSpectator(player, true);
}
}

View File

@ -119,7 +119,7 @@ public class GamePlayerManager implements Listener
else
{
Manager.Clear(player);
Manager.GetGame().SetSpectator(player, true);
Manager.addSpectator(player, true);
UtilPlayer.message(player, F.main("Game", Manager.GetGame().GetName() + " is in progress, please wait for next game!"));
}
@ -143,7 +143,7 @@ public class GamePlayerManager implements Listener
}
else
{
Manager.GetGame().SetSpectator(player, true);
Manager.addSpectator(player, true);
event.setRespawnLocation(Manager.GetGame().GetSpectatorLocation());
}
@ -265,15 +265,12 @@ public class GamePlayerManager implements Listener
Player player = event.getPlayer();
//Observer
if (Manager.IsObserver(player))
if (Manager.IsObserver(player) || Manager.isSpectator(player))
{
UtilPlayer.message(player, F.main("Game", "Spectators cannot partake in games."));
return;
}
if (player.getGameMode() != GameMode.SURVIVAL)
return;
Kit kit = Manager.GetLobby().GetClickedKit(event.getRightClicked());
if (kit == null)
@ -297,15 +294,12 @@ public class GamePlayerManager implements Listener
if (player == null) return;
//Observer
if (Manager.IsObserver(player))
if (Manager.IsObserver(player) || Manager.isSpectator(player))
{
UtilPlayer.message(player, F.main("Game", "Spectators cannot partake in games."));
return;
}
if (player.getGameMode() != GameMode.SURVIVAL)
return;
LivingEntity target = event.GetDamageeEntity();
Kit kit = Manager.GetLobby().GetClickedKit(target);
@ -396,7 +390,7 @@ public class GamePlayerManager implements Listener
event.setCancelled(true);
if (game.IsAlive(player) || player.getGameMode() != GameMode.CREATIVE)
if (game.IsAlive(player) || !Manager.isSpectator(player))
{
UtilPlayer.message(player, F.main("Game", "Only Spectators can use this command."));
return;