132 lines
3.3 KiB
Java
132 lines
3.3 KiB
Java
package nautilus.game.arcade.managers;
|
|
|
|
import mineplex.core.common.util.C;
|
|
import mineplex.core.common.util.UtilPlayer;
|
|
import mineplex.core.common.util.UtilServer;
|
|
import mineplex.core.updater.UpdateType;
|
|
import mineplex.core.updater.event.UpdateEvent;
|
|
import nautilus.game.arcade.ArcadeManager;
|
|
|
|
import org.bukkit.Material;
|
|
import org.bukkit.entity.Player;
|
|
import org.bukkit.event.EventHandler;
|
|
import org.bukkit.event.EventPriority;
|
|
import org.bukkit.event.Listener;
|
|
import org.bukkit.event.block.Action;
|
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
|
import org.bukkit.event.inventory.PrepareItemCraftEvent;
|
|
import org.bukkit.event.player.PlayerInteractEvent;
|
|
import org.bukkit.inventory.CraftingInventory;
|
|
|
|
public class MiscManager implements Listener
|
|
{
|
|
ArcadeManager Manager;
|
|
|
|
public MiscManager(ArcadeManager manager)
|
|
{
|
|
Manager = manager;
|
|
|
|
Manager.GetPluginManager().registerEvents(this, Manager.GetPlugin());
|
|
}
|
|
|
|
@EventHandler(priority = EventPriority.LOWEST)
|
|
public void InteractActive(PlayerInteractEvent event)
|
|
{
|
|
event.setCancelled(false);
|
|
}
|
|
|
|
@EventHandler(priority = EventPriority.LOW)
|
|
public void InteractClickCancel(PlayerInteractEvent event)
|
|
{
|
|
if (Manager.GetGame() == null)
|
|
return;
|
|
|
|
Player player = event.getPlayer();
|
|
|
|
if (!Manager.GetGame().IsAlive(player))
|
|
{
|
|
event.setCancelled(true);
|
|
}
|
|
else if (event.getPlayer().getItemInHand().getType() == Material.INK_SACK && event.getPlayer().getItemInHand().getData().getData() == (byte)15)
|
|
{
|
|
if (event.getAction() == Action.RIGHT_CLICK_BLOCK)
|
|
event.setCancelled(true);
|
|
}
|
|
}
|
|
|
|
@EventHandler(priority = EventPriority.LOWEST)
|
|
public void InventoryClickCancel(InventoryClickEvent event)
|
|
{
|
|
if (Manager.GetGame() == null)
|
|
return;
|
|
|
|
Player player = UtilPlayer.searchExact(event.getWhoClicked().getName());
|
|
|
|
if (Manager.GetGame().IsLive() && !Manager.GetGame().IsAlive(player))
|
|
{
|
|
event.setCancelled(true);
|
|
player.closeInventory();
|
|
}
|
|
}
|
|
|
|
@EventHandler(priority = EventPriority.HIGH)
|
|
public void CraftingDeny(PrepareItemCraftEvent event)
|
|
{
|
|
if (event.getRecipe().getResult() == null)
|
|
return;
|
|
|
|
Material type = event.getRecipe().getResult().getType();
|
|
|
|
if (type != Material.GOLDEN_APPLE &&
|
|
type != Material.GOLDEN_CARROT &&
|
|
type != Material.FLINT_AND_STEEL)
|
|
return;
|
|
|
|
if (!(event.getInventory() instanceof CraftingInventory))
|
|
return;
|
|
|
|
CraftingInventory inv = (CraftingInventory)event.getInventory();
|
|
inv.setResult(null);
|
|
}
|
|
|
|
@EventHandler
|
|
public void SpectatorMessage(UpdateEvent event)
|
|
{
|
|
if (Manager.GetGame() == null)
|
|
return;
|
|
|
|
if (!Manager.GetGame().IsLive())
|
|
return;
|
|
|
|
if (event.getType() != UpdateType.SLOWER)
|
|
return;
|
|
|
|
for (Player player : UtilServer.getPlayers())
|
|
{
|
|
if (Manager.IsAlive(player))
|
|
continue;
|
|
|
|
UtilPlayer.message(player, C.cYellow + C.Bold + "You are out of the game, but " + C.cGold + C.Bold + "DON'T QUIT" + C.cYellow + C.Bold + "!");
|
|
UtilPlayer.message(player, C.cYellow + C.Bold + "The next game will be starting soon...");
|
|
}
|
|
}
|
|
|
|
@EventHandler
|
|
public void EnsureHubClock(UpdateEvent event)
|
|
{
|
|
if (event.getType() != UpdateType.SLOW)
|
|
return;
|
|
|
|
for (Player player : UtilServer.getPlayers())
|
|
{
|
|
if (Manager.GetGame() == null || !Manager.GetGame().IsAlive(player))
|
|
{
|
|
if (!player.getInventory().contains(Material.WATCH))
|
|
{
|
|
Manager.HubClock(player);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|