From f6b06c63ac0b1e90683874e408fa3a598b305173 Mon Sep 17 00:00:00 2001 From: LCastr0 Date: Sat, 10 Sep 2016 00:43:08 -0300 Subject: [PATCH 01/11] Fixes for the Omega chest giving duplicated items --- .../gadget/commands/LockCosmeticsCommand.java | 57 +++++++------- .../commands/UnlockCosmeticsCommand.java | 74 ++++++++++++------- .../mineplex/core/reward/RewardManager.java | 2 +- .../reward/rewards/UnknownPackageReward.java | 31 +++++++- 4 files changed, 104 insertions(+), 60 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/LockCosmeticsCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/LockCosmeticsCommand.java index 25e3cf585..c957b8da4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/LockCosmeticsCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/LockCosmeticsCommand.java @@ -2,15 +2,13 @@ package mineplex.core.gadget.commands; import mineplex.core.command.CommandBase; import mineplex.core.common.Rank; -import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilText; +import mineplex.core.donation.Donor; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.types.Gadget; import mineplex.core.gadget.types.GadgetType; -import mineplex.core.inventory.ClientInventory; -import mineplex.core.inventory.ClientItem; import mineplex.core.mount.Mount; import mineplex.core.pet.Pet; import org.bukkit.entity.Player; @@ -72,54 +70,56 @@ public class LockCosmeticsCommand extends CommandBase { for (GadgetType type : GadgetType.values()) { - if (type == GadgetType.ITEM) - continue; removeCosmetics(type, caller); } removeMounts(caller); removePets(caller); return; } - ClientInventory clientInventory = _plugin.getInventoryManager().Get(caller); + Donor donor = _plugin.getDonationManager().Get(caller); int removed = 0; - int amount = -1; for (Gadget gadget : _plugin.getGadgets(gadgetType)) { - if (gadgetType == GadgetType.ITEM) - continue; - if (gadget.ownsGadget(caller)) + if (gadget != null) { - ClientItem clientItem = clientInventory.getClientItem(gadget.getName()); - if (clientItem != null) + int i; + String[] names = new String[gadget.getAlternativePackageNames().length + 1]; + for (i = 0; i < gadget.getAlternativePackageNames().length; i++) { - clientInventory.removeItem(clientItem); - removed++; + names[i] = gadget.getAlternativePackageNames()[i]; + } + names[i++] = gadget.getName(); + for (String name : names) + { + if (donor.OwnsUnknownPackage(name)) + { + donor.RemoveUnknownSalesPackagesOwned(name); + removed++; + } } } } - UtilPlayer.message(caller, F.main("Cosmetics", "Removed all the " + gadgetType.name().toLowerCase() - .replace("_", " ") + " gadgets! (Removed " + C.cRed + removed + C.cGray + " " + - UtilText.plural("item", removed) + ")")); + UtilPlayer.message(caller, F.main("Lock Cosmetics", "Removed " + removed + F.elem(" " + gadgetType.getCategoryType()) + UtilText.plural(" item", removed) + "!")); } private void removeMounts(Player caller) { + Donor donor = _plugin.getDonationManager().Get(caller); int removed = 0; - ClientInventory clientInventory = _plugin.getInventoryManager().Get(caller); for (Mount mount : _plugin.getMountManager().getMounts()) { - if (mount.hasMount(caller)) + if (donor.OwnsUnknownPackage(mount.getName())) { - ClientItem clientItem = clientInventory.getClientItem(mount.getName()); - if (clientItem != null) - { - clientInventory.removeItem(clientInventory.getClientItem(mount.getName())); - removed++; - } + donor.RemoveUnknownSalesPackagesOwned(mount.getName()); + removed++; + } + else if (mount.hasMount(caller)) + { + donor.RemoveUnknownSalesPackagesOwned(mount.getName()); + removed++; } } - UtilPlayer.message(caller, F.main("Cosmetics", "Removed " + C.cRed + removed + C.cGray + " " + - UtilText.plural("mount", removed) + "!")); + UtilPlayer.message(caller, F.main("Lock Cosmetics", "Removed " + removed + UtilText.plural(" Mount", removed) + "!")); } private void removePets(Player caller) @@ -133,8 +133,7 @@ public class LockCosmeticsCommand extends CommandBase removed++; } } - UtilPlayer.message(caller, F.main("Cosmetics", "Removed " + C.cRed + removed + C.cGray + " " + - UtilText.plural("pet", removed) + "!")); + UtilPlayer.message(caller, F.main("Lock Cosmetics", "Removed " + removed + UtilText.plural(" pet", removed) + "!")); } } \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/UnlockCosmeticsCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/UnlockCosmeticsCommand.java index 36a279711..889c7ce44 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/UnlockCosmeticsCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/UnlockCosmeticsCommand.java @@ -2,10 +2,10 @@ package mineplex.core.gadget.commands; import mineplex.core.command.CommandBase; import mineplex.core.common.Rank; -import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilText; +import mineplex.core.donation.Donor; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.types.Gadget; import mineplex.core.gadget.types.GadgetType; @@ -65,47 +65,66 @@ public class UnlockCosmeticsCommand extends CommandBase } private void addCosmetics(GadgetType gadgetType, Player caller) - { - if (gadgetType == null) - { - for (GadgetType type : GadgetType.values()) - { - addCosmetics(type, caller); - } + { + if (gadgetType == null) + { + for (GadgetType type : GadgetType.values()) + { + addCosmetics(type, caller); + } addMounts(caller); addPets(caller); - return; - } + return; + } + Donor donor = _plugin.getDonationManager().Get(caller); int added = 0; - int amount = 1; - for (Gadget gadget : _plugin.getGadgets(gadgetType)) - { - if (gadgetType == GadgetType.ITEM) - amount = 20; - if (!gadget.ownsGadget(caller)) + for (Gadget gadget : _plugin.getGadgets(gadgetType)) + { + if (gadget != null) { - _plugin.getInventoryManager().addItemToInventory(caller, gadget.getName(), amount); - added++; + boolean hasGadget = false; + int i; + String[] names = new String[gadget.getAlternativePackageNames().length + 1]; + for (i = 0; i < gadget.getAlternativePackageNames().length; i++) + { + names[i] = gadget.getAlternativePackageNames()[i]; + } + names[i++] = gadget.getName(); + for (String name : names) + { + if (donor.OwnsUnknownPackage(name)) + { + hasGadget = true; + } + } + if (!hasGadget) + { + donor.AddUnknownSalesPackagesOwned(gadget.getName()); + added++; + } } - } - UtilPlayer.message(caller, F.main("Cosmetics", "Added all the " + gadgetType.name().toLowerCase() - .replace("_", " ") + "! (Added " + C.cRed + added + C.cGray + " " + - UtilText.plural("item", added) + ")")); + } + UtilPlayer.message(caller, F.main("Unlock Cosmetics", "Added" + added + F.elem(" " + gadgetType.getCategoryType()) + UtilText.plural(" item", added) + "!")); } private void addMounts(Player caller) { + Donor donor = _plugin.getDonationManager().Get(caller); int added = 0; for (Mount mount : _plugin.getMountManager().getMounts()) { - if (!mount.hasMount(caller)) + if (!donor.OwnsUnknownPackage(mount.getName())) { - _plugin.getInventoryManager().addItemToInventory(caller, mount.getName(), 1); + donor.AddUnknownSalesPackagesOwned(mount.getName()); + added++; + } + else if (!mount.hasMount(caller)) + { + donor.AddUnknownSalesPackagesOwned(mount.getName()); added++; } } - UtilPlayer.message(caller, F.main("Cosmetics", "Added " + C.cRed + added + C.cGray + " " + - UtilText.plural("mount", added) + "!")); + UtilPlayer.message(caller, F.main("Unlock Cosmetics", "Added " + added + UtilText.plural(" mount", added) + "!")); } private void addPets(Player caller) @@ -119,7 +138,6 @@ public class UnlockCosmeticsCommand extends CommandBase added++; } } - UtilPlayer.message(caller, F.main("Cosmetics", "Added " + C.cRed + added + C.cGray + " " + - UtilText.plural("pet", added) + "!")); + UtilPlayer.message(caller, F.main("Unlock Cosmetics", "Added " + added + UtilText.plural(" pet", added) + "!")); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java index c4ca55dda..0d7cc14d5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java @@ -591,7 +591,7 @@ public class RewardManager UnknownPackageReward reward = new UnknownPackageReward(_donationManager, gadget.getGadgetType().getCategoryType(), displayName, gadget.getName(), display, rarity, - weight, shards); + weight, shards, gadget.getAlternativePackageNames()); addReward(type, reward); return reward; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/UnknownPackageReward.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/UnknownPackageReward.java index 2f82d9805..99f29d7b8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/UnknownPackageReward.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/rewards/UnknownPackageReward.java @@ -19,6 +19,7 @@ public class UnknownPackageReward extends Reward private String _header; private String _name; private String _packageName; + private String[] _alternativeNames; public UnknownPackageReward(DonationManager donationManager, String header, String name, String packageName, ItemStack itemStack, RewardRarity rarity, int weight, int shardValue) { @@ -28,6 +29,18 @@ public class UnknownPackageReward extends Reward _name = name; _packageName = packageName; _itemStack = itemStack; + _alternativeNames = new String[]{}; + } + + public UnknownPackageReward(DonationManager donationManager, String header, String name, String packageName, ItemStack itemStack, RewardRarity rarity, int weight, int shardValue, String... alternativeNames) + { + super(rarity, weight, shardValue); + _donationManager = donationManager; + _header = header; + _name = name; + _packageName = packageName; + _itemStack = itemStack; + _alternativeNames = alternativeNames; } @Override @@ -46,8 +59,22 @@ public class UnknownPackageReward extends Reward System.out.println("Could not give reward " + _packageName + " to Offline Player: " + player.getName()); return false; } - - return !_donationManager.Get(player).OwnsUnknownPackage(_packageName); + boolean hasItem = false; + if (_donationManager.Get(player).OwnsUnknownPackage(_packageName)) + { + hasItem = true; + } + else + { + for (String altName : _alternativeNames) + { + if (_donationManager.Get(player).OwnsUnknownPackage(altName)) + { + hasItem = true; + } + } + } + return !hasItem; } @Override From ae6868b76ae39974763dd653fbd2d45f6b807e8a Mon Sep 17 00:00:00 2001 From: LCastr0 Date: Fri, 16 Sep 2016 20:46:52 -0300 Subject: [PATCH 02/11] Added Witch Morph Added Metal Man morph --- .../mineplex/core/common/skin/SkinData.java | 3 +- .../core/cosmetic/ui/page/GadgetPage.java | 19 ++- .../mineplex/core/gadget/GadgetManager.java | 1 + .../commands/UnlockCosmeticsCommand.java | 2 +- .../gadget/gadgets/morph/MorphMetalMan.java | 23 +--- .../core/gadget/gadgets/morph/MorphWitch.java | 113 ++++++++++++++++++ .../gadgets/morph/WitchEffectManager.java | 80 +++++++++++++ .../particle/unrelated/MetalManEffect.java | 51 ++++++-- .../unrelated/WitchParticleEffect.java | 25 ++++ .../powerplayclub/PowerPlayClubRewards.java | 10 +- 10 files changed, 288 insertions(+), 39 deletions(-) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphWitch.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/WitchEffectManager.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/unrelated/WitchParticleEffect.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/skin/SkinData.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/skin/SkinData.java index dcac2d504..b551ca902 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/skin/SkinData.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/skin/SkinData.java @@ -55,8 +55,9 @@ public class SkinData public final static SkinData SNOWMAN = new SkinData("eyJ0aW1lc3RhbXAiOjE0NTAwMTk4Nzk5NDIsInByb2ZpbGVJZCI6ImE5ZDBjMDcyYmYxOTQwYTFhMTkzNjhkMDlkNTAwMjZlIiwicHJvZmlsZU5hbWUiOiJTcGlyaXR1c1NhbmN0dXMiLCJzaWduYXR1cmVSZXF1aXJlZCI6dHJ1ZSwidGV4dHVyZXMiOnsiU0tJTiI6eyJ1cmwiOiJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzEzMTgxYWViODQzODk3NzM1ZDQwMmIyNDk2OTQxNmZkYjBjZTM0YTZiOTM3ODE2MjQzNzU2ZTlkYWU1OGUzIn19fQ==", "NZvsNu+HQ5uvGWq6O8VNDGq9A145bmk2IkHiz916uRVPMRqqCI/zwhKWNLlFACE/feuLkhYAois29ec6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s6kqTer2Rjg3X+XwYFFiDHAR/gwhfXLzrM1iBc171vgu6T+kx65iBHa/YB/V/mj8FSxwM0f5IsLpgAEdxDL9PvEKQWgWeZ1CAqEXlGnjPkd9oGzW0TgDz2MksBbYZ2kmn/S53kK9vCrVB7egZPS4VBtKpq1P7Jeu8rtgjnAKVFQJZ2lMHnVRuvGTd8JKoPHarUPpU2LURUMaCtHzSv9v/4gjkafnDhqxG4TTcr5hxFV+ho72HQchoeaUXzIO+Yo71zrVqkrS0hw6OtgMIBlvaGaEUsFvGiCZePBEiHojO43AKqJcJAVeT2RAzHcAaBAO79ACGjNKw/oj02rOurLha9i+99bKui96Eg7SS/nPchbmu5YQ9nSpkW+JeYXnBzGGzNG4y02VWgz15L718+8161zXobhuK07qlY9i1nipFbEJedqG0cfS+AUzauETFvS9nMtxhtftYPCIxm40GQj6e77asNCAEElGssaUGKO3bjm348+oF9tR/eBOYWJQ8kL46IQLDRoop7UhG4ewY="); // Comments this out for now, so it doesn't load the player profile // A better way to do this would check for the properties when getting the skull or the skin diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java index a5c62b29c..293e6b84d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/GadgetPage.java @@ -1,5 +1,9 @@ package mineplex.core.cosmetic.ui.page; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + import mineplex.core.account.CoreClientManager; import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.C; @@ -15,6 +19,7 @@ import mineplex.core.cosmetic.ui.button.deactivate.DeactivateGadgetButton; import mineplex.core.donation.DonationManager; import mineplex.core.gadget.event.GadgetChangeEvent; import mineplex.core.gadget.gadgets.morph.MorphBlock; +import mineplex.core.gadget.gadgets.morph.MorphWitch; import mineplex.core.gadget.types.Gadget; import mineplex.core.gadget.types.GadgetType; import mineplex.core.gadget.types.HatGadget; @@ -31,10 +36,6 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.BannerMeta; import org.bukkit.inventory.meta.ItemMeta; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - public class GadgetPage extends ShopPageBase { public GadgetPage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player) @@ -277,7 +278,15 @@ public class GadgetPage extends ShopPageBase //Standard if (gadget.ownsGadget(getPlayer())) { - ItemStack gadgetItemStack = new ItemStack(gadget.getDisplayMaterial(), 1, gadget.getDisplayData()); + ItemStack gadgetItemStack; + if (gadget instanceof MorphWitch) + { + gadgetItemStack = ((MorphWitch) gadget).getWitchItem(); + } + else + { + gadgetItemStack = new ItemStack(gadget.getDisplayMaterial(), 1, gadget.getDisplayData()); + } ItemMeta meta = gadgetItemStack.getItemMeta(); meta.setDisplayName(C.cGreen + C.Bold + gadget.getName()); if (gadget.getActive().contains(getPlayer())) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java index 708e2a6f1..b455013c4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java @@ -341,6 +341,7 @@ public class GadgetManager extends MiniPlugin addGadget(new MorphSnowman(this)); addGadget(new MorphUncleSam(this)); addGadget(new MorphSquid(this)); + addGadget(new MorphWitch(this)); // Not being added in this update! //addGadget(new MorphMetalMan(this)); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/UnlockCosmeticsCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/UnlockCosmeticsCommand.java index 889c7ce44..c24411ebd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/UnlockCosmeticsCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/commands/UnlockCosmeticsCommand.java @@ -20,7 +20,7 @@ public class UnlockCosmeticsCommand extends CommandBase public UnlockCosmeticsCommand(GadgetManager plugin) { - super(plugin, Rank.JNR_DEV, new Rank[]{Rank.SNR_MODERATOR}, "unlockCosmetics"); + super(plugin, Rank.JNR_DEV, "unlockCosmetics"); _plugin = plugin; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphMetalMan.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphMetalMan.java index 77e2ee795..cdb03128f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphMetalMan.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphMetalMan.java @@ -29,7 +29,8 @@ public class MorphMetalMan extends MorphGadget public MorphMetalMan(GadgetManager manager) { - super(manager, "Metal Man Morph", UtilText.splitLinesToArray(new String[]{"Placeholder"}, LineFormat.LORE), + super(manager, "Metal Man Morph", UtilText.splitLinesToArray(new String[]{C.cGray + "This powerful suit forged of metal makes the wearer strong enough to even battle the gods", + C.cWhite + "Left-click to shoot laser beam"}, LineFormat.LORE), 0, Material.IRON_INGOT, (byte) 0); } @@ -66,7 +67,7 @@ public class MorphMetalMan extends MorphGadget if (!UtilEvent.isAction(event, UtilEvent.ActionType.L)) return; - if (!Recharge.Instance.use(player, getName(), 1000, false, false, "Cosmetics")) + if (!Recharge.Instance.use(player, getName(), 5000, false, false, "Cosmetics")) return; // Creates colored laser @@ -94,25 +95,9 @@ public class MorphMetalMan extends MorphGadget { color = _playerColors.get(player.getUniqueId()); } - MetalManEffect metalManEffect = new MetalManEffect(player.getEyeLocation(), loc, color, Manager.getPlugin()); + MetalManEffect metalManEffect = new MetalManEffect(player.getEyeLocation(), loc, color, this, player); increaseColor(player.getUniqueId()); metalManEffect.start(); - - // Creates the explosion and knockback players - loc.getWorld().createExplosion(loc, 0f); - UtilParticle.PlayParticle(UtilParticle.ParticleType.HUGE_EXPLOSION, loc, 3f, 3f, 3f, 0, 32, UtilParticle.ViewDist.MAX, UtilServer.getPlayers()); - HashMap players = UtilPlayer.getInRadius(loc, 12d); - for (Player ent : players.keySet()) - { - if (Manager.collideEvent(player, this, ent)) - continue; - - double mult = players.get(ent); - - //Knockback - UtilAction.velocity(ent, UtilAlg.getTrajectory(loc, ent.getLocation()), 2 * mult, false, 0, 1 + 1 * mult, 10, true); - } - } public void increaseColor(UUID uuid) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphWitch.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphWitch.java new file mode 100644 index 000000000..82b83b9d1 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphWitch.java @@ -0,0 +1,113 @@ +package mineplex.core.gadget.gadgets.morph; + +import mineplex.core.common.skin.SkinData; +import mineplex.core.common.util.F; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilText; +import mineplex.core.disguise.disguises.DisguiseWitch; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.types.MorphGadget; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerToggleSneakEvent; +import org.bukkit.inventory.ItemStack; + +public class MorphWitch extends MorphGadget +{ + + public MorphWitch(GadgetManager manager) + { + super(manager, "Witch Morph", UtilText.splitLinesToArray(new String[]{"Press sneak to summon your trusty bat and start brewing"}, LineFormat.LORE), 0, Material.SKULL_ITEM, (byte) 3); + } + + @Override + public void enableCustom(Player player, boolean message) + { + this.applyArmor(player, message); + DisguiseWitch disguiseWitch = new DisguiseWitch(player); + disguiseWitch.setName(player.getName(), Manager.getClientManager().Get(player).GetRank()); + disguiseWitch.setCustomNameVisible(true); + Manager.getDisguiseManager().disguise(disguiseWitch); + } + + @Override + public void disableCustom(Player player, boolean message) + { + this.removeArmor(player); + WitchEffectManager witchEffectManager = WitchEffectManager.getManager(player); + if (witchEffectManager != null) + { + witchEffectManager.stop(); + } + Manager.getDisguiseManager().undisguise(player); + } + + public ItemStack getWitchItem() + { + return SkinData.WITCH.getSkull(); + } + + @EventHandler + public void onSneak(PlayerToggleSneakEvent event) + { + WitchEffectManager witchEffectManager = WitchEffectManager.getManager(event.getPlayer()); + if (witchEffectManager != null) + { + if (witchEffectManager.hasStarted()) + return; + } + + if (!isActive(event.getPlayer())) + return; + + if (!event.getPlayer().isOnGround()) + { + UtilPlayer.message(event.getPlayer(), F.main("Witch Morph", "You can't place the cauldron there!")); + return; + } + + if (!Recharge.Instance.use(event.getPlayer(), "Witch Cauldron", 15000, true, false, "Cosmetics")) + return; + + Location cauldronLocation = event.getPlayer().getLocation().clone().add(event.getPlayer().getLocation().getDirection()); + cauldronLocation.add(0, 1, 0); + if(cauldronLocation.getBlock().getType() != Material.AIR) + { + UtilPlayer.message(event.getPlayer(), F.main("Witch Morph", "You can't place the cauldron there!")); + return; + } + WitchEffectManager newManager = new WitchEffectManager(event.getPlayer(), cauldronLocation); + newManager.start(); + } + + @EventHandler + public void onUpdate(UpdateEvent updateEvent) + { + if (updateEvent.getType() != UpdateType.TICK) + return; + + long currentTime = System.currentTimeMillis(); + long delay = 5000; + for (Player player : WitchEffectManager.getPlayers()) + { + WitchEffectManager witchEffectManager = WitchEffectManager.getManager(player); + if (witchEffectManager != null) + { + if (witchEffectManager.hasStarted()) + { + if (currentTime - witchEffectManager.getStarted() >= delay) + { + witchEffectManager.stop(); + } + } + } + } + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/WitchEffectManager.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/WitchEffectManager.java new file mode 100644 index 000000000..ce6598a5d --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/WitchEffectManager.java @@ -0,0 +1,80 @@ +package mineplex.core.gadget.gadgets.morph; + +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import mineplex.core.common.util.UtilServer; +import mineplex.core.gadget.gadgets.particle.unrelated.WitchParticleEffect; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Bat; +import org.bukkit.entity.Player; + +public class WitchEffectManager +{ + + private static Map _managers = new HashMap<>(); + + private Player _player; + private Bat _bat; + private Location _location; + private long _started = -1; + private WitchParticleEffect _witchParticleEffect; + + public WitchEffectManager(Player player, Location location) + { + _player = player; + _location = location; + _managers.put(player, this); + } + + public void start() + { + _started = System.currentTimeMillis(); + _location.getBlock().setType(Material.CAULDRON); + _location.getBlock().setData((byte) 3); + + _location.getWorld().strikeLightning(_location); + Bat bat = _location.getWorld().spawn(_location.clone().add(0, 1, 0), Bat.class); + bat.setCustomName(_player.getName() + "'s Magical Bat"); + bat.setCustomNameVisible(true); + _bat = bat; + + _witchParticleEffect = new WitchParticleEffect(_location, UtilServer.getPlugin()); + _witchParticleEffect.start(); + } + + public void stop() + { + _bat.remove(); + _location.getBlock().setType(Material.AIR); + _managers.remove(_player); + _witchParticleEffect.stop(); + } + + public boolean hasStarted() + { + return _started != -1; + } + + public long getStarted() + { + return _started; + } + + public static Set getPlayers() + { + return _managers.keySet(); + } + + public static WitchEffectManager getManager(Player player) + { + if (_managers.containsKey(player)) + { + return _managers.get(player); + } + return null; + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/unrelated/MetalManEffect.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/unrelated/MetalManEffect.java index 7e1b6baa1..17a40710c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/unrelated/MetalManEffect.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/unrelated/MetalManEffect.java @@ -1,12 +1,15 @@ package mineplex.core.gadget.gadgets.particle.unrelated; import java.awt.*; +import java.util.HashMap; -import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.*; import mineplex.core.common.util.particles.ColoredParticle; import mineplex.core.common.util.particles.DustSpellColor; +import mineplex.core.gadget.types.Gadget; import org.bukkit.Location; -import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.Material; +import org.bukkit.entity.Player; import org.bukkit.util.Vector; public class MetalManEffect extends Effect @@ -14,12 +17,18 @@ public class MetalManEffect extends Effect private int _particles = 100; private int _color; + private int _count = 0; private Vector _vector; + private Location _fixedLoc; + private Gadget _gadget; + private Player _player; - public MetalManEffect(Location location, Location target, int color, JavaPlugin javaPlugin) + public MetalManEffect(Location location, Location target, int color, Gadget gadget, Player player) { - super(20, new EffectLocation(location), javaPlugin); + super(-1, new EffectLocation(location), gadget.Manager.getPlugin()); _color = color; + _gadget = gadget; + _player = player; setTargetLocation(new EffectLocation(target)); } @@ -35,16 +44,40 @@ public class MetalManEffect extends Effect link.normalize(); Vector vector = link.multiply(length / _particles); _vector = vector; + _fixedLoc = location.clone().subtract(_vector); } ColoredParticle coloredParticle = new ColoredParticle(UtilParticle.ParticleType.RED_DUST, new DustSpellColor((_color == 0) ? Color.YELLOW : Color.RED), _effectLocation.getLocation().clone()); - Location loc = location.clone().subtract(_vector); - for (int i = 0; i < _particles; i++) - { - loc.add(_vector); - coloredParticle.setLocation(loc); + for (int i = 0; i < 5; i++){ + _fixedLoc.add(_vector); + coloredParticle.setLocation(_fixedLoc); coloredParticle.display(UtilParticle.ViewDist.LONG); } + if (_fixedLoc.getBlock().getType() != Material.AIR || _count == 1000) + { + explode(); + } + _count += 5; + } + + private void explode() + { + this.stop(); + // Creates the explosion and knockback players + Location loc = _fixedLoc; + loc.getWorld().createExplosion(loc, 0f); + UtilParticle.PlayParticle(UtilParticle.ParticleType.HUGE_EXPLOSION, loc, 3f, 3f, 3f, 0, 32, UtilParticle.ViewDist.MAX, UtilServer.getPlayers()); + HashMap players = UtilPlayer.getInRadius(loc, 12d); + for (Player ent : players.keySet()) + { + if (_gadget.Manager.collideEvent(_player, _gadget, ent)) + continue; + + double mult = players.get(ent); + + //Knockback + UtilAction.velocity(ent, UtilAlg.getTrajectory(loc, ent.getLocation()), 2 * mult, false, 0, 1 + 1 * mult, 10, true); + } } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/unrelated/WitchParticleEffect.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/unrelated/WitchParticleEffect.java new file mode 100644 index 000000000..4b36d4de1 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/unrelated/WitchParticleEffect.java @@ -0,0 +1,25 @@ +package mineplex.core.gadget.gadgets.particle.unrelated; + +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilServer; +import org.bukkit.Location; +import org.bukkit.plugin.java.JavaPlugin; + +public class WitchParticleEffect extends Effect +{ + + public WitchParticleEffect(Location location, JavaPlugin javaPlugin) + { + super(-1, new EffectLocation(location), javaPlugin); + _delay = 5; + } + + @Override + public void runEffect() + { + UtilParticle.PlayParticle(UtilParticle.ParticleType.WITCH_MAGIC, _effectLocation.getLocation().clone(), + 1f, 1f, 1f, 0f, 20, + UtilParticle.ViewDist.NORMAL, UtilServer.getPlayers()); + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java b/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java index c937d4414..c7c24dcdb 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java @@ -1,5 +1,10 @@ package mineplex.core.powerplayclub; +import java.time.Month; +import java.time.Year; +import java.util.*; + +import mineplex.core.common.skin.SkinData; import mineplex.core.common.util.BukkitFuture; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; @@ -9,10 +14,6 @@ import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import java.time.Month; -import java.time.Year; -import java.util.*; - public class PowerPlayClubRewards { private static final Map> rewards = new HashMap<>(); @@ -20,6 +21,7 @@ public class PowerPlayClubRewards static { setRewards(2016, Month.SEPTEMBER, new PowerPlayClubItem("Squid Morph", 1, new ItemStack(Material.INK_SACK))); + setRewards(2016, Month.OCTOBER, new PowerPlayClubItem("Witch Morph", 1, SkinData.WITCH.getSkull())); } public static List septemberItems() // TODO: figure this out From 537dc28daaa71edba174d7b02cf79b4d2edf0d0f Mon Sep 17 00:00:00 2001 From: LCastr0 Date: Sun, 18 Sep 2016 16:16:57 -0300 Subject: [PATCH 03/11] Used proper method to add specific prizes --- .../powerplayclub/PowerPlayClubRewards.java | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java b/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java index c7c24dcdb..ff6199324 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java @@ -4,10 +4,12 @@ import java.time.Month; import java.time.Year; import java.util.*; +import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.skin.SkinData; import mineplex.core.common.util.BukkitFuture; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.donation.DonationManager; import mineplex.core.inventory.InventoryManager; import mineplex.core.inventory.data.Item; import org.bukkit.Material; @@ -95,7 +97,7 @@ public class PowerPlayClubRewards } - public static void giveAllItems(Player player, InventoryManager manager, PowerPlayClubRepository repo) + public static void giveAllItems(Player player, DonationManager donationManager, InventoryManager inventoryManager, PowerPlayClubRepository repo) { UtilPlayer.message(player, F.main("Power Play Club", "Verifying subscription..")); @@ -112,7 +114,7 @@ public class PowerPlayClubRewards for (PowerPlayClubItem item : septemberItems()) // TODO: figure this out { - Item fItem = manager.getItem(item.getPrize()); + /*Item fItem = manager.getItem(item.getPrize()); if (fItem == null) { UtilPlayer.message(player, F.main("Power Play Club", "An unexpected error happened!")); @@ -121,26 +123,31 @@ public class PowerPlayClubRewards { manager.addItemToInventory(player, fItem.Name, 1); UtilPlayer.message(player, F.main("Power Play Club", "You received " + item.getAmount() + "x " + F.elem(item.getPrize()) + ".")); - } + }*/ + donationManager.PurchaseUnknownSalesPackage(null, player.getName(), + donationManager.getClientManager().Get(player).getAccountId(), item.getPrize(), + GlobalCurrency.TREASURE_SHARD, 0, true); + UtilPlayer.message(player, F.main("Power Play Club", "You received " + item.getAmount() + "x " + + F.elem(item.getPrize()) + ".")); } - Item gameAmplifier = manager.getItem("Game Booster"); + Item gameAmplifier = inventoryManager.getItem("Game Booster"); if (gameAmplifier == null) { UtilPlayer.message(player, F.main("Power Play Club", "An unexpected error happened!")); } else { - manager.addItemToInventory(player, gameAmplifier.Name, 2); + inventoryManager.addItemToInventory(player, gameAmplifier.Name, 2); UtilPlayer.message(player, F.main("Power Play Club", "You received 2x " + F.elem("Game Boosters") + ".")); } - Item omegaChest = manager.getItem("Omega Chest"); + Item omegaChest = inventoryManager.getItem("Omega Chest"); if (omegaChest == null) { UtilPlayer.message(player, F.main("Power Play Club", "An unexpected error happened!")); } else { - manager.addItemToInventory(player, omegaChest.Name, 1); + inventoryManager.addItemToInventory(player, omegaChest.Name, 1); UtilPlayer.message(player, F.main("Power Play Club", "You received 1x " + F.elem("Omega Chest") + ".")); } })); From f0c7b1d6aafa8aaa8e50087f04efd010753849a6 Mon Sep 17 00:00:00 2001 From: LCastr0 Date: Sun, 18 Sep 2016 16:18:33 -0300 Subject: [PATCH 04/11] Whoops, forgot this --- .../core/bonuses/gui/buttons/PowerPlayClubButton.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/PowerPlayClubButton.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/PowerPlayClubButton.java index 103bdf28e..d3fd4409d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/PowerPlayClubButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/PowerPlayClubButton.java @@ -1,9 +1,12 @@ package mineplex.core.bonuses.gui.buttons; +import java.util.ArrayList; + import mineplex.core.bonuses.BonusManager; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.donation.DonationManager; import mineplex.core.gui.GuiItem; import mineplex.core.inventory.InventoryManager; import mineplex.core.powerplayclub.PowerPlayClubRepository; @@ -15,8 +18,6 @@ import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; -import java.util.ArrayList; - public class PowerPlayClubButton implements GuiItem { @@ -24,6 +25,7 @@ public class PowerPlayClubButton implements GuiItem private Player _player; private PowerPlayClubRepository _powerPlayClubRepository; private InventoryManager _inventoryManager; + private DonationManager _donationManager; private BonusManager _bonusManager; public PowerPlayClubButton(Player player, BonusManager manager) @@ -32,6 +34,7 @@ public class PowerPlayClubButton implements GuiItem _bonusManager = manager; _powerPlayClubRepository = manager.getPowerPlayClubRepository(); _inventoryManager = manager.getInventoryManager(); + _donationManager = manager.getDonationManager(); } @Override @@ -53,7 +56,7 @@ public class PowerPlayClubButton implements GuiItem { _player.closeInventory(); _player.playSound(_player.getLocation(), Sound.NOTE_PLING, 1, 1.6f); - PowerPlayClubRewards.giveAllItems(_player, _inventoryManager, _powerPlayClubRepository); + PowerPlayClubRewards.giveAllItems(_player, _donationManager, _inventoryManager, _powerPlayClubRepository); } else { From 1475243d8a1f5400596d1cfe9983ca6d939156b9 Mon Sep 17 00:00:00 2001 From: LCastr0 Date: Fri, 23 Sep 2016 23:14:10 -0300 Subject: [PATCH 05/11] Added MetalMan to the GUI for testings --- .../Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java index b455013c4..104c88080 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java @@ -343,7 +343,7 @@ public class GadgetManager extends MiniPlugin addGadget(new MorphSquid(this)); addGadget(new MorphWitch(this)); // Not being added in this update! - //addGadget(new MorphMetalMan(this)); + addGadget(new MorphMetalMan(this)); // Particles addGadget(new ParticleFoot(this)); From 4fe5eb8b456a83c9663c53cee254c54414f77003 Mon Sep 17 00:00:00 2001 From: cnr Date: Thu, 29 Sep 2016 23:55:47 -0700 Subject: [PATCH 06/11] Stub out new Power Play rewards calculations --- .../gui/buttons/PowerPlayClubButton.java | 88 ++++++++----- .../core/powerplayclub/PPCPlayerData.java | 26 ---- .../PowerPlayClubRepository.java | 119 +++++++++++++++--- .../powerplayclub/PowerPlayClubRewards.java | 114 ++++++----------- .../core/powerplayclub/PowerPlayData.java | 48 +++++++ 5 files changed, 243 insertions(+), 152 deletions(-) delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PPCPlayerData.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayData.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/PowerPlayClubButton.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/PowerPlayClubButton.java index d3fd4409d..d7593479f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/PowerPlayClubButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/PowerPlayClubButton.java @@ -1,6 +1,11 @@ package mineplex.core.bonuses.gui.buttons; +import java.time.LocalDate; +import java.time.YearMonth; import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; import mineplex.core.bonuses.BonusManager; import mineplex.core.common.util.C; @@ -11,6 +16,7 @@ import mineplex.core.gui.GuiItem; import mineplex.core.inventory.InventoryManager; import mineplex.core.powerplayclub.PowerPlayClubRepository; import mineplex.core.powerplayclub.PowerPlayClubRewards; +import mineplex.core.powerplayclub.PowerPlayData; import mineplex.core.shop.item.ShopItem; import org.bukkit.Material; import org.bukkit.Sound; @@ -52,7 +58,7 @@ public class PowerPlayClubButton implements GuiItem @Override public void click(ClickType clickType) { - if (isAvailable() && !_bonusManager.getPowerPlayClubRepository().alreadyClaimed(_player)) + if (isAvailable()) { _player.closeInventory(); _player.playSound(_player.getLocation(), Sound.NOTE_PLING, 1, 1.6f); @@ -61,9 +67,9 @@ public class PowerPlayClubButton implements GuiItem else { _player.playSound(_player.getLocation(), Sound.ITEM_BREAK, 1, 10); - if (_powerPlayClubRepository.alreadyClaimed(_player)) + if (_powerPlayClubRepository.getCachedData(_player).isSubscribed()) { - UtilPlayer.message(_player, F.main("Power Play Club", "Already claimed!")); + UtilPlayer.message(_player, F.main("Power Play Club", "Already claimed! Come back next month!")); } else { @@ -80,58 +86,72 @@ public class PowerPlayClubButton implements GuiItem private void setItem() { - ArrayList lore = new ArrayList<>(); - Material material; - byte data = 0; - String itemName; + final Material material; + final String itemName; + final List lore; - if (isAvailable()) + + PowerPlayData cached = _powerPlayClubRepository.getCachedData(_player); + List unclaimed = cached.getUnclaimedMonths(); + + if (!unclaimed.isEmpty()) { + // Player has unclaimed rewards, even if s/he's not currently subscribed material = Material.GOLD_INGOT; itemName = C.cGreenB + "Power Play Club"; + + lore = buildLore(unclaimed); lore.add(""); lore.add(C.Reset + "Click to claim!"); - } - else + + } else if (cached.isSubscribed()) { + // Player is subscribed and has claimed all of his/her rewards material = Material.REDSTONE_BLOCK; itemName = C.cRedB + "Power Play Club"; + + lore = new ArrayList<>(); + lore.add(C.cRed + "Already claimed!"); + + // TODO: 'come back later!' + + } else + { + // Player isn't subscribed; show them the rewards for this current month and tell them to subscribe + material = Material.REDSTONE_BLOCK; + itemName = C.cRedB + "Power Play Club"; + + lore = buildLore(Collections.singletonList(YearMonth.now())); + lore.add(""); + lore.add(C.cRed + "Get Power Play Club months at"); + lore.add(C.cAqua + "mineplex.com/shop"); } + _item = new ShopItem(material, (byte)0, itemName, lore.toArray(new String[lore.size()]), 1, false, false); + } + + private List buildLore(List unclaimed) + { + List lore = new ArrayList<>(); lore.add(C.cYellow + "Rewards"); - lore.add(" " + C.cWhite + "2 Game Amplifiers"); - lore.add(" " + C.cWhite + "1 Omega Chest"); - for (PowerPlayClubRewards.PowerPlayClubItem prize : PowerPlayClubRewards.septemberItems()) - { - lore.add(" " + C.cWhite + prize.getAmount() + " " + prize.getPrize()); - } - //lore.add(" "); - //lore.add(C.cYellow + "Months left: " + C.cWhite + getMonthsLeft(true)); //TODO: figure this out - if (!isAvailable()) - { - lore.add(" "); - if (_powerPlayClubRepository.alreadyClaimed(_player)) - { - lore.add(C.cRed + "Already claimed!"); - } - else - { - lore.add(C.cRed + "Get Power Play Club months at"); - lore.add(C.cAqua + "mineplex.com/shop"); - } - } + lore.add(" " + C.cWhite + (PowerPlayClubRewards.AMPLIFIERS_PER_MONTH * unclaimed.size()) + " Game Amplifier"); + lore.add(" " + C.cWhite + (PowerPlayClubRewards.CHESTS_PER_MONTH * unclaimed.size()) + " Omega Chest"); - _item = new ShopItem(material, data, itemName, lore.toArray(new String[0]), 1, false, false); + PowerPlayClubRewards.rewardsForMonths(unclaimed).forEach(prize -> + { + lore.add(" " + C.cWhite + prize.getPrize()); + }); + return lore; } private boolean isAvailable() { - return _powerPlayClubRepository.canClaim(_player); + return !_powerPlayClubRepository.getCachedData(_player).getUnclaimedMonths().isEmpty(); } public static boolean isAvailable(Player player, PowerPlayClubRepository repo) { - return repo.canClaim(player); + return !repo.getCachedData(player).getUnclaimedMonths().isEmpty(); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PPCPlayerData.java b/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PPCPlayerData.java deleted file mode 100644 index f4156ddd7..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PPCPlayerData.java +++ /dev/null @@ -1,26 +0,0 @@ -package mineplex.core.powerplayclub; - -public class PPCPlayerData { - private boolean _subscribed; - private boolean _claimed; - - public void setSubscribed(boolean subscribed) - { - _subscribed = subscribed; - } - - public void setClaimed(boolean claimed) - { - _claimed = claimed; - } - - public boolean hasClaimed() - { - return _claimed; - } - - public boolean hasSubscribed() - { - return _subscribed; - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRepository.java index 1e7c68564..218b37d1c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRepository.java @@ -1,26 +1,39 @@ package mineplex.core.powerplayclub; -import mineplex.core.MiniClientPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.account.ILoginProcessor; import mineplex.serverdata.database.DBPool; +import org.bukkit.Bukkit; import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.plugin.java.JavaPlugin; import java.sql.*; +import java.sql.Date; import java.time.LocalDate; -import java.util.UUID; +import java.time.YearMonth; +import java.util.*; import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionException; -public class PowerPlayClubRepository extends MiniClientPlugin { +public class PowerPlayClubRepository implements Listener { + // Data loaded by the first ILoginProcessor, waiting for the second + private final Map> _stageOneDataClaims = new HashMap<>(); + + // Cached data produced by combining the first and second ILoginProcessors. + // This data is not guaranteed to be fresh, and should be recalculated before + // giving a player his/her rewards. + private final Map _cachedPlayerData = new HashMap<>(); private final CoreClientManager _clientManager; public PowerPlayClubRepository(JavaPlugin plugin, CoreClientManager clientManager) { - super("PowerPlayClubRepository", plugin); - _clientManager = clientManager; + Bukkit.getPluginManager().registerEvents(this, plugin); + clientManager.addStoredProcedureLoginProcessor(new ILoginProcessor() { @Override public String getName() { @@ -29,7 +42,12 @@ public class PowerPlayClubRepository extends MiniClientPlugin { @Override public void processLoginResultSet(String playerName, UUID uuid, int accountId, ResultSet resultSet) throws SQLException { - PowerPlayClubRepository.this.Get(uuid).setClaimed(resultSet.next()); + List claims = new ArrayList<>(); + while (resultSet.next()) + { + claims.add(YearMonth.of(resultSet.getInt("claimYear"), resultSet.getInt("claimMonth"))); + } + _stageOneDataClaims.put(uuid, claims); } @Override @@ -46,7 +64,16 @@ public class PowerPlayClubRepository extends MiniClientPlugin { @Override public void processLoginResultSet(String playerName, UUID uuid, int accountId, ResultSet resultSet) throws SQLException { - PowerPlayClubRepository.this.Get(uuid).setSubscribed(resultSet.next()); + List subscriptions = new ArrayList<>(); + while (resultSet.next()) + { + LocalDate date = resultSet.getDate("startDate").toLocalDate(); + PowerPlayData.SubscriptionDuration duration = PowerPlayData.SubscriptionDuration.valueOf(resultSet.getString("duration").toUpperCase()); + subscriptions.add(new PowerPlayData.Subscription(date, duration)); + } + + // Now that we have the claims from the first processor and subscriptions from this one, combine them + _cachedPlayerData.put(uuid, PowerPlayData.fromSubsAndClaims(subscriptions, _stageOneDataClaims.remove(uuid))); } @Override @@ -56,6 +83,13 @@ public class PowerPlayClubRepository extends MiniClientPlugin { }); } + @EventHandler + public void onQuit(PlayerQuitEvent event) + { + _stageOneDataClaims.remove(event.getPlayer().getUniqueId()); // Just in case. + _cachedPlayerData.remove(event.getPlayer().getUniqueId()); + } + public CompletableFuture addSubscription(int accountId, LocalDate date, String duration) { return CompletableFuture.supplyAsync(() -> @@ -101,18 +135,75 @@ public class PowerPlayClubRepository extends MiniClientPlugin { }); } - public boolean alreadyClaimed(Player player) + public CompletableFuture loadData(Player player) { - return Get(player).hasClaimed(); + return loadSubscriptions(player).thenCombine(loadClaimMonths(player), PowerPlayData::fromSubsAndClaims); } - public boolean canClaim(Player player) + public CompletableFuture> loadClaimMonths(Player player) { - return Get(player).hasSubscribed() && !Get(player).hasClaimed(); + int accountId = _clientManager.Get(player).getAccountId(); + + return CompletableFuture.supplyAsync(() -> + { + try (Connection connection = DBPool.getAccount().getConnection()) + { + PreparedStatement statement = connection.prepareStatement("SELECT * FROM powerPlayClaims WHERE accountId = ?"); + statement.setInt(1, accountId); + ResultSet resultSet = statement.executeQuery(); + + List claims = new ArrayList<>(); + while (resultSet.next()) + { + claims.add(YearMonth.of(resultSet.getInt("claimYear"), resultSet.getInt("claimMonth"))); + } + return claims; + + } catch (SQLException e) + { + throw new CompletionException(e); + } + }); } - @Override - protected PPCPlayerData addPlayer(UUID uuid) { - return new PPCPlayerData(); + public CompletableFuture> loadSubscriptions(Player player) + { + int accountId = _clientManager.Get(player).getAccountId(); + + return CompletableFuture.supplyAsync(() -> + { + try (Connection connection = DBPool.getAccount().getConnection()) + { + PreparedStatement statement = connection.prepareStatement("SELECT * FROM powerPlaySubs WHERE accountId = ?"); + statement.setInt(1, accountId); + ResultSet resultSet = statement.executeQuery(); + + List subscriptions = new ArrayList<>(); + while (resultSet.next()) + { + LocalDate date = resultSet.getDate("startDate").toLocalDate(); + PowerPlayData.SubscriptionDuration duration = PowerPlayData.SubscriptionDuration.valueOf(resultSet.getString("duration").toUpperCase()); + subscriptions.add(new PowerPlayData.Subscription(date, duration)); + } + return subscriptions; + + } catch (SQLException e) + { + throw new CompletionException(e); + } + }); + } + + public PowerPlayData getCachedData(Player player) + { + return _cachedPlayerData.get(player.getUniqueId()); + } + + public void putCachedData(Player player, PowerPlayData data) + { + if (player.isOnline()) + { + _cachedPlayerData.put(player.getUniqueId(), data); + } } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java b/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java index ff6199324..6f997b1a3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java @@ -2,8 +2,12 @@ package mineplex.core.powerplayclub; import java.time.Month; import java.time.Year; +import java.time.YearMonth; import java.util.*; +import java.util.concurrent.CompletableFuture; +import java.util.stream.Collectors; +import com.google.common.collect.ImmutableMap; import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.skin.SkinData; import mineplex.core.common.util.BukkitFuture; @@ -18,65 +22,22 @@ import org.bukkit.inventory.ItemStack; public class PowerPlayClubRewards { - private static final Map> rewards = new HashMap<>(); + public static final int AMPLIFIERS_PER_MONTH = 2; + public static final int CHESTS_PER_MONTH = 1; - static - { - setRewards(2016, Month.SEPTEMBER, new PowerPlayClubItem("Squid Morph", 1, new ItemStack(Material.INK_SACK))); - setRewards(2016, Month.OCTOBER, new PowerPlayClubItem("Witch Morph", 1, SkinData.WITCH.getSkull())); - } + private static final Map rewards = ImmutableMap.builder() + .put(YearMonth.of(2016, Month.SEPTEMBER), new PowerPlayClubItem("Squid Morph", new ItemStack(Material.INK_SACK))) + .put(YearMonth.of(2016, Month.OCTOBER), new PowerPlayClubItem("Witch Morph", SkinData.WITCH.getSkull())) + .build(); - public static List septemberItems() // TODO: figure this out - { - return rewards.values().iterator().next(); - } - - private static void setRewards(int year, Month month, PowerPlayClubItem... items) - { - rewards.put(new RewardMonth(Year.of(year), month), Arrays.asList(items)); - } - - private static class RewardMonth - { - private final Year year; - private final Month month; - - static RewardMonth of(Year year, Month month) - { - return new RewardMonth(year, month); - } - - RewardMonth(Year year, Month month) - { - this.year = year; - this.month = month; - } - - @Override - public boolean equals(Object obj) { - if (obj == null || getClass() != obj.getClass()) return false; - - RewardMonth that = (RewardMonth) obj; - - return Objects.equals(this.year, that.year) && Objects.equals(this.month, that.month); - } - - @Override - public int hashCode() { - return Objects.hash(year, month); - } - } - - public static class PowerPlayClubItem + private static class PowerPlayClubItem { private final String _prize; - private final int _amount; private final ItemStack _display; - public PowerPlayClubItem(String prize, int amount, ItemStack display) + PowerPlayClubItem(String prize, ItemStack display) { _prize = prize; - _amount = amount; _display = display; } @@ -85,51 +46,45 @@ public class PowerPlayClubRewards return _prize; } - public int getAmount() - { - return _amount; - } - public ItemStack getDisplay() { return _display; } } + public static List rewardsForMonths(List months) + { + return months.stream().map(rewards::get).collect(Collectors.toList()); + } + public static void giveAllItems(Player player, DonationManager donationManager, InventoryManager inventoryManager, PowerPlayClubRepository repo) { UtilPlayer.message(player, F.main("Power Play Club", "Verifying subscription..")); - repo.attemptClaim(player).thenCompose(BukkitFuture.accept(success -> + repo.attemptClaim(player).thenCompose(success -> { - if (!success) { UtilPlayer.message(player, F.main("Power Play Club", "An unexpected error happened!")); - return; + return CompletableFuture.completedFuture(null); } - repo.Get(player).setClaimed(true); + PowerPlayData cached = repo.getCachedData(player); + List items = rewardsForMonths(cached.getUnclaimedMonths()); - for (PowerPlayClubItem item : septemberItems()) // TODO: figure this out + + // Give normal power play items + items.forEach(item -> { - /*Item fItem = manager.getItem(item.getPrize()); - if (fItem == null) - { - UtilPlayer.message(player, F.main("Power Play Club", "An unexpected error happened!")); - } - else - { - manager.addItemToInventory(player, fItem.Name, 1); - UtilPlayer.message(player, F.main("Power Play Club", "You received " + item.getAmount() + "x " + F.elem(item.getPrize()) + ".")); - }*/ donationManager.PurchaseUnknownSalesPackage(null, player.getName(), donationManager.getClientManager().Get(player).getAccountId(), item.getPrize(), GlobalCurrency.TREASURE_SHARD, 0, true); - UtilPlayer.message(player, F.main("Power Play Club", "You received " + item.getAmount() + "x " + + UtilPlayer.message(player, F.main("Power Play Club", "You received the " + F.elem(item.getPrize()) + ".")); - } + }); + + // Give amplifiers and chests Item gameAmplifier = inventoryManager.getItem("Game Booster"); if (gameAmplifier == null) { @@ -137,8 +92,8 @@ public class PowerPlayClubRewards } else { - inventoryManager.addItemToInventory(player, gameAmplifier.Name, 2); - UtilPlayer.message(player, F.main("Power Play Club", "You received 2x " + F.elem("Game Boosters") + ".")); + inventoryManager.addItemToInventory(player, gameAmplifier.Name, AMPLIFIERS_PER_MONTH * items.size()); + UtilPlayer.message(player, F.main("Power Play Club", "You received " + (AMPLIFIERS_PER_MONTH * items.size()) + "x " + F.elem("Game Amplifier") + ".")); } Item omegaChest = inventoryManager.getItem("Omega Chest"); if (omegaChest == null) @@ -147,10 +102,13 @@ public class PowerPlayClubRewards } else { - inventoryManager.addItemToInventory(player, omegaChest.Name, 1); - UtilPlayer.message(player, F.main("Power Play Club", "You received 1x " + F.elem("Omega Chest") + ".")); + inventoryManager.addItemToInventory(player, omegaChest.Name, CHESTS_PER_MONTH * items.size()); + UtilPlayer.message(player, F.main("Power Play Club", "You received " + (CHESTS_PER_MONTH * items.size()) + "x " + F.elem("Omega Chest") + ".")); } - })); + + // Refresh Power Play data on the server + return repo.loadData(player).thenCompose(BukkitFuture.accept(data -> repo.putCachedData(player, data))); + }); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayData.java b/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayData.java new file mode 100644 index 000000000..ced228109 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayData.java @@ -0,0 +1,48 @@ +package mineplex.core.powerplayclub; + +import java.time.LocalDate; +import java.time.YearMonth; +import java.util.List; + +public class PowerPlayData +{ + private final boolean _subscribed; + private final List _unclaimedMonths; + + static PowerPlayData fromSubsAndClaims(List subscriptions, List claimMonths) + { + // TODO + return null; + } + + static class Subscription { + private final LocalDate _startDate; + private final SubscriptionDuration _duration; + + Subscription(LocalDate startDate, SubscriptionDuration duration) + { + _startDate = startDate; + _duration = duration; + } + } + + enum SubscriptionDuration { + MONTH, YEAR + } + + private PowerPlayData(boolean subscribed, List unclaimedMonths) + { + _subscribed = subscribed; + _unclaimedMonths = unclaimedMonths; + } + + public List getUnclaimedMonths() + { + return _unclaimedMonths; + } + + public boolean isSubscribed() + { + return _subscribed; + } +} From 64802769d6ecacc69171f12eecad5e21927e9aeb Mon Sep 17 00:00:00 2001 From: cnr Date: Fri, 30 Sep 2016 11:13:29 -0700 Subject: [PATCH 07/11] Implement Power Play reward month calculations --- .../bonuses/commands/PowerPlayCommand.java | 5 +- .../gui/buttons/PowerPlayClubButton.java | 2 +- .../powerplayclub/PowerPlayClubRewards.java | 3 +- .../core/powerplayclub/PowerPlayData.java | 76 ++++++++++++++++++- 4 files changed, 78 insertions(+), 8 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/commands/PowerPlayCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/commands/PowerPlayCommand.java index edc65deb4..cc305f652 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/commands/PowerPlayCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/commands/PowerPlayCommand.java @@ -5,11 +5,13 @@ import mineplex.core.command.CommandBase; import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; +import mineplex.core.powerplayclub.PowerPlayData; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.entity.Player; import java.time.LocalDate; +import java.time.YearMonth; public class PowerPlayCommand extends CommandBase { @@ -37,7 +39,8 @@ public class PowerPlayCommand extends CommandBase return; } - _bonusManager.getPowerPlayClubRepository().Get(player).setSubscribed(true); + PowerPlayData cached = _bonusManager.getPowerPlayClubRepository().getCachedData(player); + cached.getUnclaimedMonths().add(YearMonth.now()); _bonusManager.getPowerPlayClubRepository().addSubscription(_bonusManager.getClientManager().Get(player).getAccountId(), LocalDate.now(), "month"); caller.sendMessage(ChatColor.GREEN + "Gave a month's subscription to " + player.getName()); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/PowerPlayClubButton.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/PowerPlayClubButton.java index d7593479f..f63bf5e32 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/PowerPlayClubButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/PowerPlayClubButton.java @@ -102,7 +102,7 @@ public class PowerPlayClubButton implements GuiItem lore = buildLore(unclaimed); lore.add(""); - lore.add(C.Reset + "Click to claim!"); + lore.add(C.cGold + "Click to claim!"); } else if (cached.isSubscribed()) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java b/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java index 6f997b1a3..96e028df1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java @@ -1,7 +1,6 @@ package mineplex.core.powerplayclub; import java.time.Month; -import java.time.Year; import java.time.YearMonth; import java.util.*; import java.util.concurrent.CompletableFuture; @@ -30,7 +29,7 @@ public class PowerPlayClubRewards .put(YearMonth.of(2016, Month.OCTOBER), new PowerPlayClubItem("Witch Morph", SkinData.WITCH.getSkull())) .build(); - private static class PowerPlayClubItem + public static class PowerPlayClubItem { private final String _prize; private final ItemStack _display; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayData.java b/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayData.java index ced228109..620dac03f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayData.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayData.java @@ -1,18 +1,80 @@ package mineplex.core.powerplayclub; +import com.google.common.base.Objects; + import java.time.LocalDate; import java.time.YearMonth; -import java.util.List; +import java.util.*; +import java.util.stream.Collectors; public class PowerPlayData { private final boolean _subscribed; private final List _unclaimedMonths; - static PowerPlayData fromSubsAndClaims(List subscriptions, List claimMonths) + static PowerPlayData fromSubsAndClaims(List subscriptions, List claimedMonths) { - // TODO - return null; + if (subscriptions.isEmpty()) + { + return new PowerPlayData(false, Collections.emptyList()); + } + + // Build the list of potential claim dates from subscriptions + List claimDates = subscriptions.stream() + .flatMap(sub -> buildMonths(sub).stream()) + .sorted() + .collect(Collectors.toCollection(LinkedList::new)); + + // Determine if player is subscribed + LocalDate latestSub = claimDates.get(claimDates.size() - 1); + final boolean subscribed = latestSub.plusMonths(1).isAfter(LocalDate.now()); + + // Remove already-claimed months + Optional latestClaimed = claimedMonths.stream().collect(Collectors.maxBy(YearMonth::compareTo)); + latestClaimed.ifPresent(latest -> + { + while (!claimDates.isEmpty()) + { + LocalDate claimDate = claimDates.get(0); + YearMonth claimMonth = YearMonth.from(claimDate); + if (latest.equals(claimMonth) || latest.isAfter(claimMonth)) + { + claimDates.remove(0); + + } else + { + break; + } + } + }); + + List unclaimedMonths = claimDates.stream() + .filter(date -> date.isBefore(LocalDate.now()) || date.equals(LocalDate.now())) // Filter dates yet to come + .map(YearMonth::from) + .distinct() + .collect(Collectors.toList()); + + return new PowerPlayData(subscribed, unclaimedMonths); + } + + private static List buildMonths(Subscription subscription) + { + switch (subscription._duration) + { + case MONTH: + return Collections.singletonList(subscription._startDate); + + case YEAR: + List months = new ArrayList<>(); + for (int i = 0; i < 12; i++) + { + months.add(subscription._startDate.plusMonths(i)); + } + return months; + + default: + throw new IllegalStateException("Invalid duration"); + } } static class Subscription { @@ -45,4 +107,10 @@ public class PowerPlayData { return _subscribed; } + + @Override + public String toString() + { + return Objects.toStringHelper(this).add("subscribed", _subscribed).add("unclaimed", _unclaimedMonths).toString(); + } } From 4b1b57d4525a3cc33e875fc9dc8d471cb0e12b26 Mon Sep 17 00:00:00 2001 From: cnr Date: Fri, 30 Sep 2016 20:06:29 -0700 Subject: [PATCH 08/11] Add first-time signup Metal Man reward --- .../core/bonuses/gui/buttons/PowerPlayClubButton.java | 7 +++++-- .../mineplex/core/powerplayclub/PowerPlayClubRewards.java | 5 +++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/PowerPlayClubButton.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/PowerPlayClubButton.java index f63bf5e32..083e909f5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/PowerPlayClubButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/PowerPlayClubButton.java @@ -101,7 +101,7 @@ public class PowerPlayClubButton implements GuiItem itemName = C.cGreenB + "Power Play Club"; lore = buildLore(unclaimed); - lore.add(""); + lore.add(" "); lore.add(C.cGold + "Click to claim!"); } else if (cached.isSubscribed()) @@ -122,7 +122,10 @@ public class PowerPlayClubButton implements GuiItem itemName = C.cRedB + "Power Play Club"; lore = buildLore(Collections.singletonList(YearMonth.now())); - lore.add(""); + lore.add(" "); + lore.add(C.cGreen + "First-time Bonus:"); + lore.add(" " + C.cWhite + "Metal Man Morph"); + lore.add(" "); lore.add(C.cRed + "Get Power Play Club months at"); lore.add(C.cAqua + "mineplex.com/shop"); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java b/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java index 96e028df1..98e258fc2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java @@ -73,6 +73,11 @@ public class PowerPlayClubRewards List items = rewardsForMonths(cached.getUnclaimedMonths()); + // Give Metal Man morph for signing up + donationManager.PurchaseUnknownSalesPackage(null, player.getName(), + donationManager.getClientManager().Get(player).getAccountId(), "Metal Man Morph", + GlobalCurrency.TREASURE_SHARD, 0, true); + // Give normal power play items items.forEach(item -> { From 25701dae7df89abcbb2591a68e1d112bc30659ba Mon Sep 17 00:00:00 2001 From: cnr Date: Fri, 30 Sep 2016 20:25:57 -0700 Subject: [PATCH 09/11] Enable Metal Man morph in the GUI --- .../Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java index b455013c4..3f12707a2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java @@ -342,8 +342,7 @@ public class GadgetManager extends MiniPlugin addGadget(new MorphUncleSam(this)); addGadget(new MorphSquid(this)); addGadget(new MorphWitch(this)); - // Not being added in this update! - //addGadget(new MorphMetalMan(this)); + addGadget(new MorphMetalMan(this)); // Particles addGadget(new ParticleFoot(this)); From 0797f90d3b5f58fc8d0f01d5ae077ede54bac409 Mon Sep 17 00:00:00 2001 From: LCastr0 Date: Sat, 1 Oct 2016 00:42:40 -0300 Subject: [PATCH 10/11] Fixes for the Witch Morph --- .../mineplex/core/gadget/GadgetManager.java | 12 ++++ .../gadget/gadgets/morph/MorphMetalMan.java | 9 ++- .../core/gadget/gadgets/morph/MorphWitch.java | 61 ++++++++++++++++--- .../particle/unrelated/MetalManEffect.java | 4 +- .../core/treasure/TreasureManager.java | 8 ++- 5 files changed, 80 insertions(+), 14 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java index 104c88080..940179ace 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java @@ -5,6 +5,7 @@ import java.util.function.Predicate; import mineplex.core.gadget.event.PlayerToggleSwimEvent; import mineplex.core.gadget.gadgets.morph.swim.SwimManager; +import mineplex.core.treasure.TreasureManager; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; @@ -206,6 +207,7 @@ public class GadgetManager extends MiniPlugin private final HologramManager _hologramManager; private final OutfitWindUpSuitBoosterManager _boosterManager; private final IncognitoManager _incognitoManager; + private TreasureManager _treasureManager; private NautHashMap> _gadgets; @@ -1153,4 +1155,14 @@ public class GadgetManager extends MiniPlugin } } } + + public void setTreasureManager(TreasureManager treasureManager) + { + _treasureManager = treasureManager; + } + + public TreasureManager getTreasureManager() + { + return _treasureManager; + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphMetalMan.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphMetalMan.java index cdb03128f..3722be911 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphMetalMan.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphMetalMan.java @@ -30,7 +30,7 @@ public class MorphMetalMan extends MorphGadget public MorphMetalMan(GadgetManager manager) { super(manager, "Metal Man Morph", UtilText.splitLinesToArray(new String[]{C.cGray + "This powerful suit forged of metal makes the wearer strong enough to even battle the gods", - C.cWhite + "Left-click to shoot laser beam"}, LineFormat.LORE), + "", C.cWhite + "Left-click to shoot laser beam"}, LineFormat.LORE), 0, Material.IRON_INGOT, (byte) 0); } @@ -67,7 +67,10 @@ public class MorphMetalMan extends MorphGadget if (!UtilEvent.isAction(event, UtilEvent.ActionType.L)) return; - if (!Recharge.Instance.use(player, getName(), 5000, false, false, "Cosmetics")) + if (player.getItemInHand().getType() != Material.AIR) + return; + + if (!Recharge.Instance.use(player, getName(), 5000, true, false, "Cosmetics")) return; // Creates colored laser @@ -113,7 +116,7 @@ public class MorphMetalMan extends MorphGadget } else { - _playerColors.put(uuid, 0); + _playerColors.put(uuid, 1); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphWitch.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphWitch.java index 82b83b9d1..70f8e22ab 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphWitch.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/MorphWitch.java @@ -1,16 +1,15 @@ package mineplex.core.gadget.gadgets.morph; import mineplex.core.common.skin.SkinData; -import mineplex.core.common.util.F; -import mineplex.core.common.util.LineFormat; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilText; +import mineplex.core.common.util.*; import mineplex.core.disguise.disguises.DisguiseWitch; import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.event.GadgetSelectLocationEvent; import mineplex.core.gadget.types.MorphGadget; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -23,7 +22,7 @@ public class MorphWitch extends MorphGadget public MorphWitch(GadgetManager manager) { - super(manager, "Witch Morph", UtilText.splitLinesToArray(new String[]{"Press sneak to summon your trusty bat and start brewing"}, LineFormat.LORE), 0, Material.SKULL_ITEM, (byte) 3); + super(manager, "Witch Morph", UtilText.splitLinesToArray(new String[]{C.cWhite + "Press sneak to summon your trusty bat and start brewing"}, LineFormat.LORE), 0, Material.SKULL_ITEM, (byte) 3); } @Override @@ -57,6 +56,15 @@ public class MorphWitch extends MorphGadget public void onSneak(PlayerToggleSneakEvent event) { WitchEffectManager witchEffectManager = WitchEffectManager.getManager(event.getPlayer()); + + if (!Recharge.Instance.usable(event.getPlayer(), "Witch Cauldron", true)) + { + return; + } + + if (!event.isSneaking()) + return; + if (witchEffectManager != null) { if (witchEffectManager.hasStarted()) @@ -72,9 +80,7 @@ public class MorphWitch extends MorphGadget return; } - if (!Recharge.Instance.use(event.getPlayer(), "Witch Cauldron", 15000, true, false, "Cosmetics")) - return; - + // Checks if there is a block under the cauldron Location cauldronLocation = event.getPlayer().getLocation().clone().add(event.getPlayer().getLocation().getDirection()); cauldronLocation.add(0, 1, 0); if(cauldronLocation.getBlock().getType() != Material.AIR) @@ -82,6 +88,45 @@ public class MorphWitch extends MorphGadget UtilPlayer.message(event.getPlayer(), F.main("Witch Morph", "You can't place the cauldron there!")); return; } + + // Checks if player is opening a treasure chest/close to a treasure area + if (Manager.getTreasureManager() != null) + { + if (Manager.getTreasureManager().isOpening(event.getPlayer())) + { + UtilPlayer.message(event.getPlayer(), F.main("Witch Morph", "You can't place the cauldron there!")); + return; + } + } + + // Checks if the player is close to a cactus + for (int x = -3; x < 3; x++) + { + for (int z = -3; z < 3; z++) + { + Location possibleCactus = cauldronLocation.clone().add(x, 0, z); + if (possibleCactus.getBlock().getType() == Material.CACTUS) + { + UtilPlayer.message(event.getPlayer(), F.main("Witch Morph", "You can't place the cauldron there!")); + return; + } + } + } + + // Checks if the player is in a Soccer area + GadgetSelectLocationEvent gadgetSelectLocationEvent = new GadgetSelectLocationEvent(event.getPlayer(), this, cauldronLocation.clone().subtract(0, 1, 0)); + gadgetSelectLocationEvent.setShowMessage(true); + Bukkit.getServer().getPluginManager().callEvent(gadgetSelectLocationEvent); + + if (gadgetSelectLocationEvent.isCancelled()) + { + UtilPlayer.message(event.getPlayer(), F.main("Witch Morph", "You can't place the cauldron there!")); + return; + } + + if (!Recharge.Instance.use(event.getPlayer(), "Witch Cauldron", 15000, true, false, "Cosmetics")) + return; + WitchEffectManager newManager = new WitchEffectManager(event.getPlayer(), cauldronLocation); newManager.start(); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/unrelated/MetalManEffect.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/unrelated/MetalManEffect.java index 17a40710c..5273f0e7e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/unrelated/MetalManEffect.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/particle/unrelated/MetalManEffect.java @@ -66,8 +66,8 @@ public class MetalManEffect extends Effect // Creates the explosion and knockback players Location loc = _fixedLoc; loc.getWorld().createExplosion(loc, 0f); - UtilParticle.PlayParticle(UtilParticle.ParticleType.HUGE_EXPLOSION, loc, 3f, 3f, 3f, 0, 32, UtilParticle.ViewDist.MAX, UtilServer.getPlayers()); - HashMap players = UtilPlayer.getInRadius(loc, 12d); + UtilParticle.PlayParticle(UtilParticle.ParticleType.EXPLODE, loc, 3f, 3f, 3f, 0, 32, UtilParticle.ViewDist.MAX, UtilServer.getPlayers()); + HashMap players = UtilPlayer.getInRadius(loc, 5d); for (Player ent : players.keySet()) { if (_gadget.Manager.collideEvent(_player, _gadget, ent)) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureManager.java b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureManager.java index 1dd1b3a8b..a63dc4b6f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/treasure/TreasureManager.java @@ -1,6 +1,5 @@ package mineplex.core.treasure; -import java.util.ArrayList; import java.util.List; import com.google.common.collect.Lists; @@ -63,6 +62,8 @@ public class TreasureManager extends MiniPlugin { _plugin.getServer().getPluginManager().registerEvents(treasureLocation, _plugin); } + + gadgetManager.setTreasureManager(this); } private Block[] setup(Block chestBlock) @@ -145,4 +146,9 @@ public class TreasureManager extends MiniPlugin { return _clientManager; } + + public List getTreasureLocations() + { + return _treasureLocations; + } } From d00c887a84bf4ca9c301b955dc627217934c9e6c Mon Sep 17 00:00:00 2001 From: cnr Date: Fri, 30 Sep 2016 21:00:02 -0700 Subject: [PATCH 11/11] Hide Power Play Metal Man reward for now --- .../core/bonuses/gui/buttons/PowerPlayClubButton.java | 3 --- .../src/mineplex/core/gadget/GadgetManager.java | 2 +- .../mineplex/core/powerplayclub/PowerPlayClubRewards.java | 5 ----- 3 files changed, 1 insertion(+), 9 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/PowerPlayClubButton.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/PowerPlayClubButton.java index 083e909f5..b96e421ff 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/PowerPlayClubButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/PowerPlayClubButton.java @@ -123,9 +123,6 @@ public class PowerPlayClubButton implements GuiItem lore = buildLore(Collections.singletonList(YearMonth.now())); lore.add(" "); - lore.add(C.cGreen + "First-time Bonus:"); - lore.add(" " + C.cWhite + "Metal Man Morph"); - lore.add(" "); lore.add(C.cRed + "Get Power Play Club months at"); lore.add(C.cAqua + "mineplex.com/shop"); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java index 4dd7872e4..f2ffcee5d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java @@ -344,7 +344,7 @@ public class GadgetManager extends MiniPlugin addGadget(new MorphUncleSam(this)); addGadget(new MorphSquid(this)); addGadget(new MorphWitch(this)); - addGadget(new MorphMetalMan(this)); + //addGadget(new MorphMetalMan(this)); // Soon: reward for signup // Particles addGadget(new ParticleFoot(this)); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java b/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java index 98e258fc2..96e028df1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRewards.java @@ -73,11 +73,6 @@ public class PowerPlayClubRewards List items = rewardsForMonths(cached.getUnclaimedMonths()); - // Give Metal Man morph for signing up - donationManager.PurchaseUnknownSalesPackage(null, player.getName(), - donationManager.getClientManager().Get(player).getAccountId(), "Metal Man Morph", - GlobalCurrency.TREASURE_SHARD, 0, true); - // Give normal power play items items.forEach(item -> {