From 61541c130fae0c4253afc5fe94c29ba44d69ef7f Mon Sep 17 00:00:00 2001 From: Sam Date: Sun, 10 Sep 2017 23:57:43 +0100 Subject: [PATCH] Don't get cosmetic data if cosmetics have been disabled --- .../src/mineplex/core/gadget/GadgetManager.java | 2 ++ .../gadget/persistence/UserGadgetPersistence.java | 12 ++++++++++++ .../mineplex/core/gadget/types/WinEffectGadget.java | 1 + 3 files changed, 15 insertions(+) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java index 55ceae0c8..13c7da270 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java @@ -1114,6 +1114,8 @@ public class GadgetManager extends MiniPlugin public void disableAll() { + _userGadgetPersistence.setEnabled(false); + for (GadgetType gadgetType : _gadgets.keySet()) { for (Gadget gadget : _gadgets.get(gadgetType)) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/persistence/UserGadgetPersistence.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/persistence/UserGadgetPersistence.java index 3f62be744..7439ae81c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/persistence/UserGadgetPersistence.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/persistence/UserGadgetPersistence.java @@ -16,15 +16,27 @@ public class UserGadgetPersistence private final GadgetManager _manager; private final PlayerKeyValueRepository _repository; + private boolean _enabled; public UserGadgetPersistence(GadgetManager manager) { _manager = manager; _repository = new PlayerKeyValueRepository<>("gadgets", String.class); + _enabled = true; + } + + public void setEnabled(boolean enabled) + { + _enabled = enabled; } public void load(Player player) { + if (!_enabled) + { + return; + } + _repository.getAll(player.getUniqueId()).thenCompose(BukkitFuture.accept(values -> { if (player.isOnline()) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/WinEffectGadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/WinEffectGadget.java index d646f4c91..046f74787 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/WinEffectGadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/WinEffectGadget.java @@ -123,6 +123,7 @@ public abstract class WinEffectGadget extends Gadget _allPlayers.clear(); _allPlayers = null; // Loads gadgets back when players are teleported to the arcade hub, after the win effect + Manager.getUserGadgetPersistence().setEnabled(true); for (Player player : UtilServer.getPlayers()) { Manager.getUserGadgetPersistence().load(player);