2013-08-27 17:14:08 +02:00
|
|
|
package nautilus.game.arcade.managers;
|
|
|
|
|
2014-04-20 07:54:52 +02:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
import mineplex.core.common.util.UtilServer;
|
2014-09-21 01:26:34 +02:00
|
|
|
import mineplex.core.recharge.Recharge;
|
2013-08-27 17:14:08 +02:00
|
|
|
import mineplex.core.updater.UpdateType;
|
|
|
|
import mineplex.core.updater.event.UpdateEvent;
|
|
|
|
import nautilus.game.arcade.ArcadeManager;
|
2013-09-09 10:06:44 +02:00
|
|
|
import nautilus.game.arcade.GameType;
|
2015-05-01 01:20:35 +02:00
|
|
|
import nautilus.game.arcade.events.GameStateChangeEvent;
|
2014-05-07 07:38:27 +02:00
|
|
|
import nautilus.game.arcade.game.Game.GameState;
|
2013-08-27 17:14:08 +02:00
|
|
|
|
|
|
|
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;
|
2014-04-20 07:54:52 +02:00
|
|
|
import org.bukkit.event.inventory.InventoryCloseEvent;
|
|
|
|
import org.bukkit.event.inventory.InventoryOpenEvent;
|
2013-09-15 03:12:11 +02:00
|
|
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
2013-08-27 17:14:08 +02:00
|
|
|
import org.bukkit.event.player.PlayerInteractEvent;
|
|
|
|
|
|
|
|
public class MiscManager implements Listener
|
|
|
|
{
|
2014-04-20 07:54:52 +02:00
|
|
|
private List<String> _dontGiveClockList = new ArrayList<String>();
|
|
|
|
private ArcadeManager Manager;
|
2013-08-27 17:14:08 +02:00
|
|
|
|
|
|
|
public MiscManager(ArcadeManager manager)
|
|
|
|
{
|
|
|
|
Manager = manager;
|
|
|
|
|
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.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();
|
|
|
|
|
2013-10-04 23:49:05 +02:00
|
|
|
//BoneMeal
|
2015-05-11 19:21:32 +02:00
|
|
|
if (!Manager.GetGame().WorldBoneMeal &&
|
|
|
|
event.getAction() == Action.RIGHT_CLICK_BLOCK &&
|
|
|
|
event.getPlayer().getItemInHand().getType() == Material.INK_SACK &&
|
|
|
|
event.getPlayer().getItemInHand().getData().getData() == (byte)15)
|
2013-08-27 17:14:08 +02:00
|
|
|
{
|
2015-05-11 19:21:32 +02:00
|
|
|
event.setCancelled(true);
|
2013-08-27 17:14:08 +02:00
|
|
|
}
|
2014-05-07 07:38:27 +02:00
|
|
|
else if (Manager.GetGame().GetState() != GameState.Live)
|
|
|
|
{
|
|
|
|
event.setCancelled(true);
|
|
|
|
}
|
2013-08-27 17:14:08 +02:00
|
|
|
}
|
|
|
|
|
2014-04-20 07:54:52 +02:00
|
|
|
@EventHandler
|
|
|
|
public void addClockPrevent(InventoryOpenEvent event)
|
|
|
|
{
|
|
|
|
if (event.getPlayer() instanceof Player)
|
|
|
|
{
|
|
|
|
_dontGiveClockList.add(event.getPlayer().getName());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
public void removeClockPrevent(InventoryCloseEvent event)
|
|
|
|
{
|
|
|
|
if (event.getPlayer() instanceof Player)
|
|
|
|
{
|
|
|
|
_dontGiveClockList.remove(event.getPlayer().getName());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
@EventHandler
|
2013-09-15 03:12:11 +02:00
|
|
|
public void HubClockUpdate(UpdateEvent event)
|
2013-08-27 17:14:08 +02:00
|
|
|
{
|
2014-08-30 08:33:56 +02:00
|
|
|
if (!Manager.IsHotbarHubClock())
|
2014-05-03 09:26:21 +02:00
|
|
|
return;
|
|
|
|
|
2014-08-10 02:50:31 +02:00
|
|
|
if (event.getType() != UpdateType.FAST)
|
2013-08-27 17:14:08 +02:00
|
|
|
return;
|
|
|
|
|
2013-09-15 03:12:11 +02:00
|
|
|
if (Manager.GetGame() == null)
|
|
|
|
return;
|
2014-06-27 03:38:11 +02:00
|
|
|
|
2013-08-27 17:14:08 +02:00
|
|
|
for (Player player : UtilServer.getPlayers())
|
|
|
|
{
|
2014-08-10 02:50:31 +02:00
|
|
|
if (Manager.GetGame().IsAlive(player))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (_dontGiveClockList.contains(player.getName()))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
Manager.HubClock(player);
|
2013-08-27 17:14:08 +02:00
|
|
|
}
|
|
|
|
}
|
2013-09-15 03:12:11 +02:00
|
|
|
|
|
|
|
@EventHandler(priority = EventPriority.LOWEST)
|
|
|
|
public void HubClockInteract(PlayerInteractEvent event)
|
|
|
|
{
|
2014-08-30 08:33:56 +02:00
|
|
|
if (!Manager.IsHotbarHubClock())
|
2014-05-03 09:26:21 +02:00
|
|
|
return;
|
|
|
|
|
2014-12-08 07:28:18 +01:00
|
|
|
if (event.getAction() == Action.PHYSICAL)
|
|
|
|
return;
|
|
|
|
|
2013-09-15 03:12:11 +02:00
|
|
|
Player player = event.getPlayer();
|
|
|
|
|
|
|
|
if (player.getItemInHand() == null)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (player.getItemInHand().getType() != Material.WATCH)
|
|
|
|
return;
|
|
|
|
|
2014-09-21 01:26:34 +02:00
|
|
|
if (!Recharge.Instance.usable(event.getPlayer(), "Return to Hub"))
|
|
|
|
return;
|
|
|
|
|
2015-01-11 09:42:31 +01:00
|
|
|
Manager.GetPortal().sendPlayerToServer(player, "Lobby");
|
2013-09-15 03:12:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
public void HubCommand(PlayerCommandPreprocessEvent event)
|
|
|
|
{
|
2014-12-10 05:38:57 +01:00
|
|
|
if (event.getMessage().toLowerCase().startsWith("/lobby") || event.getMessage().toLowerCase().startsWith("/hub") || event.getMessage().toLowerCase().startsWith("/leave"))
|
2013-09-15 03:12:11 +02:00
|
|
|
{
|
2015-01-11 09:42:31 +01:00
|
|
|
Manager.GetPortal().sendPlayerToServer(event.getPlayer(), "Lobby");
|
2013-09-15 03:12:11 +02:00
|
|
|
event.setCancelled(true);
|
|
|
|
}
|
|
|
|
}
|
2015-05-01 01:20:35 +02:00
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
public void disableAchievementGUI(GameStateChangeEvent event)
|
|
|
|
{
|
|
|
|
Manager.GetAchievement().setShopEnabled(event.GetState() != GameState.Prepare && event.GetState() != GameState.Live);
|
|
|
|
}
|
2013-08-27 17:14:08 +02:00
|
|
|
}
|