Disable gadgets in arcade for player count > 40
This commit is contained in:
parent
b98944b0a0
commit
32a6d572ee
@ -14,6 +14,7 @@ import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.disguise.DisguiseManager;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.gadget.event.GadgetActivateEvent;
|
||||
import mineplex.core.gadget.event.GadgetCollideEntityEvent;
|
||||
import mineplex.core.gadget.gadgets.ItemBatGun;
|
||||
import mineplex.core.gadget.gadgets.ItemCoinBomb;
|
||||
@ -63,6 +64,7 @@ import mineplex.core.gadget.types.OutfitGadget.ArmorSlot;
|
||||
import mineplex.core.gadget.types.ParticleGadget;
|
||||
import mineplex.core.inventory.InventoryManager;
|
||||
import mineplex.core.mount.MountManager;
|
||||
import mineplex.core.mount.event.MountActivateEvent;
|
||||
import mineplex.core.pet.PetManager;
|
||||
import mineplex.core.preferences.PreferencesManager;
|
||||
import mineplex.core.projectile.ProjectileManager;
|
||||
@ -91,6 +93,7 @@ public class GadgetManager extends MiniPlugin
|
||||
private BlockRestore _blockRestore;
|
||||
private ProjectileManager _projectileManager;
|
||||
private AchievementManager _achievementManager;
|
||||
private MountManager _mountManager;
|
||||
|
||||
private NautHashMap<GadgetType, List<Gadget>> _gadgets;
|
||||
|
||||
@ -99,6 +102,7 @@ public class GadgetManager extends MiniPlugin
|
||||
|
||||
private boolean _hideParticles = false;
|
||||
private int _activeItemSlot = 3;
|
||||
private boolean _gadgetsEnabled = true;
|
||||
|
||||
public GadgetManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager,
|
||||
MountManager mountManager, PetManager petManager, PreferencesManager preferencesManager,
|
||||
@ -115,6 +119,7 @@ public class GadgetManager extends MiniPlugin
|
||||
_blockRestore = blockRestore;
|
||||
_projectileManager = projectileManager;
|
||||
_achievementManager = achievementManager;
|
||||
_mountManager = mountManager;
|
||||
|
||||
CreateGadgets();
|
||||
}
|
||||
@ -492,6 +497,40 @@ public class GadgetManager extends MiniPlugin
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isGadgetEnabled()
|
||||
{
|
||||
return _gadgetsEnabled;
|
||||
}
|
||||
|
||||
public void toggleGadgetEnabled()
|
||||
{
|
||||
setGadgetEnabled(!_gadgetsEnabled);
|
||||
}
|
||||
|
||||
public void setGadgetEnabled(boolean enabled)
|
||||
{
|
||||
if (_gadgetsEnabled != enabled)
|
||||
{
|
||||
_gadgetsEnabled = enabled;
|
||||
DisableAll();
|
||||
_mountManager.DisableAll();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void GadgetActivate(GadgetActivateEvent event)
|
||||
{
|
||||
if (!_gadgetsEnabled)
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void MountActivate(MountActivateEvent event)
|
||||
{
|
||||
if (!_gadgetsEnabled)
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void chissMeow(PlayerToggleSneakEvent event)
|
||||
{
|
||||
|
@ -28,14 +28,12 @@ import mineplex.core.disguise.DisguiseManager;
|
||||
import mineplex.core.disguise.disguises.DisguiseSlime;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.gadget.GadgetManager;
|
||||
import mineplex.core.gadget.event.GadgetActivateEvent;
|
||||
import mineplex.core.gadget.event.GadgetCollideEntityEvent;
|
||||
import mineplex.core.giveaway.GiveawayManager;
|
||||
import mineplex.core.hologram.HologramManager;
|
||||
import mineplex.core.inventory.InventoryManager;
|
||||
import mineplex.core.message.PrivateMessageEvent;
|
||||
import mineplex.core.mount.MountManager;
|
||||
import mineplex.core.mount.event.MountActivateEvent;
|
||||
import mineplex.core.notifier.NotificationManager;
|
||||
import mineplex.core.npc.NpcManager;
|
||||
import mineplex.core.packethandler.PacketHandler;
|
||||
@ -161,9 +159,6 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
||||
|
||||
private HashMap<String, ArrayList<String>> _creativeAdmin = new HashMap<String, ArrayList<String>>();
|
||||
|
||||
//Admin
|
||||
private boolean _gadgetsEnabled = true;
|
||||
|
||||
public HubManager(JavaPlugin plugin, BlockRestore blockRestore, CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager, ConditionManager conditionManager, DisguiseManager disguiseManager, TaskManager taskManager, Portal portal, PartyManager partyManager, PreferencesManager preferences, PetManager petManager, PollManager pollManager, StatsManager statsManager, AchievementManager achievementManager, HologramManager hologramManager, NpcManager npcManager, PersonalServerManager personalServerManager, PacketHandler packetHandler, Punish punish, ServerStatusManager serverStatusManager, GiveawayManager giveawayManager)
|
||||
{
|
||||
super("Hub Manager", plugin);
|
||||
@ -913,12 +908,6 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
||||
event.SetCancelled(true);
|
||||
}
|
||||
|
||||
public boolean IsGadgetEnabled()
|
||||
{
|
||||
return _gadgetsEnabled;
|
||||
}
|
||||
|
||||
|
||||
public NewsManager GetNewsManager()
|
||||
{
|
||||
return _news;
|
||||
@ -935,30 +924,15 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
||||
|
||||
public void ToggleGadget(Player caller)
|
||||
{
|
||||
_gadgetsEnabled = !_gadgetsEnabled;
|
||||
|
||||
if (!_gadgetsEnabled)
|
||||
{
|
||||
GetMount().DisableAll();
|
||||
GetGadget().DisableAll();
|
||||
toggleGadget();
|
||||
}
|
||||
|
||||
public void toggleGadget()
|
||||
{
|
||||
GetGadget().toggleGadgetEnabled();
|
||||
|
||||
for (Player player : UtilServer.getPlayers())
|
||||
player.sendMessage(C.cWhite + C.Bold + "Gadgets/Mounts are now " + F.elem(_gadgetsEnabled ? C.cGreen + C.Bold + "Enabled" : C.cRed + C.Bold + "Disabled"));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void GadgetActivate(GadgetActivateEvent event)
|
||||
{
|
||||
if (!_gadgetsEnabled)
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void MountActivate(MountActivateEvent event)
|
||||
{
|
||||
if (!_gadgetsEnabled)
|
||||
event.setCancelled(true);
|
||||
player.sendMessage(C.cWhite + C.Bold + "Gadgets/Mounts are now " + F.elem(GetGadget().isGadgetEnabled() ? C.cGreen + C.Bold + "Enabled" : C.cRed + C.Bold + "Disabled"));
|
||||
}
|
||||
|
||||
public void addGameMode(Player caller, Player target)
|
||||
|
@ -24,6 +24,7 @@ import mineplex.core.common.util.UtilAction;
|
||||
import mineplex.core.common.util.UtilGear;
|
||||
import mineplex.core.common.util.UtilInv;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.cosmetic.CosmeticManager;
|
||||
import mineplex.core.creature.Creature;
|
||||
@ -1236,6 +1237,25 @@ public class ArcadeManager extends MiniPlugin implements IRelation
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void disableGadget(PlayerJoinEvent event)
|
||||
{
|
||||
updateGadgetEnabled();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void disableGadget(PlayerQuitEvent event)
|
||||
{
|
||||
updateGadgetEnabled();
|
||||
}
|
||||
|
||||
private void updateGadgetEnabled()
|
||||
{
|
||||
// Disables gadgets if player count is greater than 40
|
||||
int playerCount = UtilServer.getPlayers().length;
|
||||
getCosmeticManager().getGadgetManager().setGadgetEnabled(playerCount <= 40);
|
||||
}
|
||||
|
||||
/*public void saveBasicStats(final Game game)
|
||||
{
|
||||
if (!IsTournamentServer())
|
||||
|
Loading…
Reference in New Issue
Block a user