2013-08-27 17:14:08 +02:00
|
|
|
package nautilus.game.arcade.managers;
|
|
|
|
|
2014-10-12 05:19:35 +02:00
|
|
|
import mineplex.core.antihack.AntiHack;
|
2013-08-27 17:14:08 +02:00
|
|
|
import mineplex.core.common.Rank;
|
|
|
|
import mineplex.core.common.util.C;
|
|
|
|
import mineplex.core.common.util.F;
|
2013-10-27 05:24:28 +01:00
|
|
|
import mineplex.core.common.util.UtilAction;
|
|
|
|
import mineplex.core.common.util.UtilAlg;
|
2013-08-27 17:14:08 +02:00
|
|
|
import mineplex.core.common.util.UtilBlock;
|
2013-10-31 02:43:54 +01:00
|
|
|
import mineplex.core.common.util.UtilInv;
|
2013-08-27 17:14:08 +02:00
|
|
|
import mineplex.core.common.util.UtilMath;
|
|
|
|
import mineplex.core.common.util.UtilPlayer;
|
|
|
|
import mineplex.core.common.util.UtilServer;
|
2015-04-03 06:28:10 +02:00
|
|
|
import mineplex.core.common.util.UtilTextMiddle;
|
2013-08-27 17:14:08 +02:00
|
|
|
import mineplex.core.itemstack.ItemStackFactory;
|
2015-03-23 01:50:09 +01:00
|
|
|
import mineplex.core.recharge.Recharge;
|
2014-11-28 00:00:31 +01:00
|
|
|
import mineplex.core.teleport.event.MineplexTeleportEvent;
|
2013-08-27 17:14:08 +02:00
|
|
|
import mineplex.core.updater.UpdateType;
|
|
|
|
import mineplex.core.updater.event.UpdateEvent;
|
|
|
|
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
|
|
|
import nautilus.game.arcade.ArcadeManager;
|
2014-01-21 01:28:12 +01:00
|
|
|
import nautilus.game.arcade.GameType;
|
2014-10-12 05:19:35 +02:00
|
|
|
import nautilus.game.arcade.events.GameStateChangeEvent;
|
2013-08-27 17:14:08 +02:00
|
|
|
import nautilus.game.arcade.events.PlayerDeathOutEvent;
|
|
|
|
import nautilus.game.arcade.game.Game;
|
|
|
|
import nautilus.game.arcade.game.Game.GameState;
|
2015-08-28 23:44:41 +02:00
|
|
|
import nautilus.game.arcade.game.GameTeam;
|
2013-08-27 17:14:08 +02:00
|
|
|
import nautilus.game.arcade.game.GameTeam.PlayerState;
|
2014-10-24 10:05:57 +02:00
|
|
|
import nautilus.game.arcade.kit.perks.event.PerkDestructorBlockEvent;
|
2013-08-27 17:14:08 +02:00
|
|
|
|
|
|
|
import org.bukkit.GameMode;
|
|
|
|
import org.bukkit.Material;
|
|
|
|
import org.bukkit.Sound;
|
|
|
|
import org.bukkit.block.Block;
|
|
|
|
import org.bukkit.block.BlockFace;
|
2015-08-28 23:44:41 +02:00
|
|
|
import org.bukkit.block.Chest;
|
|
|
|
import org.bukkit.block.DoubleChest;
|
2014-08-14 01:57:37 +02:00
|
|
|
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
|
2013-08-27 17:14:08 +02:00
|
|
|
import org.bukkit.entity.LivingEntity;
|
|
|
|
import org.bukkit.entity.Player;
|
2015-06-27 03:24:01 +02:00
|
|
|
import org.bukkit.entity.Projectile;
|
2013-08-27 17:14:08 +02:00
|
|
|
import org.bukkit.event.EventHandler;
|
|
|
|
import org.bukkit.event.EventPriority;
|
|
|
|
import org.bukkit.event.Listener;
|
|
|
|
import org.bukkit.event.block.Action;
|
2014-08-21 05:35:31 +02:00
|
|
|
import org.bukkit.event.block.BlockBurnEvent;
|
|
|
|
import org.bukkit.event.block.BlockIgniteEvent;
|
2013-08-27 17:14:08 +02:00
|
|
|
import org.bukkit.event.block.BlockPlaceEvent;
|
2014-08-22 09:05:14 +02:00
|
|
|
import org.bukkit.event.block.LeavesDecayEvent;
|
2013-08-27 17:14:08 +02:00
|
|
|
import org.bukkit.event.entity.CreatureSpawnEvent;
|
|
|
|
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
2015-08-28 23:44:41 +02:00
|
|
|
import org.bukkit.event.entity.PlayerDeathEvent;
|
2014-07-26 09:03:03 +02:00
|
|
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
2014-09-12 03:47:39 +02:00
|
|
|
import org.bukkit.event.inventory.InventoryOpenEvent;
|
2014-07-26 09:03:03 +02:00
|
|
|
import org.bukkit.event.inventory.InventoryType;
|
2014-10-31 00:35:47 +01:00
|
|
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
2013-08-27 17:14:08 +02:00
|
|
|
import org.bukkit.event.player.PlayerDropItemEvent;
|
|
|
|
import org.bukkit.event.player.PlayerInteractEvent;
|
2015-05-03 23:51:13 +02:00
|
|
|
import org.bukkit.event.player.PlayerJoinEvent;
|
2013-08-27 17:14:08 +02:00
|
|
|
import org.bukkit.event.player.PlayerMoveEvent;
|
|
|
|
import org.bukkit.event.player.PlayerPickupItemEvent;
|
2013-09-09 10:06:44 +02:00
|
|
|
import org.bukkit.event.player.PlayerQuitEvent;
|
2013-08-27 17:14:08 +02:00
|
|
|
import org.bukkit.inventory.ItemStack;
|
|
|
|
import org.bukkit.util.Vector;
|
|
|
|
|
|
|
|
public class GameFlagManager implements Listener
|
|
|
|
{
|
|
|
|
ArcadeManager Manager;
|
|
|
|
|
|
|
|
public GameFlagManager(ArcadeManager manager)
|
|
|
|
{
|
|
|
|
Manager = manager;
|
2013-09-03 02:47:15 +02:00
|
|
|
|
2015-02-26 06:07:07 +01:00
|
|
|
Manager.getPluginManager().registerEvents(this, Manager.getPlugin());
|
2013-08-27 17:14:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler(priority = EventPriority.LOW)
|
|
|
|
public void DamageEvent(CustomDamageEvent event)
|
|
|
|
{
|
|
|
|
Game game = Manager.GetGame();
|
|
|
|
if (game == null)
|
|
|
|
{
|
|
|
|
event.SetCancelled("Game Null");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
LivingEntity damagee = event.GetDamageeEntity();
|
|
|
|
LivingEntity damager = event.GetDamagerEntity(true);
|
|
|
|
|
|
|
|
if (damagee != null && damagee.getWorld().getName().equals("world"))
|
|
|
|
{
|
|
|
|
event.SetCancelled("In Lobby");
|
|
|
|
|
|
|
|
if (event.GetCause() == DamageCause.VOID)
|
|
|
|
damagee.teleport(Manager.GetLobby().GetSpawn());
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
2015-03-12 05:31:40 +01:00
|
|
|
|
|
|
|
//Damagee Spec
|
|
|
|
if (damagee != null && Manager.isSpectator(damagee))
|
|
|
|
{
|
|
|
|
event.SetCancelled("Damagee Spectator");
|
2015-04-30 10:55:30 +02:00
|
|
|
|
|
|
|
if (damagee.getFireTicks() > 0)
|
|
|
|
{
|
|
|
|
damagee.setFireTicks(0);
|
|
|
|
}
|
|
|
|
|
2015-03-12 05:31:40 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
//Damager Spec
|
|
|
|
if (damager != null && Manager.isSpectator(damager))
|
|
|
|
{
|
|
|
|
event.SetCancelled("Damager Spectator");
|
|
|
|
return;
|
|
|
|
}
|
2013-08-27 17:14:08 +02:00
|
|
|
|
|
|
|
if (!game.Damage)
|
|
|
|
{
|
|
|
|
event.SetCancelled("Damage Disabled");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (game.GetState() != GameState.Live)
|
|
|
|
{
|
|
|
|
event.SetCancelled("Game not Live");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (damagee != null && damagee instanceof Player && !game.IsAlive((Player)damagee))
|
|
|
|
{
|
|
|
|
event.SetCancelled("Damagee Not Playing");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (damager != null && damager instanceof Player && !game.IsAlive((Player)damager))
|
|
|
|
{
|
|
|
|
event.SetCancelled("Damager Not Playing");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-03-12 02:14:49 +01:00
|
|
|
if (event.GetCause() == DamageCause.FALL && !game.DamageFall)
|
|
|
|
{
|
|
|
|
event.SetCancelled("Fall Damage Disabled");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
//Entity vs Entity
|
|
|
|
if (damagee != null && damager != null)
|
|
|
|
{
|
|
|
|
//PvP
|
|
|
|
if (damagee instanceof Player && damager instanceof Player)
|
|
|
|
{
|
2014-12-03 22:06:50 +01:00
|
|
|
if (!Manager.canHurt((Player)damagee, (Player)damager))
|
2013-08-27 17:14:08 +02:00
|
|
|
{
|
2014-09-02 03:16:17 +02:00
|
|
|
event.SetCancelled("PvP Disabled");
|
2013-08-27 17:14:08 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//PvE
|
|
|
|
else if (damager instanceof Player)
|
|
|
|
{
|
|
|
|
if (!game.DamagePvE)
|
|
|
|
{
|
|
|
|
event.SetCancelled("PvE Disabled");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//EvP
|
|
|
|
else if (damagee instanceof Player)
|
|
|
|
{
|
|
|
|
if (!game.DamageEvP)
|
|
|
|
{
|
|
|
|
event.SetCancelled("EvP Disabled");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler(priority = EventPriority.HIGH)
|
|
|
|
public void DamageExplosion(CustomDamageEvent event)
|
|
|
|
{
|
|
|
|
if (event.IsCancelled())
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (event.GetCause() != DamageCause.ENTITY_EXPLOSION && event.GetCause() != DamageCause.BLOCK_EXPLOSION)
|
|
|
|
return;
|
|
|
|
|
|
|
|
Player damagee = event.GetDamageePlayer();
|
|
|
|
if (damagee == null) return;
|
|
|
|
|
|
|
|
Player damager = event.GetDamagerPlayer(true);
|
|
|
|
if (damager == null) return;
|
|
|
|
|
2014-12-03 22:06:50 +01:00
|
|
|
if (Manager.canHurt(damagee, damager))
|
2013-08-27 17:14:08 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
event.SetCancelled("Allied Explosion");
|
|
|
|
}
|
|
|
|
|
2013-09-09 10:06:44 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
|
|
|
|
@EventHandler(priority = EventPriority.LOWEST)
|
|
|
|
public void ItemPickupEvent(PlayerPickupItemEvent event)
|
|
|
|
{
|
|
|
|
Player player = event.getPlayer();
|
2013-09-03 02:47:15 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
Game game = Manager.GetGame();
|
|
|
|
|
|
|
|
if (game == null || !game.IsAlive(player) || game.GetState() != GameState.Live)
|
|
|
|
{
|
2013-09-11 04:22:55 +02:00
|
|
|
event.setCancelled(true);
|
2013-09-13 04:24:33 +02:00
|
|
|
return;
|
2013-08-27 17:14:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (game.ItemPickup)
|
|
|
|
{
|
|
|
|
if (game.ItemPickupDeny.contains(event.getItem().getItemStack().getTypeId()))
|
|
|
|
{
|
|
|
|
event.setCancelled(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!game.ItemPickupAllow.contains(event.getItem().getItemStack().getTypeId()))
|
|
|
|
{
|
|
|
|
event.setCancelled(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler(priority = EventPriority.LOWEST)
|
|
|
|
public void ItemDropEvent(PlayerDropItemEvent event)
|
|
|
|
{
|
|
|
|
Player player = event.getPlayer();
|
|
|
|
|
|
|
|
Game game = Manager.GetGame();
|
|
|
|
if (game == null || !game.IsAlive(player) || game.GetState() != GameState.Live)
|
|
|
|
{
|
2015-03-12 05:31:40 +01:00
|
|
|
//Only allow ops in creative
|
2013-08-27 17:14:08 +02:00
|
|
|
if (!player.isOp() || player.getGameMode() != GameMode.CREATIVE)
|
|
|
|
{
|
|
|
|
event.setCancelled(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (game.ItemDrop)
|
|
|
|
{
|
|
|
|
if (game.ItemDropDeny.contains(event.getItemDrop().getItemStack().getTypeId()))
|
|
|
|
{
|
|
|
|
event.setCancelled(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!game.ItemDropAllow.contains(event.getItemDrop().getItemStack().getTypeId()))
|
|
|
|
{
|
|
|
|
event.setCancelled(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-09-12 03:47:39 +02:00
|
|
|
|
2013-09-03 02:47:15 +02:00
|
|
|
@EventHandler(priority = EventPriority.LOWEST)
|
2014-09-12 03:47:39 +02:00
|
|
|
public void InventoryOpen(InventoryOpenEvent event)
|
2013-09-03 02:47:15 +02:00
|
|
|
{
|
|
|
|
Game game = Manager.GetGame();
|
|
|
|
if (game == null)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!game.InProgress())
|
|
|
|
return;
|
2015-08-28 23:46:38 +02:00
|
|
|
|
|
|
|
//normal inventories
|
2014-09-12 03:47:39 +02:00
|
|
|
if (!game.InventoryOpenBlock)
|
|
|
|
{
|
|
|
|
if (event.getInventory().getType() == InventoryType.ANVIL ||
|
|
|
|
event.getInventory().getType() == InventoryType.BEACON ||
|
|
|
|
event.getInventory().getType() == InventoryType.BREWING ||
|
|
|
|
event.getInventory().getType() == InventoryType.DISPENSER ||
|
|
|
|
event.getInventory().getType() == InventoryType.DROPPER ||
|
|
|
|
event.getInventory().getType() == InventoryType.ENCHANTING ||
|
|
|
|
event.getInventory().getType() == InventoryType.FURNACE ||
|
|
|
|
event.getInventory().getType() == InventoryType.HOPPER ||
|
|
|
|
event.getInventory().getType() == InventoryType.MERCHANT ||
|
|
|
|
event.getInventory().getType() == InventoryType.ENDER_CHEST ||
|
2015-08-28 23:44:41 +02:00
|
|
|
event.getInventory().getType() == InventoryType.WORKBENCH ||
|
|
|
|
event.getInventory().getType() == InventoryType.CHEST)
|
2015-08-28 23:46:38 +02:00
|
|
|
{
|
2015-08-28 23:44:41 +02:00
|
|
|
if (event.getInventory().getType() == InventoryType.CHEST)
|
|
|
|
{
|
2015-08-28 23:46:38 +02:00
|
|
|
if (event.getInventory().getHolder() != null && event.getInventory().getHolder() instanceof Chest || event.getInventory().getHolder() instanceof DoubleChest)
|
2015-08-28 23:44:41 +02:00
|
|
|
{
|
|
|
|
event.setCancelled(true);
|
|
|
|
event.getPlayer().closeInventory();
|
|
|
|
}
|
|
|
|
}
|
2015-08-28 23:46:38 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
event.setCancelled(true);
|
|
|
|
event.getPlayer().closeInventory();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//deal with chests
|
|
|
|
if (!game.InventoryOpenChest)
|
|
|
|
{
|
|
|
|
if (event.getInventory().getType() == InventoryType.CHEST)
|
|
|
|
{
|
|
|
|
if (event.getInventory().getHolder() instanceof Chest || event.getInventory().getHolder() instanceof DoubleChest)
|
|
|
|
{
|
|
|
|
event.setCancelled(true);
|
|
|
|
event.getPlayer().closeInventory();
|
|
|
|
}
|
2014-09-12 03:47:39 +02:00
|
|
|
}
|
|
|
|
}
|
2013-09-03 02:47:15 +02:00
|
|
|
}
|
2014-07-26 09:03:03 +02:00
|
|
|
|
|
|
|
@EventHandler(priority = EventPriority.LOWEST)
|
2014-09-01 13:37:39 +02:00
|
|
|
public void InventoryClick(InventoryClickEvent event)
|
2014-07-26 09:03:03 +02:00
|
|
|
{
|
|
|
|
Game game = Manager.GetGame();
|
|
|
|
if (game == null)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!game.InProgress())
|
|
|
|
return;
|
|
|
|
|
2014-11-15 12:32:00 +01:00
|
|
|
if (game.InventoryClick)
|
|
|
|
return;
|
|
|
|
|
2014-09-01 13:37:39 +02:00
|
|
|
Player player = UtilPlayer.searchExact(event.getWhoClicked().getName());
|
|
|
|
if (player != null && !game.IsAlive(player))
|
|
|
|
return;
|
2014-11-15 12:32:00 +01:00
|
|
|
|
|
|
|
if (!game.IsAlive(player))
|
2014-07-26 09:03:03 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (event.getInventory().getType() == InventoryType.CRAFTING)
|
|
|
|
{
|
|
|
|
event.setCancelled(true);
|
|
|
|
event.getWhoClicked().closeInventory();
|
|
|
|
}
|
|
|
|
}
|
2013-09-03 02:47:15 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
@EventHandler(priority = EventPriority.LOWEST)
|
|
|
|
public void BlockPlaceEvent(BlockPlaceEvent event)
|
|
|
|
{
|
|
|
|
Player player = event.getPlayer();
|
|
|
|
|
|
|
|
Game game = Manager.GetGame();
|
|
|
|
if (game == null)
|
|
|
|
{
|
2015-03-12 05:31:40 +01:00
|
|
|
//Only allow ops in creative
|
2013-08-27 17:14:08 +02:00
|
|
|
if (!player.isOp() || player.getGameMode() != GameMode.CREATIVE)
|
|
|
|
event.setCancelled(true);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!game.IsAlive(player))
|
|
|
|
{
|
2015-03-12 05:31:40 +01:00
|
|
|
//Only allow ops in creative
|
2013-08-27 17:14:08 +02:00
|
|
|
if (!player.isOp() || player.getGameMode() != GameMode.CREATIVE)
|
|
|
|
event.setCancelled(true);
|
|
|
|
}
|
2015-03-12 05:31:40 +01:00
|
|
|
// Event Server Allowance
|
|
|
|
else if (game.BlockPlaceCreative && player.getGameMode() == GameMode.CREATIVE)
|
2015-03-09 12:15:24 +01:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2013-08-27 17:14:08 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (game.BlockPlace)
|
|
|
|
{
|
|
|
|
if (game.BlockPlaceDeny.contains(event.getBlock().getTypeId()))
|
|
|
|
{
|
|
|
|
event.setCancelled(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!game.BlockPlaceAllow.contains(event.getBlock().getTypeId()))
|
|
|
|
{
|
|
|
|
event.setCancelled(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler(priority = EventPriority.LOWEST)
|
|
|
|
public void BlockBreakEvent(org.bukkit.event.block.BlockBreakEvent event)
|
|
|
|
{
|
|
|
|
Player player = event.getPlayer();
|
2013-09-03 02:47:15 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
Game game = Manager.GetGame();
|
|
|
|
if (game == null)
|
|
|
|
{
|
2015-03-12 05:31:40 +01:00
|
|
|
//Only allow ops in creative
|
2013-08-27 17:14:08 +02:00
|
|
|
if (!player.isOp() || player.getGameMode() != GameMode.CREATIVE)
|
|
|
|
event.setCancelled(true);
|
|
|
|
}
|
|
|
|
else if (game.GetState() == GameState.Live)
|
|
|
|
{
|
|
|
|
if (!game.IsAlive(player))
|
|
|
|
{
|
|
|
|
event.setCancelled(true);
|
|
|
|
}
|
2015-03-12 05:31:40 +01:00
|
|
|
// Event Server Allowance
|
|
|
|
else if (game.BlockBreakCreative && player.getGameMode() == GameMode.CREATIVE)
|
2015-03-09 12:15:24 +01:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2013-08-27 17:14:08 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (game.BlockBreak)
|
|
|
|
{
|
|
|
|
if (game.BlockBreakDeny.contains(event.getBlock().getTypeId()))
|
|
|
|
{
|
|
|
|
event.setCancelled(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!game.BlockBreakAllow.contains(event.getBlock().getTypeId()))
|
|
|
|
{
|
|
|
|
event.setCancelled(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
event.setCancelled(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler(priority = EventPriority.MONITOR)
|
|
|
|
public void PrivateBlockPlace(BlockPlaceEvent event)
|
|
|
|
{
|
|
|
|
Game game = Manager.GetGame();
|
|
|
|
if (game == null) return;
|
|
|
|
|
|
|
|
if (!game.PrivateBlocks)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (event.isCancelled())
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!UtilBlock.usable(event.getBlockPlaced()))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (event.getBlockPlaced().getType() != Material.CHEST &&
|
|
|
|
event.getBlockPlaced().getType() != Material.FURNACE &&
|
|
|
|
event.getBlockPlaced().getType() != Material.BURNING_FURNACE &&
|
|
|
|
event.getBlockPlaced().getType() != Material.WORKBENCH)
|
|
|
|
return;
|
|
|
|
|
|
|
|
String privateKey = event.getPlayer().getName();
|
|
|
|
|
|
|
|
//Add Empty
|
|
|
|
if (!game.PrivateBlockCount.containsKey(privateKey))
|
|
|
|
game.PrivateBlockCount.put(privateKey, 0);
|
|
|
|
|
|
|
|
if (game.PrivateBlockCount.get(privateKey) == 4)
|
|
|
|
return;
|
|
|
|
|
|
|
|
game.PrivateBlockMap.put(event.getBlockPlaced().getLocation(), event.getPlayer());
|
|
|
|
game.PrivateBlockCount.put(event.getPlayer().getName(), game.PrivateBlockCount.get(event.getPlayer().getName()) + 1);
|
|
|
|
|
|
|
|
if (game.PrivateBlockCount.get(privateKey) == 4)
|
|
|
|
{
|
2014-12-08 08:23:47 +01:00
|
|
|
event.getPlayer().sendMessage(F.main(game.GetName(), "Protected block limit reached."));
|
2013-08-27 17:14:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler(priority = EventPriority.LOW)
|
|
|
|
public void PrivateBlockPlaceCancel(BlockPlaceEvent event)
|
|
|
|
{
|
|
|
|
Game game = Manager.GetGame();
|
|
|
|
if (game == null) return;
|
|
|
|
|
|
|
|
if (!game.PrivateBlocks)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (event.isCancelled())
|
|
|
|
return;
|
|
|
|
|
|
|
|
Block block = event.getBlockPlaced();
|
|
|
|
|
|
|
|
if (block.getType() != Material.CHEST)
|
|
|
|
return;
|
|
|
|
|
|
|
|
Player player = event.getPlayer();
|
|
|
|
|
|
|
|
BlockFace[] faces = new BlockFace[] {BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST};
|
|
|
|
|
|
|
|
for (BlockFace face : faces)
|
|
|
|
{
|
|
|
|
Block other = block.getRelative(face);
|
|
|
|
|
|
|
|
if (other.getType() != Material.CHEST)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (!game.PrivateBlockMap.containsKey(other.getLocation()))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
Player owner = game.PrivateBlockMap.get(other.getLocation());
|
|
|
|
|
|
|
|
if (player.equals(owner))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
//Allow Enemy Raiding
|
|
|
|
GameTeam ownerTeam = game.GetTeam(owner);
|
|
|
|
GameTeam playerTeam = game.GetTeam(player);
|
|
|
|
|
|
|
|
if (ownerTeam != null && playerTeam != null && !ownerTeam.equals(playerTeam))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
//Disallow
|
|
|
|
UtilPlayer.message(event.getPlayer(), F.main("Game",
|
|
|
|
"You cannot combine " +
|
|
|
|
F.elem(C.cPurple + ItemStackFactory.Instance.GetName(event.getBlock(), false)) +
|
|
|
|
" with " + F.elem(Manager.GetColor(owner) + owner.getName() + ".")));
|
|
|
|
|
|
|
|
event.setCancelled(true);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler(priority = EventPriority.NORMAL)
|
|
|
|
public void PrivateBlockBreak(org.bukkit.event.block.BlockBreakEvent event)
|
|
|
|
{
|
|
|
|
Game game = Manager.GetGame();
|
|
|
|
if (game == null) return;
|
|
|
|
|
|
|
|
if (!game.PrivateBlocks)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (event.isCancelled())
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!game.PrivateBlockMap.containsKey(event.getBlock().getLocation()))
|
|
|
|
return;
|
|
|
|
|
|
|
|
Player owner = game.PrivateBlockMap.get(event.getBlock().getLocation());
|
|
|
|
Player player = event.getPlayer();
|
|
|
|
|
|
|
|
//Same Team (or no team)
|
|
|
|
if (owner.equals(player))
|
|
|
|
{
|
|
|
|
game.PrivateBlockMap.remove(event.getBlock().getLocation());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//Allow Enemy Raiding
|
|
|
|
GameTeam ownerTeam = game.GetTeam(owner);
|
|
|
|
GameTeam playerTeam = game.GetTeam(player);
|
|
|
|
|
|
|
|
if (ownerTeam != null && playerTeam != null && !ownerTeam.equals(playerTeam))
|
|
|
|
return;
|
|
|
|
|
|
|
|
//Disallow
|
|
|
|
UtilPlayer.message(event.getPlayer(), F.main("Game",
|
|
|
|
F.elem(C.cPurple + ItemStackFactory.Instance.GetName(event.getBlock(), false)) +
|
|
|
|
" belongs to " + F.elem(Manager.GetColor(owner) + owner.getName() + ".")));
|
|
|
|
|
|
|
|
event.setCancelled(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler(priority = EventPriority.LOW)
|
|
|
|
public void PrivateBlockUse(PlayerInteractEvent event)
|
|
|
|
{
|
|
|
|
Game game = Manager.GetGame();
|
|
|
|
if (game == null) return;
|
|
|
|
|
|
|
|
if (!game.PrivateBlocks)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (event.getAction() != Action.RIGHT_CLICK_BLOCK)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!UtilBlock.usable(event.getClickedBlock()))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (event.getClickedBlock().getType() != Material.CHEST &&
|
|
|
|
event.getClickedBlock().getType() != Material.FURNACE &&
|
|
|
|
event.getClickedBlock().getType() != Material.BURNING_FURNACE)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!game.PrivateBlockMap.containsKey(event.getClickedBlock().getLocation()))
|
|
|
|
return;
|
|
|
|
|
|
|
|
Player owner = game.PrivateBlockMap.get(event.getClickedBlock().getLocation());
|
2014-12-01 09:33:36 +01:00
|
|
|
|
|
|
|
if (!game.IsAlive(owner))
|
|
|
|
return;
|
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
Player player = event.getPlayer();
|
|
|
|
|
|
|
|
if (owner.equals(player))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//Allow Enemy Raiding
|
|
|
|
GameTeam ownerTeam = game.GetTeam(owner);
|
|
|
|
GameTeam playerTeam = game.GetTeam(player);
|
|
|
|
|
|
|
|
if (ownerTeam != null && playerTeam != null && !ownerTeam.equals(playerTeam))
|
|
|
|
return;
|
|
|
|
|
|
|
|
//Disallow
|
|
|
|
UtilPlayer.message(event.getPlayer(), F.main("Game",
|
|
|
|
F.elem(C.cPurple + ItemStackFactory.Instance.GetName(event.getClickedBlock(), false)) +
|
|
|
|
" belongs to " + F.elem(Manager.GetColor(owner) + owner.getName() + ".")));
|
|
|
|
|
|
|
|
event.setCancelled(true);
|
|
|
|
}
|
|
|
|
}
|
2013-09-09 10:06:44 +02:00
|
|
|
|
2014-10-24 10:05:57 +02:00
|
|
|
@EventHandler(priority = EventPriority.NORMAL)
|
|
|
|
public void PrivateBlockCrumble(PerkDestructorBlockEvent event)
|
|
|
|
{
|
|
|
|
Game game = Manager.GetGame();
|
|
|
|
if (game == null) return;
|
|
|
|
|
|
|
|
if (!game.PrivateBlocks)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (event.isCancelled())
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!game.PrivateBlockMap.containsKey(event.getBlock().getLocation()))
|
|
|
|
return;
|
|
|
|
|
|
|
|
Player owner = game.PrivateBlockMap.get(event.getBlock().getLocation());
|
|
|
|
Player player = event.getPlayer();
|
|
|
|
|
|
|
|
//Same Team (or no team)
|
|
|
|
if (owner.equals(player))
|
|
|
|
{
|
|
|
|
game.PrivateBlockMap.remove(event.getBlock().getLocation());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//Allow Enemy Raiding
|
|
|
|
GameTeam ownerTeam = game.GetTeam(owner);
|
|
|
|
GameTeam playerTeam = game.GetTeam(player);
|
|
|
|
|
|
|
|
if (ownerTeam != null && playerTeam != null && !ownerTeam.equals(playerTeam))
|
|
|
|
return;
|
|
|
|
|
|
|
|
event.setCancelled(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-09 10:06:44 +02:00
|
|
|
@EventHandler(priority = EventPriority.MONITOR)
|
|
|
|
public void PlayerDeath(PlayerDeathEvent event)
|
|
|
|
{
|
2013-10-31 02:43:54 +01:00
|
|
|
final Game game = Manager.GetGame();
|
2013-09-09 10:06:44 +02:00
|
|
|
if (game == null) return;
|
|
|
|
|
|
|
|
final Player player = event.getEntity();
|
2013-12-24 09:14:40 +01:00
|
|
|
|
|
|
|
//Visual
|
2014-09-01 13:37:39 +02:00
|
|
|
Manager.GetCondition().Factory().Blind("Ghost", player, player, 2, 0, false, false, false);
|
2013-09-09 10:06:44 +02:00
|
|
|
|
|
|
|
player.setFireTicks(0);
|
|
|
|
player.setFallDistance(0);
|
|
|
|
|
|
|
|
//Drop Items
|
|
|
|
if (game.DeathDropItems)
|
|
|
|
for (ItemStack stack : event.getDrops())
|
|
|
|
player.getWorld().dropItem(player.getLocation(), stack);
|
|
|
|
event.getDrops().clear();
|
|
|
|
|
2013-10-31 02:43:54 +01:00
|
|
|
//DEATH OUT
|
2013-09-09 10:06:44 +02:00
|
|
|
if (game.GetState() == GameState.Live && game.DeathOut)
|
|
|
|
{
|
|
|
|
//Event
|
|
|
|
PlayerDeathOutEvent outEvent = new PlayerDeathOutEvent(game, player);
|
|
|
|
UtilServer.getServer().getPluginManager().callEvent(outEvent);
|
|
|
|
|
|
|
|
if (!outEvent.isCancelled())
|
|
|
|
{
|
|
|
|
game.SetPlayerState(player, PlayerState.OUT);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-05 07:39:48 +01:00
|
|
|
//RESPAWN
|
2014-03-19 07:51:37 +01:00
|
|
|
if (game.DeathSpectateSecs <= 0 && (game.GetTeam(player) == null || game.GetTeam(player).GetRespawnTime() <= 0))
|
2013-09-09 10:06:44 +02:00
|
|
|
{
|
2013-10-31 02:43:54 +01:00
|
|
|
//Teleport
|
2015-06-16 04:01:52 +02:00
|
|
|
if (game.AutomaticRespawn && game.IsAlive(player))
|
2013-10-31 02:43:54 +01:00
|
|
|
{
|
|
|
|
game.RespawnPlayer(player);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-03-12 05:31:40 +01:00
|
|
|
Manager.addSpectator(player, true);
|
2013-10-31 02:43:54 +01:00
|
|
|
}
|
2013-09-09 10:06:44 +02:00
|
|
|
|
2015-02-26 06:07:07 +01:00
|
|
|
Manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable()
|
2013-10-31 02:43:54 +01:00
|
|
|
{
|
|
|
|
public void run()
|
|
|
|
{
|
|
|
|
player.setFireTicks(0);
|
2015-08-02 11:50:26 +02:00
|
|
|
UtilAction.zeroVelocity(player);
|
2013-10-31 02:43:54 +01:00
|
|
|
}
|
|
|
|
}, 0);
|
|
|
|
}
|
2014-03-05 07:39:48 +01:00
|
|
|
//TIMER
|
2013-10-31 02:43:54 +01:00
|
|
|
else
|
2013-09-09 10:06:44 +02:00
|
|
|
{
|
2014-03-19 07:51:37 +01:00
|
|
|
double time = game.DeathSpectateSecs;
|
|
|
|
if (game.GetTeam(player) != null)
|
|
|
|
if (game.GetTeam(player).GetRespawnTime() > time)
|
|
|
|
time = game.GetTeam(player).GetRespawnTime();
|
|
|
|
|
2013-10-31 02:43:54 +01:00
|
|
|
UtilInv.Clear(player);
|
|
|
|
Manager.GetCondition().Factory().Blind("Ghost", player, player, 1.5, 0, false, false, false);
|
2014-03-19 07:51:37 +01:00
|
|
|
Manager.GetCondition().Factory().Cloak("Ghost", player, player, time, false, false);
|
2015-03-12 05:31:40 +01:00
|
|
|
player.setAllowFlight(true);
|
2013-10-31 02:43:54 +01:00
|
|
|
player.setFlying(true);
|
2014-04-23 01:50:44 +02:00
|
|
|
((CraftPlayer)player).getHandle().spectating = true;
|
|
|
|
((CraftPlayer)player).getHandle().k = false;
|
2013-10-31 02:43:54 +01:00
|
|
|
|
2014-03-05 07:39:48 +01:00
|
|
|
for (int i=0 ; i<9 ; i++)
|
|
|
|
player.getInventory().setItem(i, new ItemStack(Material.SKULL));
|
|
|
|
|
|
|
|
UtilAction.velocity(player, new Vector(0,0,0), 1, true, 0.4, 0, 1, true);
|
|
|
|
|
2015-07-23 05:31:07 +02:00
|
|
|
if (!game.IsAlive(player))
|
|
|
|
{
|
|
|
|
Manager.addSpectator(player, true);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-08-03 16:18:59 +02:00
|
|
|
if (time > 3)
|
|
|
|
{
|
|
|
|
UtilPlayer.message(player, C.cWhite + C.Bold + "You will respawn in " + time + " seconds...");
|
|
|
|
UtilTextMiddle.display(null, "Respawning in " + time + " seconds...", 5, 40, 5, player);
|
|
|
|
}
|
2014-03-05 07:39:48 +01:00
|
|
|
|
2015-02-26 06:07:07 +01:00
|
|
|
Manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable()
|
2013-09-09 10:06:44 +02:00
|
|
|
{
|
2013-10-31 02:43:54 +01:00
|
|
|
public void run()
|
|
|
|
{
|
|
|
|
//Teleport
|
|
|
|
if (game.IsAlive(player))
|
|
|
|
{
|
|
|
|
game.RespawnPlayer(player);
|
2015-07-23 05:31:07 +02:00
|
|
|
}
|
2013-10-31 02:43:54 +01:00
|
|
|
else
|
|
|
|
{
|
2015-03-12 05:31:40 +01:00
|
|
|
Manager.addSpectator(player, true);
|
2013-10-31 02:43:54 +01:00
|
|
|
}
|
2015-04-03 06:28:10 +02:00
|
|
|
|
2013-10-31 02:43:54 +01:00
|
|
|
player.setFireTicks(0);
|
2015-08-02 11:50:26 +02:00
|
|
|
UtilAction.zeroVelocity(player);
|
2013-10-31 02:43:54 +01:00
|
|
|
}
|
2014-03-19 07:51:37 +01:00
|
|
|
}, (int)(time * 20d));
|
2013-10-31 02:43:54 +01:00
|
|
|
}
|
2013-09-09 10:06:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
public void PlayerQuit(PlayerQuitEvent event)
|
|
|
|
{
|
|
|
|
Game game = Manager.GetGame();
|
|
|
|
if (game == null) return;
|
|
|
|
|
2014-12-01 09:33:36 +01:00
|
|
|
//Drop Items
|
|
|
|
if (game.QuitDropItems)
|
2014-12-08 07:28:18 +01:00
|
|
|
if (game.IsLive())
|
|
|
|
if (game.IsAlive(event.getPlayer()))
|
|
|
|
UtilInv.drop(event.getPlayer(), true);
|
2014-12-01 09:33:36 +01:00
|
|
|
|
2013-09-09 10:06:44 +02:00
|
|
|
//Remove Kit
|
|
|
|
game.RemoveTeamPreference(event.getPlayer());
|
|
|
|
game.GetPlayerKits().remove(event.getPlayer());
|
|
|
|
game.GetPlayerGems().remove(event.getPlayer());
|
|
|
|
|
|
|
|
if (!game.QuitOut)
|
|
|
|
return;
|
|
|
|
|
|
|
|
GameTeam team = game.GetTeam(event.getPlayer());
|
2013-09-11 04:22:55 +02:00
|
|
|
|
|
|
|
if (team != null)
|
2014-04-20 05:50:15 +02:00
|
|
|
{
|
|
|
|
if (game.InProgress())
|
|
|
|
team.SetPlayerState(event.getPlayer(), PlayerState.OUT);
|
|
|
|
else
|
|
|
|
team.RemovePlayer(event.getPlayer());
|
|
|
|
}
|
2013-09-09 10:06:44 +02:00
|
|
|
}
|
2014-12-01 09:33:36 +01:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
@EventHandler
|
|
|
|
public void PlayerMoveCancel(PlayerMoveEvent event)
|
|
|
|
{
|
|
|
|
Game game = Manager.GetGame();
|
|
|
|
if (game == null || game.GetState() != GameState.Prepare)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!game.PrepareFreeze)
|
|
|
|
return;
|
2014-10-31 00:35:47 +01:00
|
|
|
|
|
|
|
if (!game.IsAlive(event.getPlayer()))
|
|
|
|
return;
|
2013-08-27 17:14:08 +02:00
|
|
|
|
2013-09-23 08:00:35 +02:00
|
|
|
if (UtilMath.offset2d(event.getFrom(), event.getTo()) <= 0)
|
2013-08-27 17:14:08 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
event.getFrom().setPitch(event.getTo().getPitch());
|
|
|
|
event.getFrom().setYaw(event.getTo().getYaw());
|
|
|
|
|
|
|
|
event.setTo(event.getFrom());
|
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
public void PlayerHealthFoodUpdate(UpdateEvent event)
|
|
|
|
{
|
|
|
|
if (event.getType() != UpdateType.FAST)
|
|
|
|
return;
|
2013-09-03 02:47:15 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
Game game = Manager.GetGame();
|
2013-10-12 00:34:46 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
//Not Playing
|
|
|
|
for (Player player : UtilServer.getPlayers())
|
|
|
|
{
|
2014-04-13 01:26:31 +02:00
|
|
|
if (game == null || game.GetState() == GameState.Recruit || !game.IsAlive(player))
|
2013-08-27 17:14:08 +02:00
|
|
|
{
|
2014-04-13 01:26:31 +02:00
|
|
|
player.setMaxHealth(20);
|
2013-08-27 17:14:08 +02:00
|
|
|
player.setHealth(20);
|
|
|
|
player.setFoodLevel(20);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-12 00:34:46 +02:00
|
|
|
if (game == null || !game.IsLive())
|
2013-08-27 17:14:08 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (game.HungerSet != -1)
|
|
|
|
for (Player player : game.GetPlayers(true))
|
|
|
|
player.setFoodLevel(game.HungerSet);
|
|
|
|
|
|
|
|
if (game.HealthSet != -1)
|
|
|
|
for (Player player : game.GetPlayers(true))
|
|
|
|
player.setHealth(game.HealthSet);
|
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler(priority = EventPriority.LOWEST)
|
|
|
|
public void PlayerBoundaryCheck(UpdateEvent event)
|
|
|
|
{
|
|
|
|
if (event.getType() != UpdateType.FAST)
|
|
|
|
return;
|
2013-09-03 02:47:15 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
Game game = Manager.GetGame();
|
|
|
|
if (game == null || game.GetState() != GameState.Live)
|
|
|
|
return;
|
2013-09-08 11:31:58 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
for (Player player : UtilServer.getPlayers())
|
|
|
|
{
|
2015-06-02 08:48:45 +02:00
|
|
|
if (!game.isInsideMap(player) && game.IsAlive(player))
|
2013-09-13 04:24:33 +02:00
|
|
|
{
|
2015-06-27 03:24:01 +02:00
|
|
|
//Riding a Projectile, edgecase
|
|
|
|
if (player.getVehicle() != null && player.getVehicle() instanceof Projectile)
|
|
|
|
{
|
|
|
|
player.getVehicle().remove();
|
|
|
|
player.leaveVehicle();
|
|
|
|
((CraftPlayer)player).getHandle().spectating = false;
|
|
|
|
}
|
|
|
|
|
2014-05-10 06:01:02 +02:00
|
|
|
if (!Manager.IsAlive(player) || ((CraftPlayer)player).getHandle().spectating)
|
2013-08-27 17:14:08 +02:00
|
|
|
{
|
|
|
|
player.teleport(game.GetSpectatorLocation());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-04-05 07:52:23 +02:00
|
|
|
if (!game.WorldBoundaryKill)
|
2014-01-21 01:28:12 +01:00
|
|
|
{
|
2014-04-05 07:52:23 +02:00
|
|
|
UtilPlayer.message(player, C.cRed + C.Bold + "WARNING: " + C.cWhite + C.Bold + "RETURN TO PLAYABLE AREA!");
|
|
|
|
|
|
|
|
if (game.GetType() != GameType.Gravity)
|
|
|
|
{
|
|
|
|
if (player.getLocation().getY() > game.WorldData.MaxY)
|
|
|
|
UtilAction.velocity(player, UtilAlg.getTrajectory2d(player.getLocation(), game.GetSpectatorLocation()), 1, true, 0, 0, 10, true);
|
|
|
|
else
|
|
|
|
UtilAction.velocity(player, UtilAlg.getTrajectory2d(player.getLocation(), game.GetSpectatorLocation()), 1, true, 0.4, 0, 10, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
Manager.GetDamage().NewDamageEvent(player, null, null,
|
|
|
|
DamageCause.VOID, 4, false, false, false,
|
2015-03-20 05:35:27 +01:00
|
|
|
"Border", "Border Damage");
|
2014-04-05 07:52:23 +02:00
|
|
|
|
|
|
|
player.getWorld().playSound(player.getLocation(), Sound.NOTE_BASS, 2f, 1f);
|
|
|
|
player.getWorld().playSound(player.getLocation(), Sound.NOTE_BASS, 2f, 1f);
|
2014-01-21 01:28:12 +01:00
|
|
|
}
|
2014-04-05 07:52:23 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
Manager.GetDamage().NewDamageEvent(player, null, null,
|
|
|
|
DamageCause.VOID, 9001, false, false, false,
|
2015-03-20 05:35:27 +01:00
|
|
|
"Border", "Border Damage");
|
2014-04-05 07:52:23 +02:00
|
|
|
}
|
2013-08-27 17:14:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler(priority = EventPriority.LOW)
|
|
|
|
public void WorldCreature(CreatureSpawnEvent event)
|
|
|
|
{
|
|
|
|
Game game = Manager.GetGame();
|
|
|
|
if (game == null) return;
|
|
|
|
|
|
|
|
if (!game.CreatureAllow && !game.CreatureAllowOverride)
|
|
|
|
{
|
|
|
|
if (game.WorldData != null)
|
|
|
|
{
|
|
|
|
if (game.WorldData.World != null)
|
|
|
|
{
|
|
|
|
if (event.getLocation().getWorld().equals(game.WorldData.World))
|
|
|
|
{
|
|
|
|
event.setCancelled(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-11-28 23:14:33 +01:00
|
|
|
}
|
2014-11-28 00:00:31 +01:00
|
|
|
|
|
|
|
@EventHandler(priority = EventPriority.MONITOR)
|
|
|
|
public void StaffDisqualify(MineplexTeleportEvent event)
|
|
|
|
{
|
|
|
|
if (event.isCancelled())
|
|
|
|
return;
|
|
|
|
|
2015-08-28 22:22:04 +02:00
|
|
|
if (Manager.GetClients().Get(event.getPlayer()).GetRank().has(Rank.DEVELOPER))
|
2014-11-28 00:00:31 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
Game game = Manager.GetGame();
|
|
|
|
if (game == null) return;
|
2014-11-28 00:09:18 +01:00
|
|
|
|
|
|
|
if (!game.IsLive())
|
|
|
|
return;
|
2015-03-06 09:11:26 +01:00
|
|
|
|
|
|
|
if (!game.TeleportsDisqualify)
|
|
|
|
return;
|
2014-11-28 00:00:31 +01:00
|
|
|
|
2015-06-02 08:48:45 +02:00
|
|
|
if (!game.IsAlive(event.getPlayer()))
|
|
|
|
return;
|
|
|
|
|
2014-11-28 00:00:31 +01:00
|
|
|
//Remove Kit
|
|
|
|
game.RemoveTeamPreference(event.getPlayer());
|
|
|
|
game.GetPlayerKits().remove(event.getPlayer());
|
|
|
|
game.GetPlayerGems().remove(event.getPlayer());
|
|
|
|
|
|
|
|
//Remove Team
|
|
|
|
GameTeam team = game.GetTeam(event.getPlayer());
|
|
|
|
if (team != null)
|
|
|
|
{
|
|
|
|
if (game.InProgress())
|
|
|
|
team.SetPlayerState(event.getPlayer(), PlayerState.OUT);
|
|
|
|
else
|
|
|
|
team.RemovePlayer(event.getPlayer());
|
|
|
|
}
|
|
|
|
|
2015-03-12 05:31:40 +01:00
|
|
|
Manager.addSpectator(event.getPlayer(), false);
|
2014-11-28 00:00:31 +01:00
|
|
|
}
|
2013-08-27 17:14:08 +02:00
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
public void WorldTime(UpdateEvent event)
|
|
|
|
{
|
|
|
|
if (event.getType() != UpdateType.TICK)
|
|
|
|
return;
|
|
|
|
|
|
|
|
Game game = Manager.GetGame();
|
|
|
|
if (game == null) return;
|
|
|
|
|
|
|
|
if (game.WorldTimeSet != -1)
|
|
|
|
{
|
|
|
|
if (game.WorldData != null)
|
|
|
|
{
|
|
|
|
if (game.WorldData.World != null)
|
|
|
|
{
|
|
|
|
game.WorldData.World.setTime(game.WorldTimeSet);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-09-06 07:58:58 +02:00
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
public void WorldWeather(UpdateEvent event)
|
|
|
|
{
|
|
|
|
if (event.getType() != UpdateType.SEC)
|
|
|
|
return;
|
|
|
|
|
|
|
|
Game game = Manager.GetGame();
|
|
|
|
if (game == null) return;
|
|
|
|
|
|
|
|
if (!game.WorldWeatherEnabled)
|
|
|
|
{
|
|
|
|
if (game.WorldData != null)
|
|
|
|
{
|
|
|
|
if (game.WorldData.World != null)
|
|
|
|
{
|
|
|
|
game.WorldData.World.setStorm(false);
|
|
|
|
game.WorldData.World.setThundering(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-08-27 17:14:08 +02:00
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
public void WorldWaterDamage(UpdateEvent event)
|
|
|
|
{
|
2015-06-30 16:18:06 +02:00
|
|
|
if (event.getType() != UpdateType.FAST)
|
|
|
|
return;
|
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
Game game = Manager.GetGame();
|
|
|
|
if (game == null) return;
|
|
|
|
|
|
|
|
if (!game.IsLive())
|
|
|
|
return;
|
2015-06-30 16:18:06 +02:00
|
|
|
|
|
|
|
if (game.WorldWaterDamage <= 0)
|
|
|
|
{
|
|
|
|
if (!game.WorldData.GetCustomLocs("WATER_DAMAGE").isEmpty())
|
|
|
|
{
|
|
|
|
game.WorldWaterDamage = 4;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2013-08-27 17:14:08 +02:00
|
|
|
|
|
|
|
for (GameTeam team : game.GetTeamList())
|
|
|
|
for (Player player : team.GetPlayers(true))
|
2014-10-31 00:35:47 +01:00
|
|
|
if (player.getLocation().getBlock().getTypeId() == 8 || player.getLocation().getBlock().getRelative(BlockFace.UP).getTypeId() == 8 ||
|
|
|
|
player.getLocation().getBlock().getTypeId() == 9 || player.getLocation().getBlock().getRelative(BlockFace.UP).getTypeId() == 9)
|
2013-08-27 17:14:08 +02:00
|
|
|
{
|
|
|
|
//Damage Event
|
|
|
|
Manager.GetDamage().NewDamageEvent(player, null, null,
|
2015-06-30 16:18:06 +02:00
|
|
|
DamageCause.DROWNING, game.WorldWaterDamage, true, false, false,
|
2013-08-27 17:14:08 +02:00
|
|
|
"Water", "Water Damage");
|
|
|
|
|
|
|
|
player.getWorld().playSound(player.getLocation(),
|
|
|
|
Sound.SPLASH, 0.8f,
|
|
|
|
1f + (float) Math.random() / 2);
|
|
|
|
}
|
|
|
|
}
|
2013-09-09 10:06:44 +02:00
|
|
|
|
2014-08-21 05:35:31 +02:00
|
|
|
@EventHandler(priority = EventPriority.LOWEST)
|
|
|
|
public void WorldSoilTrample(PlayerInteractEvent event)
|
|
|
|
{
|
|
|
|
if (event.getAction() != Action.PHYSICAL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
Game game = Manager.GetGame();
|
|
|
|
if (game == null) return;
|
|
|
|
|
|
|
|
if (game.WorldSoilTrample)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (event.getPlayer().getLocation().getBlock().getRelative(BlockFace.DOWN).getType() != Material.SOIL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
event.setCancelled(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
public void WorldBlockBurn(BlockBurnEvent event)
|
|
|
|
{
|
|
|
|
Game game = Manager.GetGame();
|
|
|
|
if (game == null) return;
|
|
|
|
|
|
|
|
if (game.WorldBlockBurn)
|
|
|
|
return;
|
|
|
|
|
|
|
|
event.setCancelled(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
public void WorldFireSpread(BlockIgniteEvent event)
|
|
|
|
{
|
|
|
|
Game game = Manager.GetGame();
|
|
|
|
if (game == null) return;
|
|
|
|
|
|
|
|
if (game.WorldFireSpread)
|
|
|
|
return;
|
|
|
|
|
2014-08-23 09:55:28 +02:00
|
|
|
event.setCancelled(true);
|
2014-08-21 05:35:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler
|
2014-08-22 09:05:14 +02:00
|
|
|
public void WorldLeavesDecay(LeavesDecayEvent event)
|
2014-08-21 05:35:31 +02:00
|
|
|
{
|
|
|
|
Game game = Manager.GetGame();
|
|
|
|
if (game == null) return;
|
|
|
|
|
|
|
|
if (game.WorldLeavesDecay)
|
|
|
|
return;
|
|
|
|
|
|
|
|
event.setCancelled(true);
|
|
|
|
}
|
|
|
|
|
2013-09-09 10:06:44 +02:00
|
|
|
@EventHandler
|
|
|
|
public void SpectatorMessage(UpdateEvent event)
|
|
|
|
{
|
2014-05-02 06:35:41 +02:00
|
|
|
if (Manager.IsTournamentServer())
|
|
|
|
return;
|
|
|
|
|
2013-09-09 10:06:44 +02:00
|
|
|
if (Manager.GetGame() == null)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!Manager.GetGame().AnnounceStay)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!Manager.GetGame().IsLive())
|
|
|
|
return;
|
|
|
|
|
2015-03-23 01:50:09 +01:00
|
|
|
if (event.getType() != UpdateType.SEC)
|
2013-09-09 10:06:44 +02:00
|
|
|
return;
|
2015-08-09 18:17:29 +02:00
|
|
|
|
2013-09-09 10:06:44 +02:00
|
|
|
for (Player player : UtilServer.getPlayers())
|
|
|
|
{
|
|
|
|
if (Manager.IsAlive(player))
|
|
|
|
continue;
|
|
|
|
|
2015-08-09 18:17:29 +02:00
|
|
|
if (Recharge.Instance.use(player, "Dont Quit Message", 300000, false, false))
|
2015-03-23 01:50:09 +01:00
|
|
|
{
|
|
|
|
UtilPlayer.message(player, " ");
|
|
|
|
UtilPlayer.message(player, C.cWhite + C.Bold + "You are out of the game, but " + C.cGold + C.Bold + "DON'T QUIT" + C.cWhite + C.Bold + "!");
|
|
|
|
UtilPlayer.message(player, C.cWhite + C.Bold + "The next game will be starting soon...");
|
|
|
|
}
|
2013-09-09 10:06:44 +02:00
|
|
|
}
|
|
|
|
}
|
2014-10-12 05:19:35 +02:00
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
public void AntiHackStrict(GameStateChangeEvent event)
|
|
|
|
{
|
|
|
|
if (event.GetState() == GameState.Prepare || event.GetState() == GameState.Live)
|
|
|
|
AntiHack.Instance.setStrict(event.GetGame().StrictAntiHack);
|
|
|
|
|
|
|
|
else
|
|
|
|
AntiHack.Instance.setStrict(true);
|
2014-10-31 00:35:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
public void PlayerKillCommandCancel(PlayerCommandPreprocessEvent event)
|
|
|
|
{
|
|
|
|
if (Manager.GetGame() == null)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!Manager.GetGame().DisableKillCommand)
|
|
|
|
return;
|
2014-10-12 05:19:35 +02:00
|
|
|
|
2014-10-31 00:35:47 +01:00
|
|
|
if (event.getMessage().toLowerCase().startsWith("/kill"))
|
|
|
|
{
|
|
|
|
UtilPlayer.message(event.getPlayer(), F.main("Game", "Suicide is disabled."));
|
|
|
|
event.setCancelled(true);
|
|
|
|
}
|
2014-10-12 05:19:35 +02:00
|
|
|
}
|
2015-05-03 23:51:13 +02:00
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
public void versionUpdateCheck(UpdateEvent event)
|
|
|
|
{
|
|
|
|
if (Manager.GetGame() == null)
|
|
|
|
return;
|
|
|
|
|
2015-05-04 07:56:12 +02:00
|
|
|
if (!Manager.GetGame().VersionRequire1_8)
|
2015-05-03 23:51:13 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (event.getType() != UpdateType.SEC)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (Player player : UtilServer.getPlayers())
|
|
|
|
{
|
|
|
|
if (!UtilPlayer.is1_8(player))
|
|
|
|
versionKick(player);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
public void versionJoinCheck(PlayerJoinEvent event)
|
|
|
|
{
|
|
|
|
if (Manager.GetGame() == null)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!Manager.GetGame().VersionRequire1_8)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!UtilPlayer.is1_8(event.getPlayer()))
|
|
|
|
versionKick(event.getPlayer());
|
|
|
|
}
|
|
|
|
|
|
|
|
public void versionKick(Player player)
|
|
|
|
{
|
2015-05-04 07:56:12 +02:00
|
|
|
if (Manager.GetGame() == null)
|
|
|
|
return;
|
2015-08-29 00:36:35 +02:00
|
|
|
//
|
|
|
|
// if (Manager.GetGame().GetType().getResourcePackUrl() == null)
|
|
|
|
// return;
|
|
|
|
//
|
2015-05-03 23:51:13 +02:00
|
|
|
UtilPlayer.message(player, " ");
|
2015-05-04 07:56:12 +02:00
|
|
|
UtilPlayer.message(player, C.cGold + C.Bold + Manager.GetGame().GetType().GetName() + " requires you to be using Minecraft 1.8!");
|
2015-05-03 23:51:13 +02:00
|
|
|
UtilPlayer.message(player, " ");
|
|
|
|
|
|
|
|
player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 10f, 1f);
|
|
|
|
Manager.GetPortal().sendPlayerToServer(player, "Lobby");
|
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
public void resourceInform(PlayerJoinEvent event)
|
|
|
|
{
|
|
|
|
if (Manager.GetGame() == null)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (Manager.GetGame().GetType().getResourcePackUrl() == null)
|
|
|
|
return;
|
|
|
|
|
|
|
|
UtilTextMiddle.display(C.cGold + C.Bold + Manager.GetGame().GetType().GetName(), "Make sure you accept the Resource Pack", 20, 120, 20, event.getPlayer());
|
|
|
|
}
|
2013-08-27 17:14:08 +02:00
|
|
|
}
|