2014-11-18 06:43:39 +01:00
|
|
|
package nautilus.game.arcade.managers;
|
|
|
|
|
|
|
|
import nautilus.game.arcade.ArcadeManager;
|
2015-10-09 04:28:07 +02:00
|
|
|
import nautilus.game.arcade.game.Game.GameState;
|
2014-11-18 06:43:39 +01:00
|
|
|
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
import org.bukkit.event.EventHandler;
|
|
|
|
import org.bukkit.event.EventPriority;
|
|
|
|
import org.bukkit.event.Listener;
|
|
|
|
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
|
|
|
import org.bukkit.event.player.PlayerInteractEvent;
|
|
|
|
import org.bukkit.event.vehicle.VehicleDamageEvent;
|
|
|
|
|
|
|
|
public class GameSpectatorManager implements Listener
|
|
|
|
{
|
|
|
|
ArcadeManager Manager;
|
|
|
|
|
|
|
|
public GameSpectatorManager(ArcadeManager manager)
|
|
|
|
{
|
|
|
|
Manager = manager;
|
|
|
|
|
2015-02-26 06:07:07 +01:00
|
|
|
Manager.getPluginManager().registerEvents(this, Manager.getPlugin());
|
2014-11-18 06:43:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler(priority = EventPriority.LOW)
|
|
|
|
public void interactCancel(PlayerInteractEvent event)
|
|
|
|
{
|
|
|
|
if (Manager.GetGame() == null)
|
|
|
|
return;
|
|
|
|
|
|
|
|
Player player = event.getPlayer();
|
|
|
|
|
|
|
|
if (!Manager.GetGame().IsAlive(player))
|
|
|
|
event.setCancelled(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler(priority = EventPriority.LOW)
|
|
|
|
public void interactEntityCancel(PlayerInteractEntityEvent event)
|
|
|
|
{
|
|
|
|
if (Manager.GetGame() == null)
|
|
|
|
return;
|
2015-10-09 04:28:07 +02:00
|
|
|
|
2014-11-18 06:43:39 +01:00
|
|
|
Player player = event.getPlayer();
|
|
|
|
|
2015-10-09 04:28:07 +02:00
|
|
|
if (Manager.GetGame().GetState() == GameState.Recruit)
|
|
|
|
{
|
|
|
|
if (Manager.getCosmeticManager().getMountManager().isMount(event.getRightClicked()))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-18 06:43:39 +01:00
|
|
|
if (!Manager.GetGame().IsAlive(player))
|
|
|
|
event.setCancelled(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler(priority = EventPriority.LOW)
|
|
|
|
public void vehicleDamage(VehicleDamageEvent event)
|
|
|
|
{
|
|
|
|
if (Manager.GetGame() == null)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!(event.getAttacker() instanceof Player))
|
|
|
|
return;
|
|
|
|
|
|
|
|
Player player = (Player)event.getAttacker();
|
|
|
|
|
|
|
|
if (!Manager.GetGame().IsAlive(player))
|
|
|
|
event.setCancelled(true);
|
|
|
|
}
|
|
|
|
}
|