2014-11-18 06:43:39 +01:00
|
|
|
package nautilus.game.arcade.managers;
|
|
|
|
|
|
|
|
import nautilus.game.arcade.ArcadeManager;
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
Player player = event.getPlayer();
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|