Enable gadgets after stats load to fix level colours "not saving"

This commit is contained in:
Sam 2018-02-16 11:06:01 +00:00 committed by Alexander Meech
parent e9a244b274
commit 15ffcaf5e9
8 changed files with 42 additions and 10 deletions

View File

@ -189,7 +189,7 @@ public class Menu extends ShopPageBase<CosmeticManager, CosmeticShop>
if (enabled.containsKey(type)) addGlow(gameModifierSlot);
type = GadgetType.BALLOON;
lore = getLore(ownedCount.get(type), maxCount.get(type), "Balloons are collectibles that you can float above your head as you wander the lobby. You can have up to 10 balloons in your hand at one time.", VISIBILITY_HUB, enabled.get(type));
lore = getLore(ownedCount.get(type), maxCount.get(type), "Balloons are collectibles that you can float above your head as you wander the lobby. You can have up to 3 balloons in your hand at one time.", VISIBILITY_HUB, enabled.get(type));
addButton(balloonsSlot, new ShopItem(Material.LEASH, "Balloons", lore, 1, false), generateButton(type, enabled.get(type)));
if (enabled.containsKey(type)) addGlow(balloonsSlot);
@ -204,7 +204,7 @@ public class Menu extends ShopPageBase<CosmeticManager, CosmeticShop>
if (enabled.containsKey(type)) addGlow(flagSlot);
type = GadgetType.WEAPON_NAME;
lore = getLore(ownedCount.get(type), maxCount.get(type), "\"Automaigcally\" changes your sword names to really show off how cool you are.", VISIBILITY_GAMES, null);
lore = getLore(ownedCount.get(type), maxCount.get(type), "\"Automagically\" changes your sword names to really show off how cool you are.", VISIBILITY_GAMES, null);
addButton(weaponNameSlot, new ShopItem(Material.DIAMOND_SWORD, "Weapon Names", lore, 1, false), new OpenWeaponNames(this, null));
if (enabled.containsKey(type)) addGlow(weaponNameSlot);

View File

@ -372,6 +372,7 @@ import mineplex.core.packethandler.PacketHandler;
import mineplex.core.pet.PetManager;
import mineplex.core.preferences.PreferencesManager;
import mineplex.core.projectile.ProjectileManager;
import mineplex.core.stats.event.PlayerStatsLoadedEvent;
@ReflectivelyCreateMiniPlugin
public class GadgetManager extends MiniPlugin
@ -1045,7 +1046,11 @@ public class GadgetManager extends MiniPlugin
// Fixes win room speed bug
event.getPlayer().setWalkSpeed(0.2f);
event.getPlayer().setFlySpeed(0.1f);
// Loads saved gadgets
}
@EventHandler
public void statsLoaded(PlayerStatsLoadedEvent event)
{
_userGadgetPersistence.load(event.getPlayer());
}

View File

@ -34,7 +34,7 @@ public class MorphWolf extends MorphAbilityGadget
C.cGray + "Arf",
C.blankLine,
C.cGreen + "Click" + C.cWhite + " your " + C.cYellow + "Bone" + C.cWhite + " to " + C.cGreen + "Pounce"
}, CostConstants.LEVEL_REWARDS, Material.BONE, (byte) 0, ACTIVE_ITEM, "Pounce", TimeUnit.SECONDS.toMillis(2));
}, CostConstants.FOUND_IN_TREASURE_CHESTS, Material.BONE, (byte) 0, ACTIVE_ITEM, "Pounce", TimeUnit.SECONDS.toMillis(2));
}
@Override

View File

@ -11,7 +11,7 @@ public enum WeaponNameType
SWORD_WOOD_SPLINTER(WeaponType.WOOD_SWORD, "Splinter", CostConstants.FOUND_IN_TREASURE_CHESTS, Material.STICK),
SWORD_WOOD_THORN(WeaponType.WOOD_SWORD, "Thorn", CostConstants.FOUND_IN_TREASURE_CHESTS, Material.RED_ROSE),
SWORD_WOOD_TOOTHPICK(WeaponType.WOOD_SWORD, "Kevins Lost Toothpick", CostConstants.FOUND_IN_TREASURE_CHESTS, Material.GRASS),
SWORD_WOOD_TOOTHPICK(WeaponType.WOOD_SWORD, "Kevin's Lost Toothpick", CostConstants.FOUND_IN_TREASURE_CHESTS, Material.GRASS),
SWORD_WOOD_STRIKER(WeaponType.WOOD_SWORD, "Striker", CostConstants.FOUND_IN_TREASURE_CHESTS, Material.BLAZE_ROD),
SWORD_WOOD_THORN_BUSH(WeaponType.WOOD_SWORD, "Thorn Bush", CostConstants.FOUND_IN_TREASURE_CHESTS, Material.DOUBLE_PLANT, (byte) 4),
SWORD_WOOD_HOWLING_SWORD(WeaponType.WOOD_SWORD, "Howling Sword", CostConstants.FOUND_IN_TREASURE_CHESTS, Material.BONE),

View File

@ -38,7 +38,7 @@ public class WinEffectEarthquake extends WinEffectGadget
public WinEffectEarthquake(GadgetManager manager)
{
super(manager, "Earthquake", UtilText.splitLineToArray(C.cGray + "Come crashing down on the losers and send them flying away!", LineFormat.LORE), CostConstants.NO_LORE, Material.STONE, (byte) 3);
super(manager, "Earthquake", UtilText.splitLineToArray(C.cGray + "Come crashing down on the losers and send them flying away!", LineFormat.LORE), CostConstants.FOUND_IN_TREASURE_CHESTS, Material.STONE, (byte) 3);
_schematicName = "TornadoPodium";
_length = TimeUnit.SECONDS.toMillis(7);

View File

@ -2,11 +2,8 @@ package mineplex.core.gadget.set;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailBalance;
import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailLegend;
import mineplex.core.gadget.gadgets.death.DeathBalance;
import mineplex.core.gadget.gadgets.death.DeathLegend;
import mineplex.core.gadget.gadgets.doublejump.DoubleJumpBalance;
import mineplex.core.gadget.gadgets.doublejump.DoubleJumpLegend;
import mineplex.core.gadget.gadgets.particle.ParticleYinYang;
import mineplex.core.gadget.types.GadgetSet;
@ -15,7 +12,7 @@ public class SetBalance extends GadgetSet
public SetBalance(GadgetManager manager)
{
super(manager, "Balance", "Improved Yin Yang",
super(manager, "Balance", "Rainbow Yin Yang",
manager.getGadget(ArrowTrailBalance.class),
manager.getGadget(DeathBalance.class),
manager.getGadget(DoubleJumpBalance.class),

View File

@ -30,6 +30,7 @@ import mineplex.core.leaderboard.LeaderboardManager;
import mineplex.core.stats.command.GiveStatCommand;
import mineplex.core.stats.command.SetLevelCommand;
import mineplex.core.stats.command.TimeCommand;
import mineplex.core.stats.event.PlayerStatsLoadedEvent;
import mineplex.core.stats.event.StatChangeEvent;
import mineplex.core.thread.ThreadPool;
import mineplex.core.updater.UpdateType;
@ -384,6 +385,7 @@ public class StatsManager extends MiniClientPlugin<PlayerStats>//MiniDbClientPlu
{
Set(uuid, stats);
UtilPlayer.message(event.getPlayer(), F.main(getName(), "Your stats have been loaded!"));
UtilServer.CallEvent(new PlayerStatsLoadedEvent(event.getPlayer()));
}
});
}, 5 * 20); //Load 5 seconds later

View File

@ -0,0 +1,28 @@
package mineplex.core.stats.event;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerEvent;
public class PlayerStatsLoadedEvent extends PlayerEvent
{
private static final HandlerList HANDLER_LIST = new HandlerList();
public PlayerStatsLoadedEvent(Player player)
{
super(player);
}
@Override
public HandlerList getHandlers()
{
return HANDLER_LIST;
}
public static HandlerList getHandlerList()
{
return HANDLER_LIST;
}
}