From dd675b407ada18116836511ff9f4fa0427f18e87 Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 28 Jul 2017 20:10:10 +0100 Subject: [PATCH] Add Game Cosmetics and the 4 basic hero morphs --- .../ui/button/open/OpenGameModifiers.java | 7 +- .../GameCosmeticCategoryPage.java | 75 +++++ .../gamemodifiers/GameCosmeticGadgetPage.java | 55 ++++ .../page/gamemodifiers/GameCosmeticsPage.java | 75 +++++ .../mineplex/core/gadget/GadgetManager.java | 269 ++++++++++------- .../gamemodifiers/GameCosmeticCategory.java | 29 +- .../gamemodifiers/GameCosmeticManager.java | 9 +- .../gamemodifiers/GameCosmeticType.java | 18 +- .../minestrike/MineStrikeSkin.java | 108 ++++--- .../core/gadget/gadgets/item/ItemTNT.java | 99 ++++--- .../gadget/gadgets/morph/moba/MorphAnath.java | 199 +++++++++++++ .../gadget/gadgets/morph/moba/MorphDana.java | 270 ++++++++++++++++++ .../gadget/gadgets/morph/moba/MorphDevon.java | 155 ++++++++++ .../gadgets/morph/moba/MorphHattori.java | 177 ++++++++++++ .../core/gadget/types/GameModifierGadget.java | 15 +- 15 files changed, 1354 insertions(+), 206 deletions(-) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/gamemodifiers/GameCosmeticCategoryPage.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/gamemodifiers/GameCosmeticGadgetPage.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/gamemodifiers/GameCosmeticsPage.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/moba/MorphAnath.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/moba/MorphDana.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/moba/MorphDevon.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/moba/MorphHattori.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/open/OpenGameModifiers.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/open/OpenGameModifiers.java index b93afd941..a882542b4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/open/OpenGameModifiers.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/open/OpenGameModifiers.java @@ -1,10 +1,9 @@ package mineplex.core.cosmetic.ui.button.open; -import org.bukkit.entity.Player; - -import mineplex.core.cosmetic.ui.page.gamemodifiers.GameModifierPage; import mineplex.core.cosmetic.ui.page.Menu; +import mineplex.core.cosmetic.ui.page.gamemodifiers.GameCosmeticsPage; import mineplex.core.gadget.types.Gadget; +import org.bukkit.entity.Player; public class OpenGameModifiers extends OpenPageButton { @@ -16,6 +15,6 @@ public class OpenGameModifiers extends OpenPageButton @Override protected void leftClick(Player player) { - getMenu().getShop().openPageForPlayer(player, new GameModifierPage(getMenu().getPlugin(), getMenu().getShop(), getMenu().getClientManager(), getMenu().getDonationManager(),player)); + getMenu().getShop().openPageForPlayer(player, new GameCosmeticsPage(getMenu().getPlugin(), getMenu().getShop(), getMenu().getClientManager(), getMenu().getDonationManager(),player)); } } \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/gamemodifiers/GameCosmeticCategoryPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/gamemodifiers/GameCosmeticCategoryPage.java new file mode 100644 index 000000000..15df48062 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/gamemodifiers/GameCosmeticCategoryPage.java @@ -0,0 +1,75 @@ +package mineplex.core.cosmetic.ui.page.gamemodifiers; + +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilUI; +import mineplex.core.cosmetic.CosmeticManager; +import mineplex.core.cosmetic.ui.CosmeticShop; +import mineplex.core.cosmetic.ui.page.GadgetPage; +import mineplex.core.donation.DonationManager; +import mineplex.core.gadget.gadgets.gamemodifiers.GameCosmeticCategory; +import mineplex.core.gadget.gadgets.gamemodifiers.GameCosmeticType; +import mineplex.core.gadget.types.GameModifierGadget; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.shop.item.ShopItem; +import org.bukkit.Material; +import org.bukkit.entity.Player; + +import java.util.List; + +public class GameCosmeticCategoryPage extends GadgetPage +{ + + private final List _categories; + private boolean _buildPage; + + public GameCosmeticCategoryPage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player, GameCosmeticType type, List categories) + { + super(plugin, shop, clientManager, donationManager, type.getName(), player); + + _categories = categories; + _buildPage = true; + + buildPage(); + } + + @Override + protected void buildPage() + { + if (!_buildPage) + { + return; + } + + int[] slots = UtilUI.getIndicesFor(_categories.size(), 2); + int index = 0; + + for (GameCosmeticCategory category : _categories) + { + int own = 0; + int total = 0; + for (GameModifierGadget gadget : category.getGadgets()) + { + if (gadget.ownsGadget(getPlayer())) + { + own++; + } + total++; + } + + ItemBuilder builder = new ItemBuilder(category.getItemStack()); + + builder.setTitle(C.cGreenB + category.getCategoryName()); + builder.addLore( + "", + C.cWhite + "You own " + own + "/" + total, + "", + C.cGreen + "Left-Click to view " + category.getCategoryName() + " cosmetics" + ); + + addButton(slots[index++], builder.build(), (player, clickType) -> getShop().openPageForPlayer(player, new GameCosmeticGadgetPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), category.getCategoryName(), player, this, category))); + } + + addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[0], 1, false), (player, clickType) -> getShop().openPageForPlayer(getPlayer(), new GameCosmeticsPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), player))); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/gamemodifiers/GameCosmeticGadgetPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/gamemodifiers/GameCosmeticGadgetPage.java new file mode 100644 index 000000000..bc74deedd --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/gamemodifiers/GameCosmeticGadgetPage.java @@ -0,0 +1,55 @@ +package mineplex.core.cosmetic.ui.page.gamemodifiers; + +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.util.C; +import mineplex.core.cosmetic.CosmeticManager; +import mineplex.core.cosmetic.ui.CosmeticShop; +import mineplex.core.cosmetic.ui.page.GadgetPage; +import mineplex.core.donation.DonationManager; +import mineplex.core.gadget.gadgets.gamemodifiers.GameCosmeticCategory; +import mineplex.core.gadget.types.GameModifierGadget; +import mineplex.core.shop.item.ShopItem; +import org.bukkit.Material; +import org.bukkit.entity.Player; + +public class GameCosmeticGadgetPage extends GadgetPage +{ + + private final GameCosmeticCategoryPage _previousMenu; + private final GameCosmeticCategory _category; + private boolean _buildPage; + + public GameCosmeticGadgetPage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player, GameCosmeticCategoryPage previousMenu, GameCosmeticCategory category) + { + super(plugin, shop, clientManager, donationManager, name, player); + + _previousMenu = previousMenu; + _category = category; + _buildPage = true; + + buildPage(); + } + + @Override + protected void buildPage() + { + if (!_buildPage) + { + return; + } + + int slot = 10; + + for (GameModifierGadget gadget : _category.getGadgets()) + { + addGadget(gadget, slot); + + if (++slot % 9 == 8) + { + slot += 2; + } + } + + addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), (player, clickType) -> getShop().openPageForPlayer(getPlayer(), _previousMenu)); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/gamemodifiers/GameCosmeticsPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/gamemodifiers/GameCosmeticsPage.java new file mode 100644 index 000000000..22e21527e --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/gamemodifiers/GameCosmeticsPage.java @@ -0,0 +1,75 @@ +package mineplex.core.cosmetic.ui.page.gamemodifiers; + +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilUI; +import mineplex.core.cosmetic.CosmeticManager; +import mineplex.core.cosmetic.ui.CosmeticShop; +import mineplex.core.cosmetic.ui.page.GadgetPage; +import mineplex.core.cosmetic.ui.page.Menu; +import mineplex.core.donation.DonationManager; +import mineplex.core.gadget.gadgets.gamemodifiers.GameCosmeticCategory; +import mineplex.core.gadget.gadgets.gamemodifiers.GameCosmeticManager; +import mineplex.core.gadget.gadgets.gamemodifiers.GameCosmeticType; +import mineplex.core.gadget.types.GameModifierGadget; +import mineplex.core.game.GameDisplay; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.shop.item.ShopItem; +import org.bukkit.Material; +import org.bukkit.entity.Player; + +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +public class GameCosmeticsPage extends GadgetPage +{ + + public GameCosmeticsPage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player) + { + super(plugin, shop, clientManager, donationManager, "Game Cosmetics", player); + } + + @Override + protected void buildPage() + { + GameCosmeticManager manager = getPlugin().getGadgetManager().getGameCosmeticManager(); + Map> cosmetics = manager.getTypes(); + int[] slots = UtilUI.getIndicesFor(cosmetics.size(), 2); + int index = 0; + + for (Entry> entry : cosmetics.entrySet()) + { + int own = 0; + int total = 0; + + for (GameCosmeticCategory category : entry.getValue()) + { + for (GameModifierGadget gadget : category.getGadgets()) + { + if (gadget.ownsGadget(getPlayer())) + { + own++; + } + total++; + } + } + + GameDisplay display = entry.getKey().getGame(); + ItemBuilder builder = new ItemBuilder(display.getMaterial(), display.getMaterialData()); + + builder.setTitle(C.cGreenB + display.getName()); + builder.addLore( + "", + C.cWhite + "You own " + own + "/" + total, + "", + C.cGreen + "Left-Click to view " + display.getName() + "'s cosmetics" + ); + + addButton(slots[index++], builder.build(), (player, clickType) -> getShop().openPageForPlayer(player, new GameCosmeticCategoryPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), player, entry.getKey(), entry.getValue()))); + } + + addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[0], 1, false), (player, clickType) -> getShop().openPageForPlayer(getPlayer(), new Menu(getPlugin(), getShop(), getClientManager(), getDonationManager(), player))); + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java index 430ffd83d..082ce46a2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java @@ -1,51 +1,11 @@ package mineplex.core.gadget; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.UUID; -import java.util.function.Predicate; - -import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailRedWhite; -import mineplex.core.gadget.gadgets.death.DeathMapleLeaf; -import mineplex.core.gadget.gadgets.doublejump.DoubleJumpMaple; -import mineplex.core.gadget.gadgets.flag.FlagType; -import mineplex.core.gadget.gadgets.gamemodifiers.GameCosmeticCategory; -import mineplex.core.gadget.gadgets.gamemodifiers.GameCosmeticManager; -import mineplex.core.gadget.gadgets.gamemodifiers.GameCosmeticType; -import mineplex.core.gadget.gadgets.morph.MorphBobRoss; -import mineplex.core.gadget.gadgets.morph.MorphFreedomFighter; -import mineplex.core.gadget.gadgets.particle.freedom.ParticleAuraNiceness; -import mineplex.core.gadget.gadgets.particle.freedom.ParticleCanadian; -import mineplex.core.gadget.gadgets.particle.freedom.ParticleFreedomFireworks; -import mineplex.core.gadget.gadgets.particle.freedom.ParticleStarSpangled; -import mineplex.core.gadget.set.SetCanadian; -import mineplex.core.gadget.types.FlagGadget; -import mineplex.core.game.GameDisplay; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.entity.PlayerDeathEvent; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerMoveEvent; -import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.event.player.PlayerToggleSneakEvent; -import org.bukkit.plugin.java.JavaPlugin; - import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClientManager; import mineplex.core.achievement.AchievementManager; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.common.Rank; +import mineplex.core.common.skin.SkinData; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilMath; @@ -62,50 +22,57 @@ import mineplex.core.gadget.event.GadgetCollideEntityEvent; import mineplex.core.gadget.event.GadgetEnableEvent; import mineplex.core.gadget.event.PlayerToggleSwimEvent; import mineplex.core.gadget.event.TauntCommandEvent; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailBlood; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailCandyCane; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailConfetti; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailCupid; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailEmerald; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailEnchant; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailFreedom; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailFrostLord; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailHalloween; -import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailStorm; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailMusic; -import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailConfetti; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailRedWhite; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailShadow; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailSpring; +import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailStorm; import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailTitan; -import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailBlood; -import mineplex.core.gadget.gadgets.arrowtrail.ArrowTrailEnchant; import mineplex.core.gadget.gadgets.balloons.BalloonItem; import mineplex.core.gadget.gadgets.balloons.BalloonType; +import mineplex.core.gadget.gadgets.death.DeathBlood; import mineplex.core.gadget.gadgets.death.DeathCandyCane; -import mineplex.core.gadget.gadgets.death.DeathPresentDanger; import mineplex.core.gadget.gadgets.death.DeathCupidsBrokenHeart; import mineplex.core.gadget.gadgets.death.DeathEmerald; +import mineplex.core.gadget.gadgets.death.DeathEnchant; import mineplex.core.gadget.gadgets.death.DeathFreedom; import mineplex.core.gadget.gadgets.death.DeathFrostLord; -import mineplex.core.gadget.gadgets.death.DeathStorm; +import mineplex.core.gadget.gadgets.death.DeathMapleLeaf; import mineplex.core.gadget.gadgets.death.DeathMusic; import mineplex.core.gadget.gadgets.death.DeathPinataBurst; +import mineplex.core.gadget.gadgets.death.DeathPresentDanger; import mineplex.core.gadget.gadgets.death.DeathShadow; import mineplex.core.gadget.gadgets.death.DeathSpring; +import mineplex.core.gadget.gadgets.death.DeathStorm; import mineplex.core.gadget.gadgets.death.DeathTitan; -import mineplex.core.gadget.gadgets.death.DeathBlood; -import mineplex.core.gadget.gadgets.death.DeathEnchant; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpBlood; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpCandyCane; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpCupidsWings; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpEmerald; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpEnchant; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpFirecracker; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpFreedom; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpFrostLord; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpHalloween; -import mineplex.core.gadget.gadgets.doublejump.DoubleJumpStorm; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpMaple; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpMusic; -import mineplex.core.gadget.gadgets.doublejump.DoubleJumpFirecracker; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpShadow; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpSpring; +import mineplex.core.gadget.gadgets.doublejump.DoubleJumpStorm; import mineplex.core.gadget.gadgets.doublejump.DoubleJumpTitan; -import mineplex.core.gadget.gadgets.doublejump.DoubleJumpBlood; -import mineplex.core.gadget.gadgets.doublejump.DoubleJumpEnchant; +import mineplex.core.gadget.gadgets.flag.FlagType; +import mineplex.core.gadget.gadgets.gamemodifiers.GameCosmeticCategory; +import mineplex.core.gadget.gadgets.gamemodifiers.GameCosmeticManager; +import mineplex.core.gadget.gadgets.gamemodifiers.GameCosmeticType; import mineplex.core.gadget.gadgets.gamemodifiers.GameModifierType; import mineplex.core.gadget.gadgets.gamemodifiers.gemhunters.GameModifierMount; import mineplex.core.gadget.gadgets.gamemodifiers.gemhunters.MountType; @@ -143,6 +110,7 @@ import mineplex.core.gadget.gadgets.morph.MorphAwkwardRabbit; import mineplex.core.gadget.gadgets.morph.MorphBat; import mineplex.core.gadget.gadgets.morph.MorphBlaze; import mineplex.core.gadget.gadgets.morph.MorphBlock; +import mineplex.core.gadget.gadgets.morph.MorphBobRoss; import mineplex.core.gadget.gadgets.morph.MorphBunny; import mineplex.core.gadget.gadgets.morph.MorphChicken; import mineplex.core.gadget.gadgets.morph.MorphChristmasKing; @@ -150,6 +118,7 @@ import mineplex.core.gadget.gadgets.morph.MorphCow; import mineplex.core.gadget.gadgets.morph.MorphCreeper; import mineplex.core.gadget.gadgets.morph.MorphDinnerbone; import mineplex.core.gadget.gadgets.morph.MorphEnderman; +import mineplex.core.gadget.gadgets.morph.MorphFreedomFighter; import mineplex.core.gadget.gadgets.morph.MorphGoldPot; import mineplex.core.gadget.gadgets.morph.MorphGrimReaper; import mineplex.core.gadget.gadgets.morph.MorphLoveDoctor; @@ -168,6 +137,10 @@ import mineplex.core.gadget.gadgets.morph.MorphWitch; import mineplex.core.gadget.gadgets.morph.MorphWither; import mineplex.core.gadget.gadgets.morph.managers.SoulManager; import mineplex.core.gadget.gadgets.morph.managers.SwimManager; +import mineplex.core.gadget.gadgets.morph.moba.MorphAnath; +import mineplex.core.gadget.gadgets.morph.moba.MorphDana; +import mineplex.core.gadget.gadgets.morph.moba.MorphDevon; +import mineplex.core.gadget.gadgets.morph.moba.MorphHattori; import mineplex.core.gadget.gadgets.outfit.OutfitTeam; import mineplex.core.gadget.gadgets.outfit.freezesuit.OutfitFreezeSuitBoots; import mineplex.core.gadget.gadgets.outfit.freezesuit.OutfitFreezeSuitChestplate; @@ -186,13 +159,22 @@ import mineplex.core.gadget.gadgets.outfit.stpatricks.OutfitStPatricksChestplate import mineplex.core.gadget.gadgets.outfit.stpatricks.OutfitStPatricksHat; import mineplex.core.gadget.gadgets.outfit.stpatricks.OutfitStPatricksLeggings; import mineplex.core.gadget.gadgets.outfit.windupsuit.OutfitWindUpSuitBoosterManager; +import mineplex.core.gadget.gadgets.particle.ParticleBlood; +import mineplex.core.gadget.gadgets.particle.ParticleCandyCane; import mineplex.core.gadget.gadgets.particle.ParticleChristmasTree; import mineplex.core.gadget.gadgets.particle.ParticleCoalFumes; +import mineplex.core.gadget.gadgets.particle.ParticleEmerald; +import mineplex.core.gadget.gadgets.particle.ParticleEnchant; import mineplex.core.gadget.gadgets.particle.ParticleFairy; import mineplex.core.gadget.gadgets.particle.ParticleFireRings; -import mineplex.core.gadget.gadgets.particle.king.CastleManager; -import mineplex.core.gadget.gadgets.particle.king.ParticleKing; +import mineplex.core.gadget.gadgets.particle.ParticleFoot; +import mineplex.core.gadget.gadgets.particle.ParticleFrostLord; +import mineplex.core.gadget.gadgets.particle.ParticleHeart; import mineplex.core.gadget.gadgets.particle.ParticleLegend; +import mineplex.core.gadget.gadgets.particle.ParticleMusic; +import mineplex.core.gadget.gadgets.particle.ParticlePartyTime; +import mineplex.core.gadget.gadgets.particle.ParticleRain; +import mineplex.core.gadget.gadgets.particle.ParticleTitan; import mineplex.core.gadget.gadgets.particle.ParticleWingsAngel; import mineplex.core.gadget.gadgets.particle.ParticleWingsBee; import mineplex.core.gadget.gadgets.particle.ParticleWingsDemons; @@ -200,19 +182,14 @@ import mineplex.core.gadget.gadgets.particle.ParticleWingsInfernal; import mineplex.core.gadget.gadgets.particle.ParticleWingsLove; import mineplex.core.gadget.gadgets.particle.ParticleWingsPixie; import mineplex.core.gadget.gadgets.particle.ParticleYinYang; -import mineplex.core.gadget.gadgets.particle.ParticleCandyCane; -import mineplex.core.gadget.gadgets.particle.ParticleHeart; -import mineplex.core.gadget.gadgets.particle.ParticleEmerald; +import mineplex.core.gadget.gadgets.particle.freedom.ParticleAuraNiceness; +import mineplex.core.gadget.gadgets.particle.freedom.ParticleCanadian; import mineplex.core.gadget.gadgets.particle.freedom.ParticleFreedom; -import mineplex.core.gadget.gadgets.particle.ParticleFrostLord; -import mineplex.core.gadget.gadgets.particle.ParticleRain; -import mineplex.core.gadget.gadgets.particle.ParticleMusic; -import mineplex.core.gadget.gadgets.particle.ParticlePartyTime; -import mineplex.core.gadget.gadgets.particle.ParticleFoot; +import mineplex.core.gadget.gadgets.particle.freedom.ParticleFreedomFireworks; +import mineplex.core.gadget.gadgets.particle.freedom.ParticleStarSpangled; +import mineplex.core.gadget.gadgets.particle.king.CastleManager; +import mineplex.core.gadget.gadgets.particle.king.ParticleKing; import mineplex.core.gadget.gadgets.particle.spring.ParticleSpringHalo; -import mineplex.core.gadget.gadgets.particle.ParticleTitan; -import mineplex.core.gadget.gadgets.particle.ParticleBlood; -import mineplex.core.gadget.gadgets.particle.ParticleEnchant; import mineplex.core.gadget.gadgets.taunts.BlowAKissTaunt; import mineplex.core.gadget.gadgets.taunts.EternalTaunt; import mineplex.core.gadget.gadgets.taunts.RainbowTaunt; @@ -234,6 +211,7 @@ import mineplex.core.gadget.gadgets.wineffect.rankrooms.rankwineffects.WinEffect import mineplex.core.gadget.gadgets.wineffect.rankrooms.rankwineffects.WinEffectRankTitan; import mineplex.core.gadget.gadgets.wineffect.rankrooms.rankwineffects.WinEffectRankUltra; import mineplex.core.gadget.persistence.UserGadgetPersistence; +import mineplex.core.gadget.set.SetCanadian; import mineplex.core.gadget.set.SetCandyCane; import mineplex.core.gadget.set.SetCupidsLove; import mineplex.core.gadget.set.SetEmerald; @@ -255,6 +233,7 @@ import mineplex.core.gadget.types.ArrowEffectGadget; import mineplex.core.gadget.types.BalloonGadget; import mineplex.core.gadget.types.DeathEffectGadget; import mineplex.core.gadget.types.DoubleJumpEffectGadget; +import mineplex.core.gadget.types.FlagGadget; import mineplex.core.gadget.types.Gadget; import mineplex.core.gadget.types.GadgetSet; import mineplex.core.gadget.types.GadgetType; @@ -268,10 +247,12 @@ import mineplex.core.gadget.types.OutfitGadget.ArmorSlot; import mineplex.core.gadget.types.ParticleGadget; import mineplex.core.gadget.types.TauntGadget; import mineplex.core.gadget.types.WinEffectGadget; +import mineplex.core.game.GameDisplay; import mineplex.core.hologram.HologramManager; import mineplex.core.incognito.IncognitoManager; import mineplex.core.incognito.events.IncognitoStatusChangeEvent; import mineplex.core.inventory.InventoryManager; +import mineplex.core.itemstack.ItemBuilder; import mineplex.core.mount.MountManager; import mineplex.core.mount.event.MountActivateEvent; import mineplex.core.packethandler.PacketHandler; @@ -280,6 +261,31 @@ import mineplex.core.pet.custom.CustomPet; import mineplex.core.preferences.PreferencesManager; import mineplex.core.projectile.ProjectileManager; import mineplex.core.treasure.TreasureManager; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.player.PlayerToggleSneakEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.plugin.java.JavaPlugin; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.UUID; +import java.util.function.Predicate; public class GadgetManager extends MiniPlugin { @@ -475,6 +481,10 @@ public class GadgetManager extends MiniPlugin addGadget(new MorphAwkwardRabbit(this)); addGadget(new MorphBobRoss(this, _hologramManager)); addGadget(new MorphFreedomFighter(this)); + addGadget(new MorphHattori(this)); + addGadget(new MorphDevon(this)); + addGadget(new MorphAnath(this)); + addGadget(new MorphDana(this)); // Particles addGadget(new ParticleFoot(this)); @@ -604,39 +614,6 @@ public class GadgetManager extends MiniPlugin addGadget(new MusicGadget(this, "Strad Disc", new String[] {""}, -2, 2264, 188000)); addGadget(new MusicGadget(this, "Ward Disc", new String[] {""}, -2, 2265, 251000)); addGadget(new MusicGadget(this, "Wait Disc", new String[] {""}, -2, 2267, 238000)); - - - // Game Modifiers - - // MineStrike - /*addGadget(new GameModifierMineStrikeSkin(this, MineStrikeSkin.P250_Muertos, -2)); - addGadget(new GameModifierMineStrikeSkin(this, MineStrikeSkin.CZ75_Auto_Tigris, -2)); - addGadget(new GameModifierMineStrikeSkin(this, MineStrikeSkin.Desert_Eagle_Blaze, -2)); - addGadget(new GameModifierMineStrikeSkin(this, MineStrikeSkin.Nova_Koi, -2)); - addGadget(new GameModifierMineStrikeSkin(this, MineStrikeSkin.XM1014_Tranquility, -2)); - addGadget(new GameModifierMineStrikeSkin(this, MineStrikeSkin.PP_Bizon_Streak, -2)); - addGadget(new GameModifierMineStrikeSkin(this, MineStrikeSkin.P90_Asiimov, -2)); - addGadget(new GameModifierMineStrikeSkin(this, MineStrikeSkin.SSG_08_Blood_in_the_Water, -2)); - addGadget(new GameModifierMineStrikeSkin(this, MineStrikeSkin.AWP_Asiimov, -2)); - - addGadget(new GameModifierMineStrikeSkin(this, MineStrikeSkin.Knife_M9_Bayonette_Fade, -2)); - addGadget(new GameModifierMineStrikeSkin(this, )); - - //Blue only - addGadget(new GameModifierMineStrikeSkin(this, MineStrikeSkin.P2000_Fire_Elemental, -2)); - addGadget(new GameModifierMineStrikeSkin(this, MineStrikeSkin.FAMAS_Pulse, -2)); - addGadget(new GameModifierMineStrikeSkin(this, MineStrikeSkin.M4A4_Howl, -2)); - addGadget(new GameModifierMineStrikeSkin(this, MineStrikeSkin.Steyr_AUG_Torque, -2)); - //Red only - addGadget(new GameModifierMineStrikeSkin(this, MineStrikeSkin.Glock_18_Fade, -2)); - addGadget(new GameModifierMineStrikeSkin(this, MineStrikeSkin.Galil_AR_Eco, -2)); - addGadget(new GameModifierMineStrikeSkin(this, MineStrikeSkin.AK_47_Vulcan, -2)); - addGadget(new GameModifierMineStrikeSkin(this, MineStrikeSkin.SG553_Pulse, -2));*/ - for (MineStrikeSkin mineStrikeSkin : MineStrikeSkin.values()) - { - addGadget(new GameModifierMineStrikeSkin(this, mineStrikeSkin, -2)); - } - // Survival Games /* for (KitModifier kitModifier : KitModifier.values()) @@ -680,22 +657,104 @@ public class GadgetManager extends MiniPlugin addGadget(new GameModifierMount(this, mount)); } - new GameCosmeticType(this, GameDisplay.MOBA.getName(), GameDisplay.MOBA) + new GameCosmeticType(this, GameDisplay.MineStrike) { @Override public void addCategories() { - new GameCosmeticCategory(this, "Hero Skins") + new GameCosmeticCategory(this, "Pistol", new ItemStack(Material.NETHER_STALK)) + { + @Override + public void addGadgets() + { + for (MineStrikeSkin mineStrikeSkin : MineStrikeSkin.getByCategory(1)) + { + addGameGadget(new GameModifierMineStrikeSkin(getManager(), mineStrikeSkin, -2)); + } + } + }; + new GameCosmeticCategory(this, "Shotgun", new ItemBuilder(Material.INK_SACK, (byte) 14).build()) + { + @Override + public void addGadgets() + { + for (MineStrikeSkin mineStrikeSkin : MineStrikeSkin.getByCategory(2)) + { + addGameGadget(new GameModifierMineStrikeSkin(getManager(), mineStrikeSkin, -2)); + } + } + }; + new GameCosmeticCategory(this, "SMG", new ItemBuilder(Material.INK_SACK, (byte) 4).build()) + { + @Override + public void addGadgets() + { + for (MineStrikeSkin mineStrikeSkin : MineStrikeSkin.getByCategory(3)) + { + addGameGadget(new GameModifierMineStrikeSkin(getManager(), mineStrikeSkin, -2)); + } + } + }; + new GameCosmeticCategory(this, "Rifle", new ItemBuilder(Material.INK_SACK, (byte) 7).build()) + { + @Override + public void addGadgets() + { + for (MineStrikeSkin mineStrikeSkin : MineStrikeSkin.getByCategory(4)) + { + addGameGadget(new GameModifierMineStrikeSkin(getManager(), mineStrikeSkin, -2)); + } + } + }; + new GameCosmeticCategory(this, "Knife", new ItemStack(Material.DIAMOND_SWORD)) + { + @Override + public void addGadgets() + { + for (MineStrikeSkin mineStrikeSkin : MineStrikeSkin.getByCategory(5)) + { + addGameGadget(new GameModifierMineStrikeSkin(getManager(), mineStrikeSkin, -2)); + } + } + }; + } + }; + + new GameCosmeticType(this, GameDisplay.MOBA) + { + @Override + public void addCategories() + { + new GameCosmeticCategory(this,"Hero Skins", SkinData.HATTORI.getSkull()) + { + @Override + public void addGadgets() + { + } + }; + new GameCosmeticCategory(this,"Taunts", new ItemStack(Material.LAVA_BUCKET)) + { + @Override + public void addGadgets() + { + } + }; + new GameCosmeticCategory(this,"Base Decorations", new ItemStack(Material.WOOD_DOOR)) + { + @Override + public void addGadgets() + { + } + }; + new GameCosmeticCategory(this,"Shop Morph", SkinData.HATTORI.getSkull()) { @Override public void addGadgets() { - } }; } }; - for (GadgetType gadgetType : GadgetType.values()) { if (!_gadgets.containsKey(gadgetType)) @@ -739,7 +798,7 @@ public class GadgetManager extends MiniPlugin _sets.add(set); } - private void addGadget(Gadget gadget) + public void addGadget(Gadget gadget) { if (!_gadgets.containsKey(gadget.getGadgetType())) _gadgets.put(gadget.getGadgetType(), new ArrayList<>()); @@ -1350,7 +1409,7 @@ public class GadgetManager extends MiniPlugin Gadget gadget = event.getGadget(); if (gadget != null) { - String value = "disabled", key = ""; + String value = "disabled", key; GadgetType gadgetType = gadget.getGadgetType(); switch (gadgetType) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/gamemodifiers/GameCosmeticCategory.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/gamemodifiers/GameCosmeticCategory.java index 8a6a73bdc..fa4983e46 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/gamemodifiers/GameCosmeticCategory.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/gamemodifiers/GameCosmeticCategory.java @@ -1,7 +1,9 @@ package mineplex.core.gadget.gadgets.gamemodifiers; import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.types.Gadget; import mineplex.core.gadget.types.GameModifierGadget; +import org.bukkit.inventory.ItemStack; import java.util.ArrayList; import java.util.List; @@ -13,16 +15,41 @@ public abstract class GameCosmeticCategory private final GadgetManager _manager; private final String _categoryName; private final List _gadgets; + private final ItemStack _itemStack; - public GameCosmeticCategory(GameCosmeticType type, String categoryName) + public GameCosmeticCategory(GameCosmeticType type, String categoryName, ItemStack itemStack) { _type = type; _manager = type.getManager(); _categoryName = categoryName; _gadgets = new ArrayList<>(); + _itemStack = itemStack; addGadgets(); + + type.addCategory(this); } public abstract void addGadgets(); + + protected void addGameGadget(GameModifierGadget gadget) + { + _gadgets.add(gadget); + _manager.addGadget(gadget); + } + + public String getCategoryName() + { + return _categoryName; + } + + public List getGadgets() + { + return _gadgets; + } + + public ItemStack getItemStack() + { + return _itemStack; + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/gamemodifiers/GameCosmeticManager.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/gamemodifiers/GameCosmeticManager.java index ca5fccd47..c86076139 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/gamemodifiers/GameCosmeticManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/gamemodifiers/GameCosmeticManager.java @@ -20,9 +20,14 @@ public class GameCosmeticManager extends MiniPlugin _cosmetics = new HashMap<>(); } - public void addCosmeticType(GameCosmeticType type) + public void addCosmeticTypes(GameCosmeticType type, List cosmetics) { - type.addCategories(); + _cosmetics.put(type, cosmetics); + } + + public Map> getTypes() + { + return _cosmetics; } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/gamemodifiers/GameCosmeticType.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/gamemodifiers/GameCosmeticType.java index c67e68073..8d053a3b4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/gamemodifiers/GameCosmeticType.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/gamemodifiers/GameCosmeticType.java @@ -3,24 +3,36 @@ package mineplex.core.gadget.gadgets.gamemodifiers; import mineplex.core.gadget.GadgetManager; import mineplex.core.game.GameDisplay; +import java.util.ArrayList; +import java.util.List; + public abstract class GameCosmeticType { private final GadgetManager _manager; private final String _name; private final GameDisplay _game; + private final List _categories; - public GameCosmeticType(GadgetManager manager, String name, GameDisplay game) + public GameCosmeticType(GadgetManager manager, GameDisplay game) { _manager = manager; - _name = name; + _name = game.getName(); _game = game; + _categories = new ArrayList<>(); - manager.getGameCosmeticManager().addCosmeticType(this); + addCategories(); + + manager.getGameCosmeticManager().addCosmeticTypes(this, _categories); } public abstract void addCategories(); + public void addCategory(GameCosmeticCategory category) + { + _categories.add(category); + } + public final GadgetManager getManager() { return _manager; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/gamemodifiers/minestrike/MineStrikeSkin.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/gamemodifiers/minestrike/MineStrikeSkin.java index af30e790e..88624e498 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/gamemodifiers/minestrike/MineStrikeSkin.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/gamemodifiers/minestrike/MineStrikeSkin.java @@ -2,70 +2,98 @@ package mineplex.core.gadget.gadgets.gamemodifiers.minestrike; import org.bukkit.Material; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + public enum MineStrikeSkin { - - P250_Muertos( "P250", "P250 Muertos", Material.INK_SACK, (byte) 3), - CZ75_Auto_Tigris( "CZ75-Auto", "CZ75-Auto Tigris", Material.CLAY_BRICK, (byte) 0), - Desert_Eagle_Blaze( "Desert Eagle", "Desert Eagle Blaze", Material.NETHER_STALK, (byte) 0), - Desert_Eagle_Golden_Gun( "Desert Eagle", "Golden Gun", Material.GLOWSTONE_DUST, (byte) 0), - Nova_Koi( "Nova", "Nova Koi", Material.INK_SACK, (byte) 14), - XM1014_Tranquility( "XM1014", "XM1014 Tranquility", Material.DIAMOND, (byte) 0), - XM1014_Pig_Gun( "XM1014", "XM1014 Pig Gun", Material.LEATHER, (byte) 0), - PP_Bizon_Streak( "PP-Bizon", "PP-Bizon Streak", Material.INK_SACK, (byte) 4), - P90_Asiimov( "P90", "P90 Asiimov", Material.INK_SACK, (byte) 0), - SSG_08_Blood_in_the_Water( "SSG 08", "SSG 08 Blood in the Water", Material.INK_SACK, (byte) 12), - AWP_Asiimov( "AWP", "AWP Asiimov", Material.SULPHUR, (byte) 0), - P2000_Fire_Elemental( "P2000", "P2000 Fire Elemental", Material.INK_SACK, (byte) 6), - FAMAS_Pulse( "FAMAS", "FAMAS Pulse", Material.CLAY_BALL, (byte) 0), - M4A4_Howl( "M4A4", "M4A4 Howl", Material.INK_SACK, (byte) 11), - M4A4_Enderman( "M4A4", "Enderman M4", Material.COAL, (byte) 0), - Steyr_AUG_Torque( "Steyr AUG", "Steyr AUG Torque", Material.BLAZE_ROD, (byte) 0), - Glock_18_Fade( "Glock 18", "Glock 18 Fade", Material.INK_SACK, (byte) 9), - Galil_AR_Eco( "Galil AR", "Galil AR Eco", Material.INK_SACK, (byte) 10), - AK_47_Vulcan( "AK-47", "AK-47 Vulcan", Material.INK_SACK, (byte) 7), - AK_47_Guardian( "AK-47", "Guardian AK", Material.PRISMARINE_SHARD, (byte) 0), - SG553_Pulse( "SG553", "SG553 Pulse", Material.INK_SACK, (byte) 5), - - Knife_M9_Bayonette_Fade( "Knife", "M9 Bayonette Fade", Material.DIAMOND_SWORD, (byte) 0), - Knife_Counter_Terrorist_Sword("Knife", "Counter Terrorist Sword", Material.STICK, (byte) 0), - Knife_Terrorist_Sword( "Knife", "Terrorist Sword", Material.FEATHER, (byte) 0), - Knife_M9_Bayonette_Glass( "Knife", "Glass M9 Bayonette", Material.QUARTZ, (byte) 0); - - - - private String _weaponName; - private String _skinName; - private Material _skinMaterial; - private byte _skinData; - - MineStrikeSkin(String weaponName, String skinName, Material newMaterial, byte newData) + P250_Muertos( "P250", "P250 Muertos", Material.INK_SACK, (byte) 3, 1), + CZ75_Auto_Tigris( "CZ75-Auto", "CZ75-Auto Tigris", Material.CLAY_BRICK, (byte) 0, 1), + Desert_Eagle_Blaze( "Desert Eagle", "Desert Eagle Blaze", Material.NETHER_STALK, (byte) 0, 1), + Desert_Eagle_Golden_Gun( "Desert Eagle", "Golden Gun", Material.GLOWSTONE_DUST, (byte) 0, 1), + Nova_Koi( "Nova", "Nova Koi", Material.INK_SACK, (byte) 14, 2), + XM1014_Tranquility( "XM1014", "XM1014 Tranquility", Material.DIAMOND, (byte) 0, 2), + XM1014_Pig_Gun( "XM1014", "XM1014 Pig Gun", Material.LEATHER, (byte) 0, 2), + PP_Bizon_Streak( "PP-Bizon", "PP-Bizon Streak", Material.INK_SACK, (byte) 4, 3), + P90_Asiimov( "P90", "P90 Asiimov", Material.INK_SACK, (byte) 0, 3), + SSG_08_Blood_in_the_Water( "SSG 08", "SSG 08 Blood in the Water", Material.INK_SACK, (byte) 12, 4), + AWP_Asiimov( "AWP", "AWP Asiimov", Material.SULPHUR, (byte) 0, 4), + P2000_Fire_Elemental( "P2000", "P2000 Fire Elemental", Material.INK_SACK, (byte) 6, 1), + FAMAS_Pulse( "FAMAS", "FAMAS Pulse", Material.CLAY_BALL, (byte) 0, 4), + M4A4_Howl( "M4A4", "M4A4 Howl", Material.INK_SACK, (byte) 11, 4), + M4A4_Enderman( "M4A4", "Enderman M4", Material.COAL, (byte) 0, 4), + Steyr_AUG_Torque( "Steyr AUG", "Steyr AUG Torque", Material.BLAZE_ROD, (byte) 0, 4), + Glock_18_Fade( "Glock 18", "Glock 18 Fade", Material.INK_SACK, (byte) 9, 1), + Galil_AR_Eco( "Galil AR", "Galil AR Eco", Material.INK_SACK, (byte) 10, 1), + AK_47_Vulcan( "AK-47", "AK-47 Vulcan", Material.INK_SACK, (byte) 7, 4), + AK_47_Guardian( "AK-47", "Guardian AK", Material.PRISMARINE_SHARD, (byte) 0, 4), + SG553_Pulse( "SG553", "SG553 Pulse", Material.INK_SACK, (byte) 5, 4), + + + Knife_M9_Bayonette_Fade( "Knife", "M9 Bayonette Fade", Material.DIAMOND_SWORD, (byte) 0, 5), + Knife_Counter_Terrorist_Sword("Knife", "Counter Terrorist Sword", Material.STICK, (byte) 0, 5), + Knife_Terrorist_Sword( "Knife", "Terrorist Sword", Material.FEATHER, (byte) 0, 5), + Knife_M9_Bayonette_Glass( "Knife", "Glass M9 Bayonette", Material.QUARTZ, (byte) 0, 5); + + private static final Map> BY_CATEGORY; + + static + { + BY_CATEGORY = new HashMap<>(); + + for (MineStrikeSkin skin : MineStrikeSkin.values()) + { + BY_CATEGORY.putIfAbsent(skin.getCategory(), new ArrayList<>()); + BY_CATEGORY.get(skin.getCategory()).add(skin); + } + } + + public static List getByCategory(int category) + { + return BY_CATEGORY.get(category); + } + + private final String _weaponName; + private final String _skinName; + private final Material _skinMaterial; + private final byte _skinData; + private final int _category; + + MineStrikeSkin(String weaponName, String skinName, Material newMaterial, byte newData, int category) { _weaponName = weaponName; _skinName = skinName; _skinMaterial = newMaterial; _skinData = newData; + _category = category; } - + public String getWeaponName() { return _weaponName; } - + public String getSkinName() { return _skinName; } - + public Material getSkinMaterial() { return _skinMaterial; } - + public byte getSkinData() { return _skinData; } + public int getCategory() + { + return _category; + } + } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemTNT.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemTNT.java index eb0d65b51..16abfccb9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemTNT.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/item/ItemTNT.java @@ -1,14 +1,5 @@ package mineplex.core.gadget.gadgets.item; -import java.util.HashMap; -import java.util.HashSet; - -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.entity.TNTPrimed; -import org.bukkit.event.EventHandler; -import org.bukkit.event.entity.EntityExplodeEvent; - import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.LineFormat; @@ -25,54 +16,60 @@ import mineplex.core.gadget.gadgets.Ammo; import mineplex.core.gadget.types.ItemGadget; 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.entity.TNTPrimed; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityExplodeEvent; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; public class ItemTNT extends ItemGadget { - private HashMap _tnt = new HashMap(); - + private final Map _tnt = new HashMap<>(); + public ItemTNT(GadgetManager manager) { - super(manager, "TNT", + super(manager, "TNT", UtilText.splitLineToArray(C.cWhite + "Throwing TNT at Mineplex Staff is highly encouraged.", LineFormat.LORE), - -1, - Material.TNT, (byte)0, - 1000, new Ammo("TNT", "20 TNT", Material.TNT, (byte)0, new String[] { C.cWhite + "20 TNT for you to explode!" }, 500, 20)); + -1, + Material.TNT, (byte) 0, + 1000, new Ammo("TNT", "20 TNT", Material.TNT, (byte) 0, new String[]{C.cWhite + "20 TNT for you to explode!"}, 500, 20)); } @Override public void ActivateCustom(Player player) { - TNTPrimed tnt = player.getWorld().spawn(player.getEyeLocation().add(player.getLocation().getDirection()), TNTPrimed.class); - tnt.setYield(0.0F); // Added in order to prevent water from being evaporated. - UtilAction.velocity(tnt, player.getLocation().getDirection(), 0.6, false, 0, 0.2, 1, false); - _tnt.put(tnt, player); + addTNT(player, player.getEyeLocation(), -1, true); //Inform UtilPlayer.message(player, F.main("Skill", "You threw " + F.skill(getName()) + ".")); } - + @EventHandler - public void Update(EntityExplodeEvent event) + public void updateTNT(EntityExplodeEvent event) { - if (!(event.getEntity() instanceof TNTPrimed)) + if (!(event.getEntity() instanceof TNTPrimed) || !_tnt.containsKey(event.getEntity())) + { return; - - if (!_tnt.containsKey(event.getEntity())) - return; - + } + Player killer = _tnt.get(event.getEntity()); - - HashMap players = UtilPlayer.getInRadius(event.getLocation(), 8); + + Map players = UtilPlayer.getInRadius(event.getLocation(), 8); + for (Player player : players.keySet()) { - if (Manager.collideEvent(killer, this, player)) - continue; - - if (Manager.getCastleManager().isInsideCastle(player.getLocation())) + if (Manager.collideEvent(killer, this, player) || Manager.getCastleManager().isInsideCastle(player.getLocation())) + { continue; + } double mult = players.get(player); - + //Knockback UtilAction.velocity(player, UtilAlg.getTrajectory(event.getLocation(), player.getLocation()), 1 * mult, false, 0, 0.5 + 0.5 * mult, 10, true); } @@ -81,20 +78,44 @@ public class ItemTNT extends ItemGadget UtilParticle.PlayParticle(ParticleType.HUGE_EXPLOSION, event.getLocation(), 0, 0, 0, 0, 1, ViewDist.NORMAL, UtilServer.getPlayers()); } - + @EventHandler - public void Clean(UpdateEvent event) + public void cleanTNT(UpdateEvent event) { if (event.getType() != UpdateType.FAST) - return; - - for (TNTPrimed tnt : new HashSet(_tnt.keySet())) { + return; + } + + Iterator iterator = _tnt.keySet().iterator(); + + while (iterator.hasNext()) + { + TNTPrimed tnt = iterator.next(); + if (!tnt.isValid() || tnt.getTicksLived() > 200) { tnt.remove(); - _tnt.remove(tnt); + iterator.remove(); } } } + + public void addTNT(Player shooter, Location location, int fuseTicks, boolean applyVelocity) + { + TNTPrimed tnt = location.getWorld().spawn(location.add(location.getDirection()), TNTPrimed.class); + tnt.setYield(0F); // Added in order to prevent water from being evaporated. + + if (fuseTicks >= 0) + { + tnt.setFuseTicks(fuseTicks); + } + + if (applyVelocity) + { + UtilAction.velocity(tnt, location.getDirection(), 0.6, false, 0, 0.2, 1, false); + } + + _tnt.put(tnt, shooter); + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/moba/MorphAnath.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/moba/MorphAnath.java new file mode 100644 index 000000000..c2303bda9 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/moba/MorphAnath.java @@ -0,0 +1,199 @@ +package mineplex.core.gadget.gadgets.morph.moba; + +import com.mojang.authlib.GameProfile; +import mineplex.core.common.skin.SkinData; +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilText; +import mineplex.core.common.util.UtilTime; +import mineplex.core.common.util.particles.effects.LineParticle; +import mineplex.core.disguise.disguises.DisguisePlayer; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.gadgets.morph.managers.UtilMorph; +import mineplex.core.gadget.types.MorphGadget; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.core.utils.UtilGameProfile; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.block.Action; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerToggleSneakEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.scheduler.BukkitRunnable; +import org.bukkit.util.Vector; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + +public class MorphAnath extends MorphGadget +{ + + private static final ItemStack ACTIVE_ITEN = new ItemBuilder(Material.FIREBALL) + .setTitle(C.cGreenB + "Anath's Butn Beam") + .addLore("Clicking this fires out a huge wave of fiery particles!") + .setUnbreakable(true) + .build(); + private static final int ACTIVE_SLOT = 2; + + private final Map _dashingPlayers = new HashMap<>(); + + public MorphAnath(GadgetManager manager) + { + super(manager, "Anath", UtilText.splitLinesToArray(new String[]{ + C.cGray + "TODO make a description", + "", + C.cGreen + "Click" + C.cWhite + " your " + C.cYellow + "fireball" + C.cWhite + " to", + C.cWhite + "fire out a huge wave of", + C.cWhite + "fiery particles.", + "", + C.cGreen + "Sneak" + C.cWhite + " to use " + C.cYellow + "Flame Dash" + C.cWhite + "." + }, LineFormat.LORE), -2, Material.GLASS, (byte) 0); + setDisplayItem(SkinData.ANATH.getSkull()); + } + + @Override + public void enableCustom(Player player, boolean message) + { + applyArmor(player, message); + + GameProfile gameProfile = UtilGameProfile.getGameProfile(player); + gameProfile.getProperties().clear(); + gameProfile.getProperties().put("textures", SkinData.ANATH.getProperty()); + + DisguisePlayer disguisePlayer = new DisguisePlayer(player, gameProfile); + disguisePlayer.showInTabList(true, 0); + UtilMorph.disguise(player, disguisePlayer, Manager); + + player.getInventory().setItem(ACTIVE_SLOT, ACTIVE_ITEN); + } + + @Override + public void disableCustom(Player player, boolean message) + { + removeArmor(player); + + UtilMorph.undisguise(player, Manager.getDisguiseManager()); + + player.getInventory().setItem(ACTIVE_SLOT, null); + } + + @EventHandler + public void interact(PlayerInteractEvent event) + { + if (event.getAction() == Action.PHYSICAL) + { + return; + } + + ItemStack itemStack = event.getItem(); + + if (itemStack == null || itemStack.equals(ACTIVE_ITEN)) + { + return; + } + + event.setCancelled(true); + + Player player = event.getPlayer(); + + if (!Recharge.Instance.use(player, "Burn Beam", 8000,true, true, "Cosmetics")) + { + return; + } + + Vector direction = player.getLocation().getDirection().setY(0); + + player.getWorld().playSound(player.getLocation(), Sound.BLAZE_BREATH, 2, 0.5F); + + LineParticle particle = new LineParticle(player.getLocation().add(direction), direction, 0.2, 9, null, ParticleType.LAVA, UtilServer.getPlayers()); + particle.setIgnoreAllBlocks(true); + + Manager.runSyncTimer(new BukkitRunnable() + { + @Override + public void run() + { + for (int i = 0; i < 3; i++) + { + if (particle.update()) + { + cancel(); + return; + } + else + { + UtilParticle.PlayParticleToAll(ParticleType.FLAME, particle.getLastLocation().clone().add(0, 5, 0), 0.4F, 5, 0.4F, 0.05F, 30, ViewDist.LONG); + } + } + + if (Math.random() < 0.1) + { + particle.getLastLocation().getWorld().playSound(particle.getLastLocation(), Sound.GHAST_FIREBALL, 1, 0.5F); + } + } + }, 0, 1); + } + + @EventHandler + public void playerSneak(PlayerToggleSneakEvent event) + { + Player player = event.getPlayer(); + + if (!isActive(event.getPlayer()) || !event.isSneaking() || !Recharge.Instance.use(player, "Flame Dash", 8000, true, false, "Cosmetics")) + { + return; + } + + _dashingPlayers.put(player, System.currentTimeMillis()); + } + + @EventHandler + public void updateDash(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + Iterator iterator = _dashingPlayers.keySet().iterator(); + + while (iterator.hasNext()) + { + Player player = iterator.next(); + long start = _dashingPlayers.get(player); + + if (UtilTime.elapsed(start, 600)) + { + UtilAction.zeroVelocity(player); + iterator.remove(); + continue; + } + + UtilAction.velocity(player, player.getLocation().getDirection()); + + Block block = player.getLocation().getBlock(); + + while (!UtilBlock.solid(block)) + { + block = block.getRelative(BlockFace.DOWN); + } + + Block fBlock = block; + Manager.runSyncLater(() -> Manager.getBlockRestore().add(fBlock.getRelative(BlockFace.UP), Material.FIRE.getId(), (byte) 0, 5000), 10); + } + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/moba/MorphDana.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/moba/MorphDana.java new file mode 100644 index 000000000..21d8802ee --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/moba/MorphDana.java @@ -0,0 +1,270 @@ +package mineplex.core.gadget.gadgets.morph.moba; + +import com.mojang.authlib.GameProfile; +import mineplex.core.common.events.EntityVelocityChangeEvent; +import mineplex.core.common.skin.SkinData; +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilText; +import mineplex.core.common.util.UtilTime; +import mineplex.core.disguise.disguises.DisguisePlayer; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.event.GadgetSelectLocationEvent; +import mineplex.core.gadget.gadgets.morph.managers.UtilMorph; +import mineplex.core.gadget.types.MorphGadget; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.core.utils.UtilGameProfile; +import org.bukkit.DyeColor; +import org.bukkit.Effect; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Banner; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.block.banner.Pattern; +import org.bukkit.block.banner.PatternType; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.block.Action; +import org.bukkit.event.entity.ItemSpawnEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.util.Vector; + +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; + +public class MorphDana extends MorphGadget +{ + + private static final ItemStack ACTIVE_ITEM = new ItemBuilder(Material.NETHER_STAR) + .setTitle(C.cGreenB + "Dana's Rally") + .addLore("You leap up into the air, and upon landing", "you plant a banner!") + .build(); + private static final int ACTIVE_SLOT = 2; + + private final Set _data = new HashSet<>(); + + public MorphDana(GadgetManager manager) + { + super(manager, "Dana", UtilText.splitLinesToArray(new String[]{ + C.cGray + "Ever wanted to dash around", + C.cGray + "the hub like a Ninja?", + C.cGray + "Well now you can!", + "", + C.cGreen + "Click" + C.cWhite + " your " + C.cYellow + "Snowball" + C.cWhite + " to fire", + C.cWhite + "snowballs in the direction you are looking.", + "", + C.cGreen + "Sneak" + C.cWhite + " to " + C.cYellow + "Dash" + C.cWhite + "." + }, LineFormat.LORE), -2, Material.GLASS, (byte) 0); + setDisplayItem(SkinData.HATTORI.getSkull()); + } + + @Override + public void enableCustom(Player player, boolean message) + { + applyArmor(player, message); + + GameProfile gameProfile = UtilGameProfile.getGameProfile(player); + gameProfile.getProperties().clear(); + gameProfile.getProperties().put("textures", SkinData.DANA.getProperty()); + + DisguisePlayer disguisePlayer = new DisguisePlayer(player, gameProfile); + disguisePlayer.showInTabList(true, 0); + UtilMorph.disguise(player, disguisePlayer, Manager); + + player.getInventory().setItem(ACTIVE_SLOT, ACTIVE_ITEM); + } + + @Override + public void disableCustom(Player player, boolean message) + { + removeArmor(player); + + UtilMorph.undisguise(player, Manager.getDisguiseManager()); + + player.getInventory().setItem(ACTIVE_SLOT, null); + } + + @EventHandler + public void interact(PlayerInteractEvent event) + { + if (event.getAction() == Action.PHYSICAL) + { + return; + } + + Player player = event.getPlayer(); + ItemStack itemStack = event.getItem(); + + if (!isActive(player) || itemStack == null || itemStack.equals(ACTIVE_ITEM)) + { + return; + } + + event.setCancelled(true); + + if (!Recharge.Instance.use(player, "Rally", 30000, false, true, "Cosmetics")) + { + return; + } + + Vector vector = player.getLocation().getDirection(); + + vector.setY(1.5); + + UtilAction.velocity(player, vector); + _data.add(new RallyData(player)); + } + + @EventHandler + public void updateLand(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + Iterator iterator = _data.iterator(); + + while (iterator.hasNext()) + { + RallyData data = iterator.next(); + Player player = data.Owner; + + if (data.Landed && UtilTime.elapsed(data.LandTime, 7000)) + { + iterator.remove(); + } + else if (UtilTime.elapsed(data.LaunchTime, 1000) && UtilEnt.isGrounded(data.Owner)) + { + data.LandTime = System.currentTimeMillis(); + data.Landed = true; + Location location = data.Owner.getLocation(); + data.Banner = location; + + Block block = location.getBlock(); + + Manager.getBlockRestore().add(block, Material.STANDING_BANNER.getId(), (byte) 0, 7500); + + boolean red = UtilMath.random.nextBoolean(); + byte colorData = (byte) (red ? 14 : 11); + Banner banner = (Banner) block.getState(); + banner.setBaseColor(red ? DyeColor.RED : DyeColor.BLUE); + banner.addPattern(getPattern(red)); + banner.update(); + + for (Block nearby : UtilBlock.getBlocksInRadius(banner.getLocation(), 5)) + { + if (UtilBlock.airFoliage(nearby) || !UtilBlock.airFoliage(nearby.getRelative(BlockFace.UP))) + { + continue; + } + + GadgetSelectLocationEvent selectLocationEvent = new GadgetSelectLocationEvent(player, this, nearby.getLocation()); + UtilServer.CallEvent(selectLocationEvent); + + if (selectLocationEvent.isCancelled()) + { + continue; + } + + Manager.getBlockRestore().add(nearby, Material.STAINED_CLAY.getId(), colorData, (long) (7000 + (Math.random() * 500))); + if (Math.random() > 0.9) + { + nearby.getWorld().playEffect(nearby.getLocation(), Effect.STEP_SOUND, Material.STAINED_CLAY, colorData); + } + } + } + } + } + + @EventHandler + public void updateParticles(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + { + return; + } + + for (RallyData data : _data) + { + if (!data.Landed) + { + continue; + } + + Location banner = data.Banner; + + for (int i = 0; i < 5; i++) + { + double x = 5 * Math.sin(data.ParticleTheta); + double z = 5 * Math.cos(data.ParticleTheta); + + banner.add(x, 0.25, z); + + UtilParticle.PlayParticleToAll(ParticleType.HAPPY_VILLAGER, banner, 0, 0, 0, 0.1F, 1, ViewDist.NORMAL); + + banner.subtract(x, 0.25, z); + + data.ParticleTheta += Math.PI / 100; + } + } + } + + @EventHandler + public void velocityChange(EntityVelocityChangeEvent event) + { + for (RallyData data : _data) + { + if (!data.Landed && data.Owner.equals(event.getEntity())) + { + event.setCancelled(true); + } + } + } + + @EventHandler + public void itemSpawn(ItemSpawnEvent event) + { + if (event.getEntity().getItemStack().getType() == Material.BANNER) + { + event.setCancelled(true); + } + } + + private Pattern getPattern(boolean red) + { + return red ? new Pattern(DyeColor.WHITE, PatternType.CROSS) : new Pattern(DyeColor.WHITE, PatternType.CIRCLE_MIDDLE); + } + + private class RallyData + { + + Player Owner; + Location Banner; + boolean Landed; + long LaunchTime; + long LandTime; + double ParticleTheta; + + RallyData(Player owner) + { + Owner = owner; + LaunchTime = System.currentTimeMillis(); + } + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/moba/MorphDevon.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/moba/MorphDevon.java new file mode 100644 index 000000000..7b67d55d8 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/moba/MorphDevon.java @@ -0,0 +1,155 @@ +package mineplex.core.gadget.gadgets.morph.moba; + +import com.mojang.authlib.GameProfile; +import mineplex.core.common.skin.SkinData; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilText; +import mineplex.core.disguise.disguises.DisguisePlayer; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.gadgets.item.ItemTNT; +import mineplex.core.gadget.gadgets.morph.managers.UtilMorph; +import mineplex.core.gadget.types.Gadget; +import mineplex.core.gadget.types.MorphGadget; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.core.utils.UtilGameProfile; +import org.bukkit.Material; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.Entity; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Projectile; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityShootBowEvent; +import org.bukkit.event.entity.ProjectileHitEvent; +import org.bukkit.inventory.ItemStack; + +import java.util.HashMap; +import java.util.Map; + +public class MorphDevon extends MorphGadget +{ + + private static final ItemStack BOW = new ItemBuilder(Material.BOW) + .setTitle(C.cGreenB + "Devon's Bow") + .addEnchantment(Enchantment.ARROW_INFINITE, 1) + .addLore("Firing this bow causes " + F.elem("TNT") + " to explode where it lands!") + .setUnbreakable(true) + .build(); + private static final int BOW_SLOT = 2; + private static final ItemStack ARROW = new ItemStack(Material.ARROW); + private static final int ARROW_SLOT = 9; + + private final Map _arrows = new HashMap<>(); + private final ItemTNT _tntGadget; + + public MorphDevon(GadgetManager manager) + { + super(manager, "Devon", UtilText.splitLinesToArray(new String[]{ + C.cGray + "You thought this was overpowered in game?", + C.cGray + "Well now you shoot TNT", + C.cGray + "at unsuspecting players in the hub!", + "", + C.cGreen + "Shoot" + C.cWhite + " your " + C.cYellow + "Bow" + C.cWhite + " to fire", + C.cYellow + "TNT Infused" + C.cWhite + " arrows which explode on contact." + }, LineFormat.LORE), -2, Material.GLASS, (byte) 0); + setDisplayItem(SkinData.DEVON.getSkull()); + + _tntGadget = manager.getGadget(ItemTNT.class); + } + + @Override + public void enableCustom(Player player, boolean message) + { + applyArmor(player, message); + + GameProfile gameProfile = UtilGameProfile.getGameProfile(player); + gameProfile.getProperties().clear(); + gameProfile.getProperties().put("textures", SkinData.DEVON.getProperty()); + + DisguisePlayer disguisePlayer = new DisguisePlayer(player, gameProfile); + disguisePlayer.showInTabList(true, 0); + UtilMorph.disguise(player, disguisePlayer, Manager); + + player.getInventory().setItem(BOW_SLOT, BOW); + player.getInventory().setItem(ARROW_SLOT, ARROW); + } + + @Override + public void disableCustom(Player player, boolean message) + { + removeArmor(player); + + UtilMorph.undisguise(player, Manager.getDisguiseManager()); + + player.getInventory().setItem(BOW_SLOT, null); + player.getInventory().setItem(ARROW_SLOT, null); + } + + @EventHandler + public void entityShootBow(EntityShootBowEvent event) + { + LivingEntity entity = event.getEntity(); + + if (!(entity instanceof Player)) + { + return; + } + + Player player = (Player) entity; + + if (!isActive(player)) + { + return; + } + + if (!Recharge.Instance.use(player, "TNT Infusion", 1000, false, true, "Cosmetics")) + { + event.setCancelled(true); + return; + } + + _arrows.put(event.getProjectile(), player); + } + + @EventHandler + public void projectileHit(ProjectileHitEvent event) + { + Entity projectile = event.getEntity(); + Player shooter = _arrows.remove(projectile); + + if (shooter == null) + { + return; + } + + _tntGadget.addTNT(shooter, projectile.getLocation(), 0, false); + projectile.remove(); + } + + @EventHandler + public void cleanup(UpdateEvent event) + { + if (event.getType() != UpdateType.SEC) + { + return; + } + + _arrows.keySet().removeIf(entity -> + { + if (!entity.isValid()) + { + entity.remove(); + return true; + } + + return false; + }); + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/moba/MorphHattori.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/moba/MorphHattori.java new file mode 100644 index 000000000..f9257969a --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/morph/moba/MorphHattori.java @@ -0,0 +1,177 @@ +package mineplex.core.gadget.gadgets.morph.moba; + +import com.mojang.authlib.GameProfile; +import mineplex.core.common.skin.SkinData; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilFirework; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle.ParticleType; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilText; +import mineplex.core.common.util.particles.effects.LineParticle; +import mineplex.core.disguise.disguises.DisguisePlayer; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.event.GadgetSelectLocationEvent; +import mineplex.core.gadget.gadgets.morph.managers.UtilMorph; +import mineplex.core.gadget.types.MorphGadget; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.recharge.Recharge; +import mineplex.core.utils.UtilGameProfile; +import org.bukkit.Color; +import org.bukkit.FireworkEffect; +import org.bukkit.FireworkEffect.Type; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.entity.Snowball; +import org.bukkit.event.EventHandler; +import org.bukkit.event.block.Action; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerToggleSneakEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.scheduler.BukkitRunnable; + +public class MorphHattori extends MorphGadget +{ + + private static final ItemStack ACTIVE_ITEM = new ItemBuilder(Material.SNOW_BALL) + .setTitle(C.cGreenB + "Hattori's Snowballs") + .addLore("Click to fire 3 snowballs, one after another.") + .build(); + private static final int SNOWBALL_SLOT = 2; + + public MorphHattori(GadgetManager manager) + { + super(manager, "Hattori", UtilText.splitLinesToArray(new String[]{ + C.cGray + "Ever wanted to dash around", + C.cGray + "the hub like a Ninja?", + C.cGray + "Well now you can!", + "", + C.cGreen + "Click" + C.cWhite + " your " + C.cYellow + "Snowball" + C.cWhite + " to fire", + C.cWhite + "snowballs in the direction you are looking.", + "", + C.cGreen + "Sneak" + C.cWhite + " to " + C.cYellow + "Dash" + C.cWhite + "." + }, LineFormat.LORE), -2, Material.GLASS, (byte) 0); + setDisplayItem(SkinData.HATTORI.getSkull()); + } + + @Override + public void enableCustom(Player player, boolean message) + { + applyArmor(player, message); + + GameProfile gameProfile = UtilGameProfile.getGameProfile(player); + gameProfile.getProperties().clear(); + gameProfile.getProperties().put("textures", SkinData.HATTORI.getProperty()); + + DisguisePlayer disguisePlayer = new DisguisePlayer(player, gameProfile); + disguisePlayer.showInTabList(true, 0); + UtilMorph.disguise(player, disguisePlayer, Manager); + + player.getInventory().setItem(SNOWBALL_SLOT, ACTIVE_ITEM); + } + + @Override + public void disableCustom(Player player, boolean message) + { + removeArmor(player); + + UtilMorph.undisguise(player, Manager.getDisguiseManager()); + + player.getInventory().setItem(SNOWBALL_SLOT, null); + } + + @EventHandler + public void snowballClick(PlayerInteractEvent event) + { + if (event.getAction() == Action.PHYSICAL) + { + return; + } + + Player player = event.getPlayer(); + ItemStack itemStack = event.getItem(); + + if (!isActive(player) || itemStack == null || itemStack.equals(ACTIVE_ITEM)) + { + return; + } + + event.setCancelled(true); + + if (!Recharge.Instance.use(player, "Snowballs", 1000, false, true, "Cosmetics")) + { + return; + } + + Manager.runSyncTimer(new BukkitRunnable() + { + int balls = 0; + + @Override + public void run() + { + player.playSound(player.getLocation(), Sound.LAVA_POP, 1, 1.3F); + player.launchProjectile(Snowball.class); + + if (++balls == 3) + { + cancel(); + } + } + }, 0, 4); + } + + @EventHandler + public void playerSneak(PlayerToggleSneakEvent event) + { + Player player = event.getPlayer(); + + if (!isActive(event.getPlayer()) || !event.isSneaking() || !Recharge.Instance.use(player, "Dash", 5000, true, false, "Cosmetics")) + { + return; + } + + Location start = player.getEyeLocation(); + GadgetSelectLocationEvent gadgetSelectLocationEvent = new GadgetSelectLocationEvent(player, this, start); + UtilServer.CallEvent(gadgetSelectLocationEvent); + + // Checks to see if it's a valid location + if (gadgetSelectLocationEvent.isCancelled()) + { + if (gadgetSelectLocationEvent.canShowMessage()) + { + UtilPlayer.message(player, F.main("Gadget", "You cannot use the laser on this area!")); + } + + return; + } + + LineParticle lineParticle = new LineParticle(start, start.getDirection(), 0.8, 15, null, ParticleType.FIREWORKS_SPARK, UtilServer.getPlayers()); + + while (!lineParticle.update()) + { + } + + Location location = lineParticle.getDestination(); + Color color = UtilMath.random.nextBoolean() ? Color.RED : Color.AQUA; + FireworkEffect effect = FireworkEffect.builder() + .with(Type.BALL) + .withColor(color) + .withFlicker() + .build(); + + UtilFirework.playFirework(player.getEyeLocation(), effect); + + player.playSound(player.getLocation(), Sound.SHOOT_ARROW, 1, 1); + player.teleport(location.add(0, 0.5, 0)); + player.playSound(player.getLocation(), Sound.SHOOT_ARROW, 1, 1); + + UtilFirework.playFirework(player.getEyeLocation(), effect); + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/GameModifierGadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/GameModifierGadget.java index ce48b6b6c..87378b697 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/GameModifierGadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/GameModifierGadget.java @@ -1,13 +1,11 @@ package mineplex.core.gadget.types; -import mineplex.core.gadget.gadgets.gamemodifiers.GameCosmeticType; -import org.bukkit.Material; -import org.bukkit.entity.Player; - import mineplex.core.common.util.F; import mineplex.core.common.util.UtilPlayer; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.gadgets.gamemodifiers.GameModifierType; +import org.bukkit.Material; +import org.bukkit.entity.Player; /** * An abstract wrapper for Gadgets of the type GameModifiers @@ -16,7 +14,6 @@ public abstract class GameModifierGadget extends Gadget { protected final GameModifierType _type; - private final GameCosmeticType _gameCosmeticType; private final boolean _allowMultiple; /** @@ -28,11 +25,10 @@ public abstract class GameModifierGadget extends Gadget * @param mat The display material used in GUIs * @param data The display data used in GUIs */ - public GameModifierGadget(GadgetManager manager, GameModifierType type, GameCosmeticType gameCosmeticType, String name, String[] desc, int cost, Material mat, byte data, boolean allowMultiple) + public GameModifierGadget(GadgetManager manager, GameModifierType type, String name, String[] desc, int cost, Material mat, byte data, boolean allowMultiple) { super(manager, GadgetType.GAME_MODIFIER, name, desc, cost, mat, data); _type = type; - _gameCosmeticType = gameCosmeticType; _allowMultiple = allowMultiple; } @@ -41,11 +37,6 @@ public abstract class GameModifierGadget extends Gadget return _type; } - public GameCosmeticType getGameCosmeticType() - { - return _gameCosmeticType; - } - public boolean canAllowMultiple() { return _allowMultiple;