From 1855cfc4edbd554432b40ca0df0a6402bf16518d Mon Sep 17 00:00:00 2001 From: LCastr0 Date: Wed, 26 Apr 2017 13:58:30 -0300 Subject: [PATCH 01/99] Added new gadget type --- .../ui/button/open/OpenRankSelector.java | 21 ++++++++ .../mineplex/core/cosmetic/ui/page/Menu.java | 21 +++++--- .../cosmetic/ui/page/RankSelectorPage.java | 50 +++++++++++++++++++ .../core/gadget/types/GadgetType.java | 3 +- 4 files changed, 88 insertions(+), 7 deletions(-) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/open/OpenRankSelector.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/RankSelectorPage.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/open/OpenRankSelector.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/open/OpenRankSelector.java new file mode 100644 index 000000000..e43f35c77 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/open/OpenRankSelector.java @@ -0,0 +1,21 @@ +package mineplex.core.cosmetic.ui.button.open; + +import org.bukkit.entity.Player; + +import mineplex.core.cosmetic.ui.page.Menu; +import mineplex.core.cosmetic.ui.page.RankSelectorPage; +import mineplex.core.gadget.types.Gadget; + +public class OpenRankSelector extends OpenPageButton +{ + public OpenRankSelector(Menu menu, Gadget active) + { + super(menu, active); + } + + @Override + protected void leftClick(Player player) + { + getMenu().getShop().openPageForPlayer(player, new RankSelectorPage(getMenu().getPlugin(), getMenu().getShop(), getMenu().getClientManager(), getMenu().getDonationManager(), "Rank Selector Particles", player)); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java index 37d7190f4..a06c32823 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java @@ -30,6 +30,7 @@ import mineplex.core.cosmetic.ui.button.open.OpenMounts; import mineplex.core.cosmetic.ui.button.open.OpenMusic; import mineplex.core.cosmetic.ui.button.open.OpenParticles; import mineplex.core.cosmetic.ui.button.open.OpenPets; +import mineplex.core.cosmetic.ui.button.open.OpenRankSelector; import mineplex.core.cosmetic.ui.button.open.OpenTaunts; import mineplex.core.cosmetic.ui.button.open.OpenWinEffect; import mineplex.core.donation.DonationManager; @@ -46,6 +47,7 @@ public class Menu extends ShopPageBase private static final String VISIBILITY_HUB = "Usable in Lobbies"; private static final String VISIBILITY_EVERYWHERE = "Visible Everywhere"; private static final String VISIBILITY_GAMES = "Visible in Games"; + private static final String VISIBILITY_GAME_HUB = "Visible in Game Lobbies"; public Menu(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player) { @@ -66,10 +68,9 @@ public class Menu extends ShopPageBase shardLore.add(C.cGray + "handy. Maybe I can collect more!"); ShopItem shards = new ShopItem(Material.PRISMARINE_SHARD, C.cAqua + C.Bold + treasureShards + " Treasure Shards", shardLore.toArray(new String[0]), 0, false); - addItem(4, shards); // Cosmetic Items - int[] slots = UtilUI.getIndicesFor(15, 1, 5, 1); + int[] slots = UtilUI.getIndicesFor(15, 0, 5, 1); /*int particleSlot = 9;//slots[0]; int arrowSlot = 11;//slots[1]; int jumpSlot = 13;//slots[2]; @@ -88,11 +89,14 @@ public class Menu extends ShopPageBase deathSlot = slots[3], gadgetSlot = slots[4], morphSlot = slots[5], mountSlot = slots[6], petSlot = slots[7], hatSlot = slots[8], costumeSlot = slots[9], musicSlot = slots[10], tauntSlot = slots[11], - winEffectSlot = slots[12], gameModifierSlot = slots[13], balloonsSlot = slots[14]; + winEffectSlot = slots[12], gameModifierSlot = slots[13], balloonsSlot = slots[14], + rankSelectorSlot = balloonsSlot + 4; - EnumMap ownedCount = new EnumMap(GadgetType.class); - EnumMap maxCount = new EnumMap(GadgetType.class); - EnumMap enabled = new EnumMap(GadgetType.class); + addItem(rankSelectorSlot + 2, shards); + + EnumMap ownedCount = new EnumMap<>(GadgetType.class); + EnumMap maxCount = new EnumMap<>(GadgetType.class); + EnumMap enabled = new EnumMap<>(GadgetType.class); for(GadgetType type : GadgetType.values()) { @@ -218,6 +222,11 @@ public class Menu extends ShopPageBase lore = getLore(ownedCount.get(type), maxCount.get(type), "Balloons are collectibles that you can float above your head as you wander the lobby. You can have up to 10 balloons in your hand at one time.", VISIBILITY_HUB, enabled.get(type)); addButton(balloonsSlot, new ShopItem(Material.LEASH, "Balloons", lore, 1, false), new OpenBalloons(this, enabled.get(type))); if (enabled.containsKey(type)) addGlow(balloonsSlot); + + type = GadgetType.RANK_SELECTOR; + lore = getLore(ownedCount.get(type), maxCount.get(type), "Placeholder", VISIBILITY_GAME_HUB, enabled.get(type)); + addButton(rankSelectorSlot, new ShopItem(Material.LEVER, "Rank Selector Particles", lore, 1, false), new OpenRankSelector(this, enabled.get(type))); + if (enabled.containsKey(type)) addGlow(rankSelectorSlot); } private String[] getLore(int ownedCount, int maxCount, String info, String visibility, Gadget enabled) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/RankSelectorPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/RankSelectorPage.java new file mode 100644 index 000000000..b291aa5a2 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/RankSelectorPage.java @@ -0,0 +1,50 @@ +package mineplex.core.cosmetic.ui.page; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; + +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.donation.DonationManager; +import mineplex.core.gadget.types.Gadget; +import mineplex.core.gadget.types.GadgetType; +import mineplex.core.shop.item.IButton; +import mineplex.core.shop.item.ShopItem; + +public class RankSelectorPage extends GadgetPage +{ + public RankSelectorPage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player) + { + super(plugin, shop, clientManager, donationManager, name, player); + } + + @Override + protected void buildPage() + { + int slot = 10; + + for (Gadget gadget : getPlugin().getGadgetManager().getGadgets(GadgetType.RANK_SELECTOR)) + { + addGadget(gadget, slot); + + if (getPlugin().getGadgetManager().getActive(getPlayer(), GadgetType.RANK_SELECTOR) == gadget) + addGlow(slot); + + slot++; + + if (slot == 17 || slot == 26 || slot == 35) + slot += 2; + } + + addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() + { + public void onClick(Player player, ClickType clickType) + { + getShop().openPageForPlayer(getPlayer(), new Menu(getPlugin(), getShop(), getClientManager(), getDonationManager(), player)); + } + }); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/GadgetType.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/GadgetType.java index 6f06cb54c..c5ab0e306 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/GadgetType.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/GadgetType.java @@ -17,7 +17,8 @@ public enum GadgetType TAUNT("Taunts", "activeTaunt"), WIN_EFFECT("Win Effects", "activeWinEffect"), GAME_MODIFIER("Game Modifiers", ""), - BALLOON("Balloons", ""); + BALLOON("Balloons", ""), + RANK_SELECTOR("Rank Selectors", "activeRankSelector"); private String _name; private String _databaseKey; From 01076ec054a0c382495854c53e2a29003f08d001 Mon Sep 17 00:00:00 2001 From: LCastr0 Date: Wed, 26 Apr 2017 14:10:49 -0300 Subject: [PATCH 02/99] Kit selector, not rank selector... --- .../ui/button/open/OpenKitSelector.java | 21 +++++++++++++++++++ .../ui/button/open/OpenRankSelector.java | 21 ------------------- ...SelectorPage.java => KitSelectorPage.java} | 8 +++---- .../mineplex/core/cosmetic/ui/page/Menu.java | 12 +++++------ .../core/gadget/types/GadgetType.java | 2 +- .../core/gadget/types/KitSelectorGadget.java | 8 +++++++ 6 files changed, 40 insertions(+), 32 deletions(-) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/open/OpenKitSelector.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/open/OpenRankSelector.java rename Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/{RankSelectorPage.java => KitSelectorPage.java} (82%) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/types/KitSelectorGadget.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/open/OpenKitSelector.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/open/OpenKitSelector.java new file mode 100644 index 000000000..cb0c3f34a --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/open/OpenKitSelector.java @@ -0,0 +1,21 @@ +package mineplex.core.cosmetic.ui.button.open; + +import org.bukkit.entity.Player; + +import mineplex.core.cosmetic.ui.page.Menu; +import mineplex.core.cosmetic.ui.page.KitSelectorPage; +import mineplex.core.gadget.types.Gadget; + +public class OpenKitSelector extends OpenPageButton +{ + public OpenKitSelector(Menu menu, Gadget active) + { + super(menu, active); + } + + @Override + protected void leftClick(Player player) + { + getMenu().getShop().openPageForPlayer(player, new KitSelectorPage(getMenu().getPlugin(), getMenu().getShop(), getMenu().getClientManager(), getMenu().getDonationManager(), "Rank Selector Particles", player)); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/open/OpenRankSelector.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/open/OpenRankSelector.java deleted file mode 100644 index e43f35c77..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/button/open/OpenRankSelector.java +++ /dev/null @@ -1,21 +0,0 @@ -package mineplex.core.cosmetic.ui.button.open; - -import org.bukkit.entity.Player; - -import mineplex.core.cosmetic.ui.page.Menu; -import mineplex.core.cosmetic.ui.page.RankSelectorPage; -import mineplex.core.gadget.types.Gadget; - -public class OpenRankSelector extends OpenPageButton -{ - public OpenRankSelector(Menu menu, Gadget active) - { - super(menu, active); - } - - @Override - protected void leftClick(Player player) - { - getMenu().getShop().openPageForPlayer(player, new RankSelectorPage(getMenu().getPlugin(), getMenu().getShop(), getMenu().getClientManager(), getMenu().getDonationManager(), "Rank Selector Particles", player)); - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/RankSelectorPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/KitSelectorPage.java similarity index 82% rename from Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/RankSelectorPage.java rename to Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/KitSelectorPage.java index b291aa5a2..26b399783 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/RankSelectorPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/KitSelectorPage.java @@ -14,9 +14,9 @@ import mineplex.core.gadget.types.GadgetType; import mineplex.core.shop.item.IButton; import mineplex.core.shop.item.ShopItem; -public class RankSelectorPage extends GadgetPage +public class KitSelectorPage extends GadgetPage { - public RankSelectorPage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player) + public KitSelectorPage(CosmeticManager plugin, CosmeticShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player) { super(plugin, shop, clientManager, donationManager, name, player); } @@ -26,11 +26,11 @@ public class RankSelectorPage extends GadgetPage { int slot = 10; - for (Gadget gadget : getPlugin().getGadgetManager().getGadgets(GadgetType.RANK_SELECTOR)) + for (Gadget gadget : getPlugin().getGadgetManager().getGadgets(GadgetType.KIT_SELECTOR)) { addGadget(gadget, slot); - if (getPlugin().getGadgetManager().getActive(getPlayer(), GadgetType.RANK_SELECTOR) == gadget) + if (getPlugin().getGadgetManager().getActive(getPlayer(), GadgetType.KIT_SELECTOR) == gadget) addGlow(slot); slot++; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java index a06c32823..b301263c1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java @@ -30,7 +30,7 @@ import mineplex.core.cosmetic.ui.button.open.OpenMounts; import mineplex.core.cosmetic.ui.button.open.OpenMusic; import mineplex.core.cosmetic.ui.button.open.OpenParticles; import mineplex.core.cosmetic.ui.button.open.OpenPets; -import mineplex.core.cosmetic.ui.button.open.OpenRankSelector; +import mineplex.core.cosmetic.ui.button.open.OpenKitSelector; import mineplex.core.cosmetic.ui.button.open.OpenTaunts; import mineplex.core.cosmetic.ui.button.open.OpenWinEffect; import mineplex.core.donation.DonationManager; @@ -90,9 +90,9 @@ public class Menu extends ShopPageBase mountSlot = slots[6], petSlot = slots[7], hatSlot = slots[8], costumeSlot = slots[9], musicSlot = slots[10], tauntSlot = slots[11], winEffectSlot = slots[12], gameModifierSlot = slots[13], balloonsSlot = slots[14], - rankSelectorSlot = balloonsSlot + 4; + kitSelectorSlot = balloonsSlot + 4; - addItem(rankSelectorSlot + 2, shards); + addItem(kitSelectorSlot + 2, shards); EnumMap ownedCount = new EnumMap<>(GadgetType.class); EnumMap maxCount = new EnumMap<>(GadgetType.class); @@ -223,10 +223,10 @@ public class Menu extends ShopPageBase addButton(balloonsSlot, new ShopItem(Material.LEASH, "Balloons", lore, 1, false), new OpenBalloons(this, enabled.get(type))); if (enabled.containsKey(type)) addGlow(balloonsSlot); - type = GadgetType.RANK_SELECTOR; + type = GadgetType.KIT_SELECTOR; lore = getLore(ownedCount.get(type), maxCount.get(type), "Placeholder", VISIBILITY_GAME_HUB, enabled.get(type)); - addButton(rankSelectorSlot, new ShopItem(Material.LEVER, "Rank Selector Particles", lore, 1, false), new OpenRankSelector(this, enabled.get(type))); - if (enabled.containsKey(type)) addGlow(rankSelectorSlot); + addButton(kitSelectorSlot, new ShopItem(Material.LEVER, "Kit Selector Particles", lore, 1, false), new OpenKitSelector(this, enabled.get(type))); + if (enabled.containsKey(type)) addGlow(kitSelectorSlot); } private String[] getLore(int ownedCount, int maxCount, String info, String visibility, Gadget enabled) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/GadgetType.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/GadgetType.java index c5ab0e306..edc823e6d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/GadgetType.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/GadgetType.java @@ -18,7 +18,7 @@ public enum GadgetType WIN_EFFECT("Win Effects", "activeWinEffect"), GAME_MODIFIER("Game Modifiers", ""), BALLOON("Balloons", ""), - RANK_SELECTOR("Rank Selectors", "activeRankSelector"); + KIT_SELECTOR("Kit Selectors", "activeKitSelector"); private String _name; private String _databaseKey; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/KitSelectorGadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/KitSelectorGadget.java new file mode 100644 index 000000000..40f3d25d5 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/KitSelectorGadget.java @@ -0,0 +1,8 @@ +package mineplex.core.gadget.types; + +/** + * Handles custom particle effects for the arcade hub kit selectors + */ +public class KitSelectorGadget +{ +} From 5764a4bce3cc72a319f7e05718a2b6bcf2ba7ae1 Mon Sep 17 00:00:00 2001 From: LCastr0 Date: Wed, 26 Apr 2017 14:34:41 -0300 Subject: [PATCH 03/99] Added gadget class --- .../core/gadget/types/KitSelectorGadget.java | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/KitSelectorGadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/KitSelectorGadget.java index 40f3d25d5..6f7737eb6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/KitSelectorGadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/KitSelectorGadget.java @@ -1,8 +1,26 @@ package mineplex.core.gadget.types; +import org.bukkit.Material; +import org.bukkit.entity.Entity; + +import mineplex.core.gadget.GadgetManager; + /** * Handles custom particle effects for the arcade hub kit selectors */ -public class KitSelectorGadget +public abstract class KitSelectorGadget extends Gadget { + + public KitSelectorGadget(GadgetManager gadgetManager, String name, String[] lore, int cost, Material mat, byte data, + String... alternativeSalesPackageNames) + { + super(gadgetManager, GadgetType.KIT_SELECTOR, name, lore, cost, mat, data, 1, alternativeSalesPackageNames); + } + + /** + * Plays the next particle for the selected entity + * @param entity + */ + public abstract void playParticle(Entity entity); + } From 4dfd1b3d21d4066faa740301893488a73dd90126 Mon Sep 17 00:00:00 2001 From: LCastr0 Date: Wed, 26 Apr 2017 16:22:24 -0300 Subject: [PATCH 04/99] Check for active gadgets while playing the particle --- .../core/gadget/types/KitSelectorGadget.java | 3 ++- .../mineplex/core/progression/ProgressiveKit.java | 13 ++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/KitSelectorGadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/KitSelectorGadget.java index 6f7737eb6..999958b5b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/KitSelectorGadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/KitSelectorGadget.java @@ -2,6 +2,7 @@ package mineplex.core.gadget.types; import org.bukkit.Material; import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; import mineplex.core.gadget.GadgetManager; @@ -21,6 +22,6 @@ public abstract class KitSelectorGadget extends Gadget * Plays the next particle for the selected entity * @param entity */ - public abstract void playParticle(Entity entity); + public abstract void playParticle(Entity entity, Player playTo); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/progression/ProgressiveKit.java b/Plugins/Mineplex.Core/src/mineplex/core/progression/ProgressiveKit.java index 395bd428d..fa4469b55 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/progression/ProgressiveKit.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/progression/ProgressiveKit.java @@ -11,6 +11,10 @@ import org.bukkit.entity.Player; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilParticle.ParticleType; import mineplex.core.common.util.UtilParticle.ViewDist; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.types.Gadget; +import mineplex.core.gadget.types.GadgetType; +import mineplex.core.gadget.types.KitSelectorGadget; import mineplex.core.progression.math.Calculations; /** @@ -269,8 +273,15 @@ public interface ProgressiveKit return getUpgradeLevel(player) >= upgradeLevel; } - default void displaySelectedEffect(Entity kitHost, Player... displayTo) + default void displaySelectedEffect(Entity kitHost, GadgetManager gadgetManager, Player displayTo) { + Gadget gadget = gadgetManager.getActive(displayTo, GadgetType.KIT_SELECTOR); + if (gadget != null) + { + KitSelectorGadget kitSelectorGadget = (KitSelectorGadget) gadget; + kitSelectorGadget.playParticle(kitHost, displayTo); + return; + } for (int i = 0; i < 1; i++) { double lead = i * ((2d * Math.PI) / 2); From 6bf1b6c1dcb6831d9c97014eee772bd022a945d5 Mon Sep 17 00:00:00 2001 From: LCastr0 Date: Wed, 26 Apr 2017 16:25:32 -0300 Subject: [PATCH 05/99] Fixed arguments --- .../managers/ProgressingKitManager.java | 47 ++++++++++--------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/ProgressingKitManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/ProgressingKitManager.java index 2ce6c2ac3..110a8d422 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/ProgressingKitManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/ProgressingKitManager.java @@ -1,24 +1,8 @@ package nautilus.game.arcade.managers; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.progression.data.PlayerKit; -import mineplex.core.progression.gui.guis.KitDisplayMenu; -import mineplex.core.progression.math.Calculations; -import nautilus.game.arcade.ArcadeFormat; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.events.GameStateChangeEvent; -import nautilus.game.arcade.events.PlayerKitApplyEvent; -import nautilus.game.arcade.game.Game; -import nautilus.game.arcade.game.Game.GameState; -import nautilus.game.arcade.kit.ChampionsKit; -import nautilus.game.arcade.kit.Kit; -import nautilus.game.arcade.kit.KitProgressionData; -import nautilus.game.arcade.kit.ProgressingKit; +import java.util.Map; +import java.util.UUID; + import org.bukkit.Bukkit; import org.bukkit.Sound; import org.bukkit.entity.Player; @@ -31,8 +15,27 @@ import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitTask; -import java.util.Map; -import java.util.UUID; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.progression.data.PlayerKit; +import mineplex.core.progression.gui.guis.KitDisplayMenu; +import mineplex.core.progression.math.Calculations; + +import nautilus.game.arcade.ArcadeFormat; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.events.PlayerKitApplyEvent; +import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.Game.GameState; +import nautilus.game.arcade.kit.ChampionsKit; +import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.kit.KitProgressionData; +import nautilus.game.arcade.kit.ProgressingKit; /** * Manages all things related to the ProgressingKit System for Arcade @@ -80,7 +83,7 @@ public class ProgressingKitManager implements Listener _tasks.remove(player); return; } - kit.displaySelectedEffect(kit.getLivingEntity(), Bukkit.getPlayer(player)); + kit.displaySelectedEffect(kit.getLivingEntity(), _manager.getCosmeticManager().getGadgetManager(), Bukkit.getPlayer(player)); } }.runTaskTimer(_manager.getPlugin(), 0L, 1L)); } From e45e3be4e8dcefb820556a1b69c0fef047b01289 Mon Sep 17 00:00:00 2001 From: LCastr0 Date: Thu, 27 Apr 2017 20:01:29 -0300 Subject: [PATCH 06/99] Added first kit selector --- .../core/common/shape/ShapeWings.java | 97 ++++++++++++++++--- .../mineplex/core/gadget/GadgetManager.java | 4 + .../kitselector/WaterWingsKitSelector.java | 37 +++++++ 3 files changed, 125 insertions(+), 13 deletions(-) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/WaterWingsKitSelector.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/shape/ShapeWings.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/shape/ShapeWings.java index 5e6621476..5fe29bf29 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/shape/ShapeWings.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/shape/ShapeWings.java @@ -3,6 +3,7 @@ package mineplex.core.common.shape; import java.awt.Color; import org.bukkit.Location; +import org.bukkit.entity.Player; import org.bukkit.util.Vector; import mineplex.core.common.util.UtilParticle; @@ -258,41 +259,111 @@ public class ShapeWings extends ShapeGrid implements CosmeticShape rotateOnXAxis(xRotation); } + /** + * Displays the wing + * @param location The location to display the visual at + */ @Override - public void display(Location loc) + public void display(Location location) { Shape clone = clone(); - clone.rotateOnYAxis(Math.toRadians(loc.getYaw())); + clone.rotateOnYAxis(Math.toRadians(location.getYaw())); for (Vector v : clone.getPoints()) { - Location ploc = loc.clone().add(v); - displayParticle(ploc); + Location particleLocation = location.clone().add(v); + displayParticle(particleLocation); } } - public void displayColored(Location loc, Color color) + /** + * Displays the wing for the given player + * @param location The location to display the visual at + * @param player The player + */ + public void display(Location location, Player player) { Shape clone = clone(); - clone.rotateOnYAxis(Math.toRadians(loc.getYaw())); + clone.rotateOnYAxis(Math.toRadians(location.getYaw())); for (Vector v : clone.getPoints()) { - Location ploc = loc.clone().add(v); - displayColoredParticle(ploc, color); + Location particleLocation = location.clone().add(v); + displayParticle(particleLocation, player); } } - + + /** + * Displays the colored wing + * @param location The location to display the visual at + * @param color The color of the particles + */ + public void displayColored(Location location, Color color) + { + Shape clone = clone(); + clone.rotateOnYAxis(Math.toRadians(location.getYaw())); + for (Vector v : clone.getPoints()) + { + Location particleLocation = location.clone().add(v); + displayColoredParticle(particleLocation, color); + } + } + + /** + * Displays the colored wing for the given player + * @param location The location to display the visual at + * @param color The color of the particles + * @param player The player + */ + public void displayColored(Location location, Color color, Player player) + { + Shape clone = clone(); + clone.rotateOnYAxis(Math.toRadians(location.getYaw())); + for (Vector v : clone.getPoints()) + { + Location particleLocation = location.clone().add(v); + displayColoredParticle(particleLocation, color, player); + } + } + /** * Display a single particle of the type provided to this shape at the given location. + * @param location The location */ - public void displayParticle(Location loc) + public void displayParticle(Location location) { - UtilParticle.PlayParticleToAll(_particle, loc, _offsetData, _speed, _count, ViewDist.NORMAL); + UtilParticle.PlayParticleToAll(_particle, location, _offsetData, _speed, _count, ViewDist.NORMAL); } - public void displayColoredParticle(Location loc, Color color) + /** + * Display a single particle of the type provided to this shape at the given location for the given player + * @param location The location + * @param player The player + */ + public void displayParticle(Location location, Player player) { - ColoredParticle coloredParticle = new ColoredParticle(ParticleType.RED_DUST, new DustSpellColor(color), loc); + UtilParticle.playParticleFor(player, _particle, location, _offsetData, _speed, _count, ViewDist.NORMAL); + } + + /** + * Display a single colored particle of the type provided to this shape at the given location. + * @param location The location + * @param color The color + */ + public void displayColoredParticle(Location location, Color color) + { + ColoredParticle coloredParticle = new ColoredParticle(ParticleType.RED_DUST, new DustSpellColor(color), location); coloredParticle.display(ViewDist.NORMAL); } + /** + * Displays a single colored particle of the type provided to this shape at the given location for the given player + * @param location The location + * @param color The color + * @param player The player + */ + public void displayColoredParticle(Location location, Color color, Player player) + { + ColoredParticle coloredParticle = new ColoredParticle(ParticleType.RED_DUST, new DustSpellColor(color), location); + coloredParticle.display(ViewDist.NORMAL, player); + } + } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java index 498bb6ae9..4e6c9d023 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java @@ -116,6 +116,7 @@ import mineplex.core.gadget.gadgets.item.ItemPaintbrush; import mineplex.core.gadget.gadgets.item.ItemPartyPopper; import mineplex.core.gadget.gadgets.item.ItemSnowball; import mineplex.core.gadget.gadgets.item.ItemTNT; +import mineplex.core.gadget.gadgets.kitselector.WaterWingsKitSelector; import mineplex.core.gadget.gadgets.morph.MorphAwkwardRabbit; import mineplex.core.gadget.gadgets.morph.MorphBat; import mineplex.core.gadget.gadgets.morph.MorphBlaze; @@ -595,6 +596,9 @@ public class GadgetManager extends MiniPlugin addGadget(new BlowAKissTaunt(this)); addGadget(new RainbowTaunt(this)); + // Kit Selectors + addGadget(new WaterWingsKitSelector(this)); + // Gem Hunters Mounts for (MountType mount : MountType.values()) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/WaterWingsKitSelector.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/WaterWingsKitSelector.java new file mode 100644 index 000000000..471aa5b2a --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/WaterWingsKitSelector.java @@ -0,0 +1,37 @@ +package mineplex.core.gadget.gadgets.kitselector; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.util.Vector; + +import mineplex.core.common.shape.ShapeWings; +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilText; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.types.KitSelectorGadget; + +public class WaterWingsKitSelector extends KitSelectorGadget +{ + + private ShapeWings _wings = new ShapeWings(UtilParticle.ParticleType.DRIP_WATER.particleName, new Vector(0.2,0.2,0.2), 1, 0, false, ShapeWings.DEFAULT_ROTATION, ShapeWings.ANGEL_WING_PATTERN); + private ShapeWings _wingsEdge = new ShapeWings(UtilParticle.ParticleType.DRIP_WATER.particleName, new Vector(0.1,0.1,0.1), 1, 0, true, ShapeWings.DEFAULT_ROTATION, ShapeWings.ANGEL_WING_PATTERN); + + public WaterWingsKitSelector(GadgetManager manager) + { + super(manager, "Water Wings", UtilText.splitLinesToArray(new String[]{C.cGray + "Placeholder"}, LineFormat.LORE), + 0, Material.GLASS, (byte) 0); + } + + @Override + public void playParticle(Entity entity, Player playTo) + { + Location loc = entity.getLocation().add(0, 1.2, 0).add(entity.getLocation().getDirection().multiply(-0.2)); + _wings.display(loc, playTo); + _wingsEdge.display(loc, playTo); + } + +} From 494fd4787cb29d5df352052b8e7c2fb092f8888e Mon Sep 17 00:00:00 2001 From: LCastr0 Date: Thu, 27 Apr 2017 23:53:37 -0300 Subject: [PATCH 07/99] Skip disabling kit selectors between game restarts --- .../Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java index 4e6c9d023..543925495 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java @@ -231,6 +231,7 @@ import mineplex.core.gadget.types.GadgetType; import mineplex.core.gadget.types.GameModifierGadget; import mineplex.core.gadget.types.HatGadget; import mineplex.core.gadget.types.ItemGadget; +import mineplex.core.gadget.types.KitSelectorGadget; import mineplex.core.gadget.types.MusicGadget; import mineplex.core.gadget.types.OutfitGadget; import mineplex.core.gadget.types.OutfitGadget.ArmorSlot; @@ -868,6 +869,9 @@ public class GadgetManager extends MiniPlugin if (gadget instanceof TauntGadget) continue; + + if (gadget instanceof KitSelectorGadget) + continue; for (Player player : UtilServer.getPlayers()) gadget.disable(player); From 1000c190a2741e3996f95e9b25e55f335f4b7784 Mon Sep 17 00:00:00 2001 From: LCastr0 Date: Fri, 28 Apr 2017 00:32:29 -0300 Subject: [PATCH 08/99] Fixed Y offset for Water Wings and added Flames of Fury and Halo effects --- .../mineplex/core/gadget/GadgetManager.java | 4 + .../kitselector/FlamesOfFuryKitSelector.java | 29 +++++ .../gadgets/kitselector/HaloKitSelector.java | 102 ++++++++++++++++++ .../kitselector/WaterWingsKitSelector.java | 34 +++++- 4 files changed, 168 insertions(+), 1 deletion(-) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/FlamesOfFuryKitSelector.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/HaloKitSelector.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java index 543925495..b4fe90c99 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java @@ -116,6 +116,8 @@ import mineplex.core.gadget.gadgets.item.ItemPaintbrush; import mineplex.core.gadget.gadgets.item.ItemPartyPopper; import mineplex.core.gadget.gadgets.item.ItemSnowball; import mineplex.core.gadget.gadgets.item.ItemTNT; +import mineplex.core.gadget.gadgets.kitselector.FlamesOfFuryKitSelector; +import mineplex.core.gadget.gadgets.kitselector.HaloKitSelector; import mineplex.core.gadget.gadgets.kitselector.WaterWingsKitSelector; import mineplex.core.gadget.gadgets.morph.MorphAwkwardRabbit; import mineplex.core.gadget.gadgets.morph.MorphBat; @@ -599,6 +601,8 @@ public class GadgetManager extends MiniPlugin // Kit Selectors addGadget(new WaterWingsKitSelector(this)); + addGadget(new FlamesOfFuryKitSelector(this)); + addGadget(new HaloKitSelector(this)); // Gem Hunters Mounts for (MountType mount : MountType.values()) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/FlamesOfFuryKitSelector.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/FlamesOfFuryKitSelector.java new file mode 100644 index 000000000..c01297abb --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/FlamesOfFuryKitSelector.java @@ -0,0 +1,29 @@ +package mineplex.core.gadget.gadgets.kitselector; + +import org.bukkit.Material; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilText; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.types.KitSelectorGadget; + +public class FlamesOfFuryKitSelector extends KitSelectorGadget +{ + + public FlamesOfFuryKitSelector(GadgetManager manager) + { + super(manager, "Flames Of Fury", UtilText.splitLinesToArray(new String[]{C.cGray + "Placeholder"}, LineFormat.LORE), + 0, Material.GLASS, (byte) 0); + } + + @Override + public void playParticle(Entity entity, Player playTo) + { + UtilParticle.playParticleFor(playTo, UtilParticle.ParticleType.FLAME, entity.getLocation().add(0, 1, 0), 0.5f, 0.5f, 0.5f, 0, 1, UtilParticle.ViewDist.NORMAL); + } + +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/HaloKitSelector.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/HaloKitSelector.java new file mode 100644 index 000000000..4fd7fe89e --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/HaloKitSelector.java @@ -0,0 +1,102 @@ +package mineplex.core.gadget.gadgets.kitselector; + +import java.util.HashMap; +import java.util.Map; + +import org.bukkit.Material; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilColor; +import mineplex.core.common.util.UtilText; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.types.KitSelectorGadget; +import mineplex.core.particleeffects.ColoredCircleEffect; + +public class HaloKitSelector extends KitSelectorGadget +{ + + private Map _circleEffects = new HashMap<>(); + private Map _selectedEntity = new HashMap<>(); + + public HaloKitSelector(GadgetManager manager) + { + super(manager, "Halo", UtilText.splitLinesToArray(new String[]{C.cGray + "Placeholder"}, LineFormat.LORE), + 0, Material.GLASS, (byte) 0); + } + + @Override + public void disableCustom(Player player, boolean message) + { + super.disableCustom(player, message); + stopEffect(player); + } + + @Override + public void playParticle(Entity entity, Player playTo) + { + if (_circleEffects.containsKey(entity)) + return; + + if (_selectedEntity.containsValue(playTo)) + { + stopEffect(playTo); + } + + ColoredCircleEffect coloredCircleEffect = new ColoredCircleEffect(Manager.getPlugin(), entity, 0.6, false); + coloredCircleEffect.addColors(UtilColor.hexToRgb(0xffd700), UtilColor.hexToRgb(0xdaa520)); + coloredCircleEffect.setYOffset(getEntityYOffset(entity)); + coloredCircleEffect.start(); + + _selectedEntity.put(playTo, entity); + _circleEffects.put(entity, coloredCircleEffect); + } + + private void stopEffect(Player player) + { + if (_selectedEntity.containsKey(player)) + { + Entity entity = _selectedEntity.get(player); + if (_circleEffects.containsKey(entity)) + { + _circleEffects.get(entity).stop(); + _circleEffects.remove(entity); + } + _selectedEntity.remove(player); + } + } + + /** + * Gets the right Y offset for that entity based on the type + * @param entity The entity + * @return The correct Y offset + */ + public double getEntityYOffset(Entity entity) + { + EntityType entityType = entity.getType(); + switch (entityType) + { + case SHEEP: + case PIG: + case BAT: + case MAGMA_CUBE: + case GUARDIAN: + case CHICKEN: + case SLIME: + case SQUID: + case WOLF: + case OCELOT: + return 1.3; + case SPIDER: + case CAVE_SPIDER: + return 0.75; + case ENDERMAN: + return 3.3; + } + return 2.3; + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/WaterWingsKitSelector.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/WaterWingsKitSelector.java index 471aa5b2a..a7a68a856 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/WaterWingsKitSelector.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/WaterWingsKitSelector.java @@ -3,6 +3,7 @@ package mineplex.core.gadget.gadgets.kitselector; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.util.Vector; @@ -29,9 +30,40 @@ public class WaterWingsKitSelector extends KitSelectorGadget @Override public void playParticle(Entity entity, Player playTo) { - Location loc = entity.getLocation().add(0, 1.2, 0).add(entity.getLocation().getDirection().multiply(-0.2)); + double offsetY = getEntityYOffset(entity); + Location loc = entity.getLocation().add(0, offsetY, 0).add(entity.getLocation().getDirection().multiply(-0.2)); _wings.display(loc, playTo); _wingsEdge.display(loc, playTo); } + /** + * Gets the right Y offset for that entity based on the type + * @param entity The entity + * @return The correct Y offset + */ + public double getEntityYOffset(Entity entity) + { + EntityType entityType = entity.getType(); + switch (entityType) + { + case SHEEP: + case PIG: + case BAT: + case MAGMA_CUBE: + case GUARDIAN: + case CHICKEN: + case SLIME: + case SQUID: + case WOLF: + case OCELOT: + return 0.75; + case SPIDER: + case CAVE_SPIDER: + return 0.25; + case ENDERMAN: + return 1.5; + } + return 1.2; + } + } From ae8b348264dadce89a940dfcc4ae3f54bef569f8 Mon Sep 17 00:00:00 2001 From: LCastr0 Date: Fri, 28 Apr 2017 01:37:27 -0300 Subject: [PATCH 09/99] Ember Kit selector --- .../mineplex/core/gadget/GadgetManager.java | 2 ++ .../gadgets/kitselector/EmberKitSelector.java | 29 +++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/EmberKitSelector.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java index b4fe90c99..006b0cfab 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java @@ -116,6 +116,7 @@ import mineplex.core.gadget.gadgets.item.ItemPaintbrush; import mineplex.core.gadget.gadgets.item.ItemPartyPopper; import mineplex.core.gadget.gadgets.item.ItemSnowball; import mineplex.core.gadget.gadgets.item.ItemTNT; +import mineplex.core.gadget.gadgets.kitselector.EmberKitSelector; import mineplex.core.gadget.gadgets.kitselector.FlamesOfFuryKitSelector; import mineplex.core.gadget.gadgets.kitselector.HaloKitSelector; import mineplex.core.gadget.gadgets.kitselector.WaterWingsKitSelector; @@ -603,6 +604,7 @@ public class GadgetManager extends MiniPlugin addGadget(new WaterWingsKitSelector(this)); addGadget(new FlamesOfFuryKitSelector(this)); addGadget(new HaloKitSelector(this)); + addGadget(new EmberKitSelector(this)); // Gem Hunters Mounts for (MountType mount : MountType.values()) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/EmberKitSelector.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/EmberKitSelector.java new file mode 100644 index 000000000..f33014f47 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/EmberKitSelector.java @@ -0,0 +1,29 @@ +package mineplex.core.gadget.gadgets.kitselector; + +import org.bukkit.Material; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilText; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.types.KitSelectorGadget; + +public class EmberKitSelector extends KitSelectorGadget +{ + + public EmberKitSelector(GadgetManager manager) + { + super(manager, "Halo", UtilText.splitLinesToArray(new String[]{C.cGray + "Placeholder"}, LineFormat.LORE), + 0, Material.GLASS, (byte) 0); + } + + @Override + public void playParticle(Entity entity, Player playTo) + { + UtilParticle.playParticleFor(playTo, UtilParticle.ParticleType.SMOKE, entity.getLocation().add(0, 1, 0), 0.5f, 0.5f, 0.5f, 0, 1, UtilParticle.ViewDist.NORMAL); + } + +} From e9d1ac85f153c199370a6d9874b17a98f3056ed0 Mon Sep 17 00:00:00 2001 From: LCastr0 Date: Fri, 28 Apr 2017 01:46:26 -0300 Subject: [PATCH 10/99] Changed single-type particle to an enum, added love particles --- .../mineplex/core/gadget/GadgetManager.java | 16 +++-- .../gadgets/kitselector/EmberKitSelector.java | 29 -------- .../kitselector/FlamesOfFuryKitSelector.java | 29 -------- .../SingleParticleKitSelector.java | 66 +++++++++++++++++++ 4 files changed, 75 insertions(+), 65 deletions(-) delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/EmberKitSelector.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/FlamesOfFuryKitSelector.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/SingleParticleKitSelector.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java index 006b0cfab..3bb6a7f2e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java @@ -45,12 +45,12 @@ 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.halloween.ArrowTrailHalloween; import mineplex.core.gadget.gadgets.arrowtrail.candycane.ArrowTrailCandyCane; import mineplex.core.gadget.gadgets.arrowtrail.cupidslove.ArrowTrailCupid; import mineplex.core.gadget.gadgets.arrowtrail.emerald.ArrowTrailEmerald; import mineplex.core.gadget.gadgets.arrowtrail.freedom.ArrowTrailFreedom; import mineplex.core.gadget.gadgets.arrowtrail.frostlord.ArrowTrailFrostLord; +import mineplex.core.gadget.gadgets.arrowtrail.halloween.ArrowTrailHalloween; import mineplex.core.gadget.gadgets.arrowtrail.howlingwinds.ArrowTrailStorm; import mineplex.core.gadget.gadgets.arrowtrail.music.ArrowTrailMusic; import mineplex.core.gadget.gadgets.arrowtrail.party.ArrowTrailConfetti; @@ -75,12 +75,12 @@ import mineplex.core.gadget.gadgets.death.spring.DeathSpring; import mineplex.core.gadget.gadgets.death.titan.DeathTitan; import mineplex.core.gadget.gadgets.death.vampire.DeathBlood; import mineplex.core.gadget.gadgets.death.wisdom.DeathEnchant; -import mineplex.core.gadget.gadgets.doublejump.halloween.DoubleJumpHalloween; import mineplex.core.gadget.gadgets.doublejump.candycane.DoubleJumpCandyCane; import mineplex.core.gadget.gadgets.doublejump.cupidslove.DoubleJumpCupidsWings; import mineplex.core.gadget.gadgets.doublejump.emerald.DoubleJumpEmerald; import mineplex.core.gadget.gadgets.doublejump.freedom.DoubleJumpFreedom; import mineplex.core.gadget.gadgets.doublejump.frostlord.DoubleJumpFrostLord; +import mineplex.core.gadget.gadgets.doublejump.halloween.DoubleJumpHalloween; import mineplex.core.gadget.gadgets.doublejump.howlingwinds.DoubleJumpStorm; import mineplex.core.gadget.gadgets.doublejump.music.DoubleJumpMusic; import mineplex.core.gadget.gadgets.doublejump.party.DoubleJumpFirecracker; @@ -116,9 +116,8 @@ import mineplex.core.gadget.gadgets.item.ItemPaintbrush; import mineplex.core.gadget.gadgets.item.ItemPartyPopper; import mineplex.core.gadget.gadgets.item.ItemSnowball; import mineplex.core.gadget.gadgets.item.ItemTNT; -import mineplex.core.gadget.gadgets.kitselector.EmberKitSelector; -import mineplex.core.gadget.gadgets.kitselector.FlamesOfFuryKitSelector; import mineplex.core.gadget.gadgets.kitselector.HaloKitSelector; +import mineplex.core.gadget.gadgets.kitselector.SingleParticleKitSelector; import mineplex.core.gadget.gadgets.kitselector.WaterWingsKitSelector; import mineplex.core.gadget.gadgets.morph.MorphAwkwardRabbit; import mineplex.core.gadget.gadgets.morph.MorphBat; @@ -172,7 +171,6 @@ import mineplex.core.gadget.gadgets.particle.ParticleCoalFumes; import mineplex.core.gadget.gadgets.particle.ParticleFairy; import mineplex.core.gadget.gadgets.particle.ParticleFireRings; import mineplex.core.gadget.gadgets.particle.ParticleLegend; -import mineplex.core.gadget.gadgets.particle.spring.ParticleSpringHalo; import mineplex.core.gadget.gadgets.particle.ParticleWingsAngel; import mineplex.core.gadget.gadgets.particle.ParticleWingsBee; import mineplex.core.gadget.gadgets.particle.ParticleWingsDemons; @@ -189,6 +187,7 @@ import mineplex.core.gadget.gadgets.particle.howlingwinds.ParticleRain; import mineplex.core.gadget.gadgets.particle.music.ParticleMusic; import mineplex.core.gadget.gadgets.particle.party.ParticlePartyTime; import mineplex.core.gadget.gadgets.particle.shadow.ParticleFoot; +import mineplex.core.gadget.gadgets.particle.spring.ParticleSpringHalo; import mineplex.core.gadget.gadgets.particle.titan.ParticleTitan; import mineplex.core.gadget.gadgets.particle.vampire.ParticleBlood; import mineplex.core.gadget.gadgets.particle.wisdom.ParticleEnchant; @@ -602,9 +601,12 @@ public class GadgetManager extends MiniPlugin // Kit Selectors addGadget(new WaterWingsKitSelector(this)); - addGadget(new FlamesOfFuryKitSelector(this)); addGadget(new HaloKitSelector(this)); - addGadget(new EmberKitSelector(this)); + + for(SingleParticleKitSelector.SingleParticleSelectors singleParticleSelectors : SingleParticleKitSelector.SingleParticleSelectors.values()) + { + addGadget(singleParticleSelectors.getKitSelectorGadget(this)); + } // Gem Hunters Mounts for (MountType mount : MountType.values()) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/EmberKitSelector.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/EmberKitSelector.java deleted file mode 100644 index f33014f47..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/EmberKitSelector.java +++ /dev/null @@ -1,29 +0,0 @@ -package mineplex.core.gadget.gadgets.kitselector; - -import org.bukkit.Material; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Player; - -import mineplex.core.common.util.C; -import mineplex.core.common.util.LineFormat; -import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilText; -import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.types.KitSelectorGadget; - -public class EmberKitSelector extends KitSelectorGadget -{ - - public EmberKitSelector(GadgetManager manager) - { - super(manager, "Halo", UtilText.splitLinesToArray(new String[]{C.cGray + "Placeholder"}, LineFormat.LORE), - 0, Material.GLASS, (byte) 0); - } - - @Override - public void playParticle(Entity entity, Player playTo) - { - UtilParticle.playParticleFor(playTo, UtilParticle.ParticleType.SMOKE, entity.getLocation().add(0, 1, 0), 0.5f, 0.5f, 0.5f, 0, 1, UtilParticle.ViewDist.NORMAL); - } - -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/FlamesOfFuryKitSelector.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/FlamesOfFuryKitSelector.java deleted file mode 100644 index c01297abb..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/FlamesOfFuryKitSelector.java +++ /dev/null @@ -1,29 +0,0 @@ -package mineplex.core.gadget.gadgets.kitselector; - -import org.bukkit.Material; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Player; - -import mineplex.core.common.util.C; -import mineplex.core.common.util.LineFormat; -import mineplex.core.common.util.UtilParticle; -import mineplex.core.common.util.UtilText; -import mineplex.core.gadget.GadgetManager; -import mineplex.core.gadget.types.KitSelectorGadget; - -public class FlamesOfFuryKitSelector extends KitSelectorGadget -{ - - public FlamesOfFuryKitSelector(GadgetManager manager) - { - super(manager, "Flames Of Fury", UtilText.splitLinesToArray(new String[]{C.cGray + "Placeholder"}, LineFormat.LORE), - 0, Material.GLASS, (byte) 0); - } - - @Override - public void playParticle(Entity entity, Player playTo) - { - UtilParticle.playParticleFor(playTo, UtilParticle.ParticleType.FLAME, entity.getLocation().add(0, 1, 0), 0.5f, 0.5f, 0.5f, 0, 1, UtilParticle.ViewDist.NORMAL); - } - -} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/SingleParticleKitSelector.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/SingleParticleKitSelector.java new file mode 100644 index 000000000..f0d187575 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/SingleParticleKitSelector.java @@ -0,0 +1,66 @@ +package mineplex.core.gadget.gadgets.kitselector; + +import org.bukkit.Material; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilText; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.types.KitSelectorGadget; + +public class SingleParticleKitSelector extends KitSelectorGadget +{ + + private UtilParticle.ParticleType _particleType; + + public SingleParticleKitSelector(GadgetManager manager, String name, String[] lore, int cost, Material mat, byte data, + UtilParticle.ParticleType particleType, String... alternativeSalesPackageNames) + { + super(manager, name, lore, cost, mat, data, alternativeSalesPackageNames); + _particleType = particleType; + } + + @Override + public void playParticle(Entity entity, Player playTo) + { + UtilParticle.playParticleFor(playTo, _particleType, entity.getLocation().add(0, 1, 0), 0.5f, 0.5f, 0.5f, 0, 1, UtilParticle.ViewDist.NORMAL); + } + + public enum SingleParticleSelectors + { + FLAMES_OF_FURY("Flames Of Fury", UtilText.splitLinesToArray(new String[]{C.cGray + "Placeholder"}, LineFormat.LORE), + 0, Material.GLASS, (byte) 0, UtilParticle.ParticleType.FLAME), + EMBER("Halo", UtilText.splitLinesToArray(new String[]{C.cGray + "Placeholder"}, LineFormat.LORE), + 0, Material.GLASS, (byte) 0, UtilParticle.ParticleType.SMOKE), + LOVE("Kit Love", UtilText.splitLinesToArray(new String[]{C.cGray + "Placeholder"}, LineFormat.LORE), + 0, Material.GLASS, (byte) 0, UtilParticle.ParticleType.HEART); + + private String _name; + private String[] _lore; + private int _cost; + private Material _material; + private byte _data; + private UtilParticle.ParticleType _particleType; + private String[] _alternativeSalesPackageNames; + + SingleParticleSelectors(String name, String[] lore, int cost, Material material, byte data, UtilParticle.ParticleType particleType, String... alternativeSalesPackageNames) + { + _name = name; + _lore = lore; + _cost = cost; + _material = material; + _data = data; + _particleType = particleType; + _alternativeSalesPackageNames = alternativeSalesPackageNames; + } + + public KitSelectorGadget getKitSelectorGadget(GadgetManager manager) + { + return new SingleParticleKitSelector(manager, _name, _lore, _cost, _material, _data, _particleType, _alternativeSalesPackageNames); + } + } + +} From 42e4564a2580dce1c40ae9289b90eb32ff120c4e Mon Sep 17 00:00:00 2001 From: LCastr0 Date: Fri, 28 Apr 2017 11:14:22 -0300 Subject: [PATCH 11/99] Rainbow Dance selector --- .../mineplex/core/gadget/GadgetManager.java | 2 + .../kitselector/RainbowDanceKitSelector.java | 61 +++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/RainbowDanceKitSelector.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java index 3bb6a7f2e..f4b0fbc60 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java @@ -117,6 +117,7 @@ import mineplex.core.gadget.gadgets.item.ItemPartyPopper; import mineplex.core.gadget.gadgets.item.ItemSnowball; import mineplex.core.gadget.gadgets.item.ItemTNT; import mineplex.core.gadget.gadgets.kitselector.HaloKitSelector; +import mineplex.core.gadget.gadgets.kitselector.RainbowDanceKitSelector; import mineplex.core.gadget.gadgets.kitselector.SingleParticleKitSelector; import mineplex.core.gadget.gadgets.kitselector.WaterWingsKitSelector; import mineplex.core.gadget.gadgets.morph.MorphAwkwardRabbit; @@ -602,6 +603,7 @@ public class GadgetManager extends MiniPlugin // Kit Selectors addGadget(new WaterWingsKitSelector(this)); addGadget(new HaloKitSelector(this)); + addGadget(new RainbowDanceKitSelector(this)); for(SingleParticleKitSelector.SingleParticleSelectors singleParticleSelectors : SingleParticleKitSelector.SingleParticleSelectors.values()) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/RainbowDanceKitSelector.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/RainbowDanceKitSelector.java new file mode 100644 index 000000000..e82e80238 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/RainbowDanceKitSelector.java @@ -0,0 +1,61 @@ +package mineplex.core.gadget.gadgets.kitselector; + +import java.awt.Color; + +import org.bukkit.Material; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilText; +import mineplex.core.common.util.particles.ColoredParticle; +import mineplex.core.common.util.particles.DustSpellColor; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.types.KitSelectorGadget; + +public class RainbowDanceKitSelector extends KitSelectorGadget +{ + + private Color[] _rainbowColors = new Color[] + { + new Color(148, 0, 211), + new Color(75, 0, 130), + new Color(0, 0, 255), + new Color(0, 255, 0), + new Color(255, 255, 0), + new Color(255, 127, 0), + new Color(255, 0, 0) + }; + private int _colorCount = 0; + + public RainbowDanceKitSelector(GadgetManager manager) + { + super(manager, "Rainbow Dance", UtilText.splitLinesToArray(new String[]{C.cGray + "Placeholder"}, LineFormat.LORE), + 0, Material.GLASS, (byte) 0); + } + + @Override + public void playParticle(Entity entity, Player playTo) + { + int tick = entity.getTicksLived(); + + float x = (float) (Math.sin(tick / 7d) * 1f); + float z = (float) (Math.cos(tick / 7d) * 1f); + float y = (float) (Math.cos(tick / 17d) * 1f + 1f); + + ColoredParticle coloredParticle = new ColoredParticle(UtilParticle.ParticleType.RED_DUST, new DustSpellColor(getNextColor()), entity.getLocation().add(x, y, z)); + coloredParticle.display(UtilParticle.ViewDist.NORMAL, playTo); + } + + private Color getNextColor() + { + Color color = _rainbowColors[_colorCount]; + _colorCount++; + if (_colorCount == _rainbowColors.length) + _colorCount = 0; + return color; + } + +} From 89f47d4c6cf9f57894552e5a21bf73157c8fc5ce Mon Sep 17 00:00:00 2001 From: LCastr0 Date: Fri, 28 Apr 2017 11:20:27 -0300 Subject: [PATCH 12/99] Rain Cloud selector --- .../mineplex/core/gadget/GadgetManager.java | 2 ++ .../kitselector/RainCloudKitSelector.java | 36 +++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/RainCloudKitSelector.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java index f4b0fbc60..9efd9c3a3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java @@ -117,6 +117,7 @@ import mineplex.core.gadget.gadgets.item.ItemPartyPopper; import mineplex.core.gadget.gadgets.item.ItemSnowball; import mineplex.core.gadget.gadgets.item.ItemTNT; import mineplex.core.gadget.gadgets.kitselector.HaloKitSelector; +import mineplex.core.gadget.gadgets.kitselector.RainCloudKitSelector; import mineplex.core.gadget.gadgets.kitselector.RainbowDanceKitSelector; import mineplex.core.gadget.gadgets.kitselector.SingleParticleKitSelector; import mineplex.core.gadget.gadgets.kitselector.WaterWingsKitSelector; @@ -604,6 +605,7 @@ public class GadgetManager extends MiniPlugin addGadget(new WaterWingsKitSelector(this)); addGadget(new HaloKitSelector(this)); addGadget(new RainbowDanceKitSelector(this)); + addGadget(new RainCloudKitSelector(this)); for(SingleParticleKitSelector.SingleParticleSelectors singleParticleSelectors : SingleParticleKitSelector.SingleParticleSelectors.values()) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/RainCloudKitSelector.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/RainCloudKitSelector.java new file mode 100644 index 000000000..0d303b93a --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/RainCloudKitSelector.java @@ -0,0 +1,36 @@ +package mineplex.core.gadget.gadgets.kitselector; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilText; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.types.KitSelectorGadget; + +public class RainCloudKitSelector extends KitSelectorGadget +{ + + public RainCloudKitSelector(GadgetManager manager) + { + super(manager, "Rain Cloud", UtilText.splitLinesToArray(new String[]{C.cGray + "Placeholder"}, LineFormat.LORE), + 0, Material.GLASS, (byte) 0); + } + + + @Override + public void playParticle(Entity entity, Player playTo) + { + Location loc = entity.getLocation().add(0, 3.5, 0); + UtilParticle.playParticleFor(playTo, UtilParticle.ParticleType.EXPLODE, loc, 0.6f, 0f, 0.6f, 0, 8, UtilParticle.ViewDist.NORMAL); + + UtilParticle.playParticleFor(playTo, UtilParticle.ParticleType.CLOUD, loc, 0.6f, 0.1f, 0.6f, 0, 8, UtilParticle.ViewDist.NORMAL); + + UtilParticle.playParticleFor(playTo, UtilParticle.ParticleType.DRIP_WATER, loc, 0.4f, 0.1f, 0.4f, 0, 2, UtilParticle.ViewDist.NORMAL); + } + +} From 1b686a1446713305344b88e7178e1ee35853ad92 Mon Sep 17 00:00:00 2001 From: LCastr0 Date: Fri, 28 Apr 2017 11:43:13 -0300 Subject: [PATCH 13/99] Shimmering Ring kit selector --- .../mineplex/core/gadget/GadgetManager.java | 2 + .../ShimmeringRingKitSelector.java | 91 +++++++++++++++++++ 2 files changed, 93 insertions(+) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/ShimmeringRingKitSelector.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java index 9efd9c3a3..83eb1995a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java @@ -119,6 +119,7 @@ import mineplex.core.gadget.gadgets.item.ItemTNT; import mineplex.core.gadget.gadgets.kitselector.HaloKitSelector; import mineplex.core.gadget.gadgets.kitselector.RainCloudKitSelector; import mineplex.core.gadget.gadgets.kitselector.RainbowDanceKitSelector; +import mineplex.core.gadget.gadgets.kitselector.ShimmeringRingKitSelector; import mineplex.core.gadget.gadgets.kitselector.SingleParticleKitSelector; import mineplex.core.gadget.gadgets.kitselector.WaterWingsKitSelector; import mineplex.core.gadget.gadgets.morph.MorphAwkwardRabbit; @@ -606,6 +607,7 @@ public class GadgetManager extends MiniPlugin addGadget(new HaloKitSelector(this)); addGadget(new RainbowDanceKitSelector(this)); addGadget(new RainCloudKitSelector(this)); + addGadget(new ShimmeringRingKitSelector(this)); for(SingleParticleKitSelector.SingleParticleSelectors singleParticleSelectors : SingleParticleKitSelector.SingleParticleSelectors.values()) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/ShimmeringRingKitSelector.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/ShimmeringRingKitSelector.java new file mode 100644 index 000000000..5bc779247 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/ShimmeringRingKitSelector.java @@ -0,0 +1,91 @@ +package mineplex.core.gadget.gadgets.kitselector; + +import java.util.HashMap; +import java.util.Map; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.common.util.UtilText; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.types.KitSelectorGadget; + +public class ShimmeringRingKitSelector extends KitSelectorGadget +{ + + private static final int PARTICLES_PER_CIRCLE = 20; + + private Map _selectedEntity = new HashMap<>(); + private Map _circleHeight = new HashMap<>(); + private Map _direction = new HashMap<>(); + + public ShimmeringRingKitSelector(GadgetManager manager) + { + super(manager, "Shimmering Ring", UtilText.splitLinesToArray(new String[]{C.cGray + "Placeholder"}, LineFormat.LORE), + 0, Material.GLASS, (byte) 0); + } + + @Override + public void disableCustom(Player player, boolean message) + { + super.disableCustom(player, message); + if (_selectedEntity.containsKey(player)) + { + Entity selected = _selectedEntity.get(player); + _circleHeight.remove(selected); + _direction.remove(selected); + _selectedEntity.remove(player); + } + } + + @Override + public void playParticle(Entity entity, Player playTo) + { + if (_selectedEntity.containsKey(playTo)) + { + Entity selected = _selectedEntity.get(playTo); + if (!selected.equals(entity)) + { + _selectedEntity.remove(playTo); + _circleHeight.remove(selected); + _direction.remove(selected); + _selectedEntity.put(playTo, entity); + _circleHeight.put(entity, 0.0); + _direction.put(entity, true); + } + } + + // Updates height and direction of particles + double height = _circleHeight.get(entity); + boolean up = (height == 0) || ((height == getEntityHeight(entity)) ? false : _direction.get(entity)); + _direction.put(entity, up); + if (up) + height += 0.1; + else + height -= 0.1; + _circleHeight.put(entity, height); + + for (int i = 0; i < PARTICLES_PER_CIRCLE; i++) + { + Location location = entity.getLocation().add(0, height, 0); + double increment = (2 * Math.PI) / PARTICLES_PER_CIRCLE; + double angle = i * increment; + Vector vector = new Vector(Math.cos(angle), 0, Math.sin(angle)); + UtilParticle.playParticleFor(playTo, UtilParticle.ParticleType.FLAME, location.add(vector), 0, 0, 0, 0, 1, UtilParticle.ViewDist.NORMAL); + } + } + + private double getEntityHeight(Entity entity) + { + net.minecraft.server.v1_8_R3.Entity nmsEntity = ((CraftEntity) entity).getHandle(); + return nmsEntity.getBoundingBox().e - nmsEntity.getBoundingBox().b; + } + +} From c1f06595bb6181d9fa642f40847642d24d42ad15 Mon Sep 17 00:00:00 2001 From: LCastr0 Date: Fri, 28 Apr 2017 13:17:00 -0300 Subject: [PATCH 14/99] Fix NPE --- .../gadgets/kitselector/ShimmeringRingKitSelector.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/ShimmeringRingKitSelector.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/ShimmeringRingKitSelector.java index 5bc779247..a5c651595 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/ShimmeringRingKitSelector.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/ShimmeringRingKitSelector.java @@ -61,6 +61,12 @@ public class ShimmeringRingKitSelector extends KitSelectorGadget _direction.put(entity, true); } } + else + { + _selectedEntity.put(playTo, entity); + _circleHeight.put(entity, 0.0); + _direction.put(entity, true); + } // Updates height and direction of particles double height = _circleHeight.get(entity); From adef8945a4b6a77b9ff590c3cf015c7aadebb25b Mon Sep 17 00:00:00 2001 From: LCastr0 Date: Fri, 28 Apr 2017 13:20:25 -0300 Subject: [PATCH 15/99] Disable other gadgets before enabling --- .../Mineplex.Core/src/mineplex/core/gadget/types/Gadget.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/Gadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/Gadget.java index 141885d0c..aab6e9c71 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/Gadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/Gadget.java @@ -141,8 +141,8 @@ public abstract class Gadget extends SalesPackageBase implements Listener return; } - Manager.setActive(player, this); enableCustom(player, message); + Manager.setActive(player, this); Bukkit.getServer().getPluginManager().callEvent(new GadgetAppliedEvent(player, this)); } From df563793c565a364da0eb551815412b55812a3ac Mon Sep 17 00:00:00 2001 From: LCastr0 Date: Fri, 28 Apr 2017 13:25:10 -0300 Subject: [PATCH 16/99] Fixed name --- .../gadget/gadgets/kitselector/SingleParticleKitSelector.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/SingleParticleKitSelector.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/SingleParticleKitSelector.java index f0d187575..3f8f09b32 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/SingleParticleKitSelector.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/SingleParticleKitSelector.java @@ -33,7 +33,7 @@ public class SingleParticleKitSelector extends KitSelectorGadget { FLAMES_OF_FURY("Flames Of Fury", UtilText.splitLinesToArray(new String[]{C.cGray + "Placeholder"}, LineFormat.LORE), 0, Material.GLASS, (byte) 0, UtilParticle.ParticleType.FLAME), - EMBER("Halo", UtilText.splitLinesToArray(new String[]{C.cGray + "Placeholder"}, LineFormat.LORE), + EMBER("Ember", UtilText.splitLinesToArray(new String[]{C.cGray + "Placeholder"}, LineFormat.LORE), 0, Material.GLASS, (byte) 0, UtilParticle.ParticleType.SMOKE), LOVE("Kit Love", UtilText.splitLinesToArray(new String[]{C.cGray + "Placeholder"}, LineFormat.LORE), 0, Material.GLASS, (byte) 0, UtilParticle.ParticleType.HEART); From f8566437d53873ca91c4889385a6e6ec71ff8dd8 Mon Sep 17 00:00:00 2001 From: LCastr0 Date: Fri, 28 Apr 2017 21:23:19 -0300 Subject: [PATCH 17/99] Fixed shimmering rings --- .../ShimmeringRingKitSelector.java | 35 +++++++++++++++---- 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/ShimmeringRingKitSelector.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/ShimmeringRingKitSelector.java index a5c651595..9bd9282cd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/ShimmeringRingKitSelector.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/ShimmeringRingKitSelector.java @@ -5,7 +5,6 @@ import java.util.Map; import org.bukkit.Location; import org.bukkit.Material; -import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.util.Vector; @@ -70,9 +69,15 @@ public class ShimmeringRingKitSelector extends KitSelectorGadget // Updates height and direction of particles double height = _circleHeight.get(entity); - boolean up = (height == 0) || ((height == getEntityHeight(entity)) ? false : _direction.get(entity)); - _direction.put(entity, up); - if (up) + if (height <= 0) + { + _direction.put(entity, true); + } + else if (height >= getEntityHeight(entity)) + { + _direction.put(entity, false); + } + if (_direction.get(entity)) height += 0.1; else height -= 0.1; @@ -90,8 +95,26 @@ public class ShimmeringRingKitSelector extends KitSelectorGadget private double getEntityHeight(Entity entity) { - net.minecraft.server.v1_8_R3.Entity nmsEntity = ((CraftEntity) entity).getHandle(); - return nmsEntity.getBoundingBox().e - nmsEntity.getBoundingBox().b; + switch (entity.getType()) + { + case SHEEP: + case PIG: + case BAT: + case MAGMA_CUBE: + case GUARDIAN: + case CHICKEN: + case SLIME: + case SQUID: + case WOLF: + case OCELOT: + return 0.75; + case SPIDER: + case CAVE_SPIDER: + return 0.5; + case ENDERMAN: + return 3; + } + return 2; } } From 08150b2c0fab4e453d755e1a802a1cd20475d32a Mon Sep 17 00:00:00 2001 From: LCastr0 Date: Sun, 30 Apr 2017 11:28:40 -0300 Subject: [PATCH 18/99] Added rank-based win effects --- .../core/cosmetic/ui/page/GadgetPage.java | 11 +- .../core/cosmetic/ui/page/WinEffectPage.java | 30 +++++ .../mineplex/core/gadget/GadgetManager.java | 31 +++++ .../rankrooms/WinEffectRankBased.java | 113 ++++++++++++++++++ .../rankwineffects/WinEffectRankEternal.java | 29 +++++ .../rankwineffects/WinEffectRankHero.java | 29 +++++ .../rankwineffects/WinEffectRankLegend.java | 29 +++++ .../rankwineffects/WinEffectRankTitan.java | 29 +++++ .../rankwineffects/WinEffectRankUltra.java | 29 +++++ 9 files changed, 327 insertions(+), 3 deletions(-) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/WinEffectRankBased.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankEternal.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankHero.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankLegend.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankTitan.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankUltra.java 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 3d8aedbb7..657d98b30 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 @@ -78,6 +78,11 @@ public class GadgetPage extends ShopPageBase } protected void addGadget(Gadget gadget, int slot) + { + addGadget(gadget, slot, false); + } + + protected void addGadget(Gadget gadget, int slot, boolean locked) { List itemLore = new ArrayList(); @@ -102,7 +107,7 @@ public class GadgetPage extends ShopPageBase itemLore.add(" " + (gadget.getSet().isActive(getPlayer()) ? C.cGreen : C.cGray) + bonus); } - if (!gadget.ownsGadget(getPlayer())) + if (!gadget.ownsGadget(getPlayer()) || locked) { if (gadget.getCost(GlobalCurrency.TREASURE_SHARD) == -1) { @@ -261,7 +266,7 @@ public class GadgetPage extends ShopPageBase ItemMeta im = item.getItemMeta(); im.setDisplayName(C.cGreen + C.Bold + gadget.getName()); - if (gadget.ownsGadget(getPlayer())) + if (gadget.ownsGadget(getPlayer()) && !locked) { if (gadget.getActive().contains(getPlayer())) { @@ -320,7 +325,7 @@ public class GadgetPage extends ShopPageBase } //Standard - if (gadget.ownsGadget(getPlayer())) + if (gadget.ownsGadget(getPlayer()) && !locked) { ItemStack gadgetItemStack; /*if (gadget instanceof MorphWitch) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/WinEffectPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/WinEffectPage.java index 3236de2fb..de763e016 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/WinEffectPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/WinEffectPage.java @@ -5,10 +5,12 @@ import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; import mineplex.core.account.CoreClientManager; +import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.cosmetic.CosmeticManager; import mineplex.core.cosmetic.ui.CosmeticShop; import mineplex.core.donation.DonationManager; +import mineplex.core.gadget.gadgets.wineffect.rankrooms.WinEffectRankBased; import mineplex.core.gadget.types.Gadget; import mineplex.core.gadget.types.GadgetType; import mineplex.core.shop.item.IButton; @@ -30,6 +32,9 @@ public class WinEffectPage extends GadgetPage for (Gadget gadget : getPlugin().getGadgetManager().getGadgets(GadgetType.WIN_EFFECT)) { + if (gadget instanceof WinEffectRankBased) + continue; + addGadget(gadget, slot); if (getPlugin().getGadgetManager().getActive(getPlayer(), GadgetType.WIN_EFFECT) == gadget) @@ -40,6 +45,31 @@ public class WinEffectPage extends GadgetPage if (slot == 17) slot += 2; } + + // Adds rank based win effects + Rank maxRank = WinEffectRankBased.getHighestRankForPlayer(getPlayer()); + + for (WinEffectRankBased.WinEffectType winEffectType : WinEffectRankBased.WinEffectType.values()) + { + Rank originalRank = maxRank; + + if (maxRank.equals(Rank.ALL)) + maxRank = Rank.ULTRA; + + WinEffectRankBased winEffectRankBased = getPlugin().getGadgetManager().getRankBasedWinEffect(winEffectType, maxRank); + if (winEffectRankBased != null) + { + addGadget(winEffectRankBased, slot, (originalRank.equals(Rank.ALL))); + + if (winEffectRankBased.isActive(getPlayer())) + addGlow(slot); + + slot++; + + if (slot == 17) + slot += 2; + } + } addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java index 83eb1995a..33478c909 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java @@ -29,6 +29,7 @@ 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.util.F; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilMath; @@ -208,6 +209,12 @@ import mineplex.core.gadget.gadgets.wineffect.WinEffectPodium; import mineplex.core.gadget.gadgets.wineffect.WinEffectRiseOfTheElderGuardian; import mineplex.core.gadget.gadgets.wineffect.WinEffectSnowTrails; import mineplex.core.gadget.gadgets.wineffect.WinEffectWinterWarfare; +import mineplex.core.gadget.gadgets.wineffect.rankrooms.WinEffectRankBased; +import mineplex.core.gadget.gadgets.wineffect.rankrooms.rankwineffects.WinEffectRankEternal; +import mineplex.core.gadget.gadgets.wineffect.rankrooms.rankwineffects.WinEffectRankHero; +import mineplex.core.gadget.gadgets.wineffect.rankrooms.rankwineffects.WinEffectRankLegend; +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.SetCandyCane; import mineplex.core.gadget.set.SetCupidsLove; @@ -276,6 +283,7 @@ public class GadgetManager extends MiniPlugin private SoulManager _soulManager; private Map> _gadgets; + private List _rankBasedWinEffects; private final Map _lastMove = new HashMap<>(); private final Map> _playerActiveGadgetMap = new HashMap<>(); @@ -357,6 +365,7 @@ public class GadgetManager extends MiniPlugin private void createGadgets() { _gadgets = new HashMap<>(); + _rankBasedWinEffects = new ArrayList<>(); // Items addGadget(new ItemEtherealPearl(this)); @@ -538,6 +547,13 @@ public class GadgetManager extends MiniPlugin addGadget(new WinEffectWinterWarfare(this)); addGadget(new WinEffectLoveIsABattlefield(this)); + // Rank based win effects + addGadget(new WinEffectRankUltra(this)); + addGadget(new WinEffectRankHero(this)); + addGadget(new WinEffectRankLegend(this)); + addGadget(new WinEffectRankTitan(this)); + addGadget(new WinEffectRankEternal(this)); + // Music addGadget(new MusicGadget(this, "13 Disc", new String[] {""}, -2, 2256, 178000)); addGadget(new MusicGadget(this, "Cat Disc", new String[] {""}, -2, 2257, 185000)); @@ -669,6 +685,9 @@ public class GadgetManager extends MiniPlugin _gadgets.put(gadget.getGadgetType(), new ArrayList<>()); _gadgets.get(gadget.getGadgetType()).add(gadget); + + if (gadget instanceof WinEffectRankBased) + _rankBasedWinEffects.add((WinEffectRankBased) gadget); } @EventHandler @@ -815,6 +834,18 @@ public class GadgetManager extends MiniPlugin } return null; } + + public WinEffectRankBased getRankBasedWinEffect(WinEffectRankBased.WinEffectType winEffectType, Rank rank) + { + for (WinEffectRankBased winEffectRankBased : _rankBasedWinEffects) + { + if (winEffectRankBased.getWinEffectType().equals(winEffectType) && winEffectRankBased.getRank().equals(rank)) + { + return winEffectRankBased; + } + } + return null; + } // Disallows two armor gadgets in same slot. public void removeOutfit(Player player, ArmorSlot slot) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/WinEffectRankBased.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/WinEffectRankBased.java new file mode 100644 index 000000000..8822869ca --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/WinEffectRankBased.java @@ -0,0 +1,113 @@ +package mineplex.core.gadget.gadgets.wineffect.rankrooms; + +import org.bukkit.Material; +import org.bukkit.entity.Player; + +import mineplex.core.Managers; +import mineplex.core.common.Rank; +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.UtilText; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.types.WinEffectGadget; + +/** + * Helper class to create win effects based on ranks + */ +public abstract class WinEffectRankBased extends WinEffectGadget +{ + + private Rank _rank; + private WinEffectType _winEffectType; + + /** + * @param manager The gadget manager + * @param rank The rank needed for the win room + * @param winEffectType The win effect type, used to display in menus + * @param alternativeSalepackageNames + */ + public WinEffectRankBased(GadgetManager manager, Rank rank, WinEffectType winEffectType, String... alternativeSalepackageNames) + { + super(manager, winEffectType.getName() + " " + rank.getRawTag(), winEffectType.getLore(), + (rank.equals(Rank.ETERNAL) ? -15 : (rank.equals(Rank.TITAN) ? -13 : (rank.equals(Rank.LEGEND) ? -12 : (rank.equals(Rank.HERO) ? -11 : -10)))), + winEffectType.getMaterial(), winEffectType.getData(), true, alternativeSalepackageNames); + _rank = rank; + _winEffectType = winEffectType; + _schematicName = winEffectType.getSchematic().replace("%r%", rank.getRawTag()); + } + + public Rank getRank() + { + return _rank; + } + + public WinEffectType getWinEffectType() + { + return _winEffectType; + } + + /** + * Gets the highest possible rank for the player + * @param player The player + * @return The highest rank for that player or null if GadgetManager isn't loaded + */ + public static Rank getHighestRankForPlayer(Player player) + { + GadgetManager gadgetManager = Managers.get(GadgetManager.class); + if (gadgetManager != null) + { + Rank rank = gadgetManager.getClientManager().Get(player).GetRank(); + if (rank.has(Rank.ETERNAL)) + return Rank.ETERNAL; + else + return rank; + } + return null; + } + + public enum WinEffectType + { + RANK_WIN_EFFECT("Rank Win Effect", UtilText.splitLinesToArray(new String[]{C.cGray + "Placeholder"}, LineFormat.LORE), Material.GLASS, (byte) 0, "WinRank%r%"); + + private String _name; + private String[] _lore; + private Material _material; + private byte _data; + private String _schematic; + + WinEffectType(String name, String[] lore, Material material, byte data, String schematic) + { + _name = name; + _lore = lore; + _material = material; + _data = data; + _schematic = schematic; + } + + public String getName() + { + return _name; + } + + public String[] getLore() + { + return _lore; + } + + public Material getMaterial() + { + return _material; + } + + public byte getData() + { + return _data; + } + + public String getSchematic() + { + return _schematic; + } + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankEternal.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankEternal.java new file mode 100644 index 000000000..846f43216 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankEternal.java @@ -0,0 +1,29 @@ +package mineplex.core.gadget.gadgets.wineffect.rankrooms.rankwineffects; + +import org.bukkit.Bukkit; + +import mineplex.core.common.Rank; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.gadgets.wineffect.rankrooms.WinEffectRankBased; + +public class WinEffectRankEternal extends WinEffectRankBased +{ + + public WinEffectRankEternal(GadgetManager manager) + { + super(manager, Rank.ETERNAL, WinEffectType.RANK_WIN_EFFECT); + } + + @Override + public void play() + { + Bukkit.broadcastMessage("Playing effect win effect eternal: " + getName()); + } + + @Override + public void finish() + { + Bukkit.broadcastMessage("Playing effect win effect eternal: " + getName()); + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankHero.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankHero.java new file mode 100644 index 000000000..eff18f125 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankHero.java @@ -0,0 +1,29 @@ +package mineplex.core.gadget.gadgets.wineffect.rankrooms.rankwineffects; + +import org.bukkit.Bukkit; + +import mineplex.core.common.Rank; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.gadgets.wineffect.rankrooms.WinEffectRankBased; + +public class WinEffectRankHero extends WinEffectRankBased +{ + + public WinEffectRankHero(GadgetManager manager) + { + super(manager, Rank.HERO, WinEffectType.RANK_WIN_EFFECT); + } + + @Override + public void play() + { + Bukkit.broadcastMessage("Playing effect win effect hero: " + getName()); + } + + @Override + public void finish() + { + Bukkit.broadcastMessage("Playing effect win effect hero: " + getName()); + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankLegend.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankLegend.java new file mode 100644 index 000000000..bf15f89a3 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankLegend.java @@ -0,0 +1,29 @@ +package mineplex.core.gadget.gadgets.wineffect.rankrooms.rankwineffects; + +import org.bukkit.Bukkit; + +import mineplex.core.common.Rank; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.gadgets.wineffect.rankrooms.WinEffectRankBased; + +public class WinEffectRankLegend extends WinEffectRankBased +{ + + public WinEffectRankLegend(GadgetManager manager) + { + super(manager, Rank.LEGEND, WinEffectType.RANK_WIN_EFFECT); + } + + @Override + public void play() + { + Bukkit.broadcastMessage("Playing effect win effect legend: " + getName()); + } + + @Override + public void finish() + { + Bukkit.broadcastMessage("Playing effect win effect legend: " + getName()); + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankTitan.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankTitan.java new file mode 100644 index 000000000..607dc9b39 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankTitan.java @@ -0,0 +1,29 @@ +package mineplex.core.gadget.gadgets.wineffect.rankrooms.rankwineffects; + +import org.bukkit.Bukkit; + +import mineplex.core.common.Rank; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.gadgets.wineffect.rankrooms.WinEffectRankBased; + +public class WinEffectRankTitan extends WinEffectRankBased +{ + + public WinEffectRankTitan(GadgetManager manager) + { + super(manager, Rank.TITAN, WinEffectType.RANK_WIN_EFFECT); + } + + @Override + public void play() + { + Bukkit.broadcastMessage("Playing effect win effect titan: " + getName()); + } + + @Override + public void finish() + { + Bukkit.broadcastMessage("Playing effect win effect titan: " + getName()); + } + +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankUltra.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankUltra.java new file mode 100644 index 000000000..7db8fbd2d --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankUltra.java @@ -0,0 +1,29 @@ +package mineplex.core.gadget.gadgets.wineffect.rankrooms.rankwineffects; + +import org.bukkit.Bukkit; + +import mineplex.core.common.Rank; +import mineplex.core.gadget.GadgetManager; +import mineplex.core.gadget.gadgets.wineffect.rankrooms.WinEffectRankBased; + +public class WinEffectRankUltra extends WinEffectRankBased +{ + + public WinEffectRankUltra(GadgetManager manager) + { + super(manager, Rank.ULTRA, WinEffectType.RANK_WIN_EFFECT); + } + + @Override + public void play() + { + Bukkit.broadcastMessage("Playing effect win effect ultra: " + getName()); + } + + @Override + public void finish() + { + Bukkit.broadcastMessage("Playing effect win effect ultra: " + getName()); + } + +} From 95e4170cc121495863fc7ea1c47751b4b4ddcd9b Mon Sep 17 00:00:00 2001 From: LCastr0 Date: Sun, 30 Apr 2017 11:47:57 -0300 Subject: [PATCH 19/99] Added creeper --- .../rankwineffects/WinEffectRankUltra.java | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankUltra.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankUltra.java index 7db8fbd2d..eedbfaf2e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankUltra.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankUltra.java @@ -1,14 +1,20 @@ package mineplex.core.gadget.gadgets.wineffect.rankrooms.rankwineffects; -import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.entity.Creeper; +import org.bukkit.entity.LivingEntity; import mineplex.core.common.Rank; +import mineplex.core.disguise.disguises.DisguisePlayer; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.gadgets.wineffect.rankrooms.WinEffectRankBased; public class WinEffectRankUltra extends WinEffectRankBased { + private DisguisePlayer _npc; + private Creeper _creeper; + public WinEffectRankUltra(GadgetManager manager) { super(manager, Rank.ULTRA, WinEffectType.RANK_WIN_EFFECT); @@ -17,13 +23,21 @@ public class WinEffectRankUltra extends WinEffectRankBased @Override public void play() { - Bukkit.broadcastMessage("Playing effect win effect ultra: " + getName()); + Location loc = getBaseLocation(); + loc.setDirection(_player.getLocation().subtract(loc).toVector()); + + _npc = getNPC(getPlayer(), loc); + + _creeper = loc.getWorld().spawn(loc.add(loc.getDirection().multiply(-3)), Creeper.class); + _creeper.setPowered(true); + _creeper.setTarget((LivingEntity) _npc.getEntity().getBukkitEntity()); } @Override public void finish() { - Bukkit.broadcastMessage("Playing effect win effect ultra: " + getName()); + if (!_creeper.isDead()) + _creeper.remove(); } } From d04e29a4734ccd2614abce0f9ec63710dc52a1a6 Mon Sep 17 00:00:00 2001 From: LCastr0 Date: Sun, 30 Apr 2017 14:46:15 -0300 Subject: [PATCH 20/99] Tests --- .../rankrooms/rankwineffects/WinEffectRankUltra.java | 10 +++++++++- .../mineplex/core/gadget/types/WinEffectGadget.java | 4 +++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankUltra.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankUltra.java index eedbfaf2e..5bdc877c6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankUltra.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankUltra.java @@ -3,8 +3,10 @@ package mineplex.core.gadget.gadgets.wineffect.rankrooms.rankwineffects; import org.bukkit.Location; import org.bukkit.entity.Creeper; import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; import mineplex.core.common.Rank; +import mineplex.core.common.util.UtilServer; import mineplex.core.disguise.disguises.DisguisePlayer; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.gadgets.wineffect.rankrooms.WinEffectRankBased; @@ -24,13 +26,19 @@ public class WinEffectRankUltra extends WinEffectRankBased public void play() { Location loc = getBaseLocation(); - loc.setDirection(_player.getLocation().subtract(loc).toVector()); + + loc.setDirection(_player.getLocation().subtract(loc).toVector().multiply(-1)); _npc = getNPC(getPlayer(), loc); _creeper = loc.getWorld().spawn(loc.add(loc.getDirection().multiply(-3)), Creeper.class); _creeper.setPowered(true); _creeper.setTarget((LivingEntity) _npc.getEntity().getBukkitEntity()); + + for (Player player : UtilServer.getPlayers()) + { + player.teleport(_npc.getEntity().getBukkitEntity()); + } } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/WinEffectGadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/WinEffectGadget.java index 3b16c5c4a..4a3fb08a1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/WinEffectGadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/WinEffectGadget.java @@ -349,7 +349,9 @@ public abstract class WinEffectGadget extends Gadget public Schematic pasteScematic(String schematicName) { try { - Schematic schematic = UtilSchematic.loadSchematic(new File("../../update/schematic/" + schematicName + ".schematic")); + // TODO CHANGE FOLDER + //Schematic schematic = UtilSchematic.loadSchematic(new File("../../update/schematic/" + schematicName + ".schematic")); + Schematic schematic = UtilSchematic.loadSchematic(new File("../../schematics/" + schematicName + ".schematic")); if (schematic != null) schematic.paste(getBaseLocation(), false, true); return schematic; From 8ec6ebd06082d6bc0df07bde3925ad4b23c4bd2d Mon Sep 17 00:00:00 2001 From: LCastr0 Date: Sun, 30 Apr 2017 18:42:16 -0300 Subject: [PATCH 21/99] Fix particles being sent to everyone --- .../mineplex/core/common/shape/ShapeWings.java | 2 +- .../gadgets/kitselector/HaloKitSelector.java | 1 + .../kitselector/RainCloudKitSelector.java | 6 +++--- .../kitselector/ShimmeringRingKitSelector.java | 2 +- .../kitselector/SingleParticleKitSelector.java | 2 +- .../particleeffects/ColoredCircleEffect.java | 17 +++++++++++++++-- 6 files changed, 22 insertions(+), 8 deletions(-) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/shape/ShapeWings.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/shape/ShapeWings.java index 5fe29bf29..72c5f2851 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/shape/ShapeWings.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/shape/ShapeWings.java @@ -340,7 +340,7 @@ public class ShapeWings extends ShapeGrid implements CosmeticShape */ public void displayParticle(Location location, Player player) { - UtilParticle.playParticleFor(player, _particle, location, _offsetData, _speed, _count, ViewDist.NORMAL); + UtilParticle.PlayParticle(_particle, location, (float) _offsetData.getX(), (float) _offsetData.getY(), (float) _offsetData.getZ(), _speed, _count, ViewDist.NORMAL, player); } /** diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/HaloKitSelector.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/HaloKitSelector.java index 4fd7fe89e..9004ac106 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/HaloKitSelector.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/HaloKitSelector.java @@ -49,6 +49,7 @@ public class HaloKitSelector extends KitSelectorGadget ColoredCircleEffect coloredCircleEffect = new ColoredCircleEffect(Manager.getPlugin(), entity, 0.6, false); coloredCircleEffect.addColors(UtilColor.hexToRgb(0xffd700), UtilColor.hexToRgb(0xdaa520)); coloredCircleEffect.setYOffset(getEntityYOffset(entity)); + coloredCircleEffect.setPlayers(playTo); coloredCircleEffect.start(); _selectedEntity.put(playTo, entity); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/RainCloudKitSelector.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/RainCloudKitSelector.java index 0d303b93a..852680e22 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/RainCloudKitSelector.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/RainCloudKitSelector.java @@ -26,11 +26,11 @@ public class RainCloudKitSelector extends KitSelectorGadget public void playParticle(Entity entity, Player playTo) { Location loc = entity.getLocation().add(0, 3.5, 0); - UtilParticle.playParticleFor(playTo, UtilParticle.ParticleType.EXPLODE, loc, 0.6f, 0f, 0.6f, 0, 8, UtilParticle.ViewDist.NORMAL); + UtilParticle.PlayParticle(UtilParticle.ParticleType.EXPLODE, loc, 0.6f, 0f, 0.6f, 0, 8, UtilParticle.ViewDist.NORMAL, playTo); - UtilParticle.playParticleFor(playTo, UtilParticle.ParticleType.CLOUD, loc, 0.6f, 0.1f, 0.6f, 0, 8, UtilParticle.ViewDist.NORMAL); + UtilParticle.PlayParticle(UtilParticle.ParticleType.CLOUD, loc, 0.6f, 0.1f, 0.6f, 0, 8, UtilParticle.ViewDist.NORMAL, playTo); - UtilParticle.playParticleFor(playTo, UtilParticle.ParticleType.DRIP_WATER, loc, 0.4f, 0.1f, 0.4f, 0, 2, UtilParticle.ViewDist.NORMAL); + UtilParticle.PlayParticle(UtilParticle.ParticleType.DRIP_WATER, loc, 0.4f, 0.1f, 0.4f, 0, 2, UtilParticle.ViewDist.NORMAL, playTo); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/ShimmeringRingKitSelector.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/ShimmeringRingKitSelector.java index 9bd9282cd..874216c33 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/ShimmeringRingKitSelector.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/ShimmeringRingKitSelector.java @@ -89,7 +89,7 @@ public class ShimmeringRingKitSelector extends KitSelectorGadget double increment = (2 * Math.PI) / PARTICLES_PER_CIRCLE; double angle = i * increment; Vector vector = new Vector(Math.cos(angle), 0, Math.sin(angle)); - UtilParticle.playParticleFor(playTo, UtilParticle.ParticleType.FLAME, location.add(vector), 0, 0, 0, 0, 1, UtilParticle.ViewDist.NORMAL); + UtilParticle.PlayParticle(UtilParticle.ParticleType.FLAME, location.add(vector), 0, 0, 0, 0, 1, UtilParticle.ViewDist.NORMAL, playTo); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/SingleParticleKitSelector.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/SingleParticleKitSelector.java index 3f8f09b32..fd6c60132 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/SingleParticleKitSelector.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/SingleParticleKitSelector.java @@ -26,7 +26,7 @@ public class SingleParticleKitSelector extends KitSelectorGadget @Override public void playParticle(Entity entity, Player playTo) { - UtilParticle.playParticleFor(playTo, _particleType, entity.getLocation().add(0, 1, 0), 0.5f, 0.5f, 0.5f, 0, 1, UtilParticle.ViewDist.NORMAL); + UtilParticle.PlayParticle(_particleType, entity.getLocation().add(0, 1, 0), 0.5f, 0.5f, 0.5f, 0, 1, UtilParticle.ViewDist.NORMAL, playTo); } public enum SingleParticleSelectors diff --git a/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/ColoredCircleEffect.java b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/ColoredCircleEffect.java index 51851e40b..21a4b2681 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/ColoredCircleEffect.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/particleeffects/ColoredCircleEffect.java @@ -7,6 +7,7 @@ import java.util.List; import org.bukkit.Location; import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.util.Vector; @@ -26,6 +27,7 @@ public class ColoredCircleEffect extends Effect private int _maxCircles = -1; private int _totalCircles = 0; private double _yOffset = 0.0; + private Player[] _players = null; private static final int PARTICLES_PER_CIRCLE = 20; @@ -38,6 +40,11 @@ public class ColoredCircleEffect extends Effect Collections.addAll(_colors, colors); } + public void setPlayers(Player... players) + { + _players = players; + } + public void setMaxCircles(int circles) { _maxCircles = circles; @@ -83,7 +90,10 @@ public class ColoredCircleEffect extends Effect double angle = _steps * increment; Vector vector = new Vector(Math.cos(angle) * _radius, 0, Math.sin(angle) * _radius); ColoredParticle coloredParticle = new ColoredParticle(UtilParticle.ParticleType.RED_DUST, new DustSpellColor(getNextColor()), location.add(vector)); - coloredParticle.display(); + if (_players != null) + coloredParticle.display(UtilParticle.ViewDist.NORMAL, _players); + else + coloredParticle.display(); _steps++; } stop(); @@ -103,7 +113,10 @@ public class ColoredCircleEffect extends Effect double angle = _steps * increment; Vector vector = new Vector(Math.cos(angle) * _radius, 0, Math.sin(angle) * _radius); ColoredParticle coloredParticle = new ColoredParticle(UtilParticle.ParticleType.RED_DUST, new DustSpellColor(getNextColor()), location.add(vector)); - coloredParticle.display(); + if (_players != null) + coloredParticle.display(UtilParticle.ViewDist.NORMAL, _players); + else + coloredParticle.display(); _steps++; if (_steps >= PARTICLES_PER_CIRCLE) { From e7c171749c3ff9e8eb865366fd5de81c4b7b457e Mon Sep 17 00:00:00 2001 From: LCastr0 Date: Mon, 1 May 2017 12:25:03 -0300 Subject: [PATCH 22/99] Set pitch and yaw for npc --- .../wineffect/rankrooms/rankwineffects/WinEffectRankUltra.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankUltra.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankUltra.java index 5bdc877c6..f712b69d9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankUltra.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankUltra.java @@ -28,7 +28,8 @@ public class WinEffectRankUltra extends WinEffectRankBased Location loc = getBaseLocation(); loc.setDirection(_player.getLocation().subtract(loc).toVector().multiply(-1)); - + loc.setPitch(0); + loc.setYaw(0); _npc = getNPC(getPlayer(), loc); _creeper = loc.getWorld().spawn(loc.add(loc.getDirection().multiply(-3)), Creeper.class); From 8f117e744e5cd4ba5d695ee278cde893034b9fb2 Mon Sep 17 00:00:00 2001 From: LCastr0 Date: Mon, 1 May 2017 22:14:46 -0300 Subject: [PATCH 23/99] More stuff in ultra effect --- .../rankwineffects/WinEffectRankUltra.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankUltra.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankUltra.java index f712b69d9..0badbde6f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankUltra.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankUltra.java @@ -1,11 +1,22 @@ package mineplex.core.gadget.gadgets.wineffect.rankrooms.rankwineffects; +import java.util.Set; + import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; import org.bukkit.entity.Creeper; +import org.bukkit.entity.FallingBlock; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityExplodeEvent; +import mineplex.core.common.MaterialData; import mineplex.core.common.Rank; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilServer; import mineplex.core.disguise.disguises.DisguisePlayer; import mineplex.core.gadget.GadgetManager; @@ -14,6 +25,8 @@ import mineplex.core.gadget.gadgets.wineffect.rankrooms.WinEffectRankBased; public class WinEffectRankUltra extends WinEffectRankBased { + private static final int RADIUS = 5; + private DisguisePlayer _npc; private Creeper _creeper; @@ -49,4 +62,21 @@ public class WinEffectRankUltra extends WinEffectRankBased _creeper.remove(); } + @EventHandler + public void onEntityExplode(EntityExplodeEvent event) + { + if (event.getEntity().equals(_creeper)) + { + Set blocks = UtilBlock.getBlocksInRadius(_npc.getEntity().getBukkitEntity().getLocation(), RADIUS, RADIUS); + for (Block block : blocks) + { + MaterialData materialData = MaterialData.of(block.getType(), block.getData()); + block.setType(Material.AIR); + FallingBlock fallingBlock = block.getLocation().getWorld().spawnFallingBlock(block.getLocation(), materialData.getMaterial(), materialData.getData()); + fallingBlock.setDropItem(false); + UtilAction.velocity(fallingBlock, UtilAlg.getTrajectory(fallingBlock.getLocation(), _npc.getEntity().getBukkitEntity().getLocation()).multiply(-1), .75, true, 0.8, 0, 1.0, true); + } + } + } + } From bbfa6321060d7b4218d8646110ea2c4d85d63688 Mon Sep 17 00:00:00 2001 From: LCastr0 Date: Wed, 3 May 2017 22:05:54 -0300 Subject: [PATCH 24/99] Add all the mechanics to the win effects --- .../rankwineffects/WinEffectRankEternal.java | 100 +++++++++++++++++- .../rankwineffects/WinEffectRankHero.java | 100 +++++++++++++++++- .../rankwineffects/WinEffectRankLegend.java | 98 ++++++++++++++++- .../rankwineffects/WinEffectRankTitan.java | 60 ++++++++++- .../rankwineffects/WinEffectRankUltra.java | 12 +-- .../core/gadget/types/WinEffectGadget.java | 22 ++++ 6 files changed, 372 insertions(+), 20 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankEternal.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankEternal.java index 846f43216..030f6b24c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankEternal.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankEternal.java @@ -1,14 +1,39 @@ package mineplex.core.gadget.gadgets.wineffect.rankrooms.rankwineffects; -import org.bukkit.Bukkit; +import java.util.Set; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.ArmorStand; +import org.bukkit.entity.FallingBlock; +import org.bukkit.entity.Guardian; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.EventHandler; +import org.bukkit.util.Vector; + +import mineplex.core.common.MaterialData; import mineplex.core.common.Rank; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.disguise.disguises.DisguisePlayer; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.gadgets.wineffect.rankrooms.WinEffectRankBased; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; public class WinEffectRankEternal extends WinEffectRankBased { + private DisguisePlayer _npc; + private Guardian _guardian = null; + private int _step = 0; + + private static final int POINTS = 100; + private static final float RADIUS = 15F; + private static final int BLOCK_RADIUS = 5; + public WinEffectRankEternal(GadgetManager manager) { super(manager, Rank.ETERNAL, WinEffectType.RANK_WIN_EFFECT); @@ -17,13 +42,82 @@ public class WinEffectRankEternal extends WinEffectRankBased @Override public void play() { - Bukkit.broadcastMessage("Playing effect win effect eternal: " + getName()); + Location loc = getBaseLocation(); + + loc.setDirection(_player.getLocation().subtract(loc).toVector().multiply(-1)); + + _npc = getNPC(getPlayer(), loc, true); } @Override public void finish() { - Bukkit.broadcastMessage("Playing effect win effect eternal: " + getName()); + if (_guardian != null) + { + _guardian.remove(); + _guardian = null; + } + _step = 0; + } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (!isRunning()) + return; + + if (event.getType() != UpdateType.FASTEST) + return; + + Location npcLocation = _npc.getEntity().getBukkitEntity().getLocation(); + + if (_guardian == null) + { + _guardian = npcLocation.getWorld().spawn(npcLocation.add(0, 20, 0), Guardian.class); + } + + double increment = (2 * Math.PI) / POINTS; + + double angle = _step * increment; + Vector vector = new Vector(Math.cos(angle) * RADIUS, 0, Math.sin(angle) * RADIUS); + _guardian.setVelocity(new Vector(0,0,0)); + _guardian.teleport(_player.getLocation().clone().add(vector)); + Vector direction = npcLocation.toVector().subtract(_guardian.getEyeLocation().toVector()); + Location enderLocation = _guardian.getLocation().setDirection(direction); + _guardian.teleport(enderLocation); + + _step++; + + if (_step % 2 == 0) + zap(); + + if (_step == 25) + { + breakBlocks(); + } + } + + private void zap() + { + if (_guardian != null) + { + _guardian.setTarget((LivingEntity) _npc.getEntity().getBukkitEntity()); + } + } + + private void breakBlocks() + { + Set blocks = UtilBlock.getBlocksInRadius(_npc.getEntity().getBukkitEntity().getLocation(), BLOCK_RADIUS, BLOCK_RADIUS); + for (Block block : blocks) + { + MaterialData materialData = MaterialData.of(block.getType(), block.getData()); + block.setType(Material.AIR); + FallingBlock fallingBlock = block.getLocation().getWorld().spawnFallingBlock(block.getLocation(), materialData.getMaterial(), materialData.getData()); + fallingBlock.setDropItem(false); + UtilAction.velocity(fallingBlock, UtilAlg.getTrajectory(fallingBlock.getLocation(), _npc.getEntity().getBukkitEntity().getLocation()).multiply(-1), .75, true, 0.8, 0, 1.0, true); + } + ArmorStand armorStand = (ArmorStand) _npc.getEntity().getBukkitEntity(); + armorStand.setHealth(0); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankHero.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankHero.java index eff18f125..9144436e5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankHero.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankHero.java @@ -1,14 +1,39 @@ package mineplex.core.gadget.gadgets.wineffect.rankrooms.rankwineffects; -import org.bukkit.Bukkit; +import java.util.Set; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEnderDragon; +import org.bukkit.entity.ArmorStand; +import org.bukkit.entity.EnderDragon; +import org.bukkit.entity.FallingBlock; +import org.bukkit.event.EventHandler; +import org.bukkit.util.Vector; + +import mineplex.core.common.MaterialData; import mineplex.core.common.Rank; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.disguise.disguises.DisguisePlayer; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.gadgets.wineffect.rankrooms.WinEffectRankBased; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; public class WinEffectRankHero extends WinEffectRankBased { + private DisguisePlayer _npc; + private EnderDragon _enderDragon = null; + private int _step = 0; + + private static final int POINTS = 100; + private static final float RADIUS = 15F; + private static final int BLOCK_RADIUS = 5; + public WinEffectRankHero(GadgetManager manager) { super(manager, Rank.HERO, WinEffectType.RANK_WIN_EFFECT); @@ -17,13 +42,82 @@ public class WinEffectRankHero extends WinEffectRankBased @Override public void play() { - Bukkit.broadcastMessage("Playing effect win effect hero: " + getName()); + Location loc = getBaseLocation(); + + loc.setDirection(_player.getLocation().subtract(loc).toVector().multiply(-1)); + + _npc = getNPC(getPlayer(), loc, true); } @Override public void finish() { - Bukkit.broadcastMessage("Playing effect win effect hero: " + getName()); + if (_enderDragon != null) + { + _enderDragon.remove(); + _enderDragon = null; + } + _step = 0; + } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (!isRunning()) + return; + + if (_step > 70) + return; + + if (_step == 70) + { + breakBlocks(); + } + + if (event.getType() != UpdateType.FASTEST) + return; + + Location npcLocation = _npc.getEntity().getBukkitEntity().getLocation(); + + if (_enderDragon == null) + { + _enderDragon = npcLocation.getWorld().spawn(npcLocation.add(0, 20, 0), EnderDragon.class); + } + + double increment = (2 * Math.PI) / POINTS; + + double angle = _step * increment; + Vector vector = new Vector(Math.cos(angle) * RADIUS, 0, Math.sin(angle) * RADIUS); + _enderDragon.setVelocity(new Vector(0,0,0)); + _enderDragon.teleport(_player.getLocation().clone().add(vector)); + Vector direction = npcLocation.toVector().subtract(_enderDragon.getEyeLocation().toVector()).multiply(-1); + Location enderLocation = _enderDragon.getLocation().setDirection(direction); + _enderDragon.teleport(enderLocation); + + _step++; + + if (_step >= 50) + setTarget(); + } + + private void setTarget() + { + ((CraftEnderDragon) _enderDragon).getHandle().setTargetBlock(_baseLocation.getBlockX(), _baseLocation.getBlockY(), _baseLocation.getBlockZ()); + } + + private void breakBlocks() + { + Set blocks = UtilBlock.getBlocksInRadius(_baseLocation.add(0, 1, 0), BLOCK_RADIUS, BLOCK_RADIUS); + for (Block block : blocks) + { + MaterialData materialData = MaterialData.of(block.getType(), block.getData()); + block.setType(Material.AIR); + FallingBlock fallingBlock = block.getLocation().getWorld().spawnFallingBlock(block.getLocation(), materialData.getMaterial(), materialData.getData()); + fallingBlock.setDropItem(false); + UtilAction.velocity(fallingBlock, UtilAlg.getTrajectory(fallingBlock.getLocation(), _npc.getEntity().getBukkitEntity().getLocation()).multiply(-1), .75, true, 0.8, 0, 1.0, true); + } + ArmorStand armorStand = (ArmorStand) _npc.getEntity().getBukkitEntity(); + armorStand.setHealth(0); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankLegend.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankLegend.java index bf15f89a3..d1ba4afbd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankLegend.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankLegend.java @@ -1,14 +1,39 @@ package mineplex.core.gadget.gadgets.wineffect.rankrooms.rankwineffects; -import org.bukkit.Bukkit; +import java.util.Set; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.ArmorStand; +import org.bukkit.entity.FallingBlock; +import org.bukkit.entity.Wither; +import org.bukkit.entity.WitherSkull; +import org.bukkit.event.EventHandler; +import org.bukkit.util.Vector; + +import mineplex.core.common.MaterialData; import mineplex.core.common.Rank; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.disguise.disguises.DisguisePlayer; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.gadgets.wineffect.rankrooms.WinEffectRankBased; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; public class WinEffectRankLegend extends WinEffectRankBased { + private DisguisePlayer _npc; + private Wither _wither = null; + private int _step = 0; + + private static final int POINTS = 100; + private static final float RADIUS = 15F; + private static final int BLOCK_RADIUS = 5; + public WinEffectRankLegend(GadgetManager manager) { super(manager, Rank.LEGEND, WinEffectType.RANK_WIN_EFFECT); @@ -17,13 +42,80 @@ public class WinEffectRankLegend extends WinEffectRankBased @Override public void play() { - Bukkit.broadcastMessage("Playing effect win effect legend: " + getName()); + Location loc = getBaseLocation(); + + loc.setDirection(_player.getLocation().subtract(loc).toVector().multiply(-1)); + + _npc = getNPC(getPlayer(), loc, true); } @Override public void finish() { - Bukkit.broadcastMessage("Playing effect win effect legend: " + getName()); + if (_wither != null) + { + _wither.remove(); + _wither = null; + } + _step = 0; + } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (!isRunning()) + return; + + if (event.getType() != UpdateType.FASTEST) + return; + + Location npcLocation = _npc.getEntity().getBukkitEntity().getLocation(); + + if (_wither == null) + { + _wither = npcLocation.getWorld().spawn(npcLocation.add(0, 20, 0), Wither.class); + } + + double increment = (2 * Math.PI) / POINTS; + + double angle = _step * increment; + Vector vector = new Vector(Math.cos(angle) * RADIUS, 0, Math.sin(angle) * RADIUS); + _wither.setVelocity(new Vector(0,0,0)); + _wither.teleport(_player.getLocation().clone().add(vector)); + Vector direction = npcLocation.toVector().subtract(_wither.getEyeLocation().toVector()); + Location enderLocation = _wither.getLocation().setDirection(direction); + _wither.teleport(enderLocation); + + _step++; + + if (_step % 5 == 0) + spawnSkull(); + + if (_step == 40) + breakBlocks(); + } + + private void spawnSkull() + { + if (_wither != null) + { + _wither.launchProjectile(WitherSkull.class); + } + } + + private void breakBlocks() + { + Set blocks = UtilBlock.getBlocksInRadius(_npc.getEntity().getBukkitEntity().getLocation(), BLOCK_RADIUS, BLOCK_RADIUS); + for (Block block : blocks) + { + MaterialData materialData = MaterialData.of(block.getType(), block.getData()); + block.setType(Material.AIR); + FallingBlock fallingBlock = block.getLocation().getWorld().spawnFallingBlock(block.getLocation(), materialData.getMaterial(), materialData.getData()); + fallingBlock.setDropItem(false); + UtilAction.velocity(fallingBlock, UtilAlg.getTrajectory(fallingBlock.getLocation(), _npc.getEntity().getBukkitEntity().getLocation()).multiply(-1), .75, true, 0.8, 0, 1.0, true); + } + ArmorStand armorStand = (ArmorStand) _npc.getEntity().getBukkitEntity(); + armorStand.setHealth(0); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankTitan.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankTitan.java index 607dc9b39..8526e8df5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankTitan.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankTitan.java @@ -1,14 +1,33 @@ package mineplex.core.gadget.gadgets.wineffect.rankrooms.rankwineffects; -import org.bukkit.Bukkit; +import java.util.Set; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.ArmorStand; +import org.bukkit.entity.FallingBlock; +import org.bukkit.entity.Giant; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageEvent; + +import mineplex.core.common.MaterialData; import mineplex.core.common.Rank; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.disguise.disguises.DisguisePlayer; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.gadgets.wineffect.rankrooms.WinEffectRankBased; public class WinEffectRankTitan extends WinEffectRankBased { + private DisguisePlayer _npc; + private Giant _giant = null; + + private static final int RADIUS = 5; + public WinEffectRankTitan(GadgetManager manager) { super(manager, Rank.TITAN, WinEffectType.RANK_WIN_EFFECT); @@ -17,13 +36,48 @@ public class WinEffectRankTitan extends WinEffectRankBased @Override public void play() { - Bukkit.broadcastMessage("Playing effect win effect titan: " + getName()); + Location loc = getBaseLocation(); + + loc.setDirection(_player.getLocation().subtract(loc).toVector().multiply(-1)); + + _npc = getNPC(getPlayer(), loc); + + _giant = loc.getWorld().spawn(loc.add(0, 20, 0), Giant.class); } @Override public void finish() { - Bukkit.broadcastMessage("Playing effect win effect titan: " + getName()); + if (_giant != null) + { + _giant.remove(); + _giant = null; + } + } + + @EventHandler + public void onGiantFall(EntityDamageEvent event) + { + if (_giant == null) + return; + + if (event.getCause().equals(EntityDamageEvent.DamageCause.FALL)) + { + if (event.getEntity().equals(_giant)) + { + Set blocks = UtilBlock.getBlocksInRadius(_npc.getEntity().getBukkitEntity().getLocation(), RADIUS, RADIUS); + for (Block block : blocks) + { + MaterialData materialData = MaterialData.of(block.getType(), block.getData()); + block.setType(Material.AIR); + FallingBlock fallingBlock = block.getLocation().getWorld().spawnFallingBlock(block.getLocation(), materialData.getMaterial(), materialData.getData()); + fallingBlock.setDropItem(false); + UtilAction.velocity(fallingBlock, UtilAlg.getTrajectory(fallingBlock.getLocation(), _npc.getEntity().getBukkitEntity().getLocation()).multiply(-1), .75, true, 0.8, 0, 1.0, true); + } + ArmorStand armorStand = (ArmorStand) _npc.getEntity().getBukkitEntity(); + armorStand.setHealth(0); + } + } } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankUltra.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankUltra.java index 0badbde6f..dc3ccc130 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankUltra.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankUltra.java @@ -5,10 +5,10 @@ import java.util.Set; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; +import org.bukkit.entity.ArmorStand; import org.bukkit.entity.Creeper; import org.bukkit.entity.FallingBlock; import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityExplodeEvent; @@ -17,7 +17,6 @@ import mineplex.core.common.Rank; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilServer; import mineplex.core.disguise.disguises.DisguisePlayer; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.gadgets.wineffect.rankrooms.WinEffectRankBased; @@ -43,16 +42,11 @@ public class WinEffectRankUltra extends WinEffectRankBased loc.setDirection(_player.getLocation().subtract(loc).toVector().multiply(-1)); loc.setPitch(0); loc.setYaw(0); - _npc = getNPC(getPlayer(), loc); + _npc = getNPC(getPlayer(), loc, true); _creeper = loc.getWorld().spawn(loc.add(loc.getDirection().multiply(-3)), Creeper.class); _creeper.setPowered(true); _creeper.setTarget((LivingEntity) _npc.getEntity().getBukkitEntity()); - - for (Player player : UtilServer.getPlayers()) - { - player.teleport(_npc.getEntity().getBukkitEntity()); - } } @Override @@ -76,6 +70,8 @@ public class WinEffectRankUltra extends WinEffectRankBased fallingBlock.setDropItem(false); UtilAction.velocity(fallingBlock, UtilAlg.getTrajectory(fallingBlock.getLocation(), _npc.getEntity().getBukkitEntity().getLocation()).multiply(-1), .75, true, 0.8, 0, 1.0, true); } + ArmorStand armorStand = (ArmorStand) _npc.getEntity().getBukkitEntity(); + armorStand.setHealth(0); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/WinEffectGadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/WinEffectGadget.java index 4a3fb08a1..8edce5e2d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/WinEffectGadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/WinEffectGadget.java @@ -339,6 +339,28 @@ public abstract class WinEffectGadget extends Gadget Manager.getDisguiseManager().disguise(disguise); return disguise; } + + /** + * Get a disguised ArmorStand with the skin of the provided player at the provided location. The ArmorStand got 2048 health. + * @param player The player to create the disguise from + * @param loc The location to spawn the ArmorStand at + * @param gravity true if the armorstand should have gravity + * @return Returns a disguised ArmorStand at the given location + */ + public DisguisePlayer getNPC(Player player, Location loc, boolean gravity) { + ArmorStand stand = loc.getWorld().spawn(loc, ArmorStand.class); + + stand.setMaxHealth(2048); + stand.setHealth(2048); + stand.setGravity(gravity); + + GameProfile profile = new GameProfile(UUID.randomUUID(), player.getName()); + profile.getProperties().putAll(((CraftPlayer) player).getHandle().getProfile().getProperties()); + + DisguisePlayer disguise = new DisguisePlayer(stand, profile); + Manager.getDisguiseManager().disguise(disguise); + return disguise; + } /** * Paste a schematic relative to the base location From ddd196ba0cb5ae51aa4402783d3ba0dff4429dcf Mon Sep 17 00:00:00 2001 From: LCastr0 Date: Wed, 3 May 2017 22:08:31 -0300 Subject: [PATCH 25/99] Revert temporary folder for schematics --- .../src/mineplex/core/gadget/types/WinEffectGadget.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/WinEffectGadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/WinEffectGadget.java index 8edce5e2d..faf54e131 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/WinEffectGadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/WinEffectGadget.java @@ -371,9 +371,7 @@ public abstract class WinEffectGadget extends Gadget public Schematic pasteScematic(String schematicName) { try { - // TODO CHANGE FOLDER - //Schematic schematic = UtilSchematic.loadSchematic(new File("../../update/schematic/" + schematicName + ".schematic")); - Schematic schematic = UtilSchematic.loadSchematic(new File("../../schematics/" + schematicName + ".schematic")); + Schematic schematic = UtilSchematic.loadSchematic(new File("../../update/schematic/" + schematicName + ".schematic")); if (schematic != null) schematic.paste(getBaseLocation(), false, true); return schematic; From cf56dfb9cfba89970bcfdb6a95e574232e3dcc1a Mon Sep 17 00:00:00 2001 From: LCastr0 Date: Wed, 3 May 2017 22:22:16 -0300 Subject: [PATCH 26/99] Increase amount of smoke particles --- .../SingleParticleKitSelector.java | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/SingleParticleKitSelector.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/SingleParticleKitSelector.java index fd6c60132..70286f2ed 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/SingleParticleKitSelector.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/SingleParticleKitSelector.java @@ -15,18 +15,20 @@ public class SingleParticleKitSelector extends KitSelectorGadget { private UtilParticle.ParticleType _particleType; + private int _particleCount; public SingleParticleKitSelector(GadgetManager manager, String name, String[] lore, int cost, Material mat, byte data, - UtilParticle.ParticleType particleType, String... alternativeSalesPackageNames) + UtilParticle.ParticleType particleType, int particleCount, String... alternativeSalesPackageNames) { super(manager, name, lore, cost, mat, data, alternativeSalesPackageNames); _particleType = particleType; + _particleCount = particleCount; } @Override public void playParticle(Entity entity, Player playTo) { - UtilParticle.PlayParticle(_particleType, entity.getLocation().add(0, 1, 0), 0.5f, 0.5f, 0.5f, 0, 1, UtilParticle.ViewDist.NORMAL, playTo); + UtilParticle.PlayParticle(_particleType, entity.getLocation().add(0, 1, 0), 0.5f, 0.5f, 0.5f, 0, _particleCount, UtilParticle.ViewDist.NORMAL, playTo); } public enum SingleParticleSelectors @@ -34,7 +36,7 @@ public class SingleParticleKitSelector extends KitSelectorGadget FLAMES_OF_FURY("Flames Of Fury", UtilText.splitLinesToArray(new String[]{C.cGray + "Placeholder"}, LineFormat.LORE), 0, Material.GLASS, (byte) 0, UtilParticle.ParticleType.FLAME), EMBER("Ember", UtilText.splitLinesToArray(new String[]{C.cGray + "Placeholder"}, LineFormat.LORE), - 0, Material.GLASS, (byte) 0, UtilParticle.ParticleType.SMOKE), + 0, Material.GLASS, (byte) 0, UtilParticle.ParticleType.SMOKE, 3), LOVE("Kit Love", UtilText.splitLinesToArray(new String[]{C.cGray + "Placeholder"}, LineFormat.LORE), 0, Material.GLASS, (byte) 0, UtilParticle.ParticleType.HEART); @@ -44,6 +46,7 @@ public class SingleParticleKitSelector extends KitSelectorGadget private Material _material; private byte _data; private UtilParticle.ParticleType _particleType; + private int _particleCount = 1; private String[] _alternativeSalesPackageNames; SingleParticleSelectors(String name, String[] lore, int cost, Material material, byte data, UtilParticle.ParticleType particleType, String... alternativeSalesPackageNames) @@ -57,9 +60,21 @@ public class SingleParticleKitSelector extends KitSelectorGadget _alternativeSalesPackageNames = alternativeSalesPackageNames; } + SingleParticleSelectors(String name, String[] lore, int cost, Material material, byte data, UtilParticle.ParticleType particleType, int particleCount, String... alternativeSalesPackageNames) + { + _name = name; + _lore = lore; + _cost = cost; + _material = material; + _data = data; + _particleType = particleType; + _alternativeSalesPackageNames = alternativeSalesPackageNames; + _particleCount = particleCount; + } + public KitSelectorGadget getKitSelectorGadget(GadgetManager manager) { - return new SingleParticleKitSelector(manager, _name, _lore, _cost, _material, _data, _particleType, _alternativeSalesPackageNames); + return new SingleParticleKitSelector(manager, _name, _lore, _cost, _material, _data, _particleType, _particleCount, _alternativeSalesPackageNames); } } From 229c888498f1318013fa48431a517956341bab8c Mon Sep 17 00:00:00 2001 From: LCastr0 Date: Wed, 3 May 2017 22:27:38 -0300 Subject: [PATCH 27/99] Reduce amount of particles spawned with the water wings --- .../kitselector/WaterWingsKitSelector.java | 25 ++++++++++++++++--- .../core/gadget/types/KitSelectorGadget.java | 3 ++- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/WaterWingsKitSelector.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/WaterWingsKitSelector.java index a7a68a856..b3753844f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/WaterWingsKitSelector.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/WaterWingsKitSelector.java @@ -5,6 +5,7 @@ import org.bukkit.Material; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; import org.bukkit.util.Vector; import mineplex.core.common.shape.ShapeWings; @@ -14,6 +15,8 @@ import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilText; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.types.KitSelectorGadget; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; public class WaterWingsKitSelector extends KitSelectorGadget { @@ -21,6 +24,9 @@ public class WaterWingsKitSelector extends KitSelectorGadget private ShapeWings _wings = new ShapeWings(UtilParticle.ParticleType.DRIP_WATER.particleName, new Vector(0.2,0.2,0.2), 1, 0, false, ShapeWings.DEFAULT_ROTATION, ShapeWings.ANGEL_WING_PATTERN); private ShapeWings _wingsEdge = new ShapeWings(UtilParticle.ParticleType.DRIP_WATER.particleName, new Vector(0.1,0.1,0.1), 1, 0, true, ShapeWings.DEFAULT_ROTATION, ShapeWings.ANGEL_WING_PATTERN); + private int _tick = 0; + private int _lastTick = 0; + public WaterWingsKitSelector(GadgetManager manager) { super(manager, "Water Wings", UtilText.splitLinesToArray(new String[]{C.cGray + "Placeholder"}, LineFormat.LORE), @@ -30,10 +36,21 @@ public class WaterWingsKitSelector extends KitSelectorGadget @Override public void playParticle(Entity entity, Player playTo) { - double offsetY = getEntityYOffset(entity); - Location loc = entity.getLocation().add(0, offsetY, 0).add(entity.getLocation().getDirection().multiply(-0.2)); - _wings.display(loc, playTo); - _wingsEdge.display(loc, playTo); + if (_tick != _lastTick) + { + double offsetY = getEntityYOffset(entity); + Location loc = entity.getLocation().add(0, offsetY, 0).add(entity.getLocation().getDirection().multiply(-0.2)); + _wings.display(loc, playTo); + _wingsEdge.display(loc, playTo); + _lastTick = _tick; + } + } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (event.getType() == UpdateType.FASTEST) + _tick++; } /** diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/KitSelectorGadget.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/KitSelectorGadget.java index 999958b5b..b8dff0bd6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/KitSelectorGadget.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/types/KitSelectorGadget.java @@ -20,7 +20,8 @@ public abstract class KitSelectorGadget extends Gadget /** * Plays the next particle for the selected entity - * @param entity + * @param entity The entity of the selected kit + * @param playTo The player that will receive the particles */ public abstract void playParticle(Entity entity, Player playTo); From 196e0b9688fc937f6d473aba045ea25258c27969 Mon Sep 17 00:00:00 2001 From: LCastr0 Date: Wed, 3 May 2017 22:29:06 -0300 Subject: [PATCH 28/99] Reduce the amount of lines in the Shimmering Ring --- .../gadget/gadgets/kitselector/ShimmeringRingKitSelector.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/ShimmeringRingKitSelector.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/ShimmeringRingKitSelector.java index 874216c33..7ed2845c1 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/ShimmeringRingKitSelector.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/ShimmeringRingKitSelector.java @@ -78,9 +78,9 @@ public class ShimmeringRingKitSelector extends KitSelectorGadget _direction.put(entity, false); } if (_direction.get(entity)) - height += 0.1; + height += 0.2; else - height -= 0.1; + height -= 0.2; _circleHeight.put(entity, height); for (int i = 0; i < PARTICLES_PER_CIRCLE; i++) From b3f46ad4fc6768b4d1a98b4cddcf30ef14e5a7ce Mon Sep 17 00:00:00 2001 From: LCastr0 Date: Wed, 3 May 2017 23:30:16 -0300 Subject: [PATCH 29/99] Added names, icons and lores --- .../mineplex/core/cosmetic/ui/page/Menu.java | 2 +- .../gadgets/kitselector/HaloKitSelector.java | 4 +- .../kitselector/RainCloudKitSelector.java | 4 +- .../kitselector/RainbowDanceKitSelector.java | 4 +- .../ShimmeringRingKitSelector.java | 4 +- .../SingleParticleKitSelector.java | 12 +++--- .../kitselector/WaterWingsKitSelector.java | 4 +- .../rankrooms/WinEffectRankBased.java | 41 +++---------------- .../rankwineffects/WinEffectRankEternal.java | 7 +++- .../rankwineffects/WinEffectRankHero.java | 7 +++- .../rankwineffects/WinEffectRankLegend.java | 7 +++- .../rankwineffects/WinEffectRankTitan.java | 7 +++- .../rankwineffects/WinEffectRankUltra.java | 6 ++- 13 files changed, 51 insertions(+), 58 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java index b301263c1..8a27df36e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/Menu.java @@ -224,7 +224,7 @@ public class Menu extends ShopPageBase if (enabled.containsKey(type)) addGlow(balloonsSlot); type = GadgetType.KIT_SELECTOR; - lore = getLore(ownedCount.get(type), maxCount.get(type), "Placeholder", VISIBILITY_GAME_HUB, enabled.get(type)); + lore = getLore(ownedCount.get(type), maxCount.get(type), "Click here to select different particles to indicate which kit you have selected!", VISIBILITY_GAME_HUB, enabled.get(type)); addButton(kitSelectorSlot, new ShopItem(Material.LEVER, "Kit Selector Particles", lore, 1, false), new OpenKitSelector(this, enabled.get(type))); if (enabled.containsKey(type)) addGlow(kitSelectorSlot); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/HaloKitSelector.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/HaloKitSelector.java index 9004ac106..c05fe3a10 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/HaloKitSelector.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/HaloKitSelector.java @@ -24,8 +24,8 @@ public class HaloKitSelector extends KitSelectorGadget public HaloKitSelector(GadgetManager manager) { - super(manager, "Halo", UtilText.splitLinesToArray(new String[]{C.cGray + "Placeholder"}, LineFormat.LORE), - 0, Material.GLASS, (byte) 0); + super(manager, "Halo", UtilText.splitLinesToArray(new String[]{C.cGray + "Fight like an Angel."}, LineFormat.LORE), + 0, Material.GOLD_HELMET, (byte) 0); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/RainCloudKitSelector.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/RainCloudKitSelector.java index 852680e22..55cb97461 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/RainCloudKitSelector.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/RainCloudKitSelector.java @@ -17,8 +17,8 @@ public class RainCloudKitSelector extends KitSelectorGadget public RainCloudKitSelector(GadgetManager manager) { - super(manager, "Rain Cloud", UtilText.splitLinesToArray(new String[]{C.cGray + "Placeholder"}, LineFormat.LORE), - 0, Material.GLASS, (byte) 0); + super(manager, "Rain Cloud", UtilText.splitLinesToArray(new String[]{C.cGray + "The rain keeps falling, and the kit keeps calling."}, LineFormat.LORE), + 0, Material.POTION, (byte) 0); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/RainbowDanceKitSelector.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/RainbowDanceKitSelector.java index e82e80238..c4aed4e90 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/RainbowDanceKitSelector.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/RainbowDanceKitSelector.java @@ -32,8 +32,8 @@ public class RainbowDanceKitSelector extends KitSelectorGadget public RainbowDanceKitSelector(GadgetManager manager) { - super(manager, "Rainbow Dance", UtilText.splitLinesToArray(new String[]{C.cGray + "Placeholder"}, LineFormat.LORE), - 0, Material.GLASS, (byte) 0); + super(manager, "Rainbow Dance", UtilText.splitLinesToArray(new String[]{C.cGray + "At the end of this Rainbow is the kit of your dreams."}, LineFormat.LORE), + 0, Material.WOOL, (byte) 6); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/ShimmeringRingKitSelector.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/ShimmeringRingKitSelector.java index 7ed2845c1..a6535bfe9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/ShimmeringRingKitSelector.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/ShimmeringRingKitSelector.java @@ -27,8 +27,8 @@ public class ShimmeringRingKitSelector extends KitSelectorGadget public ShimmeringRingKitSelector(GadgetManager manager) { - super(manager, "Shimmering Ring", UtilText.splitLinesToArray(new String[]{C.cGray + "Placeholder"}, LineFormat.LORE), - 0, Material.GLASS, (byte) 0); + super(manager, "Shimmering Ring", UtilText.splitLinesToArray(new String[]{C.cGray + "Encaged in your golden rings, your kits weapon still sing."}, LineFormat.LORE), + 0, Material.WOOL, (byte) 4); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/SingleParticleKitSelector.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/SingleParticleKitSelector.java index 70286f2ed..8ae065c88 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/SingleParticleKitSelector.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/SingleParticleKitSelector.java @@ -33,12 +33,12 @@ public class SingleParticleKitSelector extends KitSelectorGadget public enum SingleParticleSelectors { - FLAMES_OF_FURY("Flames Of Fury", UtilText.splitLinesToArray(new String[]{C.cGray + "Placeholder"}, LineFormat.LORE), - 0, Material.GLASS, (byte) 0, UtilParticle.ParticleType.FLAME), - EMBER("Ember", UtilText.splitLinesToArray(new String[]{C.cGray + "Placeholder"}, LineFormat.LORE), - 0, Material.GLASS, (byte) 0, UtilParticle.ParticleType.SMOKE, 3), - LOVE("Kit Love", UtilText.splitLinesToArray(new String[]{C.cGray + "Placeholder"}, LineFormat.LORE), - 0, Material.GLASS, (byte) 0, UtilParticle.ParticleType.HEART); + FLAMES_OF_FURY("Flames Of Fury", UtilText.splitLinesToArray(new String[]{C.cGray + "Through the Fire and the Flames we will ride"}, LineFormat.LORE), + 0, Material.FIRE, (byte) 0, UtilParticle.ParticleType.FLAME), + EMBER("Ember", UtilText.splitLinesToArray(new String[]{C.cGray + "I'd like my kit well done."}, LineFormat.LORE), + 0, Material.COAL, (byte) 0, UtilParticle.ParticleType.SMOKE, 3), + LOVE("Kit Love", UtilText.splitLinesToArray(new String[]{C.cGray + "I think I LIKE this kit, if you know what I mean."}, LineFormat.LORE), + 0, Material.POTION, (byte) 8233, UtilParticle.ParticleType.HEART); private String _name; private String[] _lore; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/WaterWingsKitSelector.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/WaterWingsKitSelector.java index b3753844f..c776610f3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/WaterWingsKitSelector.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/WaterWingsKitSelector.java @@ -29,8 +29,8 @@ public class WaterWingsKitSelector extends KitSelectorGadget public WaterWingsKitSelector(GadgetManager manager) { - super(manager, "Water Wings", UtilText.splitLinesToArray(new String[]{C.cGray + "Placeholder"}, LineFormat.LORE), - 0, Material.GLASS, (byte) 0); + super(manager, "Water Wings", UtilText.splitLinesToArray(new String[]{C.cGray + "These wings won't help you float or fly, but they look pretty sweet."}, LineFormat.LORE), + 0, Material.WATER_BUCKET, (byte) 0); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/WinEffectRankBased.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/WinEffectRankBased.java index 8822869ca..35993d8ca 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/WinEffectRankBased.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/WinEffectRankBased.java @@ -5,9 +5,6 @@ import org.bukkit.entity.Player; import mineplex.core.Managers; import mineplex.core.common.Rank; -import mineplex.core.common.util.C; -import mineplex.core.common.util.LineFormat; -import mineplex.core.common.util.UtilText; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.types.WinEffectGadget; @@ -26,11 +23,11 @@ public abstract class WinEffectRankBased extends WinEffectGadget * @param winEffectType The win effect type, used to display in menus * @param alternativeSalepackageNames */ - public WinEffectRankBased(GadgetManager manager, Rank rank, WinEffectType winEffectType, String... alternativeSalepackageNames) + public WinEffectRankBased(GadgetManager manager, String name, String[] lore, Material material, byte data, Rank rank, WinEffectType winEffectType, String... alternativeSalepackageNames) { - super(manager, winEffectType.getName() + " " + rank.getRawTag(), winEffectType.getLore(), + super(manager, name, lore, (rank.equals(Rank.ETERNAL) ? -15 : (rank.equals(Rank.TITAN) ? -13 : (rank.equals(Rank.LEGEND) ? -12 : (rank.equals(Rank.HERO) ? -11 : -10)))), - winEffectType.getMaterial(), winEffectType.getData(), true, alternativeSalepackageNames); + material, data, true, alternativeSalepackageNames); _rank = rank; _winEffectType = winEffectType; _schematicName = winEffectType.getSchematic().replace("%r%", rank.getRawTag()); @@ -67,43 +64,15 @@ public abstract class WinEffectRankBased extends WinEffectGadget public enum WinEffectType { - RANK_WIN_EFFECT("Rank Win Effect", UtilText.splitLinesToArray(new String[]{C.cGray + "Placeholder"}, LineFormat.LORE), Material.GLASS, (byte) 0, "WinRank%r%"); + RANK_WIN_EFFECT("WinRank%r%"); - private String _name; - private String[] _lore; - private Material _material; - private byte _data; private String _schematic; - WinEffectType(String name, String[] lore, Material material, byte data, String schematic) + WinEffectType(String schematic) { - _name = name; - _lore = lore; - _material = material; - _data = data; _schematic = schematic; } - public String getName() - { - return _name; - } - - public String[] getLore() - { - return _lore; - } - - public Material getMaterial() - { - return _material; - } - - public byte getData() - { - return _data; - } - public String getSchematic() { return _schematic; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankEternal.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankEternal.java index 030f6b24c..a925c889e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankEternal.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankEternal.java @@ -14,9 +14,12 @@ import org.bukkit.util.Vector; import mineplex.core.common.MaterialData; import mineplex.core.common.Rank; +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilText; import mineplex.core.disguise.disguises.DisguisePlayer; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.gadgets.wineffect.rankrooms.WinEffectRankBased; @@ -36,7 +39,9 @@ public class WinEffectRankEternal extends WinEffectRankBased public WinEffectRankEternal(GadgetManager manager) { - super(manager, Rank.ETERNAL, WinEffectType.RANK_WIN_EFFECT); + super(manager, "Eternal Win Effect", + UtilText.splitLinesToArray(new String[]{C.cGray + "GWEN is ALWAYS watching."}, LineFormat.LORE), + Material.PRISMARINE_SHARD, (byte) 0, Rank.ETERNAL, WinEffectType.RANK_WIN_EFFECT); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankHero.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankHero.java index 9144436e5..94530ce6e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankHero.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankHero.java @@ -14,9 +14,12 @@ import org.bukkit.util.Vector; import mineplex.core.common.MaterialData; import mineplex.core.common.Rank; +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilText; import mineplex.core.disguise.disguises.DisguisePlayer; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.gadgets.wineffect.rankrooms.WinEffectRankBased; @@ -36,7 +39,9 @@ public class WinEffectRankHero extends WinEffectRankBased public WinEffectRankHero(GadgetManager manager) { - super(manager, Rank.HERO, WinEffectType.RANK_WIN_EFFECT); + super(manager, "Hero Win Effect", + UtilText.splitLinesToArray(new String[]{C.cGray + "To become a True Hero you must first defeat the Dragon."}, LineFormat.LORE), + Material.DRAGON_EGG, (byte) 0, Rank.HERO, WinEffectType.RANK_WIN_EFFECT); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankLegend.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankLegend.java index d1ba4afbd..479c5d62c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankLegend.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankLegend.java @@ -14,9 +14,12 @@ import org.bukkit.util.Vector; import mineplex.core.common.MaterialData; import mineplex.core.common.Rank; +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilText; import mineplex.core.disguise.disguises.DisguisePlayer; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.gadgets.wineffect.rankrooms.WinEffectRankBased; @@ -36,7 +39,9 @@ public class WinEffectRankLegend extends WinEffectRankBased public WinEffectRankLegend(GadgetManager manager) { - super(manager, Rank.LEGEND, WinEffectType.RANK_WIN_EFFECT); + super(manager, "Legend Win Effect", + UtilText.splitLinesToArray(new String[]{C.cGray + "Can you weather this Withering Assault?"}, LineFormat.LORE), + Material.SKULL_ITEM, (byte) 1, Rank.LEGEND, WinEffectType.RANK_WIN_EFFECT); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankTitan.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankTitan.java index 8526e8df5..3a7bfb876 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankTitan.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankTitan.java @@ -13,9 +13,12 @@ import org.bukkit.event.entity.EntityDamageEvent; import mineplex.core.common.MaterialData; import mineplex.core.common.Rank; +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilText; import mineplex.core.disguise.disguises.DisguisePlayer; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.gadgets.wineffect.rankrooms.WinEffectRankBased; @@ -30,7 +33,9 @@ public class WinEffectRankTitan extends WinEffectRankBased public WinEffectRankTitan(GadgetManager manager) { - super(manager, Rank.TITAN, WinEffectType.RANK_WIN_EFFECT); + super(manager, "Titan Win Effect", + UtilText.splitLinesToArray(new String[]{C.cGray + "Legend has it that the Titans were so powerful they towered over even the gods."}, LineFormat.LORE), + Material.ROTTEN_FLESH, (byte) 0, Rank.TITAN, WinEffectType.RANK_WIN_EFFECT); } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankUltra.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankUltra.java index dc3ccc130..7d7a2766d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankUltra.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankUltra.java @@ -14,9 +14,12 @@ import org.bukkit.event.entity.EntityExplodeEvent; import mineplex.core.common.MaterialData; import mineplex.core.common.Rank; +import mineplex.core.common.util.C; +import mineplex.core.common.util.LineFormat; import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilText; import mineplex.core.disguise.disguises.DisguisePlayer; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.gadgets.wineffect.rankrooms.WinEffectRankBased; @@ -31,7 +34,8 @@ public class WinEffectRankUltra extends WinEffectRankBased public WinEffectRankUltra(GadgetManager manager) { - super(manager, Rank.ULTRA, WinEffectType.RANK_WIN_EFFECT); + super(manager, "Ultra Win Effect", UtilText.splitLinesToArray(new String[]{C.cGray + "Always check behind you."}, LineFormat.LORE), + Material.SKULL_ITEM, (byte) 4, Rank.ULTRA, WinEffectType.RANK_WIN_EFFECT); } @Override From 58078ae4bde2153b4dc57bf4bc3c51c0f73af5b0 Mon Sep 17 00:00:00 2001 From: LCastr0 Date: Wed, 3 May 2017 23:42:18 -0300 Subject: [PATCH 30/99] Added kit selectors to chests --- .../mineplex/core/gadget/GadgetManager.java | 11 ++++- .../mineplex/core/reward/RewardManager.java | 45 +++++++++++++++++++ 2 files changed, 55 insertions(+), 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 c219306f9..e35168a9b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/GadgetManager.java @@ -286,6 +286,7 @@ public class GadgetManager extends MiniPlugin private CastleManager _castleManager; private Map> _gadgets; + private Map _singleParticleSelectors; private List _rankBasedWinEffects; private final Map _lastMove = new HashMap<>(); @@ -370,6 +371,7 @@ public class GadgetManager extends MiniPlugin { _gadgets = new HashMap<>(); _rankBasedWinEffects = new ArrayList<>(); + _singleParticleSelectors = new HashMap<>(); // Items addGadget(new ItemEtherealPearl(this)); @@ -630,7 +632,9 @@ public class GadgetManager extends MiniPlugin for(SingleParticleKitSelector.SingleParticleSelectors singleParticleSelectors : SingleParticleKitSelector.SingleParticleSelectors.values()) { - addGadget(singleParticleSelectors.getKitSelectorGadget(this)); + Gadget gadget = singleParticleSelectors.getKitSelectorGadget(this); + addGadget(gadget); + _singleParticleSelectors.put(singleParticleSelectors, gadget); } // Gem Hunters Mounts @@ -849,6 +853,11 @@ public class GadgetManager extends MiniPlugin } return null; } + + public SingleParticleKitSelector getSingleParticleKitSelector(SingleParticleKitSelector.SingleParticleSelectors singleParticleSelectors) + { + return (SingleParticleKitSelector) _singleParticleSelectors.get(singleParticleSelectors); + } // Disallows two armor gadgets in same slot. public void removeOutfit(Player player, ArmorSlot slot) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java index 171bfa55e..5f4e5fb16 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/reward/RewardManager.java @@ -70,6 +70,12 @@ import mineplex.core.gadget.gadgets.item.ItemPaintballGun; import mineplex.core.gadget.gadgets.item.ItemPartyPopper; import mineplex.core.gadget.gadgets.item.ItemSnowball; import mineplex.core.gadget.gadgets.item.ItemTNT; +import mineplex.core.gadget.gadgets.kitselector.HaloKitSelector; +import mineplex.core.gadget.gadgets.kitselector.RainCloudKitSelector; +import mineplex.core.gadget.gadgets.kitselector.RainbowDanceKitSelector; +import mineplex.core.gadget.gadgets.kitselector.ShimmeringRingKitSelector; +import mineplex.core.gadget.gadgets.kitselector.SingleParticleKitSelector; +import mineplex.core.gadget.gadgets.kitselector.WaterWingsKitSelector; import mineplex.core.gadget.gadgets.morph.MorphAwkwardRabbit; import mineplex.core.gadget.gadgets.morph.MorphBat; import mineplex.core.gadget.gadgets.morph.MorphBlock; @@ -609,6 +615,23 @@ public class RewardManager addGadget(Type.SPRING, getGadget(ArrowTrailSpring.class), rarity, 100); addGadget(Type.SPRING, getGadget(DeathSpring.class), rarity, 100); addGadget(Type.SPRING, getGadget(DoubleJumpSpring.class), rarity, 100); + + // KIT SELECTORS + addGadget(Type.OMEGA, getGadget(HaloKitSelector.class), rarity, 100); + addGadget(Type.ILLUMINATED, getGadget(HaloKitSelector.class), rarity, 100); + addGadget(Type.MYTHICAL, getGadget(HaloKitSelector.class), rarity, 100); + + addGadget(Type.OMEGA, getGadget(RainbowDanceKitSelector.class), rarity, 100); + addGadget(Type.ILLUMINATED, getGadget(RainbowDanceKitSelector.class), rarity, 100); + addGadget(Type.MYTHICAL, getGadget(RainbowDanceKitSelector.class), rarity, 100); + + addGadget(Type.OMEGA, getGadget(ShimmeringRingKitSelector.class), rarity, 150); + addGadget(Type.ILLUMINATED, getGadget(ShimmeringRingKitSelector.class), rarity, 150); + addGadget(Type.MYTHICAL, getGadget(ShimmeringRingKitSelector.class), rarity, 150); + + addGadget(Type.OMEGA, getSingleParticleKitSelector(SingleParticleKitSelector.SingleParticleSelectors.FLAMES_OF_FURY), rarity, 150); + addGadget(Type.ILLUMINATED, getSingleParticleKitSelector(SingleParticleKitSelector.SingleParticleSelectors.FLAMES_OF_FURY), rarity, 150); + addGadget(Type.MYTHICAL, getSingleParticleKitSelector(SingleParticleKitSelector.SingleParticleSelectors.FLAMES_OF_FURY), rarity, 150); } public void addLegendary() @@ -872,6 +895,23 @@ public class RewardManager addGadget(Type.SPRING, getGadget(MorphAwkwardRabbit.class), rarity, 25); addPetReward(Type.SPRING, PetType.KILLER_BUNNY, rarity, 50); + + // KIT SELECTORS + addGadget(Type.OMEGA, getGadget(RainCloudKitSelector.class), rarity, 100); + addGadget(Type.ILLUMINATED, getGadget(RainCloudKitSelector.class), rarity, 100); + addGadget(Type.MYTHICAL, getGadget(RainCloudKitSelector.class), rarity, 100); + + addGadget(Type.OMEGA, getGadget(WaterWingsKitSelector.class), rarity, 50); + addGadget(Type.ILLUMINATED, getGadget(WaterWingsKitSelector.class), rarity, 50); + addGadget(Type.MYTHICAL, getGadget(WaterWingsKitSelector.class), rarity, 50); + + addGadget(Type.OMEGA, getSingleParticleKitSelector(SingleParticleKitSelector.SingleParticleSelectors.EMBER), rarity, 100); + addGadget(Type.ILLUMINATED, getSingleParticleKitSelector(SingleParticleKitSelector.SingleParticleSelectors.EMBER), rarity, 100); + addGadget(Type.MYTHICAL, getSingleParticleKitSelector(SingleParticleKitSelector.SingleParticleSelectors.EMBER), rarity, 100); + + addGadget(Type.OMEGA, getSingleParticleKitSelector(SingleParticleKitSelector.SingleParticleSelectors.LOVE), rarity, 100); + addGadget(Type.ILLUMINATED, getSingleParticleKitSelector(SingleParticleKitSelector.SingleParticleSelectors.LOVE), rarity, 100); + addGadget(Type.MYTHICAL, getSingleParticleKitSelector(SingleParticleKitSelector.SingleParticleSelectors.LOVE), rarity, 100); } public UnknownPackageReward addMount(Type type, Mount mount, RewardRarity rarity, int weight) @@ -1045,6 +1085,11 @@ public class RewardManager return 0; } } + + private SingleParticleKitSelector getSingleParticleKitSelector(SingleParticleKitSelector.SingleParticleSelectors singleParticleSelectors) + { + return _gadgetManager.getSingleParticleKitSelector(singleParticleSelectors); + } public int getAmmoMin(RewardRarity rarity) { From f23016df28ba5be2098f6ce737baa5b723dec5d3 Mon Sep 17 00:00:00 2001 From: LCastr0 Date: Wed, 3 May 2017 23:59:16 -0300 Subject: [PATCH 31/99] Change to blaze powder --- .../gadget/gadgets/kitselector/SingleParticleKitSelector.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/SingleParticleKitSelector.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/SingleParticleKitSelector.java index 8ae065c88..a2ec8e93b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/SingleParticleKitSelector.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/SingleParticleKitSelector.java @@ -34,7 +34,7 @@ public class SingleParticleKitSelector extends KitSelectorGadget public enum SingleParticleSelectors { FLAMES_OF_FURY("Flames Of Fury", UtilText.splitLinesToArray(new String[]{C.cGray + "Through the Fire and the Flames we will ride"}, LineFormat.LORE), - 0, Material.FIRE, (byte) 0, UtilParticle.ParticleType.FLAME), + 0, Material.BLAZE_POWDER, (byte) 0, UtilParticle.ParticleType.FLAME), EMBER("Ember", UtilText.splitLinesToArray(new String[]{C.cGray + "I'd like my kit well done."}, LineFormat.LORE), 0, Material.COAL, (byte) 0, UtilParticle.ParticleType.SMOKE, 3), LOVE("Kit Love", UtilText.splitLinesToArray(new String[]{C.cGray + "I think I LIKE this kit, if you know what I mean."}, LineFormat.LORE), From f9f2e362c4a8262c3984eaf703d7ea47424bc861 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 4 May 2017 18:28:49 -0400 Subject: [PATCH 32/99] Make ItemBuilder properly clone all options and implement a builder to create enchanted books --- .../core/itemstack/EnchantedBookBuilder.java | 63 +++++++++++++++++++ .../mineplex/core/itemstack/ItemBuilder.java | 15 ++++- 2 files changed, 76 insertions(+), 2 deletions(-) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/itemstack/EnchantedBookBuilder.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/itemstack/EnchantedBookBuilder.java b/Plugins/Mineplex.Core/src/mineplex/core/itemstack/EnchantedBookBuilder.java new file mode 100644 index 000000000..f4228e06d --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/itemstack/EnchantedBookBuilder.java @@ -0,0 +1,63 @@ +package mineplex.core.itemstack; + +import java.util.HashMap; +import java.util.Map; + +import org.bukkit.Material; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.EnchantmentStorageMeta;; + +public class EnchantedBookBuilder +{ + private Map _enchantments; + private int _amount; + + public EnchantedBookBuilder(int amount) + { + _enchantments = new HashMap<>(); + _amount = amount; + } + + public Map getEnchantments() + { + return _enchantments; + } + + public Integer getLevel(Enchantment enchantment) + { + return _enchantments.getOrDefault(enchantment, 0); + } + + public EnchantedBookBuilder setLevel(Enchantment enchantment, Integer level) + { + if (level <= 0) + { + _enchantments.remove(enchantment); + } + else + { + _enchantments.put(enchantment, level); + } + + return this; + } + + public EnchantedBookBuilder removeEnchantment(Enchantment enchantment) + { + _enchantments.remove(enchantment); + + return this; + } + + public ItemStack build() + { + ItemStack item = new ItemStack(Material.ENCHANTED_BOOK, _amount); + EnchantmentStorageMeta meta = (EnchantmentStorageMeta) item.getItemMeta(); + + _enchantments.entrySet().forEach(entry -> meta.addStoredEnchant(entry.getKey(), entry.getValue(), true)); + item.setItemMeta(meta); + + return item; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/itemstack/ItemBuilder.java b/Plugins/Mineplex.Core/src/mineplex/core/itemstack/ItemBuilder.java index 14af0f28d..b0a1f825d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/itemstack/ItemBuilder.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/itemstack/ItemBuilder.java @@ -8,8 +8,6 @@ import java.util.HashSet; import java.util.List; import java.util.Map; -import mineplex.core.common.util.UtilInput; -import mineplex.core.common.util.UtilInv; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Color; @@ -26,6 +24,7 @@ import org.bukkit.inventory.meta.LeatherArmorMeta; import org.bukkit.inventory.meta.SkullMeta; import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilInv; public class ItemBuilder { @@ -311,6 +310,18 @@ public class ItemBuilder // newBuilder.potion = potion; newBuilder.setDurability(_durability); + newBuilder.setData(_data); + + newBuilder.setAmount(_amount); + + newBuilder.setUnbreakable(_unbreakable); + + newBuilder.setGlow(_glow); + + newBuilder.setItemFlags(_itemFlags); + + newBuilder.setPlayerHead(_playerHeadName); + return newBuilder; } From 6ffd10133eee793a4e417a1b291b6d29475138af Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 4 May 2017 18:29:38 -0400 Subject: [PATCH 33/99] Implement a new crown currency --- .../core/donation/DonationManager.java | 151 +++++++++++++++++- .../core/donation/command/CrownCommand.java | 91 +++++++++++ .../core/donation/crown/CrownRepository.java | 117 ++++++++++++++ 3 files changed, 358 insertions(+), 1 deletion(-) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/donation/command/CrownCommand.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/donation/crown/CrownRepository.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java b/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java index 9b1934c9c..8ef17f337 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java @@ -1,9 +1,12 @@ package mineplex.core.donation; +import java.sql.ResultSet; +import java.sql.SQLException; import java.util.HashMap; import java.util.LinkedList; import java.util.Map; import java.util.UUID; +import java.util.concurrent.ConcurrentHashMap; import java.util.function.Consumer; import org.bukkit.entity.Player; @@ -15,10 +18,14 @@ import mineplex.core.MiniClientPlugin; import mineplex.core.ReflectivelyCreateMiniPlugin; import mineplex.core.account.CoreClient; import mineplex.core.account.CoreClientManager; +import mineplex.core.account.ILoginProcessor; +import mineplex.core.account.event.ClientUnloadEvent; import mineplex.core.account.event.ClientWebResponseEvent; import mineplex.core.common.currency.GlobalCurrency; +import mineplex.core.donation.command.CrownCommand; import mineplex.core.donation.command.GemCommand; import mineplex.core.donation.command.ShardCommand; +import mineplex.core.donation.crown.CrownRepository; import mineplex.core.donation.gold.GoldRepository; import mineplex.core.donation.repository.DonationRepository; import mineplex.core.donation.repository.token.DonorTokenWrapper; @@ -40,7 +47,10 @@ public class DonationManager extends MiniClientPlugin private static final Gson GSON = new Gson(); private final Map> _attemptUntilSuccess = new HashMap<>(); - + + private final Map _crownBalance = new ConcurrentHashMap<>(); + private final CrownRepository _crownRepository; + private final CoreClientManager _clientManager = require(CoreClientManager.class); private final DonationRepository _repository; @@ -52,6 +62,36 @@ public class DonationManager extends MiniClientPlugin _repository = new DonationRepository(); _goldRepository = new GoldRepository(); + + _crownRepository = new CrownRepository(); + _clientManager.addStoredProcedureLoginProcessor(new ILoginProcessor() + { + @Override + public String getName() + { + return "crown-balance-loader"; + } + + @Override + public void processLoginResultSet(String playerName, UUID uuid, int accountId, ResultSet resultSet) throws SQLException + { + boolean hasRow = resultSet.next(); + if (hasRow) + { + _crownBalance.put(uuid, resultSet.getInt(1)); + } + else + { + _crownBalance.put(uuid, 0); + } + } + + @Override + public String getQuery(int accountId, String uuid, String name) + { + return "SELECT crownCount FROM accountCrowns WHERE accountId=" + accountId + ";"; + } + }); UtilScheduler.runEvery(UpdateType.FAST, this::processCoinAttemptQueue); } @@ -61,6 +101,7 @@ public class DonationManager extends MiniClientPlugin { addCommand(new GemCommand(this)); addCommand(new ShardCommand(this)); + addCommand(new CrownCommand(this)); } @EventHandler @@ -75,6 +116,88 @@ public class DonationManager extends MiniClientPlugin { return _goldRepository; } + + public int getCrowns(Player player) + { + return getCrowns(player.getUniqueId()); + } + + public int getCrowns(UUID uuid) + { + return _crownBalance.computeIfAbsent(uuid, key -> 0); + } + + /** + * Adds an unknown sales package to the specified {@link Player} + * + * @param callback The callback which will be called on the main thread. Possible responses are: + * {@link TransactionResponse#InsufficientFunds}, when the player does not have enough of the currency + * {@link TransactionResponse#Success}, when everything worked fine + * {@link TransactionResponse#Failed}, when an known exception occured + * {@link TransactionResponse#AlreadyOwns}, when the player already owns the package + */ + public void purchaseUnknownSalesPackageCrown(Player player, String packageName, int cost, boolean oneTimePurchase, Consumer callback) + { + purchaseUnknownSalesPackageCrown(_clientManager.Get(player), packageName, cost, oneTimePurchase, callback); + } + + /** + * Adds an unknown sales package to the specified {@link CoreClient} + * + * @param callback The callback which will be called on the main thread. Possible responses are: + * {@link TransactionResponse#InsufficientFunds}, when the player does not have enough of the currency + * {@link TransactionResponse#Success}, when everything worked fine + * {@link TransactionResponse#Failed}, when an known exception occured + * {@link TransactionResponse#AlreadyOwns}, when the player already owns the package + */ + public void purchaseUnknownSalesPackageCrown(CoreClient client, String packageName, int cost, boolean oneTimePurchase, Consumer callback) + { + Donor donor = Get(client.getUniqueId()); + + if (donor != null) + { + if (oneTimePurchase && donor.ownsUnknownSalesPackage(packageName)) + { + if (callback != null) + { + callback.accept(TransactionResponse.AlreadyOwns); + } + + return; + } + } + + _crownRepository.consumeCrowns(result -> + { + if (result == TransactionResponse.Success) + { + if (_crownBalance.containsKey(client.getUniqueId())) + { + _crownBalance.put(client.getUniqueId(), _crownBalance.get(client.getUniqueId()) - cost); + } + _repository.purchaseUnknownSalesPackage(client.getName(), packageName, GlobalCurrency.GEM, 0, response -> + { + if (response == TransactionResponse.Success) + { + if (donor != null) + { + donor.addOwnedUnknownSalesPackage(packageName); + donor.addBalance(GlobalCurrency.GEM, 0); + } + } + + if (callback != null) + { + callback.accept(response); + } + }); + } + else if (callback != null) + { + callback.accept(result); + } + }, client.getAccountId(), cost); + } /** * Adds an unknown sales package to the specified {@link Player} @@ -187,6 +310,26 @@ public class DonationManager extends MiniClientPlugin callback.accept(response); }); } + + public void rewardCrowns(int crowns, Player player) + { + rewardCrowns(crowns, player, null); + } + + public void rewardCrowns(int crowns, Player player, Consumer completed) + { + _crownRepository.rewardCrowns(success -> + { + if (success) + { + _crownBalance.merge(player.getUniqueId(), crowns, Integer::sum); + } + if (completed != null) + { + completed.accept(success); + } + }, _clientManager.Get(player).getAccountId(), crowns); + } /** * Rewards the specified {@link Player} with {@code amount} of {@code currency} because of {@code reason} @@ -405,4 +548,10 @@ public class DonationManager extends MiniClientPlugin { return _clientManager; } + + @EventHandler + public void unloadCrownBalance(ClientUnloadEvent event) + { + _crownBalance.remove(event.getUniqueId()); + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/donation/command/CrownCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/donation/command/CrownCommand.java new file mode 100644 index 000000000..72800e748 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/donation/command/CrownCommand.java @@ -0,0 +1,91 @@ +package mineplex.core.donation.command; + +import org.bukkit.entity.Player; + +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.common.util.UtilServer; +import mineplex.core.donation.DonationManager; + +public class CrownCommand extends CommandBase +{ + public CrownCommand(DonationManager plugin) + { + super(plugin, Rank.ADMIN, "crown"); + } + + @Override + public void Execute(final Player caller, String[] args) + { + if (args.length < 2) + { + UtilPlayer.message(caller, F.main("Crown", "Missing Args: " + F.elem("/crown "))); + return; + } + + String targetName = args[0]; + + int amount; + + try + { + amount = Integer.parseInt(args[1]); + } + catch (NumberFormatException ex) + { + UtilPlayer.message(caller, F.main("Crown", "Invalid crown Amount")); + return; + } + + if (targetName.equalsIgnoreCase("@a")) + { + rewardAllCrowns(caller, amount); + } + else + { + Player target = UtilPlayer.searchExact(targetName); + if (target != null) + { + rewardCrowns(caller, target, amount); + } + else + { + UtilPlayer.message(caller, F.main("Crown", "Could not find player " + F.name(targetName))); + } + } + } + + private void rewardAllCrowns(Player caller, int crowns) + { + if (crowns > 1000) + { + UtilPlayer.message(caller, F.main("Crown", "You can only give everybody 1000 crowns at a time.")); + return; + } + + for (Player player : UtilServer.getPlayers()) + { + Plugin.rewardCrowns(crowns, player); + } + + UtilPlayer.message(caller, F.main("Crown", "Gave everyone " + F.elem(crowns + " crowns"))); + } + + private void rewardCrowns(Player caller, Player target, int crowns) + { + Plugin.rewardCrowns(crowns, target, completed -> + { + if (completed) + { + UtilPlayer.message(caller, F.main("Crown", "You gave " + F.elem(crowns + " crowns") + " to " + F.name(target.getName()) + ".")); + UtilPlayer.message(target, F.main("Crown", F.name(caller.getName()) + " gave you " + F.elem(crowns + " crowns") + ".")); + } + else + { + UtilPlayer.message(caller, F.main("Crown", "There was an error giving " + F.elem(crowns + " crowns") + " to " + F.name(target.getName()) + ".")); + } + }); + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/donation/crown/CrownRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/donation/crown/CrownRepository.java new file mode 100644 index 000000000..1a449f565 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/donation/crown/CrownRepository.java @@ -0,0 +1,117 @@ +package mineplex.core.donation.crown; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; + +import org.bukkit.Bukkit; + +import mineplex.core.common.util.Callback; +import mineplex.core.common.util.UtilServer; +import mineplex.core.server.util.TransactionResponse; +import mineplex.serverdata.database.DBPool; + +public class CrownRepository +{ + private static final String CREATE_TABLE = "CREATE TABLE accountCrowns (accountId INT(11) NOT NULL, crownCount INT NOT NULL, PRIMARY KEY (accountId), FOREIGN KEY (accountId) REFERENCES accounts(id));"; + private static final String REWARD_ACCOUNT_CROWNS = "INSERT INTO accountCrowns (accountId, crownCount) VALUES (?, ?) ON DUPLICATE KEY UPDATE crownCount=crownCount+VALUES(crownCount);"; + private static final String CONSUME_ACCOUNT_CROWNS = "UPDATE accountCrowns SET crownCount=(crownCount - ?) WHERE accountId=? AND crownCount >= ?;"; + private static final String SET_ACCOUNT_CROWNS = "INSERT INTO accountCrowns (accountId, crownCount) VALUES (?, ?) ON DUPLICATE KEY UPDATE crownCount=VALUES(crownCount);"; + + public CrownRepository() {} + + public void rewardCrowns(final Callback callback, final int accountId, final int crowns) + { + Bukkit.getScheduler().runTaskAsynchronously(UtilServer.getPlugin(), () -> + { + try (Connection connection = DBPool.getAccount().getConnection()) + { + PreparedStatement statement = connection.prepareStatement(REWARD_ACCOUNT_CROWNS); + statement.setInt(1, accountId); + statement.setInt(2, crowns); + statement.executeUpdate(); + + if (callback != null) + { + Bukkit.getScheduler().runTask(UtilServer.getPlugin(), () -> callback.run(true)); + } + } + catch (SQLException e) + { + e.printStackTrace(); + + if (callback != null) + { + Bukkit.getScheduler().runTask(UtilServer.getPlugin(), () -> callback.run(false)); + } + } + }); + } + + public void consumeCrowns(final Callback callback, final int accountId, final int crowns) + { + Bukkit.getScheduler().runTaskAsynchronously(UtilServer.getPlugin(), () -> + { + try (Connection connection = DBPool.getAccount().getConnection()) + { + String baseStmt = "INSERT INTO accountCrowns (accountId, crownCount) VALUES (" + accountId + ", 0) ON DUPLICATE KEY UPDATE crownCount=crownCount;"; + PreparedStatement statement = connection.prepareStatement(baseStmt + CONSUME_ACCOUNT_CROWNS); + statement.setInt(1, crowns); + statement.setInt(2, accountId); + statement.setInt(3, crowns); + statement.execute(); + + statement.getMoreResults(); + + final TransactionResponse response = statement.getUpdateCount() > 0 ? TransactionResponse.Success : TransactionResponse.InsufficientFunds; + + if (callback != null) + { + Bukkit.getScheduler().runTask(UtilServer.getPlugin(), () -> callback.run(response)); + } + } + catch (SQLException e) + { + e.printStackTrace(); + + if (callback != null) + { + Bukkit.getScheduler().runTask(UtilServer.getPlugin(), () -> callback.run(TransactionResponse.Failed)); + } + } + }); + } + + public void setGold(final Callback callback, final int accountId, final int crowns) + { + if (crowns < 0) + { + throw new IllegalArgumentException("Crowns cannot be negative"); + } + + Bukkit.getScheduler().runTaskAsynchronously(UtilServer.getPlugin(), () -> + { + try (Connection connection = DBPool.getAccount().getConnection()) + { + PreparedStatement statement = connection.prepareStatement(SET_ACCOUNT_CROWNS); + statement.setInt(1, accountId); + statement.setInt(2, crowns); + statement.executeUpdate(); + + if (callback != null) + { + Bukkit.getScheduler().runTask(UtilServer.getPlugin(), () -> callback.run(true)); + } + } + catch (SQLException e) + { + e.printStackTrace(); + + if (callback != null) + { + Bukkit.getScheduler().runTask(UtilServer.getPlugin(), () -> callback.run(false)); + } + } + }); + } +} \ No newline at end of file From 39f997faf1d5accb3917633aa8540ba0a28e2705 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 4 May 2017 18:30:39 -0400 Subject: [PATCH 34/99] Give ProgressiveKits the ability to not use xp or use crowns instead of gems for leveling --- .../src/mineplex/core/progression/ProgressiveKit.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/progression/ProgressiveKit.java b/Plugins/Mineplex.Core/src/mineplex/core/progression/ProgressiveKit.java index 395bd428d..05c48e0b7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/progression/ProgressiveKit.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/progression/ProgressiveKit.java @@ -285,4 +285,14 @@ public interface ProgressiveKit ViewDist.NORMAL, displayTo); } } + + default boolean usesXp() + { + return true; + } + + default boolean crownsEnabled() + { + return false; + } } \ No newline at end of file From 6684e812d151e6466e9a2f0f75f851f8abbd5853 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 4 May 2017 18:33:48 -0400 Subject: [PATCH 35/99] Implement xp-less and crown kit upgrading and slightly modify kit progression gui --- .../progression/data/KitUpgradeProcessor.java | 60 ++++++++++++------- .../gui/buttons/KitUpgradeDetailsButton.java | 34 ++++++++--- .../gui/buttons/KitUpgradeMenuButton.java | 24 ++++++-- .../progression/gui/guis/KitDisplayMenu.java | 9 ++- .../gui/guis/KitInformationTrackerMenu.java | 26 +++++--- .../core/progression/math/Calculations.java | 54 +++++++++++++++-- 6 files changed, 156 insertions(+), 51 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/progression/data/KitUpgradeProcessor.java b/Plugins/Mineplex.Core/src/mineplex/core/progression/data/KitUpgradeProcessor.java index e8cff97ee..e090dae6b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/progression/data/KitUpgradeProcessor.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/progression/data/KitUpgradeProcessor.java @@ -1,6 +1,6 @@ package mineplex.core.progression.data; -import mineplex.core.server.util.TransactionResponse; +import java.util.function.Consumer; import org.bukkit.Sound; import org.bukkit.entity.Player; @@ -11,6 +11,7 @@ import mineplex.core.common.util.F; import mineplex.core.progression.KitProgressionManager; import mineplex.core.progression.ProgressiveKit; import mineplex.core.progression.math.Calculations; +import mineplex.core.server.util.TransactionResponse; import mineplex.core.shop.confirmation.ConfirmationCallback; import mineplex.core.shop.confirmation.ConfirmationProcessor; @@ -39,27 +40,40 @@ public class KitUpgradeProcessor implements ConfirmationProcessor { String packageName = _kit.getInternalName() + "." + _upgradeLevel; int cost = Calculations.getGemsCost(_upgradeLevel); + if (!_kit.usesXp()) + { + cost = Calculations.getGemsCostXpLess(_upgradeLevel); + } + + Consumer handler = response -> + { + if (response == TransactionResponse.Success) + { + _kit.upgrade(_upgradeLevel, _player.getUniqueId()); + + _player.playSound(_player.getLocation(), Sound.CAT_MEOW, 5.0f, 1.0f); + _player.sendMessage(F.main("Kit Progression", "Purchased upgrades for " + _kit.getDisplayName() + " level " + _upgradeLevel)); + + callback.resolve("Success! You now own this upgrade!"); + } + else if (response == TransactionResponse.InsufficientFunds) + { + callback.reject("Insufficient funds!"); + } + else + { + callback.reject("There was an error processing your transaction. Try again later"); + } + }; + // Use UnknownPackages for this right now as it handles overspending gems properly - _manager.getDonationManager().purchaseUnknownSalesPackage(_player, packageName, GlobalCurrency.GEM, cost, false, - data -> - { - if (data == TransactionResponse.Success) - { - _kit.upgrade(_upgradeLevel, _player.getUniqueId()); - - _player.playSound(_player.getLocation(), Sound.CAT_MEOW, 5.0f, 1.0f); - _player.sendMessage(F.main("Kit Progression", "Purchased upgrades for " + _kit.getDisplayName() + " level " + _upgradeLevel)); - - callback.resolve("Success! You now own this upgrade!"); - } - else if (data == TransactionResponse.InsufficientFunds) - { - callback.reject("Insufficient funds!"); - } - else - { - callback.reject("There was an error processing your transaction. Try again later"); - } - }); + if (_kit.crownsEnabled()) + { + _manager.getDonationManager().purchaseUnknownSalesPackageCrown(_player, packageName, cost, false, handler); + } + else + { + _manager.getDonationManager().purchaseUnknownSalesPackage(_player, packageName, GlobalCurrency.GEM, cost, false, handler); + } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitUpgradeDetailsButton.java b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitUpgradeDetailsButton.java index 911a8087d..11a12c356 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitUpgradeDetailsButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitUpgradeDetailsButton.java @@ -1,14 +1,18 @@ package mineplex.core.progression.gui.buttons; +import java.util.List; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + import com.google.common.collect.Lists; + import mineplex.core.common.util.C; import mineplex.core.itemstack.ItemBuilder; import mineplex.core.menu.IconButton; +import mineplex.core.progression.ProgressiveKit; import mineplex.core.progression.math.Calculations; -import org.bukkit.Material; -import org.bukkit.inventory.ItemStack; - -import java.util.List; /** * Representing this kits Abilities in a GUI @@ -18,11 +22,13 @@ public class KitUpgradeDetailsButton extends IconButton private ItemStack _item; - public KitUpgradeDetailsButton(int level, List details) + public KitUpgradeDetailsButton(ProgressiveKit kit, Player player, int level, List details) { super(null); - - ItemBuilder builder = new ItemBuilder(Material.SLIME_BALL); + + int current = kit.getUpgradeLevel(player.getUniqueId()); + + ItemBuilder builder = new ItemBuilder(Material.STAINED_CLAY).setData((current >= level) ? (short)5 : (short)14); builder.setTitle(C.cYellow + "Level " + level + " upgrades"); @@ -34,7 +40,19 @@ public class KitUpgradeDetailsButton extends IconButton } lore.add(""); - lore.add(C.cGray + "Unlocks at kit level " + C.cGreen + Calculations.getLevelRequiredFor(level)); + if (kit.usesXp()) + { + lore.add(C.cGray + "Unlocks at kit level " + C.cGreen + Calculations.getLevelRequiredFor(level)); + } + else + { + String currency = C.cGreen + "%cost% Gems"; + if (kit.crownsEnabled()) + { + currency = C.cGold + "%cost% Crowns"; + } + lore.add(C.cGray + "Unlocks with " + currency.replace("%cost%", Calculations.getGemsCostXpLess(level) + "")); + } builder.setLore(lore.toArray(new String[lore.size()])); _item = builder.build(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitUpgradeMenuButton.java b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitUpgradeMenuButton.java index 0bd36086c..263f69476 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitUpgradeMenuButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/buttons/KitUpgradeMenuButton.java @@ -1,5 +1,6 @@ package mineplex.core.progression.gui.buttons; +import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.C; import mineplex.core.itemstack.ItemBuilder; import mineplex.core.progression.KitProgressionManager; @@ -47,14 +48,20 @@ public class KitUpgradeMenuButton extends KitButton //The difference between the players current level, and the next upgrade level int diff = nextUpgradeLevelPlayer - level; + int balance = plugin.getDonationManager().Get(player).getBalance(GlobalCurrency.GEM); + if (kit.crownsEnabled()) + { + balance = plugin.getDonationManager().getCrowns(player); + } + //This ONLY flashes if their next upgrade level isn't their same one. - _flash = Calculations.isUpgradeLevelEligible(level) && (nextUpgradeLevel > upgradeLevel); + _flash = (kit.usesXp() ? (Calculations.isUpgradeLevelEligible(level) && (nextUpgradeLevel > upgradeLevel)) : (Calculations.isUpgradeLevelEligibleXpLess(balance) && upgradeLevel < Calculations.getNextUpgradeLevelXpLess(upgradeLevel))); ChatColor color = Calculations.getColor(level, nextUpgradeLevelPlayer); - if(kit.showUpgrades()) + if (kit.showUpgrades()) { - ItemBuilder builder = lore(new ItemBuilder(Material.ENCHANTMENT_TABLE), upgradeLevel, color, diff); + ItemBuilder builder = kit.usesXp() ? lore(new ItemBuilder(Material.ENCHANTMENT_TABLE), upgradeLevel, color, diff) : lore(new ItemBuilder(Material.ENCHANTMENT_TABLE), upgradeLevel); builder.setTitle(C.cYellow + "Upgrade Level " + upgradeLevel); _item = builder.build(); } @@ -138,4 +145,13 @@ public class KitUpgradeMenuButton extends KitButton ChatColor.WHITE + "Click to view Upgrade and XP tracking"); return builder; } -} + + private ItemBuilder lore(ItemBuilder builder, int upgradeLevel) + { + builder.setLore(" ", + ChatColor.WHITE + "Upgrade Level: " + ChatColor.GREEN + upgradeLevel + " out of 5", + "", + ChatColor.WHITE + "Click to view Upgrades"); + return builder; + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/guis/KitDisplayMenu.java b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/guis/KitDisplayMenu.java index 2a9d73b67..e32104822 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/guis/KitDisplayMenu.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/guis/KitDisplayMenu.java @@ -63,8 +63,11 @@ public class KitDisplayMenu extends KitMenu */ private void setUpNextMenuButtons(Button[] buttons, Player player) { - buttons[48] = new KitXPButton(getKit(), player, getPlugin()); - buttons[50] = new KitUpgradeMenuButton(getKit(), player, getPlugin()); + if (getKit().usesXp()) + { + buttons[48] = new KitXPButton(getKit(), player, getPlugin()); + } + buttons[getKit().usesXp() ? 50 : 49] = new KitUpgradeMenuButton(getKit(), player, getPlugin()); } /** @@ -90,7 +93,7 @@ public class KitDisplayMenu extends KitMenu int index = 0; for(int i : UPGRADE_SLOTS) { - buttons[i] = new KitUpgradeDetailsButton(index + 1, details.get(index++)); + buttons[i] = new KitUpgradeDetailsButton(getKit(), player, index + 1, details.get(index++)); } return; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/guis/KitInformationTrackerMenu.java b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/guis/KitInformationTrackerMenu.java index 42d1aa723..9a61c872f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/guis/KitInformationTrackerMenu.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/progression/gui/guis/KitInformationTrackerMenu.java @@ -59,11 +59,13 @@ public class KitInformationTrackerMenu extends KitMenu Button[] buttons = new Button[52]; buttons[0] = new BackButton(new KitDisplayMenu(getKit(), getPlugin())); - - setUpXP(buttons, player); - - setUpLevel(buttons, player); - + + if (getKit().usesXp()) + { + setUpXP(buttons, player); + setUpLevel(buttons, player); + } + setUpUpgrade(buttons, player); return buttons; @@ -155,10 +157,10 @@ public class KitInformationTrackerMenu extends KitMenu Map> details = getKit().getUpgradeDetails(); int index = 0; - for(int i : UPGRADE_SLOTS) + for (int i : (getKit().usesXp() ? UPGRADE_SLOTS : LEVEL_SLOTS)) { List list = details.get(index++); - KitUpgradeDetailsButton detailsButton = new KitUpgradeDetailsButton(index, list); + KitUpgradeDetailsButton detailsButton = new KitUpgradeDetailsButton(getKit(), player, index, list); ItemBuilder itemStack = new ItemBuilder(detailsButton.getItemStack()); if (getKit().ownsUpgrade(player.getUniqueId(), index)) @@ -168,12 +170,18 @@ public class KitInformationTrackerMenu extends KitMenu else if (getKit().canPurchaseUpgrade(player.getUniqueId(), index)) { itemStack.setGlow(true); - itemStack.addLore("Costs " + C.cGreen + Calculations.getGemsCost(index) + C.cGray + " gems"); + if (getKit().usesXp()) + { + itemStack.addLore("Costs " + (getKit().crownsEnabled() ? C.cGold : C.cGreen) + Calculations.getGemsCost(index) + C.cGray + (getKit().crownsEnabled() ? " crowns" : " gems")); + } itemStack.addLore(C.cGreen + "Click to purchase this upgrade!"); } else { - itemStack.addLore("Costs " + C.cGreen + Calculations.getGemsCost(index) + C.cGray + " gems"); + if (getKit().usesXp()) + { + itemStack.addLore("Costs " + (getKit().crownsEnabled() ? C.cGold : C.cGreen) + Calculations.getGemsCost(index) + C.cGray + (getKit().crownsEnabled() ? " crowns" : " gems")); + } itemStack.addLore(C.cRed + "You cannot purchase this upgrade!"); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/progression/math/Calculations.java b/Plugins/Mineplex.Core/src/mineplex/core/progression/math/Calculations.java index b4a6ac726..ae9c9013b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/progression/math/Calculations.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/progression/math/Calculations.java @@ -1,10 +1,12 @@ package mineplex.core.progression.math; -import com.google.common.collect.Maps; -import net.md_5.bungee.api.ChatColor; - +import java.util.HashMap; import java.util.Map; +import com.google.common.collect.Maps; + +import net.md_5.bungee.api.ChatColor; + /** * This class handles all the math and static fields needed for Kit Progressions * You can find some util methods in here as well that relate to numbers @@ -15,6 +17,7 @@ public class Calculations private static final int[] LEVELS = new int[100]; private static final int[] UPGRADE_LEVELS = {5, 10, 30, 75, 100}; private static final Map GEMS_FOR_UPGRADE = Maps.newHashMap(); + private static final Map GEMS_FOR_XPLESS_UPGRADE = new HashMap<>(); static { @@ -23,6 +26,11 @@ public class Calculations { GEMS_FOR_UPGRADE.put(level, level * 1000); } + GEMS_FOR_XPLESS_UPGRADE.put(1, 1000); + GEMS_FOR_XPLESS_UPGRADE.put(2, 5000); + GEMS_FOR_XPLESS_UPGRADE.put(3, 15000); + GEMS_FOR_XPLESS_UPGRADE.put(4, 30000); + GEMS_FOR_XPLESS_UPGRADE.put(5, 60000); } /** @@ -79,6 +87,20 @@ public class Calculations { return GEMS_FOR_UPGRADE.containsKey(currentLevel); } + + public static boolean isUpgradeLevelEligibleXpLess(int gems) + { + boolean afford = false; + + for (int cost : GEMS_FOR_XPLESS_UPGRADE.values()) + { + if (cost <= gems) + { + afford = true; + } + } + return afford; + } /** * Determines if the players current level, and his gems, are what he needs to level up this upgrade @@ -91,6 +113,11 @@ public class Calculations { return GEMS_FOR_UPGRADE.containsKey(currentLevel) && GEMS_FOR_UPGRADE.get(currentLevel) <= gems; } + + public static boolean canUpgradeXpLess(int upgradeLevel, int gems) + { + return GEMS_FOR_XPLESS_UPGRADE.containsKey(upgradeLevel) && GEMS_FOR_XPLESS_UPGRADE.get(upgradeLevel) <= gems; + } /** * Get the XP required for the next level @@ -155,7 +182,7 @@ public class Calculations } /** - * Get the next integer upgrade level based of the players current leve; + * Get the next integer upgrade level based of the players current level * * @param currentLevel The players current level * @return The next upgrade level @@ -169,6 +196,20 @@ public class Calculations } return 5; } + + public static int getNextUpgradeLevelXpLess(int currentLevel) + { + int current = 5; + for (int level : GEMS_FOR_XPLESS_UPGRADE.keySet()) + { + if (level < current && level > currentLevel) + { + current = level; + } + } + + return current; + } /** * Get the next level the player needs to reach to unlock an upgrade @@ -215,4 +256,9 @@ public class Calculations { return GEMS_FOR_UPGRADE.get(getLevelRequiredFor(upgradeLevel)); } + + public static int getGemsCostXpLess(int upgradeLevel) + { + return GEMS_FOR_XPLESS_UPGRADE.get(upgradeLevel); + } } From 43739743bfd3dfc0b2582deb32e03286d594ddce Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 4 May 2017 18:34:58 -0400 Subject: [PATCH 36/99] Add new castle siege game types to Core --- Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java b/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java index cc5ba27d4..eeb057525 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java @@ -15,6 +15,8 @@ public enum GameDisplay BossBattles("Boss Battles", Material.SKULL_ITEM, (byte) 0, GameCategory.EVENT, 55, false), Bridge("The Bridges", Material.IRON_PICKAXE, (byte)0, GameCategory.SURVIVAL, 3, true), CastleSiege("Castle Siege", Material.DIAMOND_CHESTPLATE, (byte)0, GameCategory.CLASSICS, 4, true), + CastleSiegeNew("Castle Siege New", Material.DIAMOND_CHESTPLATE, (byte)0, GameCategory.CLASSICS, 67, true), + CastleSiegeTDM("Castle Siege TDM", Material.DIAMOND_CHESTPLATE, (byte)0, GameCategory.CLASSICS, 68, true), ChampionsDominate("Champions Domination", "Champions", Material.BEACON, (byte)0, GameCategory.CHAMPIONS, 6, true), ChampionsTDM("Champions TDM", "Champions", Material.GOLD_SWORD, (byte)0, GameCategory.CHAMPIONS, 5, true), Christmas("Christmas Chaos", Material.SNOW_BALL, (byte)0, GameCategory.CLASSICS, 8, false), From 901fecb49a83f64380c7b3c35f6ca2c06761ea25 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 4 May 2017 18:36:02 -0400 Subject: [PATCH 37/99] Support multi named tiers of achievements, allow rewarding of xp/gems/crowns upon increasing achievement tiers, and replace old castle siege achievements with new ones --- .../core/achievement/Achievement.java | 125 +++++++++++++++--- .../core/achievement/AchievementCategory.java | 7 +- .../core/achievement/StatDisplay.java | 1 + .../achievement/ui/page/AchievementPage.java | 29 ++-- 4 files changed, 130 insertions(+), 32 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java index 419b8b977..87b22ddad 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java @@ -375,28 +375,76 @@ public enum Achievement AchievementCategory.MASTER_BUILDERS), //Castle Siege - CASTLE_SIEGE_WINS("FOR THE KING!", 600, - new String[]{"Castle Siege.ForTheKing"}, - new String[]{"Win as Defenders 50 times"}, - new int[]{50}, + CASTLE_SIEGE_KILL_STREAK("Kill Streak", 0, + new String[]{"Castle Siege New.KillStreak", "Castle Siege TDM.KillStreak"}, + new String[]{"Earn Kill Streak Rewards"}, + new int[][]{new int[]{0, 50, 500}, new int[]{0, 100, 750}, new int[]{0, 150, 1000}, new int[]{0, 200, 1500}, new int[]{0, 400, 2000}, new int[]{0, 500, 2500}, new int[]{0, 1000, 3000}, new int[]{0, 1500, 3500}, new int[]{0, 2000, 4000}, new int[]{0, 5000, 100000}}, + new int[]{10, 20, 50, 100, 200, 250, 500, 750, 1000, 2000}, + "Novice I", + new String[]{"Novice II", "Novice III", "Novice IV", "Novice V", "Master I", "Master II", "Master III", "Master IV", "GRANDMASTER"}, AchievementCategory.CASTLE_SIEGE), - - CASTLE_SIEGE_KINGSLAYER("Kingslayer", 800, - new String[]{"Castle Siege.KingSlayer"}, - new String[]{"Get the killing blow on the King"}, - new int[]{1}, + + CASTLE_SIEGE_FIRST_BLOOD("First Blood", 0, + new String[]{"Castle Siege New.FirstBlood", "Castle Siege TDM.FirstBlood"}, + new String[]{"Obtain the first kill in a Match"}, + new int[][]{new int[]{0, 100, 100}, new int[]{0, 150, 200}, new int[]{0, 200, 300}, new int[]{0, 250, 400}, new int[]{0, 500, 500}}, + new int[]{2, 5, 10, 25, 50}, + "Novice I", + new String[]{"Novice II", "Novice III", "Novice IV", "Novice V"}, AchievementCategory.CASTLE_SIEGE), - - CASTLE_SIEGE_BLOOD_THIRSTY("Blood Thirsty", 1200, - new String[]{"Castle Siege.BloodThirsty"}, - new String[]{"Kill 50 Undead in a single game"}, - new int[]{1}, + + CASTLE_SIEGE_FIGHTER_KIT("Fighter", 0, + new String[]{"Castle Siege New.FighterKitKills", "Castle Siege TDM.FighterKitKills"}, + new String[]{"Kill opponents while wearing the Fighter Kit"}, + new int[][]{new int[]{0, 100, 500}, new int[]{0, 150, 750}, new int[]{0, 250, 1000}, new int[]{0, 500, 1500}, new int[]{0, 1000, 2500}, new int[]{0, 1500, 3500}, new int[]{0, 2000, 4500}, new int[]{0, 3000, 6000}, new int[]{0, 5000, 10000}, new int[]{0, 10000, 100000}}, + new int[]{50, 100, 250, 500, 1000, 1500, 3000, 5000, 10000, 20000}, + "Novice I", + new String[]{"Novice II", "Novice III", "Novice IV", "Novice V", "Master I", "Master II", "Master III", "Master IV", "GRANDMASTER"}, AchievementCategory.CASTLE_SIEGE), - - CASTLE_SIEGE_ASSASSIN("Assassin", 1000, - new String[]{"Castle Siege.Assassin"}, - new String[]{"Do 50% or more of the damage to the king"}, - new int[]{1}, + + CASTLE_SIEGE_TANK_KIT("Tank", 0, + new String[]{"Castle Siege New.TankKitKills", "Castle Siege TDM.TankKitKills"}, + new String[]{"Kill opponents while wearing the Tank Kit"}, + new int[][]{new int[]{0, 100, 500}, new int[]{0, 150, 750}, new int[]{0, 250, 1000}, new int[]{0, 500, 1500}, new int[]{0, 1000, 2500}, new int[]{0, 1500, 3500}, new int[]{0, 2000, 4500}, new int[]{0, 3000, 6000}, new int[]{0, 5000, 10000}, new int[]{0, 10000, 100000}}, + new int[]{50, 100, 250, 500, 1000, 1500, 3000, 5000, 10000, 20000}, + "Novice I", + new String[]{"Novice II", "Novice III", "Novice IV", "Novice V", "Master I", "Master II", "Master III", "Master IV", "GRANDMASTER"}, + AchievementCategory.CASTLE_SIEGE), + + CASTLE_SIEGE_ARCHER_KIT("Archer", 0, + new String[]{"Castle Siege New.ArcherKitKills", "Castle Siege TDM.ArcherKitKills"}, + new String[]{"Kill opponents while wearing the Archer Kit"}, + new int[][]{new int[]{0, 100, 500}, new int[]{0, 150, 750}, new int[]{0, 250, 1000}, new int[]{0, 500, 1500}, new int[]{0, 1000, 2500}, new int[]{0, 1500, 3500}, new int[]{0, 2000, 4500}, new int[]{0, 3000, 6000}, new int[]{0, 5000, 10000}, new int[]{0, 10000, 100000}}, + new int[]{50, 100, 250, 500, 1000, 1500, 3000, 5000, 10000, 20000}, + "Novice I", + new String[]{"Novice II", "Novice III", "Novice IV", "Novice V", "Master I", "Master II", "Master III", "Master IV", "GRANDMASTER"}, + AchievementCategory.CASTLE_SIEGE), + + CASTLE_SIEGE_DEMOLITIONIST_KIT("Demolitionist", 0, + new String[]{"Castle Siege New.DemolitionistKitKills", "Castle Siege TDM.DemolitionistKitKills"}, + new String[]{"Kill opponents while wearing the Demolitionist Kit"}, + new int[][]{new int[]{0, 100, 500}, new int[]{0, 150, 750}, new int[]{0, 250, 1000}, new int[]{0, 500, 1500}, new int[]{0, 1000, 2500}, new int[]{0, 1500, 3500}, new int[]{0, 2000, 4500}, new int[]{0, 3000, 6000}, new int[]{0, 5000, 10000}, new int[]{0, 10000, 100000}}, + new int[]{50, 100, 250, 500, 1000, 1500, 3000, 5000, 10000, 20000}, + "Novice I", + new String[]{"Novice II", "Novice III", "Novice IV", "Novice V", "Master I", "Master II", "Master III", "Master IV", "GRANDMASTER"}, + AchievementCategory.CASTLE_SIEGE), + + CASTLE_SIEGE_WINNER("Siege", 0, + new String[]{"Castle Siege New.Wins", "Castle Siege TDM.Wins"}, + new String[]{"Win games of Castle Siege"}, + new int[][]{new int[]{0, 100, 500}, new int[]{0, 150, 750}, new int[]{0, 250, 1000}, new int[]{0, 500, 1500}, new int[]{0, 1000, 2500}, new int[]{0, 1500, 3500}, new int[]{0, 2000, 4500}, new int[]{0, 3000, 6000}, new int[]{0, 5000, 10000}, new int[]{0, 10000, 100000}}, + new int[]{2, 5, 25, 50, 100, 150, 250, 500, 1000, 2000}, + "Novice I", + new String[]{"Novice II", "Novice III", "Novice IV", "Novice V", "Master I", "Master II", "Master III", "Master IV", "GRANDMASTER"}, + AchievementCategory.CASTLE_SIEGE), + + CASTLE_SIEGE_MEDALIST("Medalist", 0, + new String[]{"Castle Siege New.MedalsEarned", "Castle Siege TDM.MedalsEarned"}, + new String[]{"Earn Bronze, Silver, or Gold Medals in Castle Siege Matches"}, + new int[][]{new int[]{0, 100, 500}, new int[]{0, 150, 750}, new int[]{0, 250, 1000}, new int[]{0, 500, 1500}, new int[]{0, 1000, 2500}, new int[]{0, 1500, 3500}, new int[]{0, 2000, 4500}, new int[]{0, 3000, 6000}, new int[]{0, 5000, 10000}, new int[]{0, 10000, 100000}}, + new int[]{2, 50, 150, 250, 500, 1000, 1500, 2500, 5000, 10000}, + "Novice I", + new String[]{"Novice II", "Novice III", "Novice IV", "Novice V", "Master I", "Master II", "Master III", "Master IV", "GRANDMASTER"}, AchievementCategory.CASTLE_SIEGE), //Champions @@ -1135,17 +1183,36 @@ public enum Achievement private String _name; private String[] _desc; private String[] _stats; + private int[][] _levelUpRewards; private int[] _levels; + private String _defaultLevelName; + private String[] _levelNames; private int _gems; private AchievementCategory _category; + Achievement(String name, int gems, String[] stats, String[] desc, int[][] levelUpRewards, int[] levels, String defaultLevelName, String[] levelNames, AchievementCategory category) + { + _name = name; + _gems = gems; + _desc = desc; + _stats = stats; + _levelUpRewards = levelUpRewards; + _levels = levels; + _defaultLevelName = defaultLevelName; + _levelNames = levelNames; + _category = category; + } + Achievement(String name, int gems, String[] stats, String[] desc, int[] levels, AchievementCategory category) { _name = name; _gems = gems; _desc = desc; _stats = stats; + _levelUpRewards = new int[][] {}; _levels = levels; + _levelNames = new String[] {}; + _defaultLevelName = ""; _category = category; } @@ -1228,11 +1295,26 @@ public enum Achievement { return _stats; } + + public int[][] getLevelUpRewards() + { + return _levelUpRewards; + } public int[] getLevels() { return _levels; } + + public String getDefaultLevelName() + { + return _defaultLevelName; + } + + public String[] getLevelNames() + { + return _levelNames; + } public int getMaxLevel() { @@ -1248,6 +1330,11 @@ public enum Achievement { return _levels.length == 1; } + + public boolean hasLevelNames() + { + return _levelNames.length > 0; + } public AchievementCategory getCategory() { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java index 37805a3be..3316c653b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java @@ -85,10 +85,9 @@ public enum AchievementCategory new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, Material.BLAZE_ROD, 0, GameCategory.SURVIVAL, "Witch Doctor Kit", false, GameDisplay.Wizards.getGameId()), - CASTLE_SIEGE("Castle Siege", null, - new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, new StatDisplay("Kills as Defenders"), new StatDisplay("Deaths as Defenders"), - new StatDisplay("Kills as Undead"), new StatDisplay("Deaths as Undead"), StatDisplay.GEMS_EARNED }, - Material.DIAMOND_CHESTPLATE, 0, GameCategory.CLASSICS, null, false, GameDisplay.CastleSiege.getGameId()), + CASTLE_SIEGE("Castle Siege", new String[] {"Castle Siege New", "Castle Siege TDM"}, + new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.CROWNS_EARNED }, + Material.DIAMOND_CHESTPLATE, 0, GameCategory.CLASSICS, null, false, GameDisplay.CastleSiegeNew.getGameId()), BAWK_BAWK_BATTLES("Bawk Bawk Battles", null, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.GEMS_EARNED }, diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/StatDisplay.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/StatDisplay.java index a4dc577ed..8609bb12a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/StatDisplay.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/StatDisplay.java @@ -89,6 +89,7 @@ public class StatDisplay public static final StatDisplay KILLS = new StatDisplay("Kills"); public static final StatDisplay DEATHS = new StatDisplay("Deaths"); public static final StatDisplay GEMS_EARNED = new StatDisplay("Gems Earned", "GemsEarned"); + public static final StatDisplay CROWNS_EARNED = new StatDisplay("Crowns Earned", "CrownsEarned"); public static final StatDisplay TIME_IN_GAME = new StatDisplay("Time In Game", "TimeInGame"); public static final StatDisplay GAMES_PLAYED = new StatDisplay("Games Played", "Wins", "Losses"); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/ui/page/AchievementPage.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/ui/page/AchievementPage.java index b0912addd..cdd420cbf 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/ui/page/AchievementPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/ui/page/AchievementPage.java @@ -3,6 +3,15 @@ package mineplex.core.achievement.ui.page; import java.util.ArrayList; import java.util.List; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; + import mineplex.core.account.CoreClientManager; import mineplex.core.achievement.Achievement; import mineplex.core.achievement.AchievementCategory; @@ -20,14 +29,6 @@ import mineplex.core.shop.page.ShopPageBase; import mineplex.core.stats.PlayerStats; import mineplex.core.stats.StatsManager; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.entity.Player; -import org.bukkit.event.inventory.ClickType; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; - public class AchievementPage extends ShopPageBase { private static int ACHIEVEMENT_MIDDLE_INDEX = 31; @@ -68,6 +69,7 @@ public class AchievementPage extends ShopPageBase= achievement.getMaxLevel(); if (!hasUnlocked) @@ -80,7 +82,16 @@ public class AchievementPage extends ShopPageBase lore = new ArrayList(); lore.add(" "); From 7b70695e12298e729c4c8dfd34c074cb28c16732 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 4 May 2017 18:40:57 -0400 Subject: [PATCH 38/99] Update arcade games with new crown/gem toggle and flint and steel permission flag --- .../nautilus/game/arcade/ArcadeManager.java | 16 +++++-- .../src/nautilus/game/arcade/game/Game.java | 5 ++ .../game/arcade/managers/GameFlagManager.java | 6 +++ .../arcade/managers/GameRewardManager.java | 48 +++++++++++++------ 4 files changed, 55 insertions(+), 20 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java index 20c226a03..d1aeddf52 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -4,8 +4,6 @@ import java.io.File; import java.util.ArrayList; import java.util.HashSet; -import net.minecraft.server.v1_8_R3.EntityLiving; - import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.GameMode; @@ -123,7 +121,6 @@ import mineplex.minecraft.game.core.condition.ConditionManager; import mineplex.minecraft.game.core.damage.DamageManager; import mineplex.minecraft.game.core.fire.Fire; import mineplex.serverdata.Region; - import nautilus.game.arcade.addons.SoupAddon; import nautilus.game.arcade.booster.GameBoosterManager; import nautilus.game.arcade.command.CancelNextGameCommand; @@ -168,6 +165,7 @@ import nautilus.game.arcade.managers.lobby.current.NewGameLobbyManager; import nautilus.game.arcade.managers.lobby.legacy.LegacyGameLobbyManager; import nautilus.game.arcade.player.ArcadePlayer; import nautilus.game.arcade.shop.ArcadeShop; +import net.minecraft.server.v1_8_R3.EntityLiving; public class ArcadeManager extends MiniPlugin implements IRelation { @@ -495,7 +493,6 @@ public class ArcadeManager extends MiniPlugin implements IRelation scoreboard.get(ArcadeScoreboardLine.PLAYERS_NAME).write(C.cYellow + C.Bold + "Players"); scoreboard.get(ArcadeScoreboardLine.KIT_NAME).write(C.cGray + C.Bold + "Kit"); - scoreboard.get(ArcadeScoreboardLine.GEM_NAME).write(C.cGreen + C.Bold + "Gems"); scoreboard.get(ArcadeScoreboardLine.SERVER_NAME).write(C.cAqua + C.Bold + "Server"); scoreboard.get(ArcadeScoreboardLine.SERVER_VALUE).write(_plugin.getConfig().getString("serverstatus.name")); } @@ -520,7 +517,16 @@ public class ArcadeManager extends MiniPlugin implements IRelation } scoreboard.get(ArcadeScoreboardLine.PLAYERS_VALUE).write(_gameManager.getValidPlayersForGameStart().size() + "/" + GetPlayerFull()); - scoreboard.get(ArcadeScoreboardLine.GEM_VALUE).write(donationManager.Get(scoreboard.getOwner()).getBalance(GlobalCurrency.GEM)); + if (GetGame() != null && GetGame().CrownsEnabled) + { + scoreboard.get(ArcadeScoreboardLine.GEM_NAME).write(C.cGold + C.Bold + "Crowns"); + scoreboard.get(ArcadeScoreboardLine.GEM_VALUE).write(donationManager.getCrowns(scoreboard.getOwner())); + } + else + { + scoreboard.get(ArcadeScoreboardLine.GEM_NAME).write(C.cGreen + C.Bold + "Gems"); + scoreboard.get(ArcadeScoreboardLine.GEM_VALUE).write(donationManager.Get(scoreboard.getOwner()).getBalance(GlobalCurrency.GEM)); + } if (GetGame() != null) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java index 89fe831d5..90d008a25 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java @@ -252,6 +252,8 @@ public abstract class Game extends ListenerComponent implements Lifetimed public boolean WorldSoilTrample = false; public boolean WorldBoneMeal = false; public boolean WorldChunkUnload = false; + + public boolean AllowFlintAndSteel = false; public int HungerSet = -1; public int HealthSet = -1; @@ -316,6 +318,8 @@ public abstract class Game extends ListenerComponent implements Lifetimed public final ChatStatData BlankLine = new ChatStatData().blankLine(); // Gems + public boolean CrownsEnabled = false; + public double GemMultiplier = 1; public boolean GemHunterEnabled = true; public boolean GemBoosterEnabled = true; @@ -334,6 +338,7 @@ public abstract class Game extends ListenerComponent implements Lifetimed public Location SpectatorSpawn = null; public boolean FirstKill = true; + public int FirstKillReward = 10; public String Winner = "Nobody"; public GameTeam WinnerTeam = null; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java index b7a2119d0..68791ddff 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameFlagManager.java @@ -54,6 +54,7 @@ import org.bukkit.event.block.Action; import org.bukkit.event.block.BlockBurnEvent; import org.bukkit.event.block.BlockGrowEvent; import org.bukkit.event.block.BlockIgniteEvent; +import org.bukkit.event.block.BlockIgniteEvent.IgniteCause; import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.block.LeavesDecayEvent; import org.bukkit.event.entity.CreatureSpawnEvent; @@ -1172,6 +1173,11 @@ public class GameFlagManager implements Listener if (game.WorldFireSpread) return; + if (event.getCause() == IgniteCause.FLINT_AND_STEEL && game.AllowFlintAndSteel) + { + return; + } + event.setCancelled(true); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameRewardManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameRewardManager.java index f1834bdaf..2e5e4fbdf 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameRewardManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameRewardManager.java @@ -80,7 +80,7 @@ public class GameRewardManager implements Listener //First Kill if (game.FirstKill) { - game.AddGems(killer, 10, "First Blood", false, false); + game.AddGems(killer, game.FirstKillReward, "First Blood", false, false); Manager.getPluginManager().callEvent(new FirstBloodEvent(killer)); @@ -191,7 +191,7 @@ public class GameRewardManager implements Listener } // Gem Finder - if (game.GemHunterEnabled) + if (game.GemHunterEnabled && !game.CrownsEnabled) { int gemFinder = Manager.GetAchievement().get(player, Achievement.GLOBAL_GEM_HUNTER).getLevel(); if (gemFinder > 0) @@ -216,7 +216,7 @@ public class GameRewardManager implements Listener } } - if (DoubleGem && game.GemDoubleEnabled) + if (DoubleGem && game.GemDoubleEnabled && !game.CrownsEnabled) gemsToReward += baseGemsEarned; Rank rank = Manager.GetClients().Get(player).GetRank(); @@ -232,17 +232,35 @@ public class GameRewardManager implements Listener shardsToReward += baseShardsEarned * 2; else if (rank.has(Rank.ETERNAL)) shardsToReward += baseShardsEarned * 2.5; - - Manager.GetDonation().rewardCurrency(GlobalCurrency.GEM, player, "Earned " + game.GetName(), gemsToReward); + + if (!game.CrownsEnabled) + { + Manager.GetDonation().rewardCurrency(GlobalCurrency.GEM, player, "Earned " + game.GetName(), gemsToReward); + } + else + { + Manager.GetDonation().rewardCrowns(gemsToReward, player); + } if (accountId != -1) { Manager.GetDonation().rewardCurrencyUntilSuccess(GlobalCurrency.TREASURE_SHARD, player, "Earned", shardsToReward); } - Manager.getTrackManager().getTrack(GemCollectorTrack.class).earnedGems(player, gemsToReward); + if (!game.CrownsEnabled) + { + Manager.getTrackManager().getTrack(GemCollectorTrack.class).earnedGems(player, gemsToReward); + } //Stats - Manager.GetStatsManager().incrementStat(player, "Global.GemsEarned", gemsToReward); - Manager.GetStatsManager().incrementStat(player, game.GetName() + ".GemsEarned", gemsToReward); + if (!game.CrownsEnabled) + { + Manager.GetStatsManager().incrementStat(player, "Global.GemsEarned", gemsToReward); + Manager.GetStatsManager().incrementStat(player, game.GetName() + ".GemsEarned", gemsToReward); + } + else + { + Manager.GetStatsManager().incrementStat(player, "Global.CrownsEarned", gemsToReward); + Manager.GetStatsManager().incrementStat(player, game.GetName() + ".CrownsEarned", gemsToReward); + } } private void changeName(Player player, String newName) @@ -274,7 +292,7 @@ public class GameRewardManager implements Listener UtilPlayer.message(player, ""); UtilPlayer.message(player, ArcadeFormat.Line); - UtilPlayer.message(player, Manager.IsRewardGems() ? "§f§lGems Earned" : "§f§lGame Stats"); + UtilPlayer.message(player, Manager.IsRewardGems() ? (game.CrownsEnabled ? "§f§lCrowns Earned" : "§f§lGems Earned") : "§f§lGame Stats"); UtilPlayer.message(player, ""); int earnedGems = 0; @@ -294,7 +312,7 @@ public class GameRewardManager implements Listener String out = ""; if (Manager.IsRewardGems()) - out += F.elem(C.cGreen + "+" + (int) (gemCount * game.GemMultiplier) + " Gems") + " for "; + out += F.elem((game.CrownsEnabled ? C.cGold : C.cGreen) + "+" + (int) (gemCount * game.GemMultiplier) + (game.CrownsEnabled ? " Crowns" : " Gems")) + " for "; out += F.elem(amountStr + type); UtilPlayer.message(player, out); @@ -313,7 +331,7 @@ public class GameRewardManager implements Listener int totalGems = earnedGems; //Gem Finder - if (game.GemHunterEnabled) + if (game.GemHunterEnabled && !game.CrownsEnabled) { int gemFinder = Manager.GetAchievement().get(player, Achievement.GLOBAL_GEM_HUNTER).getLevel(); if (gemFinder > 0) @@ -341,7 +359,7 @@ public class GameRewardManager implements Listener if (extraGems > 0) { - UtilPlayer.message(player, F.elem(C.cGreen + "+" + extraGems + " Gems") + " for " + + UtilPlayer.message(player, F.elem((game.CrownsEnabled ? C.cGold : C.cGreen) + "+" + extraGems + (game.CrownsEnabled ? " Crowns" : " Gems")) + " for " + F.elem("Online for " + UtilTime.MakeStr(timeOnline) + C.cGreen + " +" + (int) (hoursOnline * 20) + "%")); totalGems += extraGems; @@ -350,7 +368,7 @@ public class GameRewardManager implements Listener } //Double Gem - if (DoubleGem && game.GemDoubleEnabled) + if (DoubleGem && game.GemDoubleEnabled && !game.CrownsEnabled) { UtilPlayer.message(player, F.elem(C.cGreen + "+" + (earnedGems) + " Gems") + " for " + F.elem(C.cDGreen + "Double Gem Weekend")); @@ -393,13 +411,13 @@ public class GameRewardManager implements Listener if (give) { UtilPlayer.message(player, F.elem(C.cWhite + "§lYou now have " + - C.cGreen + C.Bold + (Manager.GetDonation().Get(player.getUniqueId()).getBalance(GlobalCurrency.GEM) + totalGems) + " Gems") + C.cWhite + C.Bold + " and " + + (game.CrownsEnabled ? (C.cGoldB + (Manager.GetDonation().getCrowns(player) + totalGems) + " Crowns") : (C.cGreenB + (Manager.GetDonation().Get(player.getUniqueId()).getBalance(GlobalCurrency.GEM) + totalGems) + " Gems"))) + C.cWhite + C.Bold + " and " + F.elem(C.cAqua + C.Bold + (Manager.GetDonation().Get(player.getUniqueId()).getBalance(GlobalCurrency.TREASURE_SHARD) + shards) + " Treasure Shards")); } else { UtilPlayer.message(player, F.elem(C.cWhite + "§lGame is still in progress...")); - UtilPlayer.message(player, F.elem(C.cWhite + "§lYou may earn more " + C.cGreen + C.Bold + "Gems" + C.cWhite + C.Bold + " when its completed.")); + UtilPlayer.message(player, F.elem(C.cWhite + "§lYou may earn more " + (game.CrownsEnabled ? (C.cGoldB + "Crowns") : (C.cGreenB + "Gems")) + C.cWhite + C.Bold + " when it's completed.")); } UtilPlayer.message(player, ArcadeFormat.Line); From ac98213d2833551cc9631183a88037e9ec96c9d9 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 4 May 2017 18:59:41 -0400 Subject: [PATCH 39/99] Update several perks to support vanilla damage system and kit progression --- .../game/arcade/kit/perks/PerkBomberHG.java | 63 +++++++++++++----- .../arcade/kit/perks/PerkFallModifier.java | 35 ++++++++-- .../game/arcade/kit/perks/PerkFletcher.java | 12 ++++ .../game/arcade/kit/perks/PerkIronSkin.java | 66 +++++++++++++++++-- 4 files changed, 152 insertions(+), 24 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBomberHG.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBomberHG.java index 947e7a3aa..7edda2765 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBomberHG.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkBomberHG.java @@ -1,6 +1,16 @@ package nautilus.game.arcade.kit.perks; import java.util.HashSet; +import java.util.Set; + +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.player.PlayerDropItemEvent; +import org.bukkit.inventory.ItemStack; import mineplex.core.common.util.C; import mineplex.core.common.util.F; @@ -13,20 +23,18 @@ import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; import nautilus.game.arcade.kit.Perk; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.entity.PlayerDeathEvent; -import org.bukkit.event.inventory.InventoryClickEvent; -import org.bukkit.event.player.PlayerDropItemEvent; - public class PerkBomberHG extends Perk { private int _spawnRate; private int _max; - + private boolean _onlyRestrictNamed; + public PerkBomberHG(int spawnRate, int max) + { + this(spawnRate, max, false); + } + + public PerkBomberHG(int spawnRate, int max, boolean onlyRestrictNamed) { super("Explosives", new String[] { @@ -35,6 +43,7 @@ public class PerkBomberHG extends Perk _spawnRate = spawnRate; _max = max; + _onlyRestrictNamed = onlyRestrictNamed; } public void Apply(Player player) @@ -53,13 +62,19 @@ public class PerkBomberHG extends Perk if (!Kit.HasKit(cur)) continue; + if (!hasPerk(cur)) + continue; + if (!Manager.GetGame().IsAlive(cur)) continue; if (!Recharge.Instance.use(cur, GetName(), _spawnRate*1000, false, false)) continue; - if (UtilInv.contains(cur, Material.TNT, (byte)0, _max)) + if (_onlyRestrictNamed ? UtilInv.contains(cur, F.item("Throwing TNT"), Material.TNT, (byte)0, _max) : UtilInv.contains(cur, Material.TNT, (byte)0, _max)) + continue; + + if (UtilPlayer.isSpectator(cur)) continue; //Add @@ -75,7 +90,13 @@ public class PerkBomberHG extends Perk if (event.isCancelled()) return; - if (!UtilInv.IsItem(event.getItemDrop().getItemStack(), Material.TNT, (byte)0)) + if (_onlyRestrictNamed ? !UtilInv.IsItem(event.getItemDrop().getItemStack(), F.item("Throwing TNT"), Material.TNT, (byte)0) : !UtilInv.IsItem(event.getItemDrop().getItemStack(), Material.TNT, (byte)0)) + return; + + if (!Kit.HasKit(event.getPlayer())) + return; + + if (!hasPerk(event.getPlayer())) return; //Cancel @@ -91,23 +112,33 @@ public class PerkBomberHG extends Perk //boolean containerOpen = !(event.getView().getTopInventory().getHolder() instanceof Player); boolean clickInContainer = event.getClickedInventory() != null && !(event.getClickedInventory().getHolder() instanceof Player); - if(clickInContainer) + if (clickInContainer) { return; } + + if (!(event.getWhoClicked() instanceof Player)) + return; + + if (!Kit.HasKit((Player)event.getWhoClicked())) + return; + + if (!hasPerk((Player)event.getWhoClicked())) + return; + UtilInv.DisallowMovementOf(event, "Throwing TNT", Material.TNT, (byte) 0, true); } @EventHandler public void TNTDeathRemove(PlayerDeathEvent event) { - HashSet remove = new HashSet(); + Set remove = new HashSet<>(); - for (org.bukkit.inventory.ItemStack item : event.getDrops()) - if (UtilInv.IsItem(item, Material.TNT, (byte)0)) + for (ItemStack item : event.getDrops()) + if (_onlyRestrictNamed ? UtilInv.IsItem(item, "Throwing TNT", Material.TNT, (byte)0) : UtilInv.IsItem(item, Material.TNT, (byte)0)) remove.add(item); - for (org.bukkit.inventory.ItemStack item : remove) + for (ItemStack item : remove) event.getDrops().remove(item); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFallModifier.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFallModifier.java index bb8decc97..3068c6bc4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFallModifier.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFallModifier.java @@ -1,13 +1,16 @@ package nautilus.game.arcade.kit.perks; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import nautilus.game.arcade.kit.Perk; - import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import mineplex.core.Managers; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import mineplex.minecraft.game.core.damage.DamageManager; +import nautilus.game.arcade.kit.Perk; + public class PerkFallModifier extends Perk { private double _fall; @@ -41,4 +44,28 @@ public class PerkFallModifier extends Perk event.AddMod("Fall Modifier", "Reduce damage", _fall, false); } -} + + @EventHandler(priority = EventPriority.HIGH) + public void handle(EntityDamageEvent event) + { + if (Managers.get(DamageManager.class).IsEnabled()) + { + return; + } + if (event.getCause() != DamageCause.FALL) + return; + + if (!(event.getEntity() instanceof Player)) + return; + + Player player = (Player) event.getEntity(); + + if (!Kit.HasKit(player)) + return; + + if (!Manager.IsAlive(player)) + return; + + event.setDamage(event.getDamage() * _fall); + } +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFletcher.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFletcher.java index 3867996c0..1b2e54207 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFletcher.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkFletcher.java @@ -183,6 +183,9 @@ public class PerkFletcher extends Perk if (!isFletchedArrow(event.getItemDrop().getItemStack())) return; + + if (!hasPerk(event.getPlayer())) + return; //Cancel event.setCancelled(true); @@ -207,6 +210,15 @@ public class PerkFletcher extends Perk @EventHandler public void FletchInvClick(InventoryClickEvent event) { + if (!(event.getWhoClicked() instanceof Player)) + { + return; + } + + if (!hasPerk((Player)event.getWhoClicked())) + { + return; + } UtilInv.DisallowMovementOf(event, _name, Material.ARROW, (byte)0, true); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkIronSkin.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkIronSkin.java index ec662a740..9db6fb6d1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkIronSkin.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/perks/PerkIronSkin.java @@ -3,23 +3,33 @@ package nautilus.game.arcade.kit.perks; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import mineplex.core.Managers; import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import mineplex.minecraft.game.core.damage.DamageManager; import nautilus.game.arcade.kit.Perk; public class PerkIronSkin extends Perk { private double _reduction; + private boolean _percentage; - public PerkIronSkin(double d) + public PerkIronSkin(double d) + { + this(d, false); + } + + public PerkIronSkin(double d, boolean percentage) { super("Iron Skin", new String[] { - "You take " + d + " less damage from attacks", + "You take " + (d * (percentage ? 100 : 1)) + (percentage ? "%" : "") + " less damage from attacks", }); _reduction = d; + _percentage = percentage; } @EventHandler(priority = EventPriority.HIGH) @@ -40,6 +50,54 @@ public class PerkIronSkin extends Perk if (!Kit.HasKit(damagee)) return; - event.AddMod(damagee.getName(), GetName(), -_reduction, false); + if (!hasPerk(damagee)) + return; + + if (_percentage) + { + event.AddMult(damagee.getName(), GetName(), _reduction, false); + } + else + { + event.AddMod(damagee.getName(), GetName(), -_reduction, false); + } } -} + + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) + public void damageDecrease(EntityDamageEvent event) + { + if (Managers.get(DamageManager.class).IsEnabled()) + { + return; + } + + if (event.getCause() == DamageCause.FIRE_TICK) + return; + + if (event.getDamage() <= 1) + return; + + if (!(event.getEntity() instanceof Player)) + return; + + Player damagee = (Player) event.getEntity(); + + if (!Kit.HasKit(damagee)) + return; + + if (!hasPerk(damagee)) + return; + + if (!Manager.IsAlive(damagee)) + return; + + if (_percentage) + { + event.setDamage(event.getDamage() * _reduction); + } + else + { + event.setDamage(event.getDamage() - _reduction); + } + } +} \ No newline at end of file From 97a4b8e94dc05857fbe23d5096b5cf6f254195e4 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 4 May 2017 19:00:05 -0400 Subject: [PATCH 40/99] Add implementation for crown and xp toggles in ProgressingKit --- .../game/arcade/kit/ProgressingKit.java | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/ProgressingKit.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/ProgressingKit.java index 75cf10209..ff7c6fdeb 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/ProgressingKit.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/kit/ProgressingKit.java @@ -18,7 +18,6 @@ import org.bukkit.entity.EntityType; import org.bukkit.entity.Firework; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.PlayerInventory; import org.bukkit.inventory.meta.FireworkMeta; import org.bukkit.scheduler.BukkitRunnable; @@ -319,7 +318,23 @@ public abstract class ProgressingKit extends Kit implements ProgressiveKit { PlayerKit playerKit = _dataManager.get(player); Donor donor = Manager.GetDonation().Get(Bukkit.getPlayer(player)); - return Calculations.canUpgrade(Calculations.getNextUpgradeLevel(playerKit.getLevel(getInternalName())), donor.getBalance(GlobalCurrency.GEM)) && playerKit.getLevel(getInternalName()) >= Calculations.getLevelRequiredFor(upgradeLevel); + int balance = donor.getBalance(GlobalCurrency.GEM); + + if (crownsEnabled()) + { + if (getUpgradeLevel(player) != (upgradeLevel - 1)) + { + return false; + } + balance = Manager.GetDonation().getCrowns(player); + } + + if (!usesXp()) + { + return Calculations.canUpgradeXpLess(upgradeLevel, balance); + } + + return Calculations.canUpgrade(Calculations.getNextUpgradeLevel(playerKit.getLevel(getInternalName())), balance) && playerKit.getLevel(getInternalName()) >= Calculations.getLevelRequiredFor(upgradeLevel); } @Override @@ -427,7 +442,7 @@ public abstract class ProgressingKit extends Kit implements ProgressiveKit public static String receiveItem(String item, int amount) { - return "Receive " + (amount == 1 ? (UtilText.startsWithVowel(item) ? "an" :" a") : C.cGreen + amount) + " " + item; + return "Receive " + (amount == 1 ? (UtilText.startsWithVowel(item) ? "an" :"a") : C.cGreen + amount) + " " + item; } public static String click(boolean left, String comp) From 455e09a9da31f843152bec8b6daa905115e28f07 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 4 May 2017 19:00:47 -0400 Subject: [PATCH 41/99] More implementation of xp toggles for kit progression, and display achievement rewards properly for tiered leveling --- .../managers/GameAchievementManager.java | 105 ++++++++++++++---- .../managers/ProgressingKitManager.java | 4 + 2 files changed, 88 insertions(+), 21 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameAchievementManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameAchievementManager.java index a14d161d7..5465f386f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameAchievementManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameAchievementManager.java @@ -1,11 +1,18 @@ package nautilus.game.arcade.managers; +import org.bukkit.ChatColor; +import org.bukkit.Sound; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerJoinEvent; + import mineplex.core.achievement.Achievement; import mineplex.core.achievement.AchievementData; import mineplex.core.achievement.AchievementLog; import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.util.C; -import mineplex.core.common.util.Callback; import mineplex.core.common.util.F; import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.UtilPlayer; @@ -16,14 +23,6 @@ import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.Game.GameState; -import org.bukkit.ChatColor; -import org.bukkit.Sound; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerJoinEvent; - public class GameAchievementManager implements Listener { ArcadeManager Manager; @@ -84,13 +83,21 @@ public class GameAchievementManager implements Listener //Display for (final Achievement type : log.keySet()) { - - AchievementData data = Manager.GetAchievement().get(player, type); String nameLevel = F.elem(C.cGold + C.Bold + type.getName()); - if (type.getMaxLevel() > 1) - nameLevel = F.elem(C.cGold + C.Bold + type.getName() + " " + ChatColor.RESET + C.cYellow + data.getLevel() + C.cGold + "/" + C.cYellow + type.getMaxLevel()); + if (type.getMaxLevel() > 1) + { + if (type.hasLevelNames()) + { + String tier = data.getLevel() == 0 ? type.getDefaultLevelName() : type.getLevelNames()[Math.min(data.getLevel(), type.getLevelNames().length) - 1]; + nameLevel = F.elem(C.cGold + C.Bold + type.getName() + " " + ChatColor.RESET + C.cYellow + "Tier: " + tier); + } + else + { + nameLevel = F.elem(C.cGold + C.Bold + type.getName() + " " + ChatColor.RESET + C.cYellow + data.getLevel() + C.cGold + "/" + C.cYellow + type.getMaxLevel()); + } + } String progress = F.elem(C.cGreen + "+" + log.get(type).Amount); @@ -102,17 +109,51 @@ public class GameAchievementManager implements Listener //Finishing for the first time if (!Manager.GetTaskManager().hasCompletedTask(player, type.getName())) { + int gems = type.getGemReward(); + int crowns = 0; + int xp = 0; + if (type.getLevelUpRewards().length > 0) + { + int[] rewards = type.getLevelUpRewards()[type.getLevelUpRewards().length - 1]; + gems += rewards[0]; + crowns += rewards[1]; + xp += rewards[2]; + } UtilPlayer.message(player, ""); - UtilPlayer.message(player, nameLevel + " " + F.elem(C.cAqua + C.Bold + "Completed!") + - " " + F.elem(C.cGreen + C.Bold + "+" + type.getGemReward() + " Gems")); + String inform = nameLevel + " " + F.elem(C.cAqua + C.Bold + "Completed!"); + if (gems > 0) + { + inform += " " + F.elem(C.cGreen + C.Bold + "+" + gems + " Gems"); + } + if (crowns > 0) + { + inform += " " + F.elem(C.cGold + C.Bold + "+" + crowns + " Crowns"); + } + if (xp > 0 && !Manager.GetTaskManager().hasCompletedTask(player, Achievement.GLOBAL_MINEPLEX_LEVEL.getName())) + { + inform += " " + F.elem(C.cYellow + C.Bold + "+" + xp + " XP"); + } + UtilPlayer.message(player, inform); player.playSound(player.getLocation(), Sound.LEVEL_UP, 1f, 1f); - Manager.GetTaskManager().completedTask(new Callback() + final int finalGems = gems; + final int finalCrowns = crowns; + final int finalXp = xp; + + Manager.GetTaskManager().completedTask(completed -> { - public void run(Boolean completed) + if (finalGems > 0) { - Manager.GetDonation().rewardCurrency(GlobalCurrency.GEM, player, type.getName(), type.getGemReward()); + Manager.GetDonation().rewardCurrency(GlobalCurrency.GEM, player, type.getName(), finalGems); + } + if (finalCrowns > 0) + { + Manager.GetDonation().rewardCrowns(finalCrowns, player); + } + if (finalXp > 0) + { + Manager.GetStatsManager().incrementStat(player, Achievement.GLOBAL_MINEPLEX_LEVEL.getStats()[0], finalXp); } }, player, type.getName()); } @@ -125,9 +166,31 @@ public class GameAchievementManager implements Listener //Multi-Level Achievements else if (log.get(type).LevelUp) { + int gems = 0; + int crowns = 0; + int xp = 0; + if (type.getLevelUpRewards().length > 0) + { + int[] rewards = type.getLevelUpRewards()[Math.min(data.getLevel(), type.getLevelUpRewards().length) - 1]; + gems += rewards[0]; + crowns += rewards[1]; + xp += rewards[2]; + } UtilPlayer.message(player, ""); - UtilPlayer.message(player, nameLevel + " " + progress + - " " + F.elem(C.cAqua + C.Bold + "LEVEL UP!")); + String inform = nameLevel + " " + progress + " " + F.elem(C.cAqua + C.Bold + "LEVEL UP!"); + if (gems > 0) + { + inform += " " + F.elem(C.cGreen + C.Bold + "+" + gems + " Gems"); + } + if (crowns > 0) + { + inform += " " + F.elem(C.cGold + C.Bold + "+" + crowns + " Crowns"); + } + if (xp > 0 && !Manager.GetTaskManager().hasCompletedTask(player, Achievement.GLOBAL_MINEPLEX_LEVEL.getName())) + { + inform += " " + F.elem(C.cYellow + C.Bold + "+" + xp + " XP"); + } + UtilPlayer.message(player, inform); player.playSound(player.getLocation(), Sound.LEVEL_UP, 1f, 1f); } @@ -179,4 +242,4 @@ public class GameAchievementManager implements Listener UtilPlayer.message(player, ""); UtilPlayer.message(player, ArcadeFormat.Line); } -} +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/ProgressingKitManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/ProgressingKitManager.java index 6491ee32c..fd043926f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/ProgressingKitManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/ProgressingKitManager.java @@ -263,6 +263,10 @@ public class ProgressingKitManager implements Listener { return; } + if (!data.getKit().usesXp()) + { + return; + } player.sendMessage(SPACE); From 00d31ffad3781fa214293e4e9efae59b960a3733 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 4 May 2017 20:46:38 -0400 Subject: [PATCH 42/99] Fix item builder to properly use null item titles --- .../src/mineplex/core/itemstack/ItemBuilder.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/itemstack/ItemBuilder.java b/Plugins/Mineplex.Core/src/mineplex/core/itemstack/ItemBuilder.java index b0a1f825d..603f5e150 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/itemstack/ItemBuilder.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/itemstack/ItemBuilder.java @@ -400,9 +400,14 @@ public class ItemBuilder public ItemBuilder setTitle(String title) { - _title = (title == null ? null - : (title.length() > 2 && ChatColor.getLastColors(title.substring(0, 2)).length() == 0 ? ChatColor.WHITE : "")) - + title; + if (title == null) + { + _title = null; + } + else + { + _title = ((title.length() > 2 && ChatColor.getLastColors(title.substring(0, 2)).length() == 0) ? ChatColor.WHITE : "") + title; + } return this; } From a635793edefe5dc3508804c68c30c54a10bf9d60 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 4 May 2017 22:00:47 -0400 Subject: [PATCH 43/99] Add new Castle Siege modes --- .../src/nautilus/game/arcade/GameType.java | 5 +- .../games/castlesiege/CastleSiegeTDM.java | 1152 +++++++++++++ .../games/castlesiege/ShockCastleSiege.java | 1448 +++++++++++++++++ .../games/castlesiege/data/CapturePoint.java | 71 + .../castlesiege/data/KillStreakData.java | 47 + .../castlesiege/data/ObjectiveTNTSpawner.java | 81 + .../games/castlesiege/data/TeamBeacon.java | 48 + .../game/games/castlesiege/data/TeamKing.java | 122 ++ .../castlesiege/data/medals/MedalData.java | 55 + .../castlesiege/data/medals/MedalType.java | 21 + .../castlesiege/shockkits/KitAlchemist.java | 32 + .../castlesiege/shockkits/KitArcher.java | 133 ++ .../castlesiege/shockkits/KitBuilder.java | 32 + .../shockkits/KitDemolitionist.java | 148 ++ .../castlesiege/shockkits/KitEnchanter.java | 35 + .../castlesiege/shockkits/KitFighter.java | 126 ++ .../castlesiege/shockkits/KitHardline.java | 30 + .../games/castlesiege/shockkits/KitNinja.java | 33 + .../castlesiege/shockkits/KitPlayer.java | 65 + .../games/castlesiege/shockkits/KitTank.java | 133 ++ .../castlesiege/shockkits/KitWorkman.java | 33 + .../castlesiege/shockkits/PerkBloodlust.java | 135 ++ 22 files changed, 3984 insertions(+), 1 deletion(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiegeTDM.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/ShockCastleSiege.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/data/CapturePoint.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/data/KillStreakData.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/data/ObjectiveTNTSpawner.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/data/TeamBeacon.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/data/TeamKing.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/data/medals/MedalData.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/data/medals/MedalType.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitAlchemist.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitArcher.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitBuilder.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitDemolitionist.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitEnchanter.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitFighter.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitHardline.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitNinja.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitPlayer.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitTank.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitWorkman.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/PerkBloodlust.java diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java index 66bef53c0..b15bfdfb5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java @@ -6,7 +6,6 @@ import mineplex.core.common.MinecraftVersion; import mineplex.core.common.Pair; import mineplex.core.game.GameCategory; import mineplex.core.game.GameDisplay; - import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.games.baconbrawl.BaconBrawl; import nautilus.game.arcade.game.games.barbarians.Barbarians; @@ -26,6 +25,8 @@ import nautilus.game.arcade.game.games.build.modes.TeamBuild; import nautilus.game.arcade.game.games.buildmavericks.BuildMavericks; import nautilus.game.arcade.game.games.cards.Cards; import nautilus.game.arcade.game.games.castlesiege.CastleSiege; +import nautilus.game.arcade.game.games.castlesiege.CastleSiegeTDM; +import nautilus.game.arcade.game.games.castlesiege.ShockCastleSiege; import nautilus.game.arcade.game.games.champions.ChampionsCTF; import nautilus.game.arcade.game.games.champions.ChampionsDominate; import nautilus.game.arcade.game.games.champions.ChampionsTDM; @@ -131,6 +132,8 @@ public enum GameType BossBattles(BossBattles.class, GameDisplay.BossBattles), Bridge(Bridge.class, GameDisplay.Bridge), CastleSiege(CastleSiege.class, GameDisplay.CastleSiege), + CastleSiegeNew(ShockCastleSiege.class, GameDisplay.CastleSiegeNew), + CastleSiegeTDM(CastleSiegeTDM.class, GameDisplay.CastleSiegeTDM), ChampionsCTF(ChampionsCTF.class, GameDisplay.ChampionsCTF), ChampionsDominate(ChampionsDominate.class, GameDisplay.ChampionsDominate), ChampionsTDM(ChampionsTDM.class, GameDisplay.ChampionsTDM), diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiegeTDM.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiegeTDM.java new file mode 100644 index 000000000..56e117868 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiegeTDM.java @@ -0,0 +1,1152 @@ +package nautilus.game.arcade.game.games.castlesiege; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.WeakHashMap; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.block.Chest; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.EnderPearl; +import org.bukkit.entity.Entity; +import org.bukkit.entity.ItemFrame; +import org.bukkit.entity.Painting; +import org.bukkit.entity.Player; +import org.bukkit.entity.TNTPrimed; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.block.BlockBurnEvent; +import org.bukkit.event.block.BlockDispenseEvent; +import org.bukkit.event.block.BlockFadeEvent; +import org.bukkit.event.block.BlockFromToEvent; +import org.bukkit.event.block.LeavesDecayEvent; +import org.bukkit.event.entity.ExplosionPrimeEvent; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.entity.ProjectileHitEvent; +import org.bukkit.event.hanging.HangingBreakEvent; +import org.bukkit.event.inventory.InventoryAction; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.inventory.InventoryType; +import org.bukkit.event.inventory.PrepareItemCraftEvent; +import org.bukkit.event.player.PlayerBucketEmptyEvent; +import org.bukkit.event.player.PlayerBucketFillEvent; +import org.bukkit.event.player.PlayerDropItemEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.material.Dispenser; +import org.bukkit.material.MaterialData; +import org.bukkit.metadata.MetadataValue; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.itemstack.EnchantedBookBuilder; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.loot.ChestLoot; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.combat.DeathMessageType; +import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.GameType; +import nautilus.game.arcade.events.FirstBloodEvent; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.GemData; +import nautilus.game.arcade.game.TeamGame; +import nautilus.game.arcade.game.games.castlesiege.data.KillStreakData; +import nautilus.game.arcade.game.games.castlesiege.data.medals.MedalData; +import nautilus.game.arcade.game.games.castlesiege.data.medals.MedalData.MedalLevel; +import nautilus.game.arcade.game.games.castlesiege.data.medals.MedalType; +import nautilus.game.arcade.game.games.castlesiege.shockkits.KitArcher; +import nautilus.game.arcade.game.games.castlesiege.shockkits.KitDemolitionist; +import nautilus.game.arcade.game.games.castlesiege.shockkits.KitFighter; +import nautilus.game.arcade.game.games.castlesiege.shockkits.KitPlayer; +import nautilus.game.arcade.game.games.castlesiege.shockkits.KitTank; +import nautilus.game.arcade.game.modules.compass.CompassModule; +import nautilus.game.arcade.kit.Kit; + +public class CastleSiegeTDM extends TeamGame +{ + private static final int MAX_FLINT_AND_STEEL_USES = 4; + private static final int ITEMS_PER_CHEST = 5; + private static final long TIME_TILL_REFILL = 2 * 60 * 1000; + + private long _lastRefill; + + private ItemBuilder _flintAndSteel; + + private Map _streakData = new WeakHashMap<>(); + private Map _medalData = new WeakHashMap<>(); + private Map _teamKills = new HashMap<>(); + + private List _chests = new ArrayList<>(); + + private ChestLoot _diamondGearCommon = new ChestLoot(true); + private ChestLoot _diamondGearRare = new ChestLoot(true); + private ChestLoot _weaponGearCommon = new ChestLoot(true); + private ChestLoot _weaponGearRare = new ChestLoot(true); + private ChestLoot _rangedGear = new ChestLoot(true); + private ChestLoot _rodsAndGaps = new ChestLoot(true); + private ChestLoot _potionGearCommon = new ChestLoot(true); + private ChestLoot _potionGearRare = new ChestLoot(true); + //private ChestLoot _blockGear = new ChestLoot(); + private ChestLoot _enchantGearCommon = new ChestLoot(true); + private ChestLoot _enchantGearRare = new ChestLoot(true); + private ChestLoot _miscGear = new ChestLoot(); + + private boolean _writeScoreboard = true; + + @SuppressWarnings("deprecation") + public CastleSiegeTDM(ArcadeManager manager) + { + super(manager, GameType.CastleSiegeNew, + new Kit[] + { + //new KitAlchemist(manager), + new KitArcher(manager), + new KitDemolitionist(manager), + //new KitEnchanter(manager), + new KitFighter(manager), + //new KitHardline(manager), + //new KitNinja(manager), + new KitTank(manager) + }, + new String[] {"AlexTheCoder is awesome!"}); + + this.StrictAntiHack = true; + this.HungerSet = 20; + this.DeathOut = false; + this.DeathSpectateSecs = 5; + this.CreatureAllow = false; + this.DeathDropItems = false; + this.WorldWeatherEnabled = false; + this.AllowParticles = false; + this.SoupEnabled = false; + this.InventoryClick = true; + this.InventoryOpenChest = true; + this.InventoryOpenBlock = true; + this.ItemDrop = true; + this.ItemPickup = true; + this.AllowFlintAndSteel = true; + this.BlockPlaceAllow.add(Material.FIRE.getId()); + this.CrownsEnabled = true; + this.FirstKillReward = 20; + + new CompassModule() + .setGiveCompass(true) + .setGiveCompassToSpecs(true) + .setGiveCompassToAlive(false) + .register(this); + + _flintAndSteel = new ItemBuilder(Material.FLINT_AND_STEEL).setData((short) (Material.FLINT_AND_STEEL.getMaxDurability() - MAX_FLINT_AND_STEEL_USES)); + generateLoot(); + } + + private Player[] getMedalOwners(MedalType type) + { + Player gold = null; + Double goldScore = 0D; + Player silver = null; + Double silverScore = 0D; + Player bronze = null; + Double bronzeScore = 0D; + + //GOLD + for (Entry scores : _medalData.entrySet()) + { + if (scores.getValue().getScore(type) > goldScore) + { + gold = scores.getKey(); + goldScore = scores.getValue().getScore(type); + } + } + + //SILVER + for (Entry scores : _medalData.entrySet()) + { + if (gold != null && gold.getName().equals(scores.getKey().getName())) + { + continue; + } + if (scores.getValue().getScore(type) > silverScore) + { + silver = scores.getKey(); + silverScore = scores.getValue().getScore(type); + } + } + + //BRONZE + for (Entry scores : _medalData.entrySet()) + { + if (gold != null && gold.getName().equals(scores.getKey().getName())) + { + continue; + } + if (silver != null && silver.getName().equals(scores.getKey().getName())) + { + continue; + } + if (scores.getValue().getScore(type) > bronzeScore) + { + bronze = scores.getKey(); + bronzeScore = scores.getValue().getScore(type); + } + } + + return new Player[] {gold, silver, bronze}; + } + + private void generateLoot() + { + { + _diamondGearCommon.addLoot(new ItemStack(Material.DIAMOND_HELMET), 2); + _diamondGearCommon.addLoot(new ItemStack(Material.DIAMOND_CHESTPLATE), 2); + _diamondGearCommon.addLoot(new ItemStack(Material.DIAMOND_LEGGINGS), 2); + _diamondGearCommon.addLoot(new ItemStack(Material.DIAMOND_BOOTS), 2); + _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_HELMET).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1).build(), 1); + _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_CHESTPLATE).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1).build(), 1); + _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_LEGGINGS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1).build(), 1); + _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_BOOTS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1).build(), 1); + _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_HELMET).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).build(), 1); + _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_CHESTPLATE).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).build(), 1); + _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_LEGGINGS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).build(), 1); + _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_BOOTS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).build(), 1); + _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_HELMET).addEnchantment(Enchantment.PROTECTION_PROJECTILE, 3).build(), 1); + _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_CHESTPLATE).addEnchantment(Enchantment.PROTECTION_PROJECTILE, 3).build(), 1); + _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_LEGGINGS).addEnchantment(Enchantment.PROTECTION_PROJECTILE, 3).build(), 1); + _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_BOOTS).addEnchantment(Enchantment.PROTECTION_PROJECTILE, 3).build(), 1); + } + { + _diamondGearRare.addLoot(new ItemBuilder(Material.DIAMOND_HELMET).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4).build(), 1); + _diamondGearRare.addLoot(new ItemBuilder(Material.DIAMOND_CHESTPLATE).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4).build(), 1); + _diamondGearRare.addLoot(new ItemBuilder(Material.DIAMOND_LEGGINGS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4).build(), 1); + _diamondGearRare.addLoot(new ItemBuilder(Material.DIAMOND_BOOTS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4).build(), 1); + } + { + _weaponGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_SWORD).build(), 2); + _weaponGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_SWORD).addEnchantment(Enchantment.DAMAGE_ALL, 1).build(), 2); + } + { + _weaponGearRare.addLoot(new ItemBuilder(Material.DIAMOND_SWORD).addEnchantment(Enchantment.DAMAGE_ALL, 2).build(), 1); + } + { + _rangedGear.addLoot(new ItemStack(Material.BOW), 3); + _rangedGear.addLoot(Material.ARROW, 3, 8, 16); + } + { + _rodsAndGaps.addLoot(new ItemStack(Material.FISHING_ROD), 3); + _rodsAndGaps.addLoot(new ItemBuilder(Material.GOLDEN_APPLE).setTitle(C.cPurple + "Golden Applegate").build(), 3); + } + { + _potionGearCommon.addLoot(new ItemBuilder(Material.POTION).setData((short)16418).build(), 2); + _potionGearCommon.addLoot(new ItemBuilder(Material.POTION).setData((short)16417).build(), 2); + } + { + _potionGearRare.addLoot(new ItemBuilder(Material.POTION).setData((short)8193).build(), 2); + _potionGearRare.addLoot(new ItemBuilder(Material.POTION).setData((short)8195).build(), 2); + } + /*{ + _blockGear.addLoot(new ItemStack(Material.STONE, 64), 2); + _blockGear.addLoot(new ItemStack(Material.WOOD, 64), 2); + }*/ + { + _enchantGearCommon.addLoot(new EnchantedBookBuilder(1).setLevel(Enchantment.PROTECTION_ENVIRONMENTAL, 1).build(), 2); + _enchantGearCommon.addLoot(new EnchantedBookBuilder(1).setLevel(Enchantment.DAMAGE_ALL, 1).build(), 2); + _enchantGearCommon.addLoot(new EnchantedBookBuilder(1).setLevel(Enchantment.ARROW_DAMAGE, 1).build(), 2); + _enchantGearCommon.addLoot(new ItemStack(Material.EXP_BOTTLE, 64), 1); + } + { + _enchantGearRare.addLoot(new EnchantedBookBuilder(1).setLevel(Enchantment.FIRE_ASPECT, 1).build(), 1); + } + { + _miscGear.addLoot(new ItemStack(Material.ENDER_PEARL), 2); + _miscGear.addLoot(new ItemBuilder(Material.TNT, 4).setTitle(F.item("Throwing TNT")).build(), 2); + _miscGear.addLoot(new ItemStack(Material.WATER_BUCKET), 2); + _miscGear.addLoot(_flintAndSteel.build(), 2); + _miscGear.addLoot(new ItemStack(Material.SNOW_BALL, 16), 3); + } + } + + private void fillChest(Block block) + { + if (block.getType() != Material.CHEST && block.getType() != Material.TRAPPED_CHEST) + { + return; + } + Chest chest = (Chest) block.getState(); + + chest.getBlockInventory().clear(); + int[] slots = UtilMath.random.ints(ITEMS_PER_CHEST, 0, chest.getBlockInventory().getSize()).toArray(); + + for (int slot : slots) + { + double chance = UtilMath.random.nextDouble(); + double subChance = UtilMath.random.nextDouble(); + + ChestLoot loot = _miscGear; + if (chance <= 0.6) + { + loot = _rodsAndGaps; + } + if (chance <= 0.5) + { + loot = _potionGearCommon; + if (subChance <= 0.45) + { + loot = _potionGearRare; + } + } + if (chance <= 0.3) + { + loot = _rangedGear; + }/* + if (chance <= 0.4) + { + loot = _weaponGearCommon; + if (subChance <= 0.4) + { + loot = _weaponGearRare; + } + } + if (chance <= 0.3) + { + loot = _diamondGearCommon; + if (subChance <= 0.3) + { + loot = _diamondGearRare; + } + }*/ + chest.getBlockInventory().setItem(slot, loot.getLoot()); + } + } + + public ItemStack getNewFlintAndSteel(boolean kitItem) + { + if (kitItem) + { + return _flintAndSteel.clone().setLore(C.cGold + "Kit Item").build(); + } + return _flintAndSteel.build(); + } + + public void writeScoreboard() + { + if (!_writeScoreboard) + { + return; + } + Scoreboard.reset(); + Scoreboard.write(C.cDRedB + GetName()); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cGreenB + "Chest Refill"); + long refillTime = _lastRefill + TIME_TILL_REFILL - System.currentTimeMillis(); + if (!IsLive()) + { + refillTime = TIME_TILL_REFILL; + } + Scoreboard.write(UtilTime.MakeStr(refillTime)); + Scoreboard.writeNewLine(); + GameTeam red = GetTeam(ChatColor.RED); + GameTeam blue = GetTeam(ChatColor.AQUA); + Scoreboard.write(red.GetFormattedName() + " Team Kills"); + Scoreboard.write(_teamKills.get(red) + ""); + Scoreboard.writeNewLine(); + Scoreboard.write(blue.GetFormattedName() + " Team Kills"); + Scoreboard.write(_teamKills.get(blue) + ""); + Scoreboard.draw(); + } + + public void writeFinalScoreboard(String winner, int kills) + { + _writeScoreboard = false; + Scoreboard.reset(); + Scoreboard.writeNewLine(); + Scoreboard.write(winner + C.cBlue + " has won"); + Scoreboard.write(C.cBlue + "with " + C.cGreen + kills + C.cBlue + " kills!"); + Scoreboard.writeNewLine(); + + Scoreboard.draw(); + } + + @Override + public void ParseData() + { + for (Location chestLoc : WorldData.GetDataLocs("BROWN")) + { + Block block = chestLoc.getBlock(); + block.setType(Material.CHEST); + fillChest(block); + _chests.add(block); + } + GameTeam red = GetTeam(ChatColor.RED); + _teamKills.put(red, 0); + GameTeam blue = GetTeam(ChatColor.AQUA); + _teamKills.put(blue, 0); + } + + @Override + public void EndCheck() + { + if (!IsLive()) + { + return; + } + + List teamsAlive = new ArrayList<>(); + + for (GameTeam team : GetTeamList()) + { + if (team.GetPlayers(true).size() > 0) + { + teamsAlive.add(team); + } + } + + if (teamsAlive.size() <= 1) + { + //Announce + if (teamsAlive.size() > 0) + { + GameTeam winner = teamsAlive.get(0); + AnnounceEnd(winner); + writeFinalScoreboard(winner.GetColor() + winner.GetName(), _teamKills.get(winner)); + boolean announcedMedalStart = false; + for (MedalType type : MedalType.values()) + { + Player[] rewarding = getMedalOwners(type); + if (rewarding[0] != null) + { + if (!announcedMedalStart) + { + announcedMedalStart = true; + Bukkit.broadcastMessage(C.cGoldB + "-==Match Medal Recipients==-"); + } + AddGems(rewarding[0], 50, MedalLevel.GOLD.getName() + " " + type.getName(), false, false); + AddStat(rewarding[0], "Medalist", 1, false, false); + Bukkit.broadcastMessage(MedalLevel.GOLD.getName() + " " + type.getName() + C.cGray + ": " + MedalLevel.GOLD.getColor() + rewarding[0].getName()); + } + if (rewarding[1] != null) + { + AddGems(rewarding[1], 30, MedalLevel.SILVER.getName() + " " + type.getName(), false, false); + AddStat(rewarding[1], "Medalist", 1, false, false); + Bukkit.broadcastMessage(MedalLevel.SILVER.getName() + " " + type.getName() + C.cGray + ": " + MedalLevel.SILVER.getColor() + rewarding[1].getName()); + } + if (rewarding[2] != null) + { + AddGems(rewarding[2], 20, MedalLevel.BRONZE.getName() + " " + type.getName(), false, false); + AddStat(rewarding[2], "Medalist", 1, false, false); + Bukkit.broadcastMessage(MedalLevel.BRONZE.getName() + " " + type.getName() + C.cGray + ": " + MedalLevel.BRONZE.getColor() + rewarding[2].getName()); + } + } + for (GameTeam team : GetTeamList()) + { + for (Player player : team.GetPlayers(true)) + { + if (team.GetColor() == winner.GetColor()) + { + AddGems(player, 100, "Winning Team", false, false); + } + else + { + AddGems(player, 50, "Losing Team", false, false); + } + if (player.isOnline()) + { + AddGems(player, 10, "Participation", false, false); + } + + int streak = _streakData.getOrDefault(player, new KillStreakData()).getBestStreak(); + if (streak > 0) + { + AddGems(player, streak, streak + " Player Kill Streak", false, false); + } + + if (GetKit(player) != null) + { + KitPlayer kit = (KitPlayer) GetKit(player); + int kitLevel = kit.getUpgradeLevel(player.getUniqueId()); + if (kitLevel > 0) + { + int crowns = 0; + for (GemData data : GetGems(player).values()) + { + crowns += data.Gems; + } + + AddGems(player, (0.5 * kitLevel) * crowns, kit.GetName() + " Kit Level Bonus", false, false); + } + } + } + } + SetState(GameState.End); + return; + } + } + } + + @Override + @EventHandler + public void ScoreboardUpdate(UpdateEvent event) {}; + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + { + return; + } + if (IsLive()) + { + if (UtilTime.elapsed(_lastRefill, TIME_TILL_REFILL)) + { + _lastRefill = System.currentTimeMillis(); + _chests.forEach(this::fillChest); + Bukkit.broadcastMessage(C.cGreenB + "Chests have refilled!"); + } + + GameTeam red = GetTeam(ChatColor.RED); + GameTeam blue = GetTeam(ChatColor.AQUA); + if (_teamKills.get(blue).intValue() >= 100) + { + AnnounceEnd(blue); + writeFinalScoreboard(blue.GetColor() + blue.GetName(), _teamKills.get(blue)); + boolean announcedMedalStart = false; + for (MedalType type : MedalType.values()) + { + Player[] rewarding = getMedalOwners(type); + if (rewarding[0] != null) + { + if (!announcedMedalStart) + { + announcedMedalStart = true; + Bukkit.broadcastMessage(C.cGoldB + "-==Match Medal Recipients==-"); + } + AddGems(rewarding[0], 50, MedalLevel.GOLD.getName() + " " + type.getName(), false, false); + AddStat(rewarding[0], "Medalist", 1, false, false); + Bukkit.broadcastMessage(MedalLevel.GOLD.getName() + " " + type.getName() + C.cGray + ": " + MedalLevel.GOLD.getColor() + rewarding[0].getName()); + } + if (rewarding[1] != null) + { + AddGems(rewarding[1], 30, MedalLevel.SILVER.getName() + " " + type.getName(), false, false); + AddStat(rewarding[1], "Medalist", 1, false, false); + Bukkit.broadcastMessage(MedalLevel.SILVER.getName() + " " + type.getName() + C.cGray + ": " + MedalLevel.SILVER.getColor() + rewarding[1].getName()); + } + if (rewarding[2] != null) + { + AddGems(rewarding[2], 20, MedalLevel.BRONZE.getName() + " " + type.getName(), false, false); + AddStat(rewarding[2], "Medalist", 1, false, false); + Bukkit.broadcastMessage(MedalLevel.BRONZE.getName() + " " + type.getName() + C.cGray + ": " + MedalLevel.BRONZE.getColor() + rewarding[2].getName()); + } + } + for (GameTeam team : GetTeamList()) + { + for (Player player : team.GetPlayers(true)) + { + if (team.GetColor() == ChatColor.AQUA) + { + AddGems(player, 100, "Winning Team", false, false); + } + else + { + AddGems(player, 50, "Losing Team", false, false); + } + if (player.isOnline()) + { + AddGems(player, 10, "Participation", false, false); + } + + int streak = _streakData.getOrDefault(player, new KillStreakData()).getBestStreak(); + if (streak > 0) + { + AddGems(player, streak, streak + " Player Kill Streak", false, false); + } + + KitPlayer kit = (KitPlayer) GetKit(player); + int kitLevel = kit.getUpgradeLevel(player.getUniqueId()); + if (kitLevel > 0) + { + int crowns = 0; + for (GemData data : GetGems(player).values()) + { + crowns += data.Gems; + } + + AddGems(player, (0.5 * kitLevel) * crowns, kit.GetName() + " Kit Level Bonus", false, false); + } + } + } + SetState(GameState.End); + return; + } + if (_teamKills.get(red).intValue() >= 100) + { + AnnounceEnd(red); + writeFinalScoreboard(red.GetColor() + red.GetName(), _teamKills.get(red)); + boolean announcedMedalStart = false; + for (MedalType type : MedalType.values()) + { + Player[] rewarding = getMedalOwners(type); + if (rewarding[0] != null) + { + if (!announcedMedalStart) + { + announcedMedalStart = true; + Bukkit.broadcastMessage(C.cGoldB + "-==Match Medal Recipients==-"); + } + AddGems(rewarding[0], 50, MedalLevel.GOLD.getName() + " " + type.getName(), false, false); + AddStat(rewarding[0], "Medalist", 1, false, false); + Bukkit.broadcastMessage(MedalLevel.GOLD.getName() + " " + type.getName() + C.cGray + ": " + MedalLevel.GOLD.getColor() + rewarding[0].getName()); + } + if (rewarding[1] != null) + { + AddGems(rewarding[1], 30, MedalLevel.SILVER.getName() + " " + type.getName(), false, false); + AddStat(rewarding[1], "Medalist", 1, false, false); + Bukkit.broadcastMessage(MedalLevel.SILVER.getName() + " " + type.getName() + C.cGray + ": " + MedalLevel.SILVER.getColor() + rewarding[1].getName()); + } + if (rewarding[2] != null) + { + AddGems(rewarding[2], 20, MedalLevel.BRONZE.getName() + " " + type.getName(), false, false); + AddStat(rewarding[2], "Medalist", 1, false, false); + Bukkit.broadcastMessage(MedalLevel.BRONZE.getName() + " " + type.getName() + C.cGray + ": " + MedalLevel.BRONZE.getColor() + rewarding[2].getName()); + } + } + for (GameTeam team : GetTeamList()) + { + for (Player player : team.GetPlayers(true)) + { + if (team.GetColor() == ChatColor.RED) + { + AddGems(player, 100, "Winning Team", false, false); + } + else + { + AddGems(player, 50, "Losing Team", false, false); + } + if (player.isOnline()) + { + AddGems(player, 10, "Participation", false, false); + } + + int streak = _streakData.getOrDefault(player, new KillStreakData()).getBestStreak(); + if (streak > 0) + { + AddGems(player, streak, streak + " Player Kill Streak", false, false); + } + + KitPlayer kit = (KitPlayer) GetKit(player); + int kitLevel = kit.getUpgradeLevel(player.getUniqueId()); + if (kitLevel > 0) + { + int crowns = 0; + for (GemData data : GetGems(player).values()) + { + crowns += data.Gems; + } + + AddGems(player, (0.5 * kitLevel) * crowns, kit.GetName() + " Kit Level Bonus", false, false); + } + } + } + SetState(GameState.End); + return; + } + } + if (InProgress()) + { + writeScoreboard(); + } + } + + @EventHandler + public void onEditSettings(GameStateChangeEvent event) + { + if (event.GetGame() != this) + { + return; + } + + if (event.GetState() == GameState.Live) + { + _lastRefill = System.currentTimeMillis(); + Manager.GetDamage().SetEnabled(false); + Manager.GetExplosion().setEnabled(false); + Manager.GetCreature().SetDisableCustomDrops(true); + } + + if (event.GetState() == GameState.End) + { + Manager.GetDamage().SetEnabled(true); + Manager.GetExplosion().setEnabled(true); + Manager.GetCreature().SetDisableCustomDrops(false); + } + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void handleDeath(CombatDeathEvent event) + { + if (!IsLive()) + { + return; + } + + event.SetBroadcastType(DeathMessageType.Detailed); + } + + @EventHandler + public void disableDamageLevel(CustomDamageEvent event) + { + event.SetDamageToLevel(false); + } + + @EventHandler + public void BlockFade(BlockFadeEvent event) + { + event.setCancelled(true); + } + + @EventHandler + public void BlockBurn(BlockBurnEvent event) + { + event.setCancelled(true); + } + + @EventHandler + public void BlockDecay(LeavesDecayEvent event) + { + event.setCancelled(true); + } + + @EventHandler + public void hangingBreak(HangingBreakEvent event) + { + if (event.getEntity() instanceof ItemFrame || event.getEntity() instanceof Painting) + { + event.setCancelled(true); + } + } + + @EventHandler + public void noFlow(BlockFromToEvent event) + { + if (!IsLive()) + { + return; + } + + Block block = event.getBlock(); + if (block.getType() == Material.WATER || block.getType() == Material.STATIONARY_WATER || block.getType() == Material.LAVA || block.getType() == Material.STATIONARY_LAVA) + { + event.setCancelled(true); + } + } + + @SuppressWarnings("deprecation") + @EventHandler(ignoreCancelled=true) + public void onPlayerEmptyBucket(PlayerBucketEmptyEvent event) + { + if (!IsLive()) + { + return; + } + + Player player = event.getPlayer(); + if (player.getItemInHand().getType() == Material.WATER_BUCKET) + { + player.getItemInHand().setType(Material.BUCKET); + Block block = event.getBlockClicked().getRelative(event.getBlockFace()); + if (block.getType().toString().contains("LAVA") || (block.getType().toString().contains("WATER") && block.getType() != Material.WATER_LILY)) + { + event.setCancelled(true); + player.sendBlockChange(block.getLocation(), block.getType(), block.getData()); + return; + } + for (BlockFace bf : BlockFace.values()) + { + Block relative = block.getRelative(bf); + if (relative.getType().toString().contains("LAVA") || (relative.getType().toString().contains("WATER") && relative.getType() != Material.WATER_LILY)) + { + event.setCancelled(true); + player.sendBlockChange(block.getLocation(), block.getType(), block.getData()); + } + } + } + else if (player.getItemInHand().getType() == Material.LAVA_BUCKET) + { + event.setCancelled(true); + Block block = event.getBlockClicked().getRelative(event.getBlockFace()); + player.sendBlockChange(block.getLocation(), block.getType(), block.getData()); + } + } + + @SuppressWarnings("deprecation") + @EventHandler(ignoreCancelled=true) + public void onPlayerEmptyBucket(PlayerBucketFillEvent event) + { + if (!IsLive()) + { + return; + } + + Player player = event.getPlayer(); + if (player.getItemInHand().getType() == Material.LAVA_BUCKET) + { + event.setCancelled(true); + Block block = event.getBlockClicked().getRelative(event.getBlockFace()); + player.sendBlockChange(block.getLocation(), block.getType(), block.getData()); + } + } + + @EventHandler(ignoreCancelled=true) + public void onBlockDispense(BlockDispenseEvent event) + { + if (!IsLive()) + { + return; + } + + if (event.getItem().getType() == Material.WATER_BUCKET) + { + Block dispenser = event.getBlock(); + + MaterialData mat = dispenser.getState().getData(); + Dispenser disp_mat = (Dispenser)mat; + BlockFace face = disp_mat.getFacing(); + Block block = dispenser.getRelative(face); + if (block.getType().toString().contains("LAVA") || (block.getType().toString().contains("WATER") && block.getType() != Material.WATER_LILY)) + { + event.setCancelled(true); + return; + } + for (BlockFace bf : BlockFace.values()) + { + if (block.getRelative(bf).getType().toString().contains("LAVA") || (block.getRelative(bf).getType().toString().contains("WATER") && block.getRelative(bf).getType() != Material.WATER_LILY)) + { + event.setCancelled(true); + } + } + } + } + + @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) + public void onCombatDeath(CombatDeathEvent event) + { + if (!IsLive()) + { + return; + } + + if (event.GetLog().GetKiller() == null) + { + return; + } + + if (!event.GetLog().GetKiller().IsPlayer()) + { + return; + } + + Player player = UtilPlayer.searchExact(event.GetLog().GetKiller().GetName()); + if (player == null) + { + return; + } + + AddStat(player, GetKit(player).GetName() + "KitKills", 1, false, false); + _medalData.computeIfAbsent(player, key -> new MedalData()).addScore(MedalType.ELIM, 1D); + _teamKills.merge(GetTeam(player), 1, Integer::sum); + + player.setLevel(player.getLevel() + 1); + player.getInventory().addItem(new ItemBuilder(Material.GOLDEN_APPLE).setTitle(C.cPurple + "Golden Applegate").build()); + KillStreakData data = _streakData.computeIfAbsent(player, (key) -> new KillStreakData()); + boolean hardLine = GetKit(player).GetName().equals("Hardline"); + if (data.addKill(hardLine)) + { + AddStat(player, "KillStreak", 1, false, false); + player.sendMessage(C.cRedB + "You have received a Kill Streak Reward!"); + ((KitPlayer)GetKit(player)).awardKillStreak(player, hardLine ? (data.getKills() + 1) : data.getKills()); + } + if (UtilMath.isEven(data.getKills())) + { + Bukkit.broadcastMessage(F.main("Game", C.cGreen + C.Bold + player.getName() + ChatColor.RESET + " is on a " + F.elem(C.cAqua + C.Bold + data.getKills() + " player Kill Streak") + "!")); + } + } + + @EventHandler + public void TNTExplosion(ExplosionPrimeEvent event) + { + if (!event.getEntity().hasMetadata("THROWER")) + { + return; + } + + float radius = event.getRadius(); + event.setRadius(0f); + + Player player = UtilPlayer.searchExact(((MetadataValue)UtilEnt.GetMetadata(event.getEntity(), "THROWER")).asString()); + if (player == null) + { + return; + } + if (GetTeam(player) == null) + { + return; + } + + if (GetKit(player).GetName().equals("Demolitionist")) + { + radius += 3; + } + + Map nearby = UtilPlayer.getInRadius(event.getEntity().getLocation(), radius); + for (Player near : nearby.keySet()) + { + if (UtilPlayer.isSpectator(near)) + { + continue; + } + if (near.getEntityId() != player.getEntityId() && GetTeam(near).GetColor() == GetTeam(player).GetColor()) + { + continue; + } + + double mult = nearby.get(near); + + int highestBlastProt = 0; + int blastProtEPF = 0; + for (ItemStack item : near.getInventory().getArmorContents()) + { + if (item != null && item.getEnchantments().containsKey(Enchantment.PROTECTION_EXPLOSIONS)) + { + blastProtEPF += (2 * item.getEnchantmentLevel(Enchantment.PROTECTION_EXPLOSIONS)); + if (item.getEnchantmentLevel(Enchantment.PROTECTION_EXPLOSIONS) > highestBlastProt) + { + highestBlastProt = item.getEnchantmentLevel(Enchantment.PROTECTION_EXPLOSIONS); + } + } + } + blastProtEPF = Math.min(blastProtEPF, 20); + + double damage = 8 * mult; + damage = damage * (1 - (blastProtEPF / 25)); + + double knockbackReduction = 1 - (highestBlastProt * 0.15); + + near.damage(damage, event.getEntity()); + UtilAction.velocity(near, UtilAlg.getTrajectory(event.getEntity().getLocation(), near.getLocation()), 1 * mult * knockbackReduction, false, 0, mult * knockbackReduction, 10, true); + } + } + + @EventHandler + public void TNTThrow(PlayerInteractEvent event) + { + if (!IsLive()) + { + return; + } + + if (!UtilEvent.isAction(event, ActionType.L)) + { + return; + } + + Player player = event.getPlayer(); + + if (!UtilInv.IsItem(player.getItemInHand(), Material.TNT, (byte) 0)) + { + return; + } + + if (!IsAlive(player)) + { + return; + } + + event.setCancelled(true); + + if (!Manager.GetGame().CanThrowTNT(player.getLocation())) + { + // Inform + UtilPlayer.message(event.getPlayer(), F.main(GetName(), "You cannot use " + F.item("Throwing TNT") + " here.")); + return; + } + + UtilInv.remove(player, Material.TNT, (byte) 0, 1); + UtilInv.Update(player); + + TNTPrimed tnt = player.getWorld().spawn(player.getEyeLocation().add(player.getLocation().getDirection()), TNTPrimed.class); + + tnt.setFuseTicks(60); + + double throwMult = 1; + + if (GetKit(player).GetName().equals("Demolitionist")) + { + throwMult = ((KitDemolitionist)GetKit(player)).getThrowMultiplier(player); + } + + UtilAction.velocity(tnt, player.getLocation().getDirection(), 0.5 * throwMult, false, 0, 0.1, 10, false); + + UtilEnt.SetMetadata(tnt, "THROWER", player.getName()); + } + + @EventHandler + public void onLaunch(ProjectileHitEvent event) + { + if (!IsLive()) + { + return; + } + + if (event.getEntity() instanceof EnderPearl && event.getEntity().getShooter() != null && event.getEntity().getShooter() instanceof Entity) + { + Entity shooter = (Entity) event.getEntity().getShooter(); + Location teleport = event.getEntity().getLocation(); + teleport.setPitch(shooter.getLocation().getPitch()); + teleport.setYaw(shooter.getLocation().getYaw()); + shooter.teleport(teleport); + } + } + + @EventHandler + public void onOpenChest(PlayerInteractEvent event) + { + if (!IsLive()) + { + return; + } + + if (event.getClickedBlock() != null && event.getClickedBlock().getType() == Material.CHEST) + { + if (UtilPlayer.isSpectator(event.getPlayer())) + { + event.setCancelled(true); + } + } + } + + @EventHandler + public void onDrop(PlayerDropItemEvent event) + { + if (!IsLive()) + { + return; + } + + ItemStack drop = event.getItemDrop().getItemStack(); + if (drop.hasItemMeta() && drop.getItemMeta().hasLore() && drop.getItemMeta().getLore().stream().map(ChatColor::stripColor).anyMatch(lore -> lore.equals("Kit Item"))) + { + event.setCancelled(true); + return; + } + + event.getItemDrop().remove(); + } + + @EventHandler + public void craftItem(PrepareItemCraftEvent event) + { + if (!IsLive()) + { + return; + } + + if (event.getInventory().getResult().getType() == Material.FLINT_AND_STEEL) + { + event.getInventory().setResult(_flintAndSteel.build()); + } + } + + @EventHandler + public void onInvClick(InventoryClickEvent event) + { + if (!IsLive()) + { + return; + } + if (event.getView().getTopInventory() != null && event.getView().getTopInventory().getType() == InventoryType.CHEST) + { + ItemStack current = event.getCurrentItem(); + if (event.getAction() == InventoryAction.HOTBAR_SWAP || event.getAction() == InventoryAction.HOTBAR_MOVE_AND_READD) + { + current = event.getWhoClicked().getInventory().getItem(event.getHotbarButton()); + } + + if (current != null && current.hasItemMeta()) + { + if (current.getItemMeta().hasLore()) + { + for (String lore : current.getItemMeta().getLore()) + { + if (ChatColor.stripColor(lore).equalsIgnoreCase("Kit Item")) + { + event.setCancelled(true); + break; + } + } + } + } + } + } + + @EventHandler + public void onFirstBlood(FirstBloodEvent event) + { + if (!IsLive()) + { + return; + } + + AddStat(event.getPlayer(), "FirstBlood", 1, true, false); + } + + @EventHandler + public void onPearl(PlayerInteractEvent event) + { + if (!IsLive()) + { + return; + } + + if (!UtilEvent.isAction(event, ActionType.R)) + { + return; + } + + if (event.getItem() != null && event.getItem().getType() == Material.ENDER_PEARL) + { + Player player = (Player) event.getPlayer(); + if (!Recharge.Instance.use(player, "Enderpearl", 4000, true, true)) + { + event.setCancelled(true); + player.updateInventory(); + } + } + } + + @EventHandler + public void onDeath(PlayerDeathEvent event) + { + Player player = event.getEntity(); + + _streakData.getOrDefault(player, new KillStreakData()).reset(); + } +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/ShockCastleSiege.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/ShockCastleSiege.java new file mode 100644 index 000000000..52c725d24 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/ShockCastleSiege.java @@ -0,0 +1,1448 @@ +package nautilus.game.arcade.game.games.castlesiege; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.WeakHashMap; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Color; +import org.bukkit.FireworkEffect.Type; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.block.Chest; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.EnderPearl; +import org.bukkit.entity.Entity; +import org.bukkit.entity.ItemFrame; +import org.bukkit.entity.Painting; +import org.bukkit.entity.Player; +import org.bukkit.entity.TNTPrimed; +import org.bukkit.entity.Zombie; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.block.BlockBurnEvent; +import org.bukkit.event.block.BlockDispenseEvent; +import org.bukkit.event.block.BlockFadeEvent; +import org.bukkit.event.block.BlockFromToEvent; +import org.bukkit.event.block.LeavesDecayEvent; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.entity.ExplosionPrimeEvent; +import org.bukkit.event.entity.ItemDespawnEvent; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.entity.ProjectileHitEvent; +import org.bukkit.event.hanging.HangingBreakEvent; +import org.bukkit.event.inventory.InventoryAction; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.inventory.InventoryType; +import org.bukkit.event.inventory.PrepareItemCraftEvent; +import org.bukkit.event.player.PlayerBucketEmptyEvent; +import org.bukkit.event.player.PlayerBucketFillEvent; +import org.bukkit.event.player.PlayerDropItemEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerPickupItemEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.material.Dispenser; +import org.bukkit.material.MaterialData; +import org.bukkit.metadata.FixedMetadataValue; +import org.bukkit.metadata.MetadataValue; +import org.bukkit.util.Vector; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilFirework; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.itemstack.EnchantedBookBuilder; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.loot.ChestLoot; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.combat.DeathMessageType; +import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.GameType; +import nautilus.game.arcade.events.FirstBloodEvent; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.GemData; +import nautilus.game.arcade.game.TeamGame; +import nautilus.game.arcade.game.games.castlesiege.data.KillStreakData; +import nautilus.game.arcade.game.games.castlesiege.data.ObjectiveTNTSpawner; +import nautilus.game.arcade.game.games.castlesiege.data.TeamBeacon; +import nautilus.game.arcade.game.games.castlesiege.data.TeamKing; +import nautilus.game.arcade.game.games.castlesiege.data.medals.MedalData; +import nautilus.game.arcade.game.games.castlesiege.data.medals.MedalData.MedalLevel; +import nautilus.game.arcade.game.games.castlesiege.data.medals.MedalType; +import nautilus.game.arcade.game.games.castlesiege.shockkits.KitArcher; +import nautilus.game.arcade.game.games.castlesiege.shockkits.KitDemolitionist; +import nautilus.game.arcade.game.games.castlesiege.shockkits.KitFighter; +import nautilus.game.arcade.game.games.castlesiege.shockkits.KitPlayer; +import nautilus.game.arcade.game.games.castlesiege.shockkits.KitTank; +import nautilus.game.arcade.game.modules.compass.CompassModule; +import nautilus.game.arcade.kit.Kit; + +public class ShockCastleSiege extends TeamGame +{ + private static final int MAX_FLINT_AND_STEEL_USES = 4; + private static final int ITEMS_PER_CHEST = 5; + private static final long TIME_TILL_REFILL = 2 * 60 * 1000; + + private long _lastRefill; + + private ItemBuilder _flintAndSteel; + private ItemBuilder _wearableTnt; + + private Map _streakData = new WeakHashMap<>(); + private Map _medalData = new WeakHashMap<>(); + private Map> _beacons = new HashMap<>(); + private Map _kings = new HashMap<>(); + private List _tntCarry = new ArrayList<>(); + + private List _chests = new ArrayList<>(); + + private ChestLoot _diamondGearCommon = new ChestLoot(true); + private ChestLoot _diamondGearRare = new ChestLoot(true); + private ChestLoot _weaponGearCommon = new ChestLoot(true); + private ChestLoot _weaponGearRare = new ChestLoot(true); + private ChestLoot _rangedGear = new ChestLoot(true); + private ChestLoot _rodsAndGaps = new ChestLoot(true); + private ChestLoot _potionGearCommon = new ChestLoot(true); + private ChestLoot _potionGearRare = new ChestLoot(true); + //private ChestLoot _blockGear = new ChestLoot(); + private ChestLoot _enchantGearCommon = new ChestLoot(true); + private ChestLoot _enchantGearRare = new ChestLoot(true); + private ChestLoot _miscGear = new ChestLoot(); + + private ObjectiveTNTSpawner _tntSpawner; + + private boolean _writeScoreboard = true; + + @SuppressWarnings("deprecation") + public ShockCastleSiege(ArcadeManager manager) + { + super(manager, GameType.CastleSiegeNew, + new Kit[] + { + //new KitAlchemist(manager), + new KitArcher(manager), + new KitDemolitionist(manager), + //new KitEnchanter(manager), + new KitFighter(manager), + //new KitHardline(manager), + //new KitNinja(manager), + new KitTank(manager) + }, + new String[] {"AlexTheCoder is awesome!"}); + + this.StrictAntiHack = true; + this.HungerSet = 20; + this.DeathOut = false; + this.DeathSpectateSecs = 5; + this.CreatureAllow = false; + this.DeathDropItems = false; + this.WorldWeatherEnabled = false; + this.AllowParticles = false; + this.SoupEnabled = false; + this.InventoryClick = true; + this.InventoryOpenChest = true; + this.InventoryOpenBlock = true; + this.ItemDrop = true; + this.ItemPickup = true; + this.AllowFlintAndSteel = true; + this.BlockPlaceAllow.add(Material.FIRE.getId()); + this.CrownsEnabled = true; + this.FirstKillReward = 20; + + new CompassModule() + .setGiveCompass(true) + .setGiveCompassToSpecs(true) + .setGiveCompassToAlive(false) + .register(this); + + _flintAndSteel = new ItemBuilder(Material.FLINT_AND_STEEL).setData((short) (Material.FLINT_AND_STEEL.getMaxDurability() - MAX_FLINT_AND_STEEL_USES)); + _wearableTnt = new ItemBuilder(Material.TNT).setTitle(C.cRed + "TNT").addLore(C.cRedB + "Right Click with Weapon to " + F.name("Detonate")); + generateLoot(); + } + + private Player[] getMedalOwners(MedalType type) + { + Player gold = null; + Double goldScore = 0D; + Player silver = null; + Double silverScore = 0D; + Player bronze = null; + Double bronzeScore = 0D; + + //GOLD + for (Entry scores : _medalData.entrySet()) + { + if (scores.getValue().getScore(type) > goldScore) + { + gold = scores.getKey(); + goldScore = scores.getValue().getScore(type); + } + } + + //SILVER + for (Entry scores : _medalData.entrySet()) + { + if (gold != null && gold.getName().equals(scores.getKey().getName())) + { + continue; + } + if (scores.getValue().getScore(type) > silverScore) + { + silver = scores.getKey(); + silverScore = scores.getValue().getScore(type); + } + } + + //BRONZE + for (Entry scores : _medalData.entrySet()) + { + if (gold != null && gold.getName().equals(scores.getKey().getName())) + { + continue; + } + if (silver != null && silver.getName().equals(scores.getKey().getName())) + { + continue; + } + if (scores.getValue().getScore(type) > bronzeScore) + { + bronze = scores.getKey(); + bronzeScore = scores.getValue().getScore(type); + } + } + + return new Player[] {gold, silver, bronze}; + } + + private void generateLoot() + { + { + _diamondGearCommon.addLoot(new ItemStack(Material.DIAMOND_HELMET), 2); + _diamondGearCommon.addLoot(new ItemStack(Material.DIAMOND_CHESTPLATE), 2); + _diamondGearCommon.addLoot(new ItemStack(Material.DIAMOND_LEGGINGS), 2); + _diamondGearCommon.addLoot(new ItemStack(Material.DIAMOND_BOOTS), 2); + _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_HELMET).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1).build(), 1); + _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_CHESTPLATE).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1).build(), 1); + _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_LEGGINGS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1).build(), 1); + _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_BOOTS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1).build(), 1); + _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_HELMET).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).build(), 1); + _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_CHESTPLATE).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).build(), 1); + _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_LEGGINGS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).build(), 1); + _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_BOOTS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).build(), 1); + _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_HELMET).addEnchantment(Enchantment.PROTECTION_PROJECTILE, 3).build(), 1); + _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_CHESTPLATE).addEnchantment(Enchantment.PROTECTION_PROJECTILE, 3).build(), 1); + _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_LEGGINGS).addEnchantment(Enchantment.PROTECTION_PROJECTILE, 3).build(), 1); + _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_BOOTS).addEnchantment(Enchantment.PROTECTION_PROJECTILE, 3).build(), 1); + } + { + _diamondGearRare.addLoot(new ItemBuilder(Material.DIAMOND_HELMET).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4).build(), 1); + _diamondGearRare.addLoot(new ItemBuilder(Material.DIAMOND_CHESTPLATE).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4).build(), 1); + _diamondGearRare.addLoot(new ItemBuilder(Material.DIAMOND_LEGGINGS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4).build(), 1); + _diamondGearRare.addLoot(new ItemBuilder(Material.DIAMOND_BOOTS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4).build(), 1); + } + { + _weaponGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_SWORD).build(), 2); + _weaponGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_SWORD).addEnchantment(Enchantment.DAMAGE_ALL, 1).build(), 2); + } + { + _weaponGearRare.addLoot(new ItemBuilder(Material.DIAMOND_SWORD).addEnchantment(Enchantment.DAMAGE_ALL, 2).build(), 1); + } + { + _rangedGear.addLoot(new ItemStack(Material.BOW), 3); + _rangedGear.addLoot(Material.ARROW, 3, 8, 16); + } + { + _rodsAndGaps.addLoot(new ItemStack(Material.FISHING_ROD), 3); + _rodsAndGaps.addLoot(new ItemBuilder(Material.GOLDEN_APPLE).setTitle(C.cPurple + "Golden Applegate").build(), 3); + } + { + _potionGearCommon.addLoot(new ItemBuilder(Material.POTION).setData((short)16418).build(), 2); + _potionGearCommon.addLoot(new ItemBuilder(Material.POTION).setData((short)16417).build(), 2); + } + { + _potionGearRare.addLoot(new ItemBuilder(Material.POTION).setData((short)8193).build(), 2); + _potionGearRare.addLoot(new ItemBuilder(Material.POTION).setData((short)8195).build(), 2); + } + /*{ + _blockGear.addLoot(new ItemStack(Material.STONE, 64), 2); + _blockGear.addLoot(new ItemStack(Material.WOOD, 64), 2); + }*/ + { + _enchantGearCommon.addLoot(new EnchantedBookBuilder(1).setLevel(Enchantment.PROTECTION_ENVIRONMENTAL, 1).build(), 2); + _enchantGearCommon.addLoot(new EnchantedBookBuilder(1).setLevel(Enchantment.DAMAGE_ALL, 1).build(), 2); + _enchantGearCommon.addLoot(new EnchantedBookBuilder(1).setLevel(Enchantment.ARROW_DAMAGE, 1).build(), 2); + _enchantGearCommon.addLoot(new ItemStack(Material.EXP_BOTTLE, 64), 1); + } + { + _enchantGearRare.addLoot(new EnchantedBookBuilder(1).setLevel(Enchantment.FIRE_ASPECT, 1).build(), 1); + } + { + _miscGear.addLoot(new ItemStack(Material.ENDER_PEARL), 2); + _miscGear.addLoot(new ItemBuilder(Material.TNT, 4).setTitle(F.item("Throwing TNT")).build(), 2); + _miscGear.addLoot(new ItemStack(Material.WATER_BUCKET), 2); + _miscGear.addLoot(_flintAndSteel.build(), 2); + _miscGear.addLoot(new ItemStack(Material.SNOW_BALL, 16), 3); + } + } + + private void fillChest(Block block) + { + if (block.getType() != Material.CHEST && block.getType() != Material.TRAPPED_CHEST) + { + return; + } + Chest chest = (Chest) block.getState(); + + chest.getBlockInventory().clear(); + int[] slots = UtilMath.random.ints(ITEMS_PER_CHEST, 0, chest.getBlockInventory().getSize()).toArray(); + + for (int slot : slots) + { + double chance = UtilMath.random.nextDouble(); + double subChance = UtilMath.random.nextDouble(); + + ChestLoot loot = _miscGear; + if (chance <= 0.6) + { + loot = _rodsAndGaps; + } + if (chance <= 0.5) + { + loot = _potionGearCommon; + if (subChance <= 0.45) + { + loot = _potionGearRare; + } + } + if (chance <= 0.3) + { + loot = _rangedGear; + }/* + if (chance <= 0.4) + { + loot = _weaponGearCommon; + if (subChance <= 0.4) + { + loot = _weaponGearRare; + } + } + if (chance <= 0.3) + { + loot = _diamondGearCommon; + if (subChance <= 0.3) + { + loot = _diamondGearRare; + } + }*/ + chest.getBlockInventory().setItem(slot, loot.getLoot()); + } + } + + public ItemStack getNewFlintAndSteel(boolean kitItem) + { + if (kitItem) + { + return _flintAndSteel.clone().setLore(C.cGold + "Kit Item").build(); + } + return _flintAndSteel.build(); + } + + public void writeScoreboard() + { + if (!_writeScoreboard) + { + return; + } + Scoreboard.reset(); + Scoreboard.write(C.cDRedB + GetName()); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cGreenB + "Chest Refill"); + long refillTime = _lastRefill + TIME_TILL_REFILL - System.currentTimeMillis(); + if (!IsLive()) + { + refillTime = TIME_TILL_REFILL; + } + Scoreboard.write(UtilTime.MakeStr(refillTime)); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cGreenB + "TNT Spawn"); + long tntTime = _tntSpawner.getNextTNT(); + if (!IsLive()) + { + tntTime = 60000; + } + if (_tntSpawner.isSpawned()) + { + Scoreboard.write("Spawned"); + } + else + { + Scoreboard.write(UtilTime.MakeStr(tntTime)); + } + Scoreboard.writeNewLine(); + GameTeam red = GetTeam(ChatColor.RED); + GameTeam blue = GetTeam(ChatColor.AQUA); + if (_beacons.get(red).stream().filter(TeamBeacon::isActive).count() > 0) + { + Scoreboard.write(_kings.get(red).getName(true)); + Scoreboard.write("Protected"); + } + else + { + Scoreboard.write(_kings.get(red).getName(true) + " Health"); + Scoreboard.write(_kings.get(red).getHealth() + ""); + } + Scoreboard.writeNewLine(); + if (_beacons.get(blue).stream().filter(TeamBeacon::isActive).count() > 0) + { + Scoreboard.write(_kings.get(blue).getName(true)); + Scoreboard.write("Protected"); + } + else + { + Scoreboard.write(_kings.get(blue).getName(true) + " Health"); + Scoreboard.write(_kings.get(blue).getHealth() + ""); + } + Scoreboard.draw(); + } + + public void writeFinalScoreboard(String deadKing, String winKing, String warrior) + { + _writeScoreboard = false; + Scoreboard.reset(); + Scoreboard.writeNewLine(); + Scoreboard.write(deadKing + "'s " + C.cBlue + "castle has been conquered"); + Scoreboard.write(C.cBlue + "by " + winKing + "'s " + C.cBlue + "army with the help of"); + Scoreboard.write(warrior + C.cBlue + "!"); + Scoreboard.writeNewLine(); + + Scoreboard.draw(); + } + + @Override + public void ParseData() + { + for (Location chestLoc : WorldData.GetDataLocs("BROWN")) + { + Block block = chestLoc.getBlock(); + block.setType(Material.CHEST); + fillChest(block); + _chests.add(block); + } + GameTeam red = GetTeam(ChatColor.RED); + GameTeam blue = GetTeam(ChatColor.AQUA); + Location redKing = WorldData.GetDataLocs("RED").get(0); + Location blueKing = WorldData.GetDataLocs("BLUE").get(0); + Vector redBlue = UtilAlg.getTrajectory(redKing, blueKing); + Vector blueRed = UtilAlg.getTrajectory(blueKing, redKing); + redKing.setPitch(UtilAlg.GetPitch(redBlue)); + redKing.setYaw(UtilAlg.GetYaw(redBlue)); + blueKing.setPitch(UtilAlg.GetPitch(blueRed)); + blueKing.setYaw(UtilAlg.GetYaw(blueRed)); + _beacons.put(red, Arrays.asList(new TeamBeacon(red, WorldData.GetDataLocs("PINK").get(0)), new TeamBeacon(red, WorldData.GetDataLocs("PINK").get(1)))); + _beacons.put(blue, Arrays.asList(new TeamBeacon(blue, WorldData.GetDataLocs("LIGHT_BLUE").get(0)), new TeamBeacon(blue, WorldData.GetDataLocs("LIGHT_BLUE").get(1)))); + this.CreatureAllowOverride = true; + _kings.put(red, new TeamKing(red, "King Jon", redKing)); + _kings.put(blue, new TeamKing(blue, "King Ryan", blueKing)); + this.CreatureAllowOverride = false; + _tntSpawner = new ObjectiveTNTSpawner(WorldData.GetDataLocs("BLACK")); + } + + @Override + public void EndCheck() + { + if (!IsLive()) + { + return; + } + + List teamsAlive = new ArrayList<>(); + + for (GameTeam team : GetTeamList()) + { + if (team.GetPlayers(true).size() > 0) + { + teamsAlive.add(team); + } + } + + if (teamsAlive.size() <= 1) + { + //Announce + if (teamsAlive.size() > 0) + { + GameTeam winner = teamsAlive.get(0); + TeamKing king = _kings.get(winner); + TeamKing dead = _kings.values().stream().filter(k -> k.getOwner().GetColor() != king.getOwner().GetColor()).findFirst().get(); + AnnounceEnd(winner); + writeFinalScoreboard(dead.getName(false), king.getName(false), dead.getOwner().GetColor() + "Quitters"); + boolean announcedMedalStart = false; + for (MedalType type : MedalType.values()) + { + Player[] rewarding = getMedalOwners(type); + if (rewarding[0] != null) + { + if (!announcedMedalStart) + { + announcedMedalStart = true; + Bukkit.broadcastMessage(C.cGoldB + "-==Match Medal Recipients==-"); + } + AddGems(rewarding[0], 50, MedalLevel.GOLD.getName() + " " + type.getName(), false, false); + AddStat(rewarding[0], "Medalist", 1, false, false); + Bukkit.broadcastMessage(MedalLevel.GOLD.getName() + " " + type.getName() + C.cGray + ": " + MedalLevel.GOLD.getColor() + rewarding[0].getName()); + } + if (rewarding[1] != null) + { + AddGems(rewarding[1], 30, MedalLevel.SILVER.getName() + " " + type.getName(), false, false); + AddStat(rewarding[1], "Medalist", 1, false, false); + Bukkit.broadcastMessage(MedalLevel.SILVER.getName() + " " + type.getName() + C.cGray + ": " + MedalLevel.SILVER.getColor() + rewarding[1].getName()); + } + if (rewarding[2] != null) + { + AddGems(rewarding[2], 20, MedalLevel.BRONZE.getName() + " " + type.getName(), false, false); + AddStat(rewarding[2], "Medalist", 1, false, false); + Bukkit.broadcastMessage(MedalLevel.BRONZE.getName() + " " + type.getName() + C.cGray + ": " + MedalLevel.BRONZE.getColor() + rewarding[2].getName()); + } + } + for (GameTeam team : GetTeamList()) + { + for (Player player : team.GetPlayers(true)) + { + if (team.GetColor() == winner.GetColor()) + { + AddGems(player, 100, "Winning Team", false, false); + } + else + { + AddGems(player, 50, "Losing Team", false, false); + } + if (player.isOnline()) + { + AddGems(player, 10, "Participation", false, false); + } + + int streak = _streakData.getOrDefault(player, new KillStreakData()).getBestStreak(); + if (streak > 0) + { + AddGems(player, streak, streak + " Player Kill Streak", false, false); + } + + if (GetKit(player) != null) + { + KitPlayer kit = (KitPlayer) GetKit(player); + int kitLevel = kit.getUpgradeLevel(player.getUniqueId()); + if (kitLevel > 0) + { + int crowns = 0; + for (GemData data : GetGems(player).values()) + { + crowns += data.Gems; + } + + AddGems(player, (0.5 * kitLevel) * crowns, kit.GetName() + " Kit Level Bonus", false, false); + } + } + } + } + SetState(GameState.End); + return; + } + } + } + + @Override + @EventHandler + public void ScoreboardUpdate(UpdateEvent event) {}; + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + { + return; + } + if (IsLive()) + { + if (UtilTime.elapsed(_lastRefill, TIME_TILL_REFILL)) + { + _lastRefill = System.currentTimeMillis(); + _chests.forEach(this::fillChest); + Bukkit.broadcastMessage(C.cGreenB + "Chests have refilled!"); + } + + GameTeam red = GetTeam(ChatColor.RED); + GameTeam blue = GetTeam(ChatColor.AQUA); + TeamKing redKing = _kings.get(red); + TeamKing blueKing = _kings.get(blue); + redKing.update(_beacons.get(red).stream().filter(TeamBeacon::isActive).count() > 0); + if (redKing.isDead()) + { + AnnounceEnd(blue); + writeFinalScoreboard(redKing.getName(false), blueKing.getName(false), blue.GetColor() + redKing.getLastDamager()); + boolean announcedMedalStart = false; + for (MedalType type : MedalType.values()) + { + Player[] rewarding = getMedalOwners(type); + if (rewarding[0] != null) + { + if (!announcedMedalStart) + { + announcedMedalStart = true; + Bukkit.broadcastMessage(C.cGoldB + "-==Match Medal Recipients==-"); + } + AddGems(rewarding[0], 50, MedalLevel.GOLD.getName() + " " + type.getName(), false, false); + AddStat(rewarding[0], "Medalist", 1, false, false); + Bukkit.broadcastMessage(MedalLevel.GOLD.getName() + " " + type.getName() + C.cGray + ": " + MedalLevel.GOLD.getColor() + rewarding[0].getName()); + } + if (rewarding[1] != null) + { + AddGems(rewarding[1], 30, MedalLevel.SILVER.getName() + " " + type.getName(), false, false); + AddStat(rewarding[1], "Medalist", 1, false, false); + Bukkit.broadcastMessage(MedalLevel.SILVER.getName() + " " + type.getName() + C.cGray + ": " + MedalLevel.SILVER.getColor() + rewarding[1].getName()); + } + if (rewarding[2] != null) + { + AddGems(rewarding[2], 20, MedalLevel.BRONZE.getName() + " " + type.getName(), false, false); + AddStat(rewarding[2], "Medalist", 1, false, false); + Bukkit.broadcastMessage(MedalLevel.BRONZE.getName() + " " + type.getName() + C.cGray + ": " + MedalLevel.BRONZE.getColor() + rewarding[2].getName()); + } + } + for (GameTeam team : GetTeamList()) + { + for (Player player : team.GetPlayers(true)) + { + if (player.getName().equals(redKing.getLastDamager())) + { + AddGems(player, 20, "King Slayer", false, false); + } + if (team.GetColor() == ChatColor.AQUA) + { + AddGems(player, 100, "Winning Team", false, false); + } + else + { + AddGems(player, 50, "Losing Team", false, false); + } + if (player.isOnline()) + { + AddGems(player, 10, "Participation", false, false); + } + + int streak = _streakData.getOrDefault(player, new KillStreakData()).getBestStreak(); + if (streak > 0) + { + AddGems(player, streak, streak + " Player Kill Streak", false, false); + } + + KitPlayer kit = (KitPlayer) GetKit(player); + int kitLevel = kit.getUpgradeLevel(player.getUniqueId()); + if (kitLevel > 0) + { + int crowns = 0; + for (GemData data : GetGems(player).values()) + { + crowns += data.Gems; + } + + AddGems(player, (0.5 * kitLevel) * crowns, kit.GetName() + " Kit Level Bonus", false, false); + } + } + } + SetState(GameState.End); + return; + } + blueKing.update(_beacons.get(blue).stream().filter(TeamBeacon::isActive).count() > 0); + if (blueKing.isDead()) + { + AnnounceEnd(red); + writeFinalScoreboard(blueKing.getName(false), redKing.getName(false), red.GetColor() + blueKing.getLastDamager()); + boolean announcedMedalStart = false; + for (MedalType type : MedalType.values()) + { + Player[] rewarding = getMedalOwners(type); + if (rewarding[0] != null) + { + if (!announcedMedalStart) + { + announcedMedalStart = true; + Bukkit.broadcastMessage(C.cGoldB + "-==Match Medal Recipients==-"); + } + AddGems(rewarding[0], 50, MedalLevel.GOLD.getName() + " " + type.getName(), false, false); + AddStat(rewarding[0], "Medalist", 1, false, false); + Bukkit.broadcastMessage(MedalLevel.GOLD.getName() + " " + type.getName() + C.cGray + ": " + MedalLevel.GOLD.getColor() + rewarding[0].getName()); + } + if (rewarding[1] != null) + { + AddGems(rewarding[1], 30, MedalLevel.SILVER.getName() + " " + type.getName(), false, false); + AddStat(rewarding[1], "Medalist", 1, false, false); + Bukkit.broadcastMessage(MedalLevel.SILVER.getName() + " " + type.getName() + C.cGray + ": " + MedalLevel.SILVER.getColor() + rewarding[1].getName()); + } + if (rewarding[2] != null) + { + AddGems(rewarding[2], 20, MedalLevel.BRONZE.getName() + " " + type.getName(), false, false); + AddStat(rewarding[2], "Medalist", 1, false, false); + Bukkit.broadcastMessage(MedalLevel.BRONZE.getName() + " " + type.getName() + C.cGray + ": " + MedalLevel.BRONZE.getColor() + rewarding[2].getName()); + } + } + for (GameTeam team : GetTeamList()) + { + for (Player player : team.GetPlayers(true)) + { + if (player.getName().equals(blueKing.getLastDamager())) + { + AddGems(player, 20, "King Slayer", false, false); + } + if (team.GetColor() == ChatColor.RED) + { + AddGems(player, 100, "Winning Team", false, false); + } + else + { + AddGems(player, 50, "Losing Team", false, false); + } + if (player.isOnline()) + { + AddGems(player, 10, "Participation", false, false); + } + + int streak = _streakData.getOrDefault(player, new KillStreakData()).getBestStreak(); + if (streak > 0) + { + AddGems(player, streak, streak + " Player Kill Streak", false, false); + } + + KitPlayer kit = (KitPlayer) GetKit(player); + int kitLevel = kit.getUpgradeLevel(player.getUniqueId()); + if (kitLevel > 0) + { + int crowns = 0; + for (GemData data : GetGems(player).values()) + { + crowns += data.Gems; + } + + AddGems(player, (0.5 * kitLevel) * crowns, kit.GetName() + " Kit Level Bonus", false, false); + } + } + } + SetState(GameState.End); + return; + } + + _tntSpawner.update(); + } + if (InProgress()) + { + writeScoreboard(); + } + } + + @EventHandler + public void onEditSettings(GameStateChangeEvent event) + { + if (event.GetGame() != this) + { + return; + } + + if (event.GetState() == GameState.Live) + { + _lastRefill = System.currentTimeMillis(); + _tntSpawner.onStart(); + Manager.GetDamage().SetEnabled(false); + Manager.GetExplosion().setEnabled(false); + Manager.GetCreature().SetDisableCustomDrops(true); + } + + if (event.GetState() == GameState.End) + { + Manager.GetDamage().SetEnabled(true); + Manager.GetExplosion().setEnabled(true); + Manager.GetCreature().SetDisableCustomDrops(false); + } + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void handleDeath(CombatDeathEvent event) + { + if (!IsLive()) + { + return; + } + + event.SetBroadcastType(DeathMessageType.Detailed); + } + + @EventHandler + public void disableDamageLevel(CustomDamageEvent event) + { + event.SetDamageToLevel(false); + } + + @EventHandler + public void BlockFade(BlockFadeEvent event) + { + event.setCancelled(true); + } + + @EventHandler + public void BlockBurn(BlockBurnEvent event) + { + event.setCancelled(true); + } + + @EventHandler + public void BlockDecay(LeavesDecayEvent event) + { + event.setCancelled(true); + } + + @EventHandler + public void hangingBreak(HangingBreakEvent event) + { + if (event.getEntity() instanceof ItemFrame || event.getEntity() instanceof Painting) + { + event.setCancelled(true); + } + } + + @EventHandler + public void noFlow(BlockFromToEvent event) + { + if (!IsLive()) + { + return; + } + + Block block = event.getBlock(); + if (block.getType() == Material.WATER || block.getType() == Material.STATIONARY_WATER || block.getType() == Material.LAVA || block.getType() == Material.STATIONARY_LAVA) + { + event.setCancelled(true); + } + } + + @SuppressWarnings("deprecation") + @EventHandler(ignoreCancelled=true) + public void onPlayerEmptyBucket(PlayerBucketEmptyEvent event) + { + if (!IsLive()) + { + return; + } + + Player player = event.getPlayer(); + if (player.getItemInHand().getType() == Material.WATER_BUCKET) + { + player.getItemInHand().setType(Material.BUCKET); + Block block = event.getBlockClicked().getRelative(event.getBlockFace()); + if (block.getType().toString().contains("LAVA") || (block.getType().toString().contains("WATER") && block.getType() != Material.WATER_LILY)) + { + event.setCancelled(true); + player.sendBlockChange(block.getLocation(), block.getType(), block.getData()); + return; + } + for (BlockFace bf : BlockFace.values()) + { + Block relative = block.getRelative(bf); + if (relative.getType().toString().contains("LAVA") || (relative.getType().toString().contains("WATER") && relative.getType() != Material.WATER_LILY)) + { + event.setCancelled(true); + player.sendBlockChange(block.getLocation(), block.getType(), block.getData()); + } + } + } + else if (player.getItemInHand().getType() == Material.LAVA_BUCKET) + { + event.setCancelled(true); + Block block = event.getBlockClicked().getRelative(event.getBlockFace()); + player.sendBlockChange(block.getLocation(), block.getType(), block.getData()); + } + } + + @SuppressWarnings("deprecation") + @EventHandler(ignoreCancelled=true) + public void onPlayerEmptyBucket(PlayerBucketFillEvent event) + { + if (!IsLive()) + { + return; + } + + Player player = event.getPlayer(); + if (player.getItemInHand().getType() == Material.LAVA_BUCKET) + { + event.setCancelled(true); + Block block = event.getBlockClicked().getRelative(event.getBlockFace()); + player.sendBlockChange(block.getLocation(), block.getType(), block.getData()); + } + } + + @EventHandler(ignoreCancelled=true) + public void onBlockDispense(BlockDispenseEvent event) + { + if (!IsLive()) + { + return; + } + + if (event.getItem().getType() == Material.WATER_BUCKET) + { + Block dispenser = event.getBlock(); + + MaterialData mat = dispenser.getState().getData(); + Dispenser disp_mat = (Dispenser)mat; + BlockFace face = disp_mat.getFacing(); + Block block = dispenser.getRelative(face); + if (block.getType().toString().contains("LAVA") || (block.getType().toString().contains("WATER") && block.getType() != Material.WATER_LILY)) + { + event.setCancelled(true); + return; + } + for (BlockFace bf : BlockFace.values()) + { + if (block.getRelative(bf).getType().toString().contains("LAVA") || (block.getRelative(bf).getType().toString().contains("WATER") && block.getRelative(bf).getType() != Material.WATER_LILY)) + { + event.setCancelled(true); + } + } + } + } + + @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) + public void onCombatDeath(CombatDeathEvent event) + { + if (!IsLive()) + { + return; + } + + if (event.GetLog().GetKiller() == null) + { + return; + } + + if (!event.GetLog().GetKiller().IsPlayer()) + { + return; + } + + Player player = UtilPlayer.searchExact(event.GetLog().GetKiller().GetName()); + if (player == null) + { + return; + } + + AddStat(player, GetKit(player).GetName() + "KitKills", 1, false, false); + _medalData.computeIfAbsent(player, key -> new MedalData()).addScore(MedalType.ELIM, 1D); + + for (TeamKing king : _kings.values()) + { + if (UtilMath.offsetSquared(player.getLocation(), king.getLocation()) <= 25) + { + _medalData.computeIfAbsent(player, key -> new MedalData()).addScore(MedalType.OBJECTIVE_KILL, 1D); + break; + } + } + + player.setLevel(player.getLevel() + 1); + player.getInventory().addItem(new ItemBuilder(Material.GOLDEN_APPLE).setTitle(C.cPurple + "Golden Applegate").build()); + KillStreakData data = _streakData.computeIfAbsent(player, (key) -> new KillStreakData()); + boolean hardLine = GetKit(player).GetName().equals("Hardline"); + if (data.addKill(hardLine)) + { + AddStat(player, "KillStreak", 1, false, false); + player.sendMessage(C.cRedB + "You have received a Kill Streak Reward!"); + ((KitPlayer)GetKit(player)).awardKillStreak(player, hardLine ? (data.getKills() + 1) : data.getKills()); + } + if (UtilMath.isEven(data.getKills())) + { + Bukkit.broadcastMessage(F.main("Game", C.cGreen + C.Bold + player.getName() + ChatColor.RESET + " is on a " + F.elem(C.cAqua + C.Bold + data.getKills() + " player Kill Streak") + "!")); + } + } + + @EventHandler + public void TNTExplosion(ExplosionPrimeEvent event) + { + if (!event.getEntity().hasMetadata("THROWER")) + { + return; + } + float radius = event.getRadius(); + event.setRadius(0f); + + Player player = UtilPlayer.searchExact(((MetadataValue)UtilEnt.GetMetadata(event.getEntity(), "THROWER")).asString()); + if (player == null) + { + return; + } + if (GetTeam(player) == null) + { + return; + } + if (GetKit(player).GetName().equals("Demolitionist")) + { + radius += 3; + } + + Map nearby = UtilPlayer.getInRadius(event.getEntity().getLocation(), radius); + for (Player near : nearby.keySet()) + { + if (UtilPlayer.isSpectator(near)) + { + continue; + } + if (near.getEntityId() != player.getEntityId() && GetTeam(near).GetColor() == GetTeam(player).GetColor()) + { + continue; + } + if (near.getEntityId() == player.getEntityId() && event.getEntity().hasMetadata("OBJECTIVE_TNT")) + { + continue; + } + + double mult = nearby.get(near); + + int highestBlastProt = 0; + int blastProtEPF = 0; + for (ItemStack item : near.getInventory().getArmorContents()) + { + if (item != null && item.getEnchantments().containsKey(Enchantment.PROTECTION_EXPLOSIONS)) + { + blastProtEPF += (2 * item.getEnchantmentLevel(Enchantment.PROTECTION_EXPLOSIONS)); + if (item.getEnchantmentLevel(Enchantment.PROTECTION_EXPLOSIONS) > highestBlastProt) + { + highestBlastProt = item.getEnchantmentLevel(Enchantment.PROTECTION_EXPLOSIONS); + } + } + } + blastProtEPF = Math.min(blastProtEPF, 20); + + double damage = 8 * mult; + damage = damage * (1 - (blastProtEPF / 25)); + + double knockbackReduction = 1 - (highestBlastProt * 0.15); + + near.damage(damage, event.getEntity()); + UtilAction.velocity(near, UtilAlg.getTrajectory(event.getEntity().getLocation(), near.getLocation()), 1 * mult * knockbackReduction, false, 0, mult * knockbackReduction, 10, true); + } + + if (event.getEntity().hasMetadata("OBJECTIVE_TNT")) + { + List beacons = new ArrayList<>(); + + for (List b : _beacons.values()) + { + beacons.addAll(b); + } + for (TeamBeacon beacon : beacons) + { + if (beacon.isActive() && !beacon.getOwner().HasPlayer(player) && UtilMath.offset(event.getEntity().getLocation(), beacon.getLocation()) <= radius) + { + beacon.destroy(); + AddGems(player, 40, "Beacon Destruction", false, true); + long remaining = beacons.stream().filter(b -> b.getOwner().GetColor() == beacon.getOwner().GetColor()).filter(TeamBeacon::isActive).count(); + if (remaining > 0) + { + Bukkit.broadcastMessage(F.main("Game", "One of " + F.elem(beacon.getOwner().GetFormattedName() + "'s Beacons") + " has been destroyed!")); + } + else + { + Bukkit.broadcastMessage(F.main("Game", "All of " + F.elem(beacon.getOwner().GetFormattedName() + "'s Beacons") + " has been destroyed and " + F.elem(_kings.get(beacon.getOwner()).getName(false)) + " is now vulnerable!")); + } + } + } + } + } + + @EventHandler + public void TNTThrow(PlayerInteractEvent event) + { + if (!IsLive()) + { + return; + } + + if (!UtilEvent.isAction(event, ActionType.L)) + { + return; + } + + Player player = event.getPlayer(); + + if (!UtilInv.IsItem(player.getItemInHand(), Material.TNT, (byte) 0)) + { + return; + } + + if (!IsAlive(player)) + { + return; + } + + event.setCancelled(true); + + if (!Manager.GetGame().CanThrowTNT(player.getLocation())) + { + // Inform + UtilPlayer.message(event.getPlayer(), F.main(GetName(), "You cannot use " + F.item("Throwing TNT") + " here.")); + return; + } + + UtilInv.remove(player, Material.TNT, (byte) 0, 1); + UtilInv.Update(player); + + TNTPrimed tnt = player.getWorld().spawn(player.getEyeLocation().add(player.getLocation().getDirection()), TNTPrimed.class); + + tnt.setFuseTicks(60); + + double throwMult = 1; + + if (GetKit(player).GetName().equals("Demolitionist")) + { + throwMult = ((KitDemolitionist)GetKit(player)).getThrowMultiplier(player); + } + + UtilAction.velocity(tnt, player.getLocation().getDirection(), 0.5 * throwMult, false, 0, 0.1, 10, false); + + UtilEnt.SetMetadata(tnt, "THROWER", player.getName()); + } + + @EventHandler + public void onLaunch(ProjectileHitEvent event) + { + if (!IsLive()) + { + return; + } + + if (event.getEntity() instanceof EnderPearl && event.getEntity().getShooter() != null && event.getEntity().getShooter() instanceof Entity) + { + Entity shooter = (Entity) event.getEntity().getShooter(); + if (_tntCarry.contains(shooter)) + { + return; + } + Location teleport = event.getEntity().getLocation(); + teleport.setPitch(shooter.getLocation().getPitch()); + teleport.setYaw(shooter.getLocation().getYaw()); + shooter.teleport(teleport); + } + } + + @EventHandler + public void onOpenChest(PlayerInteractEvent event) + { + if (!IsLive()) + { + return; + } + + if (event.getClickedBlock() != null && event.getClickedBlock().getType() == Material.CHEST) + { + if (UtilPlayer.isSpectator(event.getPlayer())) + { + event.setCancelled(true); + } + } + } + + @EventHandler(ignoreCancelled = true) + public void onDamage(EntityDamageEvent event) + { + if (!IsLive()) + { + return; + } + if (event.getEntity() instanceof Zombie) + { + event.setCancelled(true); + if (event instanceof EntityDamageByEntityEvent) + { + GameTeam owner = event.getEntity().getCustomName().contains("Ryan") ? GetTeam(ChatColor.AQUA) : GetTeam(ChatColor.RED); + EntityDamageByEntityEvent e = (EntityDamageByEntityEvent) event; + if (e.getDamager() instanceof Player) + { + Player p = (Player) e.getDamager(); + if (UtilPlayer.isSpectator(p)) + { + return; + } + if (owner.HasPlayer(p)) + { + return; + } + if (_beacons.get(owner).stream().filter(TeamBeacon::isActive).count() > 0) + { + UtilPlayer.message(p, F.main("Game", "You cannot attack the enemy king until your team has destroyed his protective beacons!")); + return; + } + TeamKing king = _kings.get(owner); + if (king.handleDamage(p.getName(), e.getDamage())) + { + _medalData.computeIfAbsent(p, key -> new MedalData()).addScore(MedalType.KING_DMG, e.getDamage()); + for (Player alert : owner.GetPlayers(true)) + { + if (Recharge.Instance.use(alert, "KingDamageAlert", 5000, false, false)) + { + alert.sendMessage(king.getName(true) + " is under attack!"); + } + } + } + } + } + } + } + + @EventHandler + public void onDrop(PlayerDropItemEvent event) + { + if (!IsLive()) + { + return; + } + + ItemStack drop = event.getItemDrop().getItemStack(); + if (drop.hasItemMeta() && drop.getItemMeta().hasLore() && drop.getItemMeta().getLore().stream().map(ChatColor::stripColor).anyMatch(lore -> lore.equals("Kit Item"))) + { + event.setCancelled(true); + return; + } + + event.getItemDrop().remove(); + } + + @EventHandler + public void craftItem(PrepareItemCraftEvent event) + { + if (!IsLive()) + { + return; + } + + if (event.getInventory().getResult().getType() == Material.FLINT_AND_STEEL) + { + event.getInventory().setResult(_flintAndSteel.build()); + } + } + + @EventHandler + public void onInvClick(InventoryClickEvent event) + { + if (!IsLive()) + { + return; + } + ItemStack current = event.getCurrentItem(); + if (event.getAction() == InventoryAction.HOTBAR_SWAP || event.getAction() == InventoryAction.HOTBAR_MOVE_AND_READD) + { + current = event.getWhoClicked().getInventory().getItem(event.getHotbarButton()); + } + if (current == null || !current.hasItemMeta()) + { + return; + } + if (current.getItemMeta().hasDisplayName() && current.getItemMeta().getDisplayName().equals(C.cRed + "TNT")) + { + event.setCancelled(true); + return; + } + if (event.getView().getTopInventory() != null && event.getView().getTopInventory().getType() == InventoryType.CHEST) + { + if (current.getItemMeta().hasLore()) + { + for (String lore : current.getItemMeta().getLore()) + { + if (ChatColor.stripColor(lore).equalsIgnoreCase("Kit Item")) + { + event.setCancelled(true); + break; + } + } + } + + } + } + + @EventHandler + public void onFirstBlood(FirstBloodEvent event) + { + if (!IsLive()) + { + return; + } + + AddStat(event.getPlayer(), "FirstBlood", 1, true, false); + } + + @EventHandler + public void onPearl(PlayerInteractEvent event) + { + if (!IsLive()) + { + return; + } + + if (!UtilEvent.isAction(event, ActionType.R)) + { + return; + } + + if (event.getItem() != null && event.getItem().getType() == Material.ENDER_PEARL) + { + Player player = (Player) event.getPlayer(); + if (!Recharge.Instance.use(player, "Enderpearl", 4000, true, true)) + { + event.setCancelled(true); + player.updateInventory(); + } + } + } + + @EventHandler + public void onItemDespawn(ItemDespawnEvent event) + { + if (!IsLive()) + { + return; + } + + if (_tntSpawner.isSpawned()) + { + if (_tntSpawner.getItem().getEntityId() == event.getEntity().getEntityId()) + { + event.setCancelled(true); + } + } + } + + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onPickup(PlayerPickupItemEvent event) + { + if (!IsLive()) + { + return; + } + + if (_tntSpawner.isSpawned() && event.getItem().getEntityId() == _tntSpawner.getItem().getEntityId()) + { + event.setCancelled(true); + if (!_tntCarry.contains(event.getPlayer())) + { + _tntSpawner.pickup(); + _tntCarry.add(event.getPlayer()); + event.getPlayer().setMetadata("OLD_HELM", new FixedMetadataValue(UtilServer.getPlugin(), event.getPlayer().getInventory().getHelmet())); + event.getPlayer().setMetadata("TNT_START", new FixedMetadataValue(UtilServer.getPlugin(), System.currentTimeMillis())); + event.getPlayer().getInventory().setHelmet(_wearableTnt.build()); + UtilPlayer.message(event.getPlayer(), F.main("Game", "You picked up " + F.skill("TNT") + ".")); + UtilPlayer.message(event.getPlayer(), F.main("Game", F.elem("Right-Click") + " to detonate yourself.")); + } + } + } + + @EventHandler(ignoreCancelled = true) + public void TNTUse(PlayerInteractEvent event) + { + Player player = event.getPlayer(); + + if (!_tntCarry.contains(player)) + { + return; + } + + if (!UtilEvent.isAction(event, ActionType.R)) + { + return; + } + + event.setCancelled(true); + + player.getInventory().setHelmet((ItemStack) player.getMetadata("OLD_HELM").get(0).value()); + player.removeMetadata("OLD_HELM", UtilServer.getPlugin()); + player.removeMetadata("TNT_START", UtilServer.getPlugin()); + _tntCarry.remove(player); + + TNTPrimed tnt = player.getWorld().spawn(player.getEyeLocation(), TNTPrimed.class); + UtilEnt.SetMetadata(tnt, "THROWER", player.getName()); + UtilEnt.SetMetadata(tnt, "OBJECTIVE_TNT", true); + tnt.setFuseTicks(0); + UtilPlayer.message(player, F.main("Game", "You used " + F.skill("Detonate") + ".")); + } + + @EventHandler + public void TNTExpire(UpdateEvent event) + { + if (event.getType() != UpdateType.FASTER) + return; + + Iterator tntIterator = _tntCarry.iterator(); + + while (tntIterator.hasNext()) + { + Player player = tntIterator.next(); + + if (player.isDead() || UtilTime.elapsed(player.getMetadata("TNT_START").get(0).asLong(), 60000)) + { + TNTPrimed tnt = player.getWorld().spawn(player.getEyeLocation(), TNTPrimed.class); + UtilEnt.SetMetadata(tnt, "THROWER", player.getName()); + UtilEnt.SetMetadata(tnt, "OBJECTIVE_TNT", true); + tnt.setFuseTicks(0); + + if (!player.isDead()) + { + player.getInventory().setHelmet((ItemStack) player.getMetadata("OLD_HELM").get(0).value()); + } + player.removeMetadata("OLD_HELM", UtilServer.getPlugin()); + player.removeMetadata("TNT_START", UtilServer.getPlugin()); + + tntIterator.remove(); + continue; + } + + UtilFirework.playFirework(player.getEyeLocation(), Type.BURST, Color.RED, false, false); + } + } + + @EventHandler + public void onDeath(PlayerDeathEvent event) + { + Player player = event.getEntity(); + + _streakData.getOrDefault(player, new KillStreakData()).reset(); + + if (!_tntCarry.contains(player)) + { + return; + } + + player.removeMetadata("OLD_HELM", UtilServer.getPlugin()); + player.removeMetadata("TNT_START", UtilServer.getPlugin()); + _tntCarry.remove(player); + TNTPrimed tnt = player.getWorld().spawn(player.getEyeLocation(), TNTPrimed.class); + UtilEnt.SetMetadata(tnt, "THROWER", player.getName()); + UtilEnt.SetMetadata(tnt, "OBJECTIVE_TNT", true); + tnt.setFuseTicks(0); + UtilPlayer.message(player, F.main("Game", "You used " + F.skill("Detonate") + ".")); + } +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/data/CapturePoint.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/data/CapturePoint.java new file mode 100644 index 000000000..3952467e6 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/data/CapturePoint.java @@ -0,0 +1,71 @@ +package nautilus.game.arcade.game.games.castlesiege.data; + +import org.bukkit.Location; +import org.bukkit.entity.Player; + +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import nautilus.game.arcade.game.GameTeam; + +public class CapturePoint +{ + private static final int POINTS_TO_CAPTURE = 100; + private static final long TIME_PER_POINT = 1000; + private static final int POINTS_PER_TICK = 1; + + private Location _loc; + + private long _lastCap; + private int _points = 0; + private GameTeam _owner = null; + + public CapturePoint(GameTeam owner, Location loc) + { + _owner = owner; + + _loc = loc; + } + + public int getMaxPoints() + { + return POINTS_TO_CAPTURE; + } + + public int getPoints() + { + return _points; + } + + public boolean isCaptured() + { + return _points >= POINTS_TO_CAPTURE; + } + + public void update() + { + if (!UtilTime.elapsed(_lastCap, TIME_PER_POINT)) + { + return; + } + + int capping = 0; + for (Player player : UtilPlayer.getInRadius(_loc, 3.5).keySet()) + { + if (UtilPlayer.isSpectator(player)) + { + continue; + } + if (_owner.HasPlayer(player)) + { + continue; + } + capping++; + } + + if (capping > 0 && _points < POINTS_TO_CAPTURE) + { + _lastCap = System.currentTimeMillis(); + _points += POINTS_PER_TICK; + } + } +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/data/KillStreakData.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/data/KillStreakData.java new file mode 100644 index 000000000..2735f5026 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/data/KillStreakData.java @@ -0,0 +1,47 @@ +package nautilus.game.arcade.game.games.castlesiege.data; + +public class KillStreakData +{ + private static final int[] REWARDED_STREAKS = {2, 4, 6, 8}; + private int _kills; + private int _bestStreak; + + public KillStreakData() + { + _kills = 0; + _bestStreak = 0; + } + + public int getKills() + { + return _kills; + } + + public int getBestStreak() + { + return Math.max(_bestStreak, _kills); + } + + public boolean addKill(boolean hardLine) + { + _kills++; + for (int streak : REWARDED_STREAKS) + { + if ((_kills + (hardLine ? 1 : 0)) == streak) + { + return true; + } + } + + return false; + } + + public void reset() + { + if (_kills > _bestStreak) + { + _bestStreak = _kills; + } + _kills = 0; + } +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/data/ObjectiveTNTSpawner.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/data/ObjectiveTNTSpawner.java new file mode 100644 index 000000000..648749147 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/data/ObjectiveTNTSpawner.java @@ -0,0 +1,81 @@ +package nautilus.game.arcade.game.games.castlesiege.data; + +import java.util.List; + +import org.bukkit.Color; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.FireworkEffect.Type; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Item; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.UtilFirework; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilTime; + +public class ObjectiveTNTSpawner +{ + private List _locs; + private Location _lastSpawnLoc; + private Item _entity; + private long _lastPickedUp; + + public ObjectiveTNTSpawner(List locs) + { + _locs = locs; + _lastSpawnLoc = null; + _entity = null; + _lastPickedUp = System.currentTimeMillis(); + } + + public Item getItem() + { + return _entity; + } + + public boolean isSpawned() + { + return _entity != null; + } + + public long getNextTNT() + { + return (_lastPickedUp + 60000) - System.currentTimeMillis(); + } + + public void spawn() + { + Location spawn = _locs.get(UtilMath.r(_locs.size())); + spawn.getBlock().getRelative(BlockFace.DOWN).setType(Material.REDSTONE_BLOCK); + _lastSpawnLoc = spawn.clone(); + _entity = spawn.getWorld().dropItem(spawn, new ItemStack(Material.TNT)); + UtilFirework.playFirework(spawn, Type.BURST, Color.RED, false, false); + } + + public void pickup() + { + _entity.getLocation().getBlock().getRelative(BlockFace.DOWN).setType(Material.IRON_BLOCK); + _entity.remove(); + _entity = null; + _lastSpawnLoc = null; + _lastPickedUp = System.currentTimeMillis(); + } + + public void update() + { + if (!isSpawned() && UtilTime.elapsed(_lastPickedUp, 60000)) + { + spawn(); + } + else if (isSpawned()) + { + _entity.teleport(_lastSpawnLoc); + } + } + + public void onStart() + { + _lastPickedUp = System.currentTimeMillis(); + } +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/data/TeamBeacon.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/data/TeamBeacon.java new file mode 100644 index 000000000..74469579d --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/data/TeamBeacon.java @@ -0,0 +1,48 @@ +package nautilus.game.arcade.game.games.castlesiege.data; + +import org.bukkit.Location; +import org.bukkit.Material; + +import nautilus.game.arcade.game.GameTeam; + +public class TeamBeacon +{ + private Location _loc; + private GameTeam _owner; + private boolean _destroyed; + + public TeamBeacon(GameTeam owner, Location loc) + { + _owner = owner; + _loc = loc; + + spawn(); + } + + public GameTeam getOwner() + { + return _owner; + } + + public Location getLocation() + { + return _loc; + } + + public boolean isActive() + { + return !_destroyed; + } + + public void spawn() + { + _destroyed = false; + _loc.getBlock().setType(Material.BEACON); + } + + public void destroy() + { + _destroyed = true; + _loc.getBlock().setType(Material.AIR); + } +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/data/TeamKing.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/data/TeamKing.java new file mode 100644 index 000000000..a925064dd --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/data/TeamKing.java @@ -0,0 +1,122 @@ +package nautilus.game.arcade.game.games.castlesiege.data; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Zombie; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilTime; +import mineplex.core.itemstack.ItemBuilder; +import nautilus.game.arcade.game.GameTeam; + +public class TeamKing +{ + private static final int MAX_HEALTH = 600; + private Location _loc; + private String _name; + private GameTeam _owner; + private Zombie _entity; + private int _health; + private String _lastDamager; + private long _lastDamage; + + public TeamKing(GameTeam owner, String name, Location loc) + { + _owner = owner; + _loc = loc; + _name = name; + _health = MAX_HEALTH; + _entity = (Zombie) loc.getWorld().spawnEntity(loc, EntityType.ZOMBIE); + UtilEnt.vegetate(_entity, true); + _entity.getEquipment().setHelmet(new ItemBuilder(Material.DIAMOND_HELMET).setUnbreakable(true).build()); + _entity.getEquipment().setChestplate(new ItemBuilder(Material.DIAMOND_CHESTPLATE).setUnbreakable(true).build()); + _entity.getEquipment().setLeggings(new ItemBuilder(Material.DIAMOND_LEGGINGS).setUnbreakable(true).build()); + _entity.getEquipment().setBoots(new ItemBuilder(Material.DIAMOND_BOOTS).setUnbreakable(true).build()); + _entity.setRemoveWhenFarAway(false); + _entity.setCustomName(owner.GetColor() + name); + } + + public GameTeam getOwner() + { + return _owner; + } + + public Location getLocation() + { + return _loc; + } + + public String getName(boolean bold) + { + return _owner.GetColor() + (bold ? C.Bold : "") + _name; + } + + public String getLastDamager() + { + return _lastDamager; + } + + public int getHealth() + { + return Math.max(_health, 0); + } + + public boolean isDead() + { + return getHealth() <= 0; + } + + public void update(boolean beaconsAlive) + { + _entity.teleport(_loc); + for (int y = 0; y <= 4; y++) + { + for (int x = -4; x <= 4; x++) + { + for (int z = -4; z <= 4; z++) + { + Block block = _loc.clone().add(x, y, z).getBlock(); + if ((block.getType() != Material.IRON_FENCE && block.getType() != Material.IRON_BLOCK) || !beaconsAlive) + { + block.setType(Material.AIR); + } + if (beaconsAlive) + { + if (x == -4 || x == 4 || z == -4 || z == 4) + { + if (y != 4) + { + block.setType(Material.IRON_FENCE); + } + } + if (y == 4) + { + block.setType(Material.IRON_BLOCK); + } + } + } + } + } + } + + public boolean handleDamage(String player, double damage) + { + if (!UtilTime.elapsed(_lastDamage, 400)) + { + return false; + } + _lastDamager = player; + _lastDamage = System.currentTimeMillis(); + + int dmg = (int)Math.ceil(damage); + + _health -= dmg; + + UtilEnt.PlayDamageSound(_entity); + + return true; + } +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/data/medals/MedalData.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/data/medals/MedalData.java new file mode 100644 index 000000000..2943d761a --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/data/medals/MedalData.java @@ -0,0 +1,55 @@ +package nautilus.game.arcade.game.games.castlesiege.data.medals; + +import java.util.HashMap; +import java.util.Map; + +import org.bukkit.ChatColor; + +import mineplex.core.common.util.C; + +public class MedalData +{ + private Map _medalScore; + + public MedalData() + { + _medalScore = new HashMap<>(); + } + + public Double getScore(MedalType type) + { + return _medalScore.computeIfAbsent(type, key -> 0D); + } + + public void addScore(MedalType kingDmg, Double score) + { + _medalScore.merge(kingDmg, score, Double::sum); + } + + public static enum MedalLevel + { + GOLD(C.cGold + "Gold", ChatColor.GOLD), + SILVER(C.cGray + "Silver", ChatColor.GRAY), + BRONZE(C.cWhite + "Bronze", ChatColor.WHITE) + ; + + private String _name; + private ChatColor _color; + + private MedalLevel(String name, ChatColor color) + { + _name = name; + _color = color; + } + + public String getName() + { + return _name; + } + + public ChatColor getColor() + { + return _color; + } + } +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/data/medals/MedalType.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/data/medals/MedalType.java new file mode 100644 index 000000000..e12f1bb36 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/data/medals/MedalType.java @@ -0,0 +1,21 @@ +package nautilus.game.arcade.game.games.castlesiege.data.medals; + +public enum MedalType +{ + ELIM("Eliminations"), + KING_DMG("Damage on King"), + OBJECTIVE_KILL("Objective Kills") + ; + + private String _name; + + private MedalType(String name) + { + _name = name; + } + + public String getName() + { + return _name; + } +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitAlchemist.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitAlchemist.java new file mode 100644 index 000000000..31d0dec71 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitAlchemist.java @@ -0,0 +1,32 @@ +package nautilus.game.arcade.game.games.castlesiege.shockkits; + +import org.bukkit.Material; +import org.bukkit.entity.Player; + +import mineplex.core.itemstack.ItemBuilder; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; + +public class KitAlchemist extends KitPlayer +{ + public KitAlchemist(ArcadeManager manager) + { + super(manager, "Alchemist", KitAvailability.Free, new String[] {}, new Perk[] {}, Material.POTION); + } + + @Override + public void GiveItems(Player player) + { + player.getInventory().setItem(0, new ItemBuilder(Material.IRON_SWORD).setUnbreakable(true).build()); + player.getInventory().setItem(1, new ItemBuilder(Material.POTION).setData((short)8194).build()); + player.getInventory().setItem(2, new ItemBuilder(Material.POTION).setData((short)8193).build()); + player.getInventory().setHelmet(new ItemBuilder(Material.IRON_HELMET).setUnbreakable(true).build()); + player.getInventory().setChestplate(new ItemBuilder(Material.IRON_CHESTPLATE).setUnbreakable(true).build()); + player.getInventory().setLeggings(new ItemBuilder(Material.IRON_LEGGINGS).setUnbreakable(true).build()); + player.getInventory().setBoots(new ItemBuilder(Material.IRON_BOOTS).setUnbreakable(true).build()); + } + + @Override + public void awardKillStreak(Player player, int streak) {} +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitArcher.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitArcher.java new file mode 100644 index 000000000..e8b0d5f4e --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitArcher.java @@ -0,0 +1,133 @@ +package nautilus.game.arcade.game.games.castlesiege.shockkits; + +import org.bukkit.Material; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.Player; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.itemstack.EnchantedBookBuilder; +import mineplex.core.itemstack.ItemBuilder; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.perks.PerkFletcher; + +public class KitArcher extends KitPlayer +{ + public KitArcher(ArcadeManager manager) + { + super(manager, "Archer", KitAvailability.Free, + new String[] + { + C.cGrayB + "Starting Kit:", + C.cGray + "Diamond Sword", + C.cGray + "Diamond Helmet, Iron Chestplate, Iron Leggings, Diamond Boots", + C.cGray + "10 Fletched Arrows", + C.cGreenB + "Starting Ability:", + C.cGreen + "Fletcher: Obtain 1 Fletched Arrow every 7 seconds (Max of 10)" + }, + new Perk[][] + { + new Perk[] {new PerkFletcher(7, 10, true, false)}, + new Perk[] {new PerkFletcher(7, 16, true, false)}, + new Perk[] {new PerkFletcher(7, 24, true, false)}, + new Perk[] {new PerkFletcher(7, 32, true, false)}, + new Perk[] {new PerkFletcher(7, 32, true, false)}, + new Perk[] {new PerkFletcher(7, 32, true, false)} + }, + new String[][] + { + { + C.cGray + "Increase maximum and starting amount of Fletched Arrows to 16" + }, + { + C.cGray + "Increase maximum and starting amount of Fletched Arrows to 24", + C.cGray + "Obtain a Power I Enchantment on your Bow" + }, + { + C.cGray + "Increase maximum and starting amount of Fletched Arrows to 32", + }, + { + C.cGray + "Obtain a Power II Enchantment on your Bow" + }, + { + C.cGray + "Receive a Feather Falling IV Enchantment on your Diamond Boots" + } + }, + Material.BOW); + } + + @Override + public void GiveItems(Player player) + { + giveRegeneration(player); + + player.getInventory().setItem(0, new ItemBuilder(Material.DIAMOND_SWORD).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + + int level = getUpgradeLevel(player.getUniqueId()); + if (level == 0) + { + player.getInventory().setItem(1, new ItemBuilder(Material.BOW).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + player.getInventory().setItem(2, new ItemBuilder(Material.ARROW).setAmount(10).setTitle(F.item("Fletched Arrow")).build()); + } + else if (level == 1) + { + player.getInventory().setItem(1, new ItemBuilder(Material.BOW).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + player.getInventory().setItem(2, new ItemBuilder(Material.ARROW).setAmount(16).setTitle(F.item("Fletched Arrow")).build()); + } + else if (level == 2) + { + player.getInventory().setItem(1, new ItemBuilder(Material.BOW).addEnchantment(Enchantment.ARROW_DAMAGE, 1).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + player.getInventory().setItem(2, new ItemBuilder(Material.ARROW).setAmount(24).setTitle(F.item("Fletched Arrow")).build()); + } + else if (level == 3) + { + player.getInventory().setItem(1, new ItemBuilder(Material.BOW).addEnchantment(Enchantment.ARROW_DAMAGE, 1).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + player.getInventory().setItem(2, new ItemBuilder(Material.ARROW).setAmount(32).setTitle(F.item("Fletched Arrow")).build()); + } + else if (level == 4) + { + player.getInventory().setItem(1, new ItemBuilder(Material.BOW).addEnchantment(Enchantment.ARROW_DAMAGE, 2).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + player.getInventory().setItem(2, new ItemBuilder(Material.ARROW).setAmount(32).setTitle(F.item("Fletched Arrow")).build()); + } + else if (level == 5) + { + player.getInventory().setItem(1, new ItemBuilder(Material.BOW).addEnchantment(Enchantment.ARROW_DAMAGE, 2).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + player.getInventory().setItem(2, new ItemBuilder(Material.ARROW).setAmount(32).setTitle(F.item("Fletched Arrow")).build()); + } + + player.getInventory().setHelmet(new ItemBuilder(Material.DIAMOND_HELMET).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + player.getInventory().setChestplate(new ItemBuilder(Material.IRON_CHESTPLATE).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + player.getInventory().setLeggings(new ItemBuilder(Material.IRON_LEGGINGS).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + if (level < 5) + { + player.getInventory().setBoots(new ItemBuilder(Material.DIAMOND_BOOTS).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + } + else + { + player.getInventory().setBoots(new ItemBuilder(Material.DIAMOND_BOOTS).addEnchantment(Enchantment.PROTECTION_FALL, 4).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + } + } + + @Override + public void awardKillStreak(Player player, int streak) + { + if (streak == 2) + { + player.getInventory().addItem(new ItemBuilder(Material.ARROW).setAmount(8).setTitle(F.item("Fletched Arrow")).build()); + } + else if (streak == 4) + { + player.getInventory().addItem(new EnchantedBookBuilder(1).setLevel(Enchantment.ARROW_DAMAGE, 1).build()); + } + else if (streak == 6) + { + player.getInventory().addItem(new EnchantedBookBuilder(1).setLevel(Enchantment.ARROW_KNOCKBACK, 1).build()); + } + else if (streak == 8) + { + player.getInventory().addItem(new EnchantedBookBuilder(1).setLevel(Enchantment.ARROW_DAMAGE, 1).build()); + } + } +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitBuilder.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitBuilder.java new file mode 100644 index 000000000..d69929bf1 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitBuilder.java @@ -0,0 +1,32 @@ +package nautilus.game.arcade.game.games.castlesiege.shockkits; + +import org.bukkit.Material; +import org.bukkit.entity.Player; + +import mineplex.core.itemstack.ItemBuilder; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; + +public class KitBuilder extends KitPlayer +{ + public KitBuilder(ArcadeManager manager) + { + super(manager, "Builder", KitAvailability.Free, new String[] {}, new Perk[] {}, Material.STONE); + } + + @Override + public void GiveItems(Player player) + { + player.getInventory().setItem(0, new ItemBuilder(Material.IRON_SWORD).setUnbreakable(true).build()); + player.getInventory().setItem(1, new ItemBuilder(Material.STONE).setAmount(64).build()); + player.getInventory().setItem(2, new ItemBuilder(Material.WOOD).setAmount(64).build()); + player.getInventory().setHelmet(new ItemBuilder(Material.IRON_HELMET).setUnbreakable(true).build()); + player.getInventory().setChestplate(new ItemBuilder(Material.IRON_CHESTPLATE).setUnbreakable(true).build()); + player.getInventory().setLeggings(new ItemBuilder(Material.IRON_LEGGINGS).setUnbreakable(true).build()); + player.getInventory().setBoots(new ItemBuilder(Material.IRON_BOOTS).setUnbreakable(true).build()); + } + + @Override + public void awardKillStreak(Player player, int streak) {} +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitDemolitionist.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitDemolitionist.java new file mode 100644 index 000000000..91717d869 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitDemolitionist.java @@ -0,0 +1,148 @@ +package nautilus.game.arcade.game.games.castlesiege.shockkits; + +import org.bukkit.Material; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.Player; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.itemstack.ItemBuilder; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.perks.PerkBomberHG; + +public class KitDemolitionist extends KitPlayer +{ + public KitDemolitionist(ArcadeManager manager) + { + super(manager, "Demolitionist", KitAvailability.Free, + new String[] + { + C.cGrayB + "Starting Kit:", + C.cGray + "Diamond Sword, Flint and Steel", + C.cGray + "Diamond Helmet, Iron Chestplate, Iron Leggings, Diamond Boots", + C.cGray + "Blast Protection IV on all Armor", + C.cGray + "2 Throwing TNT", + C.cGreenB + "Passive Ability:", + C.cGreen + "3 Block Range Increase on TNT Damage", + C.cGreenB + "Starting Ability:", + C.cGreen + "Bombmaker: Obtain 1 Throwing TNT every 10 seconds (Max of 2)" + }, + new Perk[][] + { + new Perk[] {new PerkBomberHG(10, 2, true)}, + new Perk[] {new PerkBomberHG(10, 4, true)}, + new Perk[] {new PerkBomberHG(10, 6, true)}, + new Perk[] {new PerkBomberHG(10, 4, true)}, + new Perk[] {new PerkBomberHG(10, 4, true)}, + new Perk[] {new PerkBomberHG(10, 6, true)} + }, + new String[][] + { + { + C.cGray + "Increase maximum and starting amount of Throwing TNT to 4" + }, + { + C.cGray + "Increase maximum and starting amount of Throwing TNT to 6" + }, + { + C.cGray + "Reduce maximum and starting amount of Throwing TNT to 4", + C.cGray + "Increase range of Throwing TNT by 1.5 times" + }, + { + C.cGray + "Increase range of Throwing TNT by 2.5 times" + }, + { + C.cGray + "Increase maximum and starting amount of Throwing TNT to 6", + C.cGray + "Increase range of Throwing TNT by 3 times" + } + }, + Material.TNT); + } + + public double getThrowMultiplier(Player player) + { + int level = getUpgradeLevel(player.getUniqueId()); + if (level == 3) + { + return 1.5; + } + else if (level == 4) + { + return 2.5; + } + else if (level == 5) + { + return 3; + } + + return 1; + } + + @Override + public void GiveItems(Player player) + { + giveRegeneration(player); + + player.getInventory().setItem(0, new ItemBuilder(Material.DIAMOND_SWORD).setUnbreakable(true).build()); + + int level = getUpgradeLevel(player.getUniqueId()); + if (level == 0) + { + player.getInventory().setItem(1, getGame().getNewFlintAndSteel(true)); + player.getInventory().setItem(2, new ItemBuilder(Material.TNT).setTitle(F.item("Throwing TNT")).setAmount(2).build()); + } + else if (level == 1) + { + player.getInventory().setItem(1, getGame().getNewFlintAndSteel(true)); + player.getInventory().setItem(2, new ItemBuilder(Material.TNT).setTitle(F.item("Throwing TNT")).setAmount(4).build()); + } + else if (level == 2) + { + player.getInventory().setItem(1, getGame().getNewFlintAndSteel(true)); + player.getInventory().setItem(2, new ItemBuilder(Material.TNT).setTitle(F.item("Throwing TNT")).setAmount(6).build()); + } + else if (level == 3) + { + player.getInventory().setItem(1, getGame().getNewFlintAndSteel(true)); + player.getInventory().setItem(2, new ItemBuilder(Material.TNT).setTitle(F.item("Throwing TNT")).setAmount(4).build()); + } + else if (level == 4) + { + player.getInventory().setItem(1, getGame().getNewFlintAndSteel(true)); + player.getInventory().setItem(2, new ItemBuilder(Material.TNT).setTitle(F.item("Throwing TNT")).setAmount(4).build()); + } + else if (level == 5) + { + player.getInventory().setItem(1, getGame().getNewFlintAndSteel(true)); + player.getInventory().setItem(2, new ItemBuilder(Material.TNT).setTitle(F.item("Throwing TNT")).setAmount(6).build()); + } + + player.getInventory().setHelmet(new ItemBuilder(Material.DIAMOND_HELMET).addEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 4).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + player.getInventory().setChestplate(new ItemBuilder(Material.IRON_CHESTPLATE).addEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 4).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + player.getInventory().setLeggings(new ItemBuilder(Material.IRON_LEGGINGS).addEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 4).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + player.getInventory().setBoots(new ItemBuilder(Material.DIAMOND_BOOTS).addEnchantment(Enchantment.PROTECTION_EXPLOSIONS, 4).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + } + + @Override + public void awardKillStreak(Player player, int streak) + { + if (streak == 2) + { + player.getInventory().addItem(new ItemBuilder(Material.TNT).setTitle(F.item("Throwing TNT")).setAmount(2).build()); + } + else if (streak == 4) + { + player.getInventory().addItem(new ItemBuilder(Material.TNT).setTitle(F.item("Throwing TNT")).setAmount(3).build()); + } + else if (streak == 6) + { + player.getInventory().addItem(new ItemBuilder(Material.TNT).setTitle(F.item("Throwing TNT")).setAmount(4).build()); + } + else if (streak == 8) + { + player.getInventory().addItem(new ItemBuilder(Material.TNT).setTitle(F.item("Throwing TNT")).setAmount(5).build()); + } + } +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitEnchanter.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitEnchanter.java new file mode 100644 index 000000000..f25217ad6 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitEnchanter.java @@ -0,0 +1,35 @@ +package nautilus.game.arcade.game.games.castlesiege.shockkits; + +import org.bukkit.Material; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.Player; + +import mineplex.core.itemstack.EnchantedBookBuilder; +import mineplex.core.itemstack.ItemBuilder; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; + +public class KitEnchanter extends KitPlayer +{ + public KitEnchanter(ArcadeManager manager) + { + super(manager, "Enchanter", KitAvailability.Free, new String[] {}, new Perk[] {}, Material.ENCHANTED_BOOK); + } + + @Override + public void GiveItems(Player player) + { + player.getInventory().setItem(0, new ItemBuilder(Material.IRON_SWORD).setUnbreakable(true).build()); + player.getInventory().setItem(1, new EnchantedBookBuilder(1).setLevel(Enchantment.DAMAGE_ALL, 1).build()); + player.getInventory().setItem(2, new EnchantedBookBuilder(1).setLevel(Enchantment.PROTECTION_ENVIRONMENTAL, 1).build()); + player.getInventory().setItem(3, new ItemBuilder(Material.EXP_BOTTLE).setAmount(32).build()); + player.getInventory().setHelmet(new ItemBuilder(Material.IRON_HELMET).setUnbreakable(true).build()); + player.getInventory().setChestplate(new ItemBuilder(Material.IRON_CHESTPLATE).setUnbreakable(true).build()); + player.getInventory().setLeggings(new ItemBuilder(Material.IRON_LEGGINGS).setUnbreakable(true).build()); + player.getInventory().setBoots(new ItemBuilder(Material.IRON_BOOTS).setUnbreakable(true).build()); + } + + @Override + public void awardKillStreak(Player player, int streak) {} +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitFighter.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitFighter.java new file mode 100644 index 000000000..5579e0f7c --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitFighter.java @@ -0,0 +1,126 @@ +package nautilus.game.arcade.game.games.castlesiege.shockkits; + +import org.bukkit.Material; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.Player; + +import mineplex.core.common.util.C; +import mineplex.core.itemstack.EnchantedBookBuilder; +import mineplex.core.itemstack.ItemBuilder; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; + +public class KitFighter extends KitPlayer +{ + public KitFighter(ArcadeManager manager) + { + super(manager, "Fighter", KitAvailability.Free, + new String[] + { + C.cGrayB + "Starting Kit:", + C.cGray + "Diamond Sword", + C.cGray + "1 Golden Applegate", + C.cGray + "Diamond Helmet, Iron Chestplate, Iron Leggings, Diamond Boots", + C.cGreenB + "Passive Ability:", + C.cGreen + "Bloodlust: Deal half a heart more damage for 3 seconds after killing an enemy" + }, + new Perk[][] + { + new Perk[] {new PerkBloodlust(1, 3)}, + new Perk[] {new PerkBloodlust(1, 3)}, + new Perk[] {new PerkBloodlust(1, 3)}, + new Perk[] {new PerkBloodlust(1, 3)}, + new Perk[] {new PerkBloodlust(1, 3)}, + new Perk[] {new PerkBloodlust(1, 3)} + }, + new String[][] + { + { + C.cGray + "Increase starting amount of Golden Applegates to 2" + }, + { + C.cGray + "Obtain a Fishing Rod" + }, + { + C.cGray + "Obtain a Sharpness I Enchantment on your Diamond Sword" + }, + { + C.cGray + "Obtain a Knockback II Enchantment on your Fishing Rod", + C.cGray + "Increase starting amount of Golden Applegates to 3" + }, + { + C.cGray + "Obtain a Sharpness II Enchantment on your Diamond Sword" + } + }, + Material.DIAMOND_SWORD); + } + + @Override + public void GiveItems(Player player) + { + giveRegeneration(player); + + int level = getUpgradeLevel(player.getUniqueId()); + if (level == 0) + { + player.getInventory().setItem(0, new ItemBuilder(Material.DIAMOND_SWORD).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + player.getInventory().setItem(1, new ItemBuilder(Material.GOLDEN_APPLE).setAmount(1).setTitle(C.cPurple + "Golden Applegate").setLore(C.cGold + "Kit Item").build()); + } + else if (level == 1) + { + player.getInventory().setItem(0, new ItemBuilder(Material.DIAMOND_SWORD).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + player.getInventory().setItem(1, new ItemBuilder(Material.GOLDEN_APPLE).setAmount(2).setTitle(C.cPurple + "Golden Applegate").setLore(C.cGold + "Kit Item").build()); + } + else if (level == 2) + { + player.getInventory().setItem(0, new ItemBuilder(Material.DIAMOND_SWORD).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + player.getInventory().setItem(1, new ItemBuilder(Material.FISHING_ROD).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + player.getInventory().setItem(2, new ItemBuilder(Material.GOLDEN_APPLE).setAmount(2).setTitle(C.cPurple + "Golden Applegate").setLore(C.cGold + "Kit Item").build()); + } + else if (level == 3) + { + player.getInventory().setItem(0, new ItemBuilder(Material.DIAMOND_SWORD).addEnchantment(Enchantment.DAMAGE_ALL, 1).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + player.getInventory().setItem(1, new ItemBuilder(Material.FISHING_ROD).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + player.getInventory().setItem(2, new ItemBuilder(Material.GOLDEN_APPLE).setAmount(2).setTitle(C.cPurple + "Golden Applegate").setLore(C.cGold + "Kit Item").build()); + } + else if (level == 4) + { + player.getInventory().setItem(0, new ItemBuilder(Material.DIAMOND_SWORD).addEnchantment(Enchantment.DAMAGE_ALL, 1).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + player.getInventory().setItem(1, new ItemBuilder(Material.FISHING_ROD).addEnchantment(Enchantment.KNOCKBACK, 2).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + player.getInventory().setItem(2, new ItemBuilder(Material.GOLDEN_APPLE).setAmount(3).setTitle(C.cPurple + "Golden Applegate").setLore(C.cGold + "Kit Item").build()); + } + else if (level == 5) + { + player.getInventory().setItem(0, new ItemBuilder(Material.DIAMOND_SWORD).addEnchantment(Enchantment.DAMAGE_ALL, 2).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + player.getInventory().setItem(1, new ItemBuilder(Material.FISHING_ROD).addEnchantment(Enchantment.KNOCKBACK, 2).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + player.getInventory().setItem(2, new ItemBuilder(Material.GOLDEN_APPLE).setAmount(3).setTitle(C.cPurple + "Golden Applegate").setLore(C.cGold + "Kit Item").build()); + } + + player.getInventory().setHelmet(new ItemBuilder(Material.DIAMOND_HELMET).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + player.getInventory().setChestplate(new ItemBuilder(Material.IRON_CHESTPLATE).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + player.getInventory().setLeggings(new ItemBuilder(Material.IRON_LEGGINGS).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + player.getInventory().setBoots(new ItemBuilder(Material.DIAMOND_BOOTS).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + } + + @Override + public void awardKillStreak(Player player, int streak) + { + if (streak == 2) + { + player.getInventory().addItem(new ItemBuilder(Material.GOLDEN_APPLE).setAmount(1).setTitle(C.cPurple + "Golden Applegate").build()); + } + else if (streak == 4) + { + player.getInventory().addItem(new EnchantedBookBuilder(1).setLevel(Enchantment.DAMAGE_ALL, 1).build()); + } + else if (streak == 6) + { + player.getInventory().addItem(new EnchantedBookBuilder(1).setLevel(Enchantment.DAMAGE_ALL, 1).build()); + } + else if (streak == 8) + { + player.getInventory().addItem(new EnchantedBookBuilder(1).setLevel(Enchantment.FIRE_ASPECT, 1).build()); + } + } +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitHardline.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitHardline.java new file mode 100644 index 000000000..e80e62e65 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitHardline.java @@ -0,0 +1,30 @@ +package nautilus.game.arcade.game.games.castlesiege.shockkits; + +import org.bukkit.Material; +import org.bukkit.entity.Player; + +import mineplex.core.itemstack.ItemBuilder; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; + +public class KitHardline extends KitPlayer +{ + public KitHardline(ArcadeManager manager) + { + super(manager, "Hardline", KitAvailability.Free, new String[] {}, new Perk[] {}, Material.GOLDEN_APPLE); + } + + @Override + public void GiveItems(Player player) + { + player.getInventory().setItem(0, new ItemBuilder(Material.IRON_SWORD).setUnbreakable(true).build()); + player.getInventory().setHelmet(new ItemBuilder(Material.IRON_HELMET).setUnbreakable(true).build()); + player.getInventory().setChestplate(new ItemBuilder(Material.IRON_CHESTPLATE).setUnbreakable(true).build()); + player.getInventory().setLeggings(new ItemBuilder(Material.IRON_LEGGINGS).setUnbreakable(true).build()); + player.getInventory().setBoots(new ItemBuilder(Material.IRON_BOOTS).setUnbreakable(true).build()); + } + + @Override + public void awardKillStreak(Player player, int streak) {} +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitNinja.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitNinja.java new file mode 100644 index 000000000..20b712abb --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitNinja.java @@ -0,0 +1,33 @@ +package nautilus.game.arcade.game.games.castlesiege.shockkits; + +import org.bukkit.Material; +import org.bukkit.entity.Player; + +import mineplex.core.itemstack.ItemBuilder; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.perks.PerkFallModifier; + +public class KitNinja extends KitPlayer +{ + public KitNinja(ArcadeManager manager) + { + super(manager, "Ninja", KitAvailability.Free, new String[] {}, new Perk[] {new PerkFallModifier(0.5)}, Material.ENDER_PEARL); + } + + @Override + public void GiveItems(Player player) + { + player.getInventory().setItem(0, new ItemBuilder(Material.IRON_SWORD).setUnbreakable(true).build()); + player.getInventory().setItem(1, new ItemBuilder(Material.WATER_BUCKET).build()); + player.getInventory().setItem(2, new ItemBuilder(Material.ENDER_PEARL).setAmount(2).build()); + player.getInventory().setHelmet(new ItemBuilder(Material.IRON_HELMET).setUnbreakable(true).build()); + player.getInventory().setChestplate(new ItemBuilder(Material.IRON_CHESTPLATE).setUnbreakable(true).build()); + player.getInventory().setLeggings(new ItemBuilder(Material.IRON_LEGGINGS).setUnbreakable(true).build()); + player.getInventory().setBoots(new ItemBuilder(Material.IRON_BOOTS).setUnbreakable(true).build()); + } + + @Override + public void awardKillStreak(Player player, int streak) {} +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitPlayer.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitPlayer.java new file mode 100644 index 000000000..b270e8310 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitPlayer.java @@ -0,0 +1,65 @@ +package nautilus.game.arcade.game.games.castlesiege.shockkits; + +import org.bukkit.Material; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; + +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.castlesiege.ShockCastleSiege; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.ProgressingKit; + +public abstract class KitPlayer extends ProgressingKit +{ + private boolean _progressionEnabled = false; + + public KitPlayer(ArcadeManager manager, String name, KitAvailability availability, String[] description, Perk[] perks, Material holding) + { + super(manager, name, "csii" + name.toLowerCase(), availability, description, perks, EntityType.ZOMBIE, new ItemStack(holding)); + } + + public KitPlayer(ArcadeManager manager, String name, KitAvailability availability, String[] description, Perk[][] perks, String[][] upgradeDetails, Material holding) + { + super(manager, name, "csii" + name.toLowerCase(), availability, description, perks, upgradeDetails, EntityType.ZOMBIE, new ItemStack(holding)); + + _progressionEnabled = true; + } + + public abstract void awardKillStreak(Player player, int streak); + + protected ShockCastleSiege getGame() + { + return (ShockCastleSiege) Manager.GetGame(); + } + + protected void giveRegeneration(Player player) + { + player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 20 * 3, 3)); + } + + @Override + public void SpawnCustom(LivingEntity ent) {} + + @Override + public boolean showUpgrades() + { + return _progressionEnabled; + } + + @Override + public boolean crownsEnabled() + { + return true; + } + + @Override + public boolean usesXp() + { + return false; + } +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitTank.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitTank.java new file mode 100644 index 000000000..67e71d8d3 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitTank.java @@ -0,0 +1,133 @@ +package nautilus.game.arcade.game.games.castlesiege.shockkits; + +import org.bukkit.Material; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.Player; + +import mineplex.core.common.util.C; +import mineplex.core.itemstack.EnchantedBookBuilder; +import mineplex.core.itemstack.ItemBuilder; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; +import nautilus.game.arcade.kit.perks.PerkIronSkin; + +public class KitTank extends KitPlayer +{ + public KitTank(ArcadeManager manager) + { + super(manager, "Tank", KitAvailability.Free, + new String[] + { + C.cGrayB + "Starting Kit:", + C.cGray + "Diamond Sword", + C.cGray + "Diamond Helmet, Iron Chestplate, Iron Leggings, Diamond Boots", + C.cGray + "Protection I on Iron Armor", + C.cGreenB + "Passive Ability:", + C.cGreen + "Iron Skin: Take half a heart less damage from all Attacks" + }, + new Perk[][] + { + new Perk[] {new PerkIronSkin(1, false)}, + new Perk[] {new PerkIronSkin(1, false)}, + new Perk[] {new PerkIronSkin(1, false)}, + new Perk[] {new PerkIronSkin(1, false)}, + new Perk[] {new PerkIronSkin(1, false)}, + new Perk[] {new PerkIronSkin(1, false)} + }, + new String[][] + { + { + C.cGray + "Obtain a Protection II Enchantment on your Iron Armor" + }, + { + C.cGray + "Obtain a Protection I Enchantment on your Diamond Helmet" + }, + { + C.cGray + "Obtain a Protection I Enchantment on your Diamond Boots" + }, + { + C.cGray + "Obtain a Protection II Enchantment on your Diamond Helmet", + C.cGray + "Obtain a Protection II Enchantment on your Diamond Boots" + }, + { + C.cGray + "Obtain a Protection III Enchantment on your Iron Chestplate", + C.cGray + "Obtain a Protection III Enchantment on your Iron Leggings" + } + }, + Material.DIAMOND_CHESTPLATE); + } + + @Override + public void GiveItems(Player player) + { + giveRegeneration(player); + + player.getInventory().setItem(0, new ItemBuilder(Material.DIAMOND_SWORD).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + + int level = getUpgradeLevel(player.getUniqueId()); + if (level == 0) + { + player.getInventory().setHelmet(new ItemBuilder(Material.DIAMOND_HELMET).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + player.getInventory().setChestplate(new ItemBuilder(Material.IRON_CHESTPLATE).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + player.getInventory().setLeggings(new ItemBuilder(Material.IRON_LEGGINGS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + player.getInventory().setBoots(new ItemBuilder(Material.DIAMOND_BOOTS).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + } + else if (level == 1) + { + player.getInventory().setHelmet(new ItemBuilder(Material.DIAMOND_HELMET).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + player.getInventory().setChestplate(new ItemBuilder(Material.IRON_CHESTPLATE).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + player.getInventory().setLeggings(new ItemBuilder(Material.IRON_LEGGINGS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + player.getInventory().setBoots(new ItemBuilder(Material.DIAMOND_BOOTS).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + } + else if (level == 2) + { + player.getInventory().setHelmet(new ItemBuilder(Material.DIAMOND_HELMET).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + player.getInventory().setChestplate(new ItemBuilder(Material.IRON_CHESTPLATE).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + player.getInventory().setLeggings(new ItemBuilder(Material.IRON_LEGGINGS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + player.getInventory().setBoots(new ItemBuilder(Material.DIAMOND_BOOTS).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + } + else if (level == 3) + { + player.getInventory().setHelmet(new ItemBuilder(Material.DIAMOND_HELMET).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + player.getInventory().setChestplate(new ItemBuilder(Material.IRON_CHESTPLATE).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + player.getInventory().setLeggings(new ItemBuilder(Material.IRON_LEGGINGS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + player.getInventory().setBoots(new ItemBuilder(Material.DIAMOND_BOOTS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + } + else if (level == 4) + { + player.getInventory().setHelmet(new ItemBuilder(Material.DIAMOND_HELMET).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + player.getInventory().setChestplate(new ItemBuilder(Material.IRON_CHESTPLATE).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + player.getInventory().setLeggings(new ItemBuilder(Material.IRON_LEGGINGS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + player.getInventory().setBoots(new ItemBuilder(Material.DIAMOND_BOOTS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + } + else if (level == 5) + { + player.getInventory().setHelmet(new ItemBuilder(Material.DIAMOND_HELMET).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + player.getInventory().setChestplate(new ItemBuilder(Material.IRON_CHESTPLATE).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 3).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + player.getInventory().setLeggings(new ItemBuilder(Material.IRON_LEGGINGS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 3).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + player.getInventory().setBoots(new ItemBuilder(Material.DIAMOND_BOOTS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).setLore(C.cGold + "Kit Item").setUnbreakable(true).build()); + } + } + + @Override + public void awardKillStreak(Player player, int streak) + { + if (streak == 2) + { + player.getInventory().addItem(new ItemBuilder(Material.GOLDEN_APPLE).setAmount(1).setTitle(C.cPurple + "Golden Applegate").build()); + } + else if (streak == 4) + { + player.getInventory().addItem(new EnchantedBookBuilder(1).setLevel(Enchantment.PROTECTION_ENVIRONMENTAL, 1).build()); + } + else if (streak == 6) + { + player.getInventory().addItem(new EnchantedBookBuilder(1).setLevel(Enchantment.PROTECTION_ENVIRONMENTAL, 1).build()); + } + else if (streak == 8) + { + player.getInventory().addItem(new EnchantedBookBuilder(1).setLevel(Enchantment.THORNS, 2).build()); + } + } +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitWorkman.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitWorkman.java new file mode 100644 index 000000000..83e9ec555 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitWorkman.java @@ -0,0 +1,33 @@ +package nautilus.game.arcade.game.games.castlesiege.shockkits; + +import org.bukkit.Material; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.Player; + +import mineplex.core.itemstack.ItemBuilder; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.Perk; + +public class KitWorkman extends KitPlayer +{ + public KitWorkman(ArcadeManager manager) + { + super(manager, "Workman", KitAvailability.Free, new String[] {}, new Perk[] {}, Material.DIAMOND_PICKAXE); + } + + @Override + public void GiveItems(Player player) + { + player.getInventory().setItem(0, new ItemBuilder(Material.IRON_SWORD).setUnbreakable(true).build()); + player.getInventory().setItem(1, new ItemBuilder(Material.DIAMOND_PICKAXE).addEnchantment(Enchantment.DIG_SPEED, 2).setUnbreakable(true).build()); + player.getInventory().setItem(2, new ItemBuilder(Material.DIAMOND_SPADE).addEnchantment(Enchantment.DIG_SPEED, 2).setUnbreakable(true).build()); + player.getInventory().setHelmet(new ItemBuilder(Material.IRON_HELMET).setUnbreakable(true).build()); + player.getInventory().setChestplate(new ItemBuilder(Material.IRON_CHESTPLATE).setUnbreakable(true).build()); + player.getInventory().setLeggings(new ItemBuilder(Material.IRON_LEGGINGS).setUnbreakable(true).build()); + player.getInventory().setBoots(new ItemBuilder(Material.IRON_BOOTS).setUnbreakable(true).build()); + } + + @Override + public void awardKillStreak(Player player, int streak) {} +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/PerkBloodlust.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/PerkBloodlust.java new file mode 100644 index 000000000..7ab56e1b3 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/PerkBloodlust.java @@ -0,0 +1,135 @@ +package nautilus.game.arcade.game.games.castlesiege.shockkits; + +import java.util.Map; +import java.util.WeakHashMap; + +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.PlayerDeathEvent; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; +import nautilus.game.arcade.kit.Perk; + +public class PerkBloodlust extends Perk +{ + private Map _lusting = new WeakHashMap<>(); + + private double _damageBoost; + private int _duration; + + public PerkBloodlust(double damageBoost, int duration) + { + super("Bloodlust", + new String[] + { + C.cGray + "Deal an extra " + (damageBoost / 2) + " hearts of damage for " + duration + " seconds after a kill.", + } + ); + + _damageBoost = damageBoost; + _duration = duration; + } + + @EventHandler + public void onDeath(PlayerDeathEvent event) + { + Integer id = _lusting.remove(event.getEntity()); + if (id != null) + { + Bukkit.getScheduler().cancelTask(id.intValue()); + } + } + + @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) + public void onCombatDeath(CombatDeathEvent event) + { + if (event.GetLog().GetKiller() == null) + { + return; + } + + if (!event.GetLog().GetKiller().IsPlayer()) + { + return; + } + + Player player = UtilPlayer.searchExact(event.GetLog().GetKiller().GetName()); + if (player == null) + { + return; + } + + if (!Kit.HasKit(player)) + { + return; + } + + if (!Manager.GetGame().IsAlive(player)) + { + return; + } + + if (UtilPlayer.isSpectator(player)) + { + return; + } + + if (!hasPerk(player)) + { + return; + } + + Integer id = _lusting.remove(player); + if (id != null) + { + Bukkit.getScheduler().cancelTask(id.intValue()); + } + + player.sendMessage(C.cRed + "You are now channeling bloodlust for 3 seconds!"); + _lusting.put(player, Bukkit.getScheduler().runTaskLater(UtilServer.getPlugin(), () -> _lusting.remove(player), _duration * 20).getTaskId()); + } + + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void damageIncrease(EntityDamageByEntityEvent event) + { + if (event.getCause() == DamageCause.FIRE_TICK) + return; + + if (event.getDamage() <= 1) + return; + + if (!(event.getDamager() instanceof Player)) + return; + + Player damager = (Player) event.getDamager(); + + if (!Kit.HasKit(damager)) + { + return; + } + + if (!hasPerk(damager)) + { + return; + } + + if (!Manager.IsAlive(damager)) + { + return; + } + + if (!_lusting.containsKey(damager)) + { + return; + } + + event.setDamage(event.getDamage() + _damageBoost); + } +} \ No newline at end of file From 4d6824c27cba1d9827f86983ac7254c73dad7471 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Fri, 5 May 2017 22:05:58 -0400 Subject: [PATCH 44/99] Update Castle Siege mechanics --- .../games/castlesiege/CastleSiegeTDM.java | 15 ++++++++---- .../games/castlesiege/ShockCastleSiege.java | 24 +++++++++++++++---- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiegeTDM.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiegeTDM.java index 56e117868..a87b6195a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiegeTDM.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiegeTDM.java @@ -368,10 +368,10 @@ public class CastleSiegeTDM extends TeamGame GameTeam red = GetTeam(ChatColor.RED); GameTeam blue = GetTeam(ChatColor.AQUA); Scoreboard.write(red.GetFormattedName() + " Team Kills"); - Scoreboard.write(_teamKills.get(red) + ""); + Scoreboard.write(_teamKills.get(red) + "/50"); Scoreboard.writeNewLine(); Scoreboard.write(blue.GetFormattedName() + " Team Kills"); - Scoreboard.write(_teamKills.get(blue) + ""); + Scoreboard.write(_teamKills.get(blue) + "/50"); Scoreboard.draw(); } @@ -525,7 +525,7 @@ public class CastleSiegeTDM extends TeamGame GameTeam red = GetTeam(ChatColor.RED); GameTeam blue = GetTeam(ChatColor.AQUA); - if (_teamKills.get(blue).intValue() >= 100) + if (_teamKills.get(blue).intValue() >= 50) { AnnounceEnd(blue); writeFinalScoreboard(blue.GetColor() + blue.GetName(), _teamKills.get(blue)); @@ -597,7 +597,7 @@ public class CastleSiegeTDM extends TeamGame SetState(GameState.End); return; } - if (_teamKills.get(red).intValue() >= 100) + if (_teamKills.get(red).intValue() >= 50) { AnnounceEnd(red); writeFinalScoreboard(red.GetColor() + red.GetName(), _teamKills.get(red)); @@ -874,6 +874,11 @@ public class CastleSiegeTDM extends TeamGame _medalData.computeIfAbsent(player, key -> new MedalData()).addScore(MedalType.ELIM, 1D); _teamKills.merge(GetTeam(player), 1, Integer::sum); + if (UtilPlayer.isSpectator(player)) + { + return; + } + player.setLevel(player.getLevel() + 1); player.getInventory().addItem(new ItemBuilder(Material.GOLDEN_APPLE).setTitle(C.cPurple + "Golden Applegate").build()); KillStreakData data = _streakData.computeIfAbsent(player, (key) -> new KillStreakData()); @@ -886,7 +891,7 @@ public class CastleSiegeTDM extends TeamGame } if (UtilMath.isEven(data.getKills())) { - Bukkit.broadcastMessage(F.main("Game", C.cGreen + C.Bold + player.getName() + ChatColor.RESET + " is on a " + F.elem(C.cAqua + C.Bold + data.getKills() + " player Kill Streak") + "!")); + Bukkit.broadcastMessage(F.main("Game", C.cGreen + C.Bold + player.getName() + ChatColor.RESET + " is on a " + F.elem(C.cDPurple + data.getKills() + " player Kill Streak") + "!")); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/ShockCastleSiege.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/ShockCastleSiege.java index 52c725d24..b6e357c3b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/ShockCastleSiege.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/ShockCastleSiege.java @@ -403,11 +403,13 @@ public class ShockCastleSiege extends TeamGame } Scoreboard.writeNewLine(); GameTeam red = GetTeam(ChatColor.RED); + long redBeacons = _beacons.get(red).stream().filter(TeamBeacon::isActive).count(); GameTeam blue = GetTeam(ChatColor.AQUA); - if (_beacons.get(red).stream().filter(TeamBeacon::isActive).count() > 0) + long blueBeacons = _beacons.get(blue).stream().filter(TeamBeacon::isActive).count(); + if (redBeacons > 0) { Scoreboard.write(_kings.get(red).getName(true)); - Scoreboard.write("Protected"); + Scoreboard.write(redBeacons + "/2 Beacons Active"); } else { @@ -415,10 +417,10 @@ public class ShockCastleSiege extends TeamGame Scoreboard.write(_kings.get(red).getHealth() + ""); } Scoreboard.writeNewLine(); - if (_beacons.get(blue).stream().filter(TeamBeacon::isActive).count() > 0) + if (blueBeacons > 0) { Scoreboard.write(_kings.get(blue).getName(true)); - Scoreboard.write("Protected"); + Scoreboard.write(blueBeacons + "/2 Beacons Active"); } else { @@ -966,6 +968,11 @@ public class ShockCastleSiege extends TeamGame } } + if (UtilPlayer.isSpectator(player)) + { + return; + } + player.setLevel(player.getLevel() + 1); player.getInventory().addItem(new ItemBuilder(Material.GOLDEN_APPLE).setTitle(C.cPurple + "Golden Applegate").build()); KillStreakData data = _streakData.computeIfAbsent(player, (key) -> new KillStreakData()); @@ -978,7 +985,7 @@ public class ShockCastleSiege extends TeamGame } if (UtilMath.isEven(data.getKills())) { - Bukkit.broadcastMessage(F.main("Game", C.cGreen + C.Bold + player.getName() + ChatColor.RESET + " is on a " + F.elem(C.cAqua + C.Bold + data.getKills() + " player Kill Streak") + "!")); + Bukkit.broadcastMessage(F.main("Game", C.cGreen + C.Bold + player.getName() + ChatColor.RESET + " is on a " + F.elem(C.cDPurple + data.getKills() + " player Kill Streak") + "!")); } } @@ -1073,6 +1080,13 @@ public class ShockCastleSiege extends TeamGame } } } + for (TeamKing king : _kings.values()) + { + if (king.isDead() && !king.getOwner().HasPlayer(player) && UtilMath.offset(event.getEntity().getLocation(), king.getLocation()) <= radius) + { + king.handleDamage(player.getName(), 50); + } + } } } From a47c4291c533420f3e143b26cf30f8df3385c255 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Fri, 5 May 2017 22:06:18 -0400 Subject: [PATCH 45/99] Update tiered achievement UI --- .../core/achievement/AchievementCategory.java | 2 +- .../achievement/ui/page/AchievementMainPage.java | 12 +++++++++++- .../core/achievement/ui/page/AchievementPage.java | 2 +- .../game/arcade/managers/GameAchievementManager.java | 2 +- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java index 3316c653b..d6137618d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java @@ -87,7 +87,7 @@ public enum AchievementCategory CASTLE_SIEGE("Castle Siege", new String[] {"Castle Siege New", "Castle Siege TDM"}, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.CROWNS_EARNED }, - Material.DIAMOND_CHESTPLATE, 0, GameCategory.CLASSICS, null, false, GameDisplay.CastleSiegeNew.getGameId()), + Material.DIAMOND_CHESTPLATE, 0, GameCategory.CLASSICS, null, false, GameDisplay.CastleSiegeNew.getGameId(), GameDisplay.CastleSiegeTDM.getGameId()), BAWK_BAWK_BATTLES("Bawk Bawk Battles", null, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.GEMS_EARNED }, diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/ui/page/AchievementMainPage.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/ui/page/AchievementMainPage.java index e2825bfde..0ff566c82 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/ui/page/AchievementMainPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/ui/page/AchievementMainPage.java @@ -107,6 +107,14 @@ public class AchievementMainPage extends ShopPageBase 1) continue; @@ -121,6 +129,8 @@ public class AchievementMainPage extends ShopPageBase 0) + { lore.add(" "); + } } -} +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/ui/page/AchievementPage.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/ui/page/AchievementPage.java index cdd420cbf..3915059e8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/ui/page/AchievementPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/ui/page/AchievementPage.java @@ -89,7 +89,7 @@ public class AchievementPage extends ShopPageBase Date: Sat, 6 May 2017 17:01:31 -0400 Subject: [PATCH 46/99] Add game tips and remove medals from initial release --- .../games/castlesiege/ShockCastleSiege.java | 184 +----------------- .../castlesiege/data/ObjectiveTNTSpawner.java | 5 +- 2 files changed, 11 insertions(+), 178 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/ShockCastleSiege.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/ShockCastleSiege.java index b6e357c3b..5c6cb8966 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/ShockCastleSiege.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/ShockCastleSiege.java @@ -6,7 +6,6 @@ import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; -import java.util.Map.Entry; import java.util.WeakHashMap; import org.bukkit.Bukkit; @@ -89,9 +88,6 @@ import nautilus.game.arcade.game.games.castlesiege.data.KillStreakData; import nautilus.game.arcade.game.games.castlesiege.data.ObjectiveTNTSpawner; import nautilus.game.arcade.game.games.castlesiege.data.TeamBeacon; import nautilus.game.arcade.game.games.castlesiege.data.TeamKing; -import nautilus.game.arcade.game.games.castlesiege.data.medals.MedalData; -import nautilus.game.arcade.game.games.castlesiege.data.medals.MedalData.MedalLevel; -import nautilus.game.arcade.game.games.castlesiege.data.medals.MedalType; import nautilus.game.arcade.game.games.castlesiege.shockkits.KitArcher; import nautilus.game.arcade.game.games.castlesiege.shockkits.KitDemolitionist; import nautilus.game.arcade.game.games.castlesiege.shockkits.KitFighter; @@ -112,7 +108,6 @@ public class ShockCastleSiege extends TeamGame private ItemBuilder _wearableTnt; private Map _streakData = new WeakHashMap<>(); - private Map _medalData = new WeakHashMap<>(); private Map> _beacons = new HashMap<>(); private Map _kings = new HashMap<>(); private List _tntCarry = new ArrayList<>(); @@ -127,7 +122,6 @@ public class ShockCastleSiege extends TeamGame private ChestLoot _rodsAndGaps = new ChestLoot(true); private ChestLoot _potionGearCommon = new ChestLoot(true); private ChestLoot _potionGearRare = new ChestLoot(true); - //private ChestLoot _blockGear = new ChestLoot(); private ChestLoot _enchantGearCommon = new ChestLoot(true); private ChestLoot _enchantGearRare = new ChestLoot(true); private ChestLoot _miscGear = new ChestLoot(); @@ -153,6 +147,14 @@ public class ShockCastleSiege extends TeamGame }, new String[] {"AlexTheCoder is awesome!"}); + _help = new String[] + { + "Use the TNT spawning platforms to run TNT to the enemy beacons to destroy them!", + "The enemy king is invulnerable until you destroy the two sentry beacons on each sentry tower", + "Go on Kill Streaks to earn Kill Streak Rewards to obtain better armor & weapons!", + "Chests refill every 2 minutes with potions, golden applegates, fishing rods, and other useful PvP items!" + }; + this.StrictAntiHack = true; this.HungerSet = 20; this.DeathOut = false; @@ -183,60 +185,6 @@ public class ShockCastleSiege extends TeamGame generateLoot(); } - private Player[] getMedalOwners(MedalType type) - { - Player gold = null; - Double goldScore = 0D; - Player silver = null; - Double silverScore = 0D; - Player bronze = null; - Double bronzeScore = 0D; - - //GOLD - for (Entry scores : _medalData.entrySet()) - { - if (scores.getValue().getScore(type) > goldScore) - { - gold = scores.getKey(); - goldScore = scores.getValue().getScore(type); - } - } - - //SILVER - for (Entry scores : _medalData.entrySet()) - { - if (gold != null && gold.getName().equals(scores.getKey().getName())) - { - continue; - } - if (scores.getValue().getScore(type) > silverScore) - { - silver = scores.getKey(); - silverScore = scores.getValue().getScore(type); - } - } - - //BRONZE - for (Entry scores : _medalData.entrySet()) - { - if (gold != null && gold.getName().equals(scores.getKey().getName())) - { - continue; - } - if (silver != null && silver.getName().equals(scores.getKey().getName())) - { - continue; - } - if (scores.getValue().getScore(type) > bronzeScore) - { - bronze = scores.getKey(); - bronzeScore = scores.getValue().getScore(type); - } - } - - return new Player[] {gold, silver, bronze}; - } - private void generateLoot() { { @@ -286,10 +234,6 @@ public class ShockCastleSiege extends TeamGame _potionGearRare.addLoot(new ItemBuilder(Material.POTION).setData((short)8193).build(), 2); _potionGearRare.addLoot(new ItemBuilder(Material.POTION).setData((short)8195).build(), 2); } - /*{ - _blockGear.addLoot(new ItemStack(Material.STONE, 64), 2); - _blockGear.addLoot(new ItemStack(Material.WOOD, 64), 2); - }*/ { _enchantGearCommon.addLoot(new EnchantedBookBuilder(1).setLevel(Enchantment.PROTECTION_ENVIRONMENTAL, 1).build(), 2); _enchantGearCommon.addLoot(new EnchantedBookBuilder(1).setLevel(Enchantment.DAMAGE_ALL, 1).build(), 2); @@ -301,7 +245,6 @@ public class ShockCastleSiege extends TeamGame } { _miscGear.addLoot(new ItemStack(Material.ENDER_PEARL), 2); - _miscGear.addLoot(new ItemBuilder(Material.TNT, 4).setTitle(F.item("Throwing TNT")).build(), 2); _miscGear.addLoot(new ItemStack(Material.WATER_BUCKET), 2); _miscGear.addLoot(_flintAndSteel.build(), 2); _miscGear.addLoot(new ItemStack(Material.SNOW_BALL, 16), 3); @@ -340,23 +283,7 @@ public class ShockCastleSiege extends TeamGame if (chance <= 0.3) { loot = _rangedGear; - }/* - if (chance <= 0.4) - { - loot = _weaponGearCommon; - if (subChance <= 0.4) - { - loot = _weaponGearRare; - } } - if (chance <= 0.3) - { - loot = _diamondGearCommon; - if (subChance <= 0.3) - { - loot = _diamondGearRare; - } - }*/ chest.getBlockInventory().setItem(slot, loot.getLoot()); } } @@ -500,34 +427,6 @@ public class ShockCastleSiege extends TeamGame TeamKing dead = _kings.values().stream().filter(k -> k.getOwner().GetColor() != king.getOwner().GetColor()).findFirst().get(); AnnounceEnd(winner); writeFinalScoreboard(dead.getName(false), king.getName(false), dead.getOwner().GetColor() + "Quitters"); - boolean announcedMedalStart = false; - for (MedalType type : MedalType.values()) - { - Player[] rewarding = getMedalOwners(type); - if (rewarding[0] != null) - { - if (!announcedMedalStart) - { - announcedMedalStart = true; - Bukkit.broadcastMessage(C.cGoldB + "-==Match Medal Recipients==-"); - } - AddGems(rewarding[0], 50, MedalLevel.GOLD.getName() + " " + type.getName(), false, false); - AddStat(rewarding[0], "Medalist", 1, false, false); - Bukkit.broadcastMessage(MedalLevel.GOLD.getName() + " " + type.getName() + C.cGray + ": " + MedalLevel.GOLD.getColor() + rewarding[0].getName()); - } - if (rewarding[1] != null) - { - AddGems(rewarding[1], 30, MedalLevel.SILVER.getName() + " " + type.getName(), false, false); - AddStat(rewarding[1], "Medalist", 1, false, false); - Bukkit.broadcastMessage(MedalLevel.SILVER.getName() + " " + type.getName() + C.cGray + ": " + MedalLevel.SILVER.getColor() + rewarding[1].getName()); - } - if (rewarding[2] != null) - { - AddGems(rewarding[2], 20, MedalLevel.BRONZE.getName() + " " + type.getName(), false, false); - AddStat(rewarding[2], "Medalist", 1, false, false); - Bukkit.broadcastMessage(MedalLevel.BRONZE.getName() + " " + type.getName() + C.cGray + ": " + MedalLevel.BRONZE.getColor() + rewarding[2].getName()); - } - } for (GameTeam team : GetTeamList()) { for (Player player : team.GetPlayers(true)) @@ -603,34 +502,6 @@ public class ShockCastleSiege extends TeamGame { AnnounceEnd(blue); writeFinalScoreboard(redKing.getName(false), blueKing.getName(false), blue.GetColor() + redKing.getLastDamager()); - boolean announcedMedalStart = false; - for (MedalType type : MedalType.values()) - { - Player[] rewarding = getMedalOwners(type); - if (rewarding[0] != null) - { - if (!announcedMedalStart) - { - announcedMedalStart = true; - Bukkit.broadcastMessage(C.cGoldB + "-==Match Medal Recipients==-"); - } - AddGems(rewarding[0], 50, MedalLevel.GOLD.getName() + " " + type.getName(), false, false); - AddStat(rewarding[0], "Medalist", 1, false, false); - Bukkit.broadcastMessage(MedalLevel.GOLD.getName() + " " + type.getName() + C.cGray + ": " + MedalLevel.GOLD.getColor() + rewarding[0].getName()); - } - if (rewarding[1] != null) - { - AddGems(rewarding[1], 30, MedalLevel.SILVER.getName() + " " + type.getName(), false, false); - AddStat(rewarding[1], "Medalist", 1, false, false); - Bukkit.broadcastMessage(MedalLevel.SILVER.getName() + " " + type.getName() + C.cGray + ": " + MedalLevel.SILVER.getColor() + rewarding[1].getName()); - } - if (rewarding[2] != null) - { - AddGems(rewarding[2], 20, MedalLevel.BRONZE.getName() + " " + type.getName(), false, false); - AddStat(rewarding[2], "Medalist", 1, false, false); - Bukkit.broadcastMessage(MedalLevel.BRONZE.getName() + " " + type.getName() + C.cGray + ": " + MedalLevel.BRONZE.getColor() + rewarding[2].getName()); - } - } for (GameTeam team : GetTeamList()) { for (Player player : team.GetPlayers(true)) @@ -680,34 +551,6 @@ public class ShockCastleSiege extends TeamGame { AnnounceEnd(red); writeFinalScoreboard(blueKing.getName(false), redKing.getName(false), red.GetColor() + blueKing.getLastDamager()); - boolean announcedMedalStart = false; - for (MedalType type : MedalType.values()) - { - Player[] rewarding = getMedalOwners(type); - if (rewarding[0] != null) - { - if (!announcedMedalStart) - { - announcedMedalStart = true; - Bukkit.broadcastMessage(C.cGoldB + "-==Match Medal Recipients==-"); - } - AddGems(rewarding[0], 50, MedalLevel.GOLD.getName() + " " + type.getName(), false, false); - AddStat(rewarding[0], "Medalist", 1, false, false); - Bukkit.broadcastMessage(MedalLevel.GOLD.getName() + " " + type.getName() + C.cGray + ": " + MedalLevel.GOLD.getColor() + rewarding[0].getName()); - } - if (rewarding[1] != null) - { - AddGems(rewarding[1], 30, MedalLevel.SILVER.getName() + " " + type.getName(), false, false); - AddStat(rewarding[1], "Medalist", 1, false, false); - Bukkit.broadcastMessage(MedalLevel.SILVER.getName() + " " + type.getName() + C.cGray + ": " + MedalLevel.SILVER.getColor() + rewarding[1].getName()); - } - if (rewarding[2] != null) - { - AddGems(rewarding[2], 20, MedalLevel.BRONZE.getName() + " " + type.getName(), false, false); - AddStat(rewarding[2], "Medalist", 1, false, false); - Bukkit.broadcastMessage(MedalLevel.BRONZE.getName() + " " + type.getName() + C.cGray + ": " + MedalLevel.BRONZE.getColor() + rewarding[2].getName()); - } - } for (GameTeam team : GetTeamList()) { for (Player player : team.GetPlayers(true)) @@ -957,16 +800,6 @@ public class ShockCastleSiege extends TeamGame } AddStat(player, GetKit(player).GetName() + "KitKills", 1, false, false); - _medalData.computeIfAbsent(player, key -> new MedalData()).addScore(MedalType.ELIM, 1D); - - for (TeamKing king : _kings.values()) - { - if (UtilMath.offsetSquared(player.getLocation(), king.getLocation()) <= 25) - { - _medalData.computeIfAbsent(player, key -> new MedalData()).addScore(MedalType.OBJECTIVE_KILL, 1D); - break; - } - } if (UtilPlayer.isSpectator(player)) { @@ -1215,7 +1048,6 @@ public class ShockCastleSiege extends TeamGame TeamKing king = _kings.get(owner); if (king.handleDamage(p.getName(), e.getDamage())) { - _medalData.computeIfAbsent(p, key -> new MedalData()).addScore(MedalType.KING_DMG, e.getDamage()); for (Player alert : owner.GetPlayers(true)) { if (Recharge.Instance.use(alert, "KingDamageAlert", 5000, false, false)) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/data/ObjectiveTNTSpawner.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/data/ObjectiveTNTSpawner.java index 648749147..70f9e2484 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/data/ObjectiveTNTSpawner.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/data/ObjectiveTNTSpawner.java @@ -16,6 +16,7 @@ import mineplex.core.common.util.UtilTime; public class ObjectiveTNTSpawner { + private static final long TNT_SPAWN_DELAY = 60000; private List _locs; private Location _lastSpawnLoc; private Item _entity; @@ -41,7 +42,7 @@ public class ObjectiveTNTSpawner public long getNextTNT() { - return (_lastPickedUp + 60000) - System.currentTimeMillis(); + return (_lastPickedUp + TNT_SPAWN_DELAY) - System.currentTimeMillis(); } public void spawn() @@ -64,7 +65,7 @@ public class ObjectiveTNTSpawner public void update() { - if (!isSpawned() && UtilTime.elapsed(_lastPickedUp, 60000)) + if (!isSpawned() && UtilTime.elapsed(_lastPickedUp, TNT_SPAWN_DELAY)) { spawn(); } From c5b62e0ec41e1c993b512415b1f856ec979d9915 Mon Sep 17 00:00:00 2001 From: LCastr0 Date: Sat, 6 May 2017 20:42:53 -0300 Subject: [PATCH 47/99] Add all the win-effects to the page --- .../core/cosmetic/ui/page/WinEffectPage.java | 30 ------------------- 1 file changed, 30 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/WinEffectPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/WinEffectPage.java index de763e016..3236de2fb 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/WinEffectPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/WinEffectPage.java @@ -5,12 +5,10 @@ import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; import mineplex.core.account.CoreClientManager; -import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.cosmetic.CosmeticManager; import mineplex.core.cosmetic.ui.CosmeticShop; import mineplex.core.donation.DonationManager; -import mineplex.core.gadget.gadgets.wineffect.rankrooms.WinEffectRankBased; import mineplex.core.gadget.types.Gadget; import mineplex.core.gadget.types.GadgetType; import mineplex.core.shop.item.IButton; @@ -32,9 +30,6 @@ public class WinEffectPage extends GadgetPage for (Gadget gadget : getPlugin().getGadgetManager().getGadgets(GadgetType.WIN_EFFECT)) { - if (gadget instanceof WinEffectRankBased) - continue; - addGadget(gadget, slot); if (getPlugin().getGadgetManager().getActive(getPlayer(), GadgetType.WIN_EFFECT) == gadget) @@ -45,31 +40,6 @@ public class WinEffectPage extends GadgetPage if (slot == 17) slot += 2; } - - // Adds rank based win effects - Rank maxRank = WinEffectRankBased.getHighestRankForPlayer(getPlayer()); - - for (WinEffectRankBased.WinEffectType winEffectType : WinEffectRankBased.WinEffectType.values()) - { - Rank originalRank = maxRank; - - if (maxRank.equals(Rank.ALL)) - maxRank = Rank.ULTRA; - - WinEffectRankBased winEffectRankBased = getPlugin().getGadgetManager().getRankBasedWinEffect(winEffectType, maxRank); - if (winEffectRankBased != null) - { - addGadget(winEffectRankBased, slot, (originalRank.equals(Rank.ALL))); - - if (winEffectRankBased.isActive(getPlayer())) - addGlow(slot); - - slot++; - - if (slot == 17) - slot += 2; - } - } addButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() { From 8e58b974f3b0438e7cdbf36a05310e4fafc3a187 Mon Sep 17 00:00:00 2001 From: LCastr0 Date: Sat, 6 May 2017 21:18:36 -0300 Subject: [PATCH 48/99] Add line --- .../src/mineplex/core/cosmetic/ui/page/WinEffectPage.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/WinEffectPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/WinEffectPage.java index 3236de2fb..4e389d3b3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/WinEffectPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/WinEffectPage.java @@ -37,7 +37,7 @@ public class WinEffectPage extends GadgetPage slot++; - if (slot == 17) + if (slot == 17 || slot == 24) slot += 2; } From 8befa61b8a2f80e598c34be68d67ad3c41c77d7a Mon Sep 17 00:00:00 2001 From: LCastr0 Date: Sat, 6 May 2017 21:29:15 -0300 Subject: [PATCH 49/99] Set force on creature module before spawning entities --- .../rankrooms/rankwineffects/WinEffectRankEternal.java | 2 ++ .../rankrooms/rankwineffects/WinEffectRankHero.java | 2 ++ .../rankrooms/rankwineffects/WinEffectRankLegend.java | 2 ++ .../rankrooms/rankwineffects/WinEffectRankTitan.java | 5 ++++- .../rankrooms/rankwineffects/WinEffectRankUltra.java | 4 ++++ 5 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankEternal.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankEternal.java index a925c889e..2b80a5573 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankEternal.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankEternal.java @@ -78,7 +78,9 @@ public class WinEffectRankEternal extends WinEffectRankBased if (_guardian == null) { + Manager.getPetManager().getCreatureModule().SetForce(true); _guardian = npcLocation.getWorld().spawn(npcLocation.add(0, 20, 0), Guardian.class); + Manager.getPetManager().getCreatureModule().SetForce(false); } double increment = (2 * Math.PI) / POINTS; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankHero.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankHero.java index 94530ce6e..678f1cc61 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankHero.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankHero.java @@ -86,7 +86,9 @@ public class WinEffectRankHero extends WinEffectRankBased if (_enderDragon == null) { + Manager.getPetManager().getCreatureModule().SetForce(true); _enderDragon = npcLocation.getWorld().spawn(npcLocation.add(0, 20, 0), EnderDragon.class); + Manager.getPetManager().getCreatureModule().SetForce(false); } double increment = (2 * Math.PI) / POINTS; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankLegend.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankLegend.java index 479c5d62c..d8266b2c8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankLegend.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankLegend.java @@ -78,7 +78,9 @@ public class WinEffectRankLegend extends WinEffectRankBased if (_wither == null) { + Manager.getPetManager().getCreatureModule().SetForce(true); _wither = npcLocation.getWorld().spawn(npcLocation.add(0, 20, 0), Wither.class); + Manager.getPetManager().getCreatureModule().SetForce(false); } double increment = (2 * Math.PI) / POINTS; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankTitan.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankTitan.java index 3a7bfb876..b6b611bfc 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankTitan.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankTitan.java @@ -47,7 +47,11 @@ public class WinEffectRankTitan extends WinEffectRankBased _npc = getNPC(getPlayer(), loc); + Manager.getPetManager().getCreatureModule().SetForce(true); + _giant = loc.getWorld().spawn(loc.add(0, 20, 0), Giant.class); + + Manager.getPetManager().getCreatureModule().SetForce(false); } @Override @@ -56,7 +60,6 @@ public class WinEffectRankTitan extends WinEffectRankBased if (_giant != null) { _giant.remove(); - _giant = null; } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankUltra.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankUltra.java index 7d7a2766d..c8261b214 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankUltra.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankUltra.java @@ -48,9 +48,13 @@ public class WinEffectRankUltra extends WinEffectRankBased loc.setYaw(0); _npc = getNPC(getPlayer(), loc, true); + Manager.getPetManager().getCreatureModule().SetForce(true); + _creeper = loc.getWorld().spawn(loc.add(loc.getDirection().multiply(-3)), Creeper.class); _creeper.setPowered(true); _creeper.setTarget((LivingEntity) _npc.getEntity().getBukkitEntity()); + + Manager.getPetManager().getCreatureModule().SetForce(false); } @Override From dc77dde98b3483f37cecad90f53d4feec61d4111 Mon Sep 17 00:00:00 2001 From: LCastr0 Date: Sat, 6 May 2017 21:29:41 -0300 Subject: [PATCH 50/99] Use correct slot --- .../src/mineplex/core/cosmetic/ui/page/WinEffectPage.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/WinEffectPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/WinEffectPage.java index 4e389d3b3..03580ec3f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/WinEffectPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/WinEffectPage.java @@ -37,7 +37,7 @@ public class WinEffectPage extends GadgetPage slot++; - if (slot == 17 || slot == 24) + if (slot == 17 || slot == 26) slot += 2; } From 8604eb2e0983b6c60263602dad81ee173fcd4094 Mon Sep 17 00:00:00 2001 From: LCastr0 Date: Sat, 6 May 2017 22:54:24 -0300 Subject: [PATCH 51/99] Teleport the creeper so it's visible --- .../rankrooms/rankwineffects/WinEffectRankUltra.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankUltra.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankUltra.java index c8261b214..2e8f43dc3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankUltra.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankUltra.java @@ -50,8 +50,10 @@ public class WinEffectRankUltra extends WinEffectRankBased Manager.getPetManager().getCreatureModule().SetForce(true); - _creeper = loc.getWorld().spawn(loc.add(loc.getDirection().multiply(-3)), Creeper.class); - _creeper.setPowered(true); + _creeper = loc.getWorld().spawn(loc.add(0, 10, 0), Creeper.class); + + _creeper.teleport(loc.subtract(0, 0, 2)); + _creeper.setTarget((LivingEntity) _npc.getEntity().getBukkitEntity()); Manager.getPetManager().getCreatureModule().SetForce(false); From 941310b5aab4bf66876b5fd6701bd787a3341d51 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Mon, 8 May 2017 00:07:42 -0400 Subject: [PATCH 52/99] Change kit prices --- .../src/mineplex/core/progression/math/Calculations.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/progression/math/Calculations.java b/Plugins/Mineplex.Core/src/mineplex/core/progression/math/Calculations.java index ae9c9013b..51299c6d0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/progression/math/Calculations.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/progression/math/Calculations.java @@ -29,8 +29,8 @@ public class Calculations GEMS_FOR_XPLESS_UPGRADE.put(1, 1000); GEMS_FOR_XPLESS_UPGRADE.put(2, 5000); GEMS_FOR_XPLESS_UPGRADE.put(3, 15000); - GEMS_FOR_XPLESS_UPGRADE.put(4, 30000); - GEMS_FOR_XPLESS_UPGRADE.put(5, 60000); + GEMS_FOR_XPLESS_UPGRADE.put(4, 50000); + GEMS_FOR_XPLESS_UPGRADE.put(5, 100000); } /** From 68205a71a13a36faaca3eda1a1c71a7847c92137 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Mon, 8 May 2017 00:08:36 -0400 Subject: [PATCH 53/99] Implement proper stat leaderboard system --- .../core/leaderboard/Leaderboard.java | 63 +++++++ .../core/leaderboard/LeaderboardManager.java | 152 +++++++++-------- .../leaderboard/LeaderboardRepository.java | 155 ++++++++++++++++++ .../leaderboard/SetTournamentCommand.java | 27 --- .../leaderboard/StatEventsRepository.java | 59 ------- .../mineplex/core/leaderboard/StatType.java | 48 ------ 6 files changed, 304 insertions(+), 200 deletions(-) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/leaderboard/Leaderboard.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardRepository.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/leaderboard/SetTournamentCommand.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/leaderboard/StatEventsRepository.java delete mode 100644 Plugins/Mineplex.Core/src/mineplex/core/leaderboard/StatType.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/Leaderboard.java b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/Leaderboard.java new file mode 100644 index 000000000..047b0cf6d --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/Leaderboard.java @@ -0,0 +1,63 @@ +package mineplex.core.leaderboard; + +import java.util.LinkedList; + +import org.bukkit.Location; + +import mineplex.core.Managers; +import mineplex.core.common.util.C; +import mineplex.core.hologram.Hologram; +import mineplex.core.leaderboard.LeaderboardRepository.LeaderboardSQLType; + +public class Leaderboard +{ + private String _display; + private String[] _statIds; + private int _size; + private LeaderboardSQLType _type; + private Location _loc; + private Hologram _holo; + + public Leaderboard(String display, String[] statIds, LeaderboardSQLType type, Location displayLoc, int size) + { + _display = display; + _statIds = statIds; + _type = type; + _size = size; + _loc = displayLoc; + + update(new LinkedList<>()); + } + + public int getSize() + { + return _size; + } + + public String[] getStatIds() + { + return _statIds; + } + + public LeaderboardSQLType getType() + { + return _type; + } + + public void update(LinkedList names) + { + deconstruct(); + names.addFirst(C.cRed + " "); + names.addFirst(C.cAqua + _display); + _holo = new Hologram(Managers.get(LeaderboardManager.class).getHologramManager(), _loc, names.toArray(new String[names.size()])).start(); + } + + public void deconstruct() + { + if (_holo != null) + { + _holo.stop(); + _holo = null; + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardManager.java b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardManager.java index 1ca8b9bc6..9d50dd388 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardManager.java @@ -1,91 +1,111 @@ package mineplex.core.leaderboard; -import mineplex.core.MiniPlugin; -import mineplex.core.account.CoreClient; -import mineplex.core.account.CoreClientManager; -import mineplex.core.spawn.command.SpawnCommand; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; -import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; -/** - * Manages dynamic Leaderboard statistics. - * - * Used for recording stat events, retrieving customized leaderboards, etc. - * @author MrTwiggy - * - */ +import mineplex.core.Managers; +import mineplex.core.MiniPlugin; +import mineplex.core.account.CoreClientManager; +import mineplex.core.command.CommandBase; +import mineplex.core.common.Rank; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilMath; +import mineplex.core.hologram.HologramManager; +import mineplex.core.leaderboard.LeaderboardRepository.LeaderboardSQLType; + public class LeaderboardManager extends MiniPlugin { + private final Map _leaderboards = new HashMap<>(); + private final long REFRESH_RATE; + private final LeaderboardRepository _repo; + private final HologramManager _holo; - private static LeaderboardManager _instance; // Singleton instance of Leaderboard Manager - private StatEventsRepository _statEvents; // 'statEvents' table repository. - private CoreClientManager _clientManager; - private String _serverGroup; - - /** - * Private class constructor to prevent non-singleton instances. - */ - public LeaderboardManager(JavaPlugin plugin, CoreClientManager clientManager) + public LeaderboardManager(JavaPlugin plugin, HologramManager hologram) { super("Leaderboard Manager", plugin); - _instance = this; - _clientManager = clientManager; - _statEvents = new StatEventsRepository(plugin); - _serverGroup = _plugin.getConfig().getString("serverstatus.group"); - } - - /** - * Attempt to trigger a stat event. - * @param player - the player responsible for the statistic - * @param stat - the display name of the statistic to be added - * @param value - the counter value used to increment the statistic - * @return true, if a stat event was successfully triggered and logged, false otherwise. - */ - public boolean attemptStatEvent(Player player, String stat, int gamemode, int value) - { - StatType type = StatType.getType(stat); + _repo = new LeaderboardRepository(plugin); + _holo = hologram; - return (type == null) ? false : onStatEvent(player, type, gamemode, value); - } - - /** - * Trigger a stat event to be recorded. - * @param player - the player responsible for the statistic - * @param type - the unique type id designating the statistic being recorded - * @param gamemode - the unique gamemode id associated with the stat event - * @param value - the counter value used to increment the statistic - * @return true, if the stat event was successfully triggered and logged, false otherwise. - */ - public boolean onStatEvent(final Player player, final StatType type, final int gamemode, final int value) - { - /* - // Asynchronously make DB call to insert stat event. - Bukkit.getScheduler().runTaskAsynchronously(getPlugin(), new Runnable() + addCommand(new CommandBase(this, Rank.DEVELOPER, "cycleleaderboard") { - public void run() + @Override + public void Execute(Player caller, String[] args) { - _statEvents.insertStatEvent(player.getName(), gamemode, _serverGroup, type.getTypeId(), value); + caller.sendMessage(F.main(getName(), "Cycling leaderboards!")); + refreshBoards(); } }); - */ - return true; + REFRESH_RATE = 5 * 60 * 20 + ((UtilMath.r(5) + 1) * 60 * 20); + + runSyncTimer(() -> refreshBoards(), 0, REFRESH_RATE); } - @Override - public void addCommands() + private void refreshBoards() { - addCommand(new SetTournamentCommand(this)); + int arrayLength = _leaderboards.size(); + Leaderboard[] boards = _leaderboards.values().toArray(new Leaderboard[arrayLength]); + List statIds = new ArrayList<>(); + int[] sizes = new int[arrayLength]; + LeaderboardSQLType[] types = new LeaderboardSQLType[arrayLength]; + for (int i = 0; i < arrayLength; i++) + { + statIds.add(boards[i].getStatIds()); + sizes[i] = boards[i].getSize(); + types[i] = boards[i].getType(); + } + + _repo.loadLeaderboards(statIds, sizes, types, nameArray -> + { + for (int i = 0; i < nameArray.length && i < boards.length; i++) + { + boards[i].update(nameArray[i]); + } + }); } - /** - * @return the singleton instance for {@link LeaderboardManager}. - */ - public static LeaderboardManager getInstance() + public HologramManager getHologramManager() { - return _instance; + return _holo; } -} + + public Leaderboard getLeaderboard(String identifier) + { + return _leaderboards.get(identifier); + } + + public void handleStatIncrease(Player player, String statId, int value) + { + int accountId = Managers.get(CoreClientManager.class).getAccountId(player); + if (accountId != -1) + { + _repo.insertStat(accountId, statId, value); + } + } + + public void registerLeaderboard(String identifier, Leaderboard board) + { + if (_leaderboards.containsKey(identifier)) + { + board.deconstruct(); + return; + } + _leaderboards.put(identifier, board); + _repo.loadLeaderboard(board.getStatIds(), board.getSize(), board.getType(), board::update); + } + + public void unregisterLeaderboard(String boardIdentifier) + { + if (!_leaderboards.containsKey(boardIdentifier)) + { + return; + } + _leaderboards.remove(boardIdentifier).deconstruct(); + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardRepository.java new file mode 100644 index 000000000..a35e71649 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardRepository.java @@ -0,0 +1,155 @@ +package mineplex.core.leaderboard; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Statement; +import java.util.LinkedList; +import java.util.List; +import java.util.function.Consumer; + +import org.bukkit.plugin.java.JavaPlugin; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilServer; +import mineplex.serverdata.database.DBPool; +import mineplex.serverdata.database.RepositoryBase; +import mineplex.serverdata.database.column.ColumnInt; +import mineplex.serverdata.database.column.ColumnVarChar; + +public class LeaderboardRepository extends RepositoryBase +{ + private static final int SEASON = 1; + private static final String CREATE = "CREATE TABLE Account.statLeaderboard (id INT NOT NULL AUTO_INCREMENT, accountId INT NOT NULL, statId INT NOT NULL, value INT NOT NULL, date DATE NOT NULL, season INT NOT NULL, PRIMARY KEY (id), UNIQUE INDEX accountStatIndex(accountId, statId, date), INDEX valueIndex(value), INDEX seasonIndex(season), FOREIGN KEY (accountId) REFERENCES Account.accounts(id), FOREIGN KEY (statId) REFERENCES Account.stats(id));"; + private static final String INSERT_STAT = "INSERT INTO statLeaderboard (accountId, statId, value, date, season) VALUES (?, (SELECT id FROM stats WHERE name=?), ?, CURDATE(), " + SEASON + ") ON DUPLICATE KEY UPDATE value=value+VALUES(value);"; + private static final String FETCH_STAT_ALL = "SELECT a.name, sl.value FROM statLeaderboard AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE sl.statId IN (SELECT id FROM stats WHERE name IN (%IDS%)) AND season=" + SEASON + " ORDER BY sl.value DESC LIMIT %LIMIT%;"; + private static final String FETCH_STAT_YEARLY = "SELECT a.name, sl.value FROM statLeaderboard AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE YEAR(sl.date) = YEAR(CURDATE()) AND sl.statId IN (SELECT id FROM stats WHERE name IN (%IDS%)) AND season=" + SEASON + " ORDER BY sl.value DESC LIMIT %LIMIT%;"; + private static final String FETCH_STAT_MONTHLY = "SELECT a.name, sl.value FROM statLeaderboard AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE MONTH(sl.date) = MONTH(CURDATE()) AND YEAR(`date`) = YEAR(CURDATE()) AND sl.statId IN (SELECT id FROM stats WHERE name IN (%IDS%)) AND season=" + SEASON + " ORDER BY sl.value DESC LIMIT %LIMIT%;"; + private static final String FETCH_STAT_WEEKLY = "SELECT a.name, sl.value FROM statLeaderboard AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE YEARWEEK(sl.date, 1) = YEARWEEK(CURDATE(), 1) AND sl.statId IN (SELECT id FROM stats WHERE name IN (%IDS%)) AND season=" + SEASON + " ORDER BY sl.value DESC LIMIT %LIMIT%;"; + private static final String FETCH_STAT_DAILY = "SELECT a.name, sl.value FROM statLeaderboard AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE sl.date = CURDATE() AND sl.statId IN (SELECT id FROM stats WHERE name IN (%IDS%)) AND season=" + SEASON + " ORDER BY sl.value DESC LIMIT %LIMIT%;"; + + public LeaderboardRepository(JavaPlugin plugin) + { + super(DBPool.getAccount()); + } + + public void insertStat(int accountId, String statId, int value) + { + UtilServer.runAsync(() -> + { + executeInsert(INSERT_STAT, null, new ColumnInt("accountId", accountId), new ColumnVarChar("name", 100, statId), new ColumnInt("value", value)); + }); + } + + public void loadLeaderboard(String[] statIds, int size, LeaderboardSQLType type, Consumer> leaderboard) + { + UtilServer.runAsync(() -> + { + try (Connection c = getConnection()) + { + LinkedList names = new LinkedList<>(); + ResultSet rs = type.getStatement(c, statIds, size).executeQuery(); + int place = 1; + while (rs.next()) + { + names.add(C.cGreen + "#" + place + " " + rs.getString(1) + C.cRed + " " + rs.getInt(2)); + place++; + } + + UtilServer.runSync(() -> leaderboard.accept(names)); + } + catch (SQLException ex) + { + ex.printStackTrace(); + } + }); + } + + @SuppressWarnings("unchecked") + public void loadLeaderboards(List statIdArray, int[] sizes, LeaderboardSQLType[] types, Consumer[]> leaderboard) + { + UtilServer.runAsync(() -> + { + try (Connection c = getConnection()) + { + LinkedList[] nameArray = new LinkedList[statIdArray.size()]; + StringBuilder queryBuilder = new StringBuilder(); + for (int i = 0; i < statIdArray.size() && i < sizes.length && i < types.length; i++) + { + String[] statIds = statIdArray.get(i); + int size = sizes[i]; + LeaderboardSQLType type = types[i]; + queryBuilder.append(type.getMultiStatement(statIds, size)); + nameArray[i] = new LinkedList<>(); + } + + if (queryBuilder.length() > 0) + { + Statement s = c.createStatement(); + s.execute(queryBuilder.toString()); + + for (int i = 0; i < nameArray.length; i++) + { + ResultSet rs = s.getResultSet(); + int place = 1; + while (rs.next()) + { + nameArray[i].add(C.cGreen + "#" + place + " " + rs.getString(1) + C.cRed + " " + rs.getInt(2)); + place++; + } + + if (!s.getMoreResults()) + { + break; + } + } + } + + UtilServer.runSync(() -> leaderboard.accept(nameArray)); + } + catch (SQLException ex) + { + ex.printStackTrace(); + } + }); + } + + public static enum LeaderboardSQLType + { + DAILY(FETCH_STAT_DAILY), + WEEKLY(FETCH_STAT_WEEKLY), + MONTHLY(FETCH_STAT_MONTHLY), + YEARLY(FETCH_STAT_YEARLY), + ALL(FETCH_STAT_ALL) + ; + + private String _sql; + + private LeaderboardSQLType(String sql) + { + _sql = sql; + } + + public PreparedStatement getStatement(Connection connection, String[] statIds, int limit) throws SQLException + { + StringBuilder idBuilder = new StringBuilder(); + for (String id : statIds) + { + idBuilder.append("'" + id + "'").append(", "); + } + PreparedStatement ps = connection.prepareStatement(_sql.replace("%LIMIT%", String.valueOf(limit)).replace("%IDS%", idBuilder.substring(0, idBuilder.length() - 2))); + return ps; + } + + public String getMultiStatement(String[] statIds, int limit) + { + StringBuilder idBuilder = new StringBuilder(); + for (String id : statIds) + { + idBuilder.append("'" + id + "'").append(", "); + } + return _sql.replace("%LIMIT%", String.valueOf(limit)).replace("%IDS%", idBuilder.substring(0, idBuilder.length() - 2)); + } + } +} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/SetTournamentCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/SetTournamentCommand.java deleted file mode 100644 index 7e25605bf..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/SetTournamentCommand.java +++ /dev/null @@ -1,27 +0,0 @@ -package mineplex.core.leaderboard; - -import mineplex.core.command.CommandBase; -import mineplex.core.common.Rank; - -import org.bukkit.entity.Player; - -public class SetTournamentCommand extends CommandBase -{ - public SetTournamentCommand(LeaderboardManager plugin) - { - super(plugin, Rank.ADMIN, "settournament", "set-tournament"); - } - - @Override - public void Execute(Player caller, String[] args) - { - // TODO: Implement set tournament command. - /*if (args.length == 3) - { - String statType = args[0]; - int gamemode = Integer.parseInt(args[1]); - int value = Integer.parseInt(args[2]); - LeaderboardManager.getInstance().attemptStatEvent(caller, statType, gamemode, value); - }*/ - } -} \ No newline at end of file diff --git a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/StatEventsRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/StatEventsRepository.java deleted file mode 100644 index 3acf6a2f8..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/StatEventsRepository.java +++ /dev/null @@ -1,59 +0,0 @@ -package mineplex.core.leaderboard; - -import mineplex.core.database.MinecraftRepository; -import mineplex.serverdata.database.DBPool; -import mineplex.serverdata.database.RepositoryBase; -import mineplex.serverdata.database.column.ColumnInt; -import mineplex.serverdata.database.column.ColumnVarChar; - -import org.bukkit.plugin.java.JavaPlugin; - - -/** - * StatEventsRepository offers the ability to insert and log newly generated stat events. - * - * Intended for the purpose of statistical tracking of players. - * @author MrTwiggy - * - */ -public class StatEventsRepository extends RepositoryBase -{ - - // Insert or update stat events query - /*private static String INSERT_EVENT = - "INSERT INTO statEvents(accountId, gamemode, serverGroup, type, value, date) " - + "VALUES (?, ?, ?, ?, ?, CURRENT_DATE()) " - + "ON DUPLICATE KEY UPDATE value=value+";*/ - - private static String INSERT_EVENT = - "INSERT INTO statEvents(accountId, gamemode, serverGroup, type, value, date) " - + "SELECT accounts.id, ?, ?, ?, ?, CURRENT_DATE() " - + "FROM accounts WHERE name = ? " - + "ON DUPLICATE KEY UPDATE value=value+"; - - /** - * Class constructor - * @param plugin - the plugin responsible for instantiating this repository. - */ - public StatEventsRepository(JavaPlugin plugin) - { - super(DBPool.getAccount()); - } - - - /** - * Insert (or update) a new stat event record for today into the repository. - * @param accountId - the id of the account responsible for the stat event. - * @param gamemode - the id of the gamemode type at the time of the stat event. - * @param serverGroup - the server group id associated with the stat event. - * @param type - the type of stat event to be inserted (id of type). - * @param value - the integer based value denoting the actual statistic being logged. - */ - public void insertStatEvent(String playerName, int gamemode, String serverGroup, int type, int value) - { - // Hacky string concatanation - Don't judge me!! - // TODO: How to handle outside value block parameters - executeUpdate(INSERT_EVENT + value + ";", new ColumnInt("gamemode", gamemode), new ColumnVarChar("serverGroup", 100, serverGroup), - new ColumnInt("type", type), new ColumnInt("value", value), new ColumnVarChar("name", 100, playerName)); - } -} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/StatType.java b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/StatType.java deleted file mode 100644 index 10663bae0..000000000 --- a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/StatType.java +++ /dev/null @@ -1,48 +0,0 @@ -package mineplex.core.leaderboard; - -/** - * An enumeration delegating the various types of statistics to be dynamically tracked. - * @author MrTwiggy - * - */ -public enum StatType -{ - WIN(1), - LOSS(2), - KILL(3), - DEATH(4); - - private int _typeId; // Unique id for stat type - public int getTypeId() { return _typeId; } - - /** - * Private class constructor - * @param typeId - the unique identifying id for this {@link StatType} - */ - private StatType(int typeId) - { - _typeId = typeId; - } - - /** - * @param stat - the display name for the stat type - * @return the {@link StatType} corresponding to the passed in {@code stat}, if one exists, - * null otherwise. - */ - public static StatType getType(String stat) - { - switch(stat.toUpperCase().trim()) - { - case "WINS": - return WIN; - case "LOSSES": - return LOSS; - case "KILLS": - return KILL; - case "DEATHS": - return DEATH; - default: - return null; - } - } -} From d7341de2f55411e5c0965c9566f915bd2af60df8 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Mon, 8 May 2017 00:09:04 -0400 Subject: [PATCH 54/99] Final tweaks to Castle Siege and implementation of leaderboards in arcade --- .../src/nautilus/game/arcade/Arcade.java | 11 +- .../src/nautilus/game/arcade/game/Game.java | 2 + .../games/castlesiege/ShockCastleSiege.java | 219 +++++++++++++++--- .../castlesiege/data/ObjectiveTNTSpawner.java | 17 +- .../{TeamBeacon.java => TeamCrystal.java} | 14 +- .../castlesiege/shockkits/KitArcher.java | 4 + .../shockkits/KitDemolitionist.java | 4 + .../castlesiege/shockkits/KitFighter.java | 8 +- .../games/castlesiege/shockkits/KitTank.java | 17 +- .../game/arcade/managers/GameStatManager.java | 30 +-- .../lobby/current/NewGameLobbyManager.java | 78 ++++--- 11 files changed, 309 insertions(+), 95 deletions(-) rename Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/data/{TeamBeacon.java => TeamCrystal.java} (57%) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java index 731d73616..9c0b9e40f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java @@ -1,10 +1,10 @@ package nautilus.game.arcade; +import static mineplex.core.Managers.require; + import java.io.File; import java.util.HashMap; -import net.minecraft.server.v1_8_R3.MinecraftServer; - import org.bukkit.Bukkit; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; @@ -83,12 +83,10 @@ import mineplex.core.visibility.VisibilityManager; import mineplex.core.website.WebsiteLinkManager; import mineplex.minecraft.game.core.combat.CombatManager; import mineplex.minecraft.game.core.damage.DamageManager; - import nautilus.game.arcade.anticheatmetadata.GameInfoMetadata; import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.GameServerConfig; - -import static mineplex.core.Managers.require; +import net.minecraft.server.v1_8_R3.MinecraftServer; public class Arcade extends JavaPlugin { @@ -167,7 +165,6 @@ public class Arcade extends JavaPlugin incognito.setPreferencesManager(preferenceManager); Creature creature = new Creature(this); - LeaderboardManager leaderboardManager = new LeaderboardManager(this, _clientManager); Teleport teleport = new Teleport(this, _clientManager); Portal portal = new Portal(); new FileUpdater(this, portal, serverStatusManager.getCurrentServerName(), serverStatusManager.getRegion(), GenericServer.HUB); @@ -199,6 +196,8 @@ public class Arcade extends JavaPlugin ProjectileManager projectileManager = new ProjectileManager(this); HologramManager hologramManager = new HologramManager(this, packetHandler); + new LeaderboardManager(this, hologramManager); + //Inventory InventoryManager inventoryManager = new InventoryManager(this, _clientManager); CastleManager castleManager = new CastleManager(this, _clientManager, hologramManager, false); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java index 90d008a25..75ad46dbb 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java @@ -346,6 +346,8 @@ public abstract class Game extends ListenerComponent implements Lifetimed //ELO public boolean EloRanking = false; public int EloStart = 1000; + + public boolean Leaderboards = false; public boolean CanAddStats = true; public boolean CanGiveLoot = true; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/ShockCastleSiege.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/ShockCastleSiege.java index 5c6cb8966..91f074691 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/ShockCastleSiege.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/ShockCastleSiege.java @@ -18,6 +18,8 @@ import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.block.Chest; import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.EnderCrystal; import org.bukkit.entity.EnderPearl; import org.bukkit.entity.Entity; import org.bukkit.entity.ItemFrame; @@ -30,7 +32,9 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.block.BlockBurnEvent; import org.bukkit.event.block.BlockDispenseEvent; import org.bukkit.event.block.BlockFadeEvent; +import org.bukkit.event.block.BlockFormEvent; import org.bukkit.event.block.BlockFromToEvent; +import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.block.LeavesDecayEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; @@ -55,6 +59,7 @@ import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.metadata.MetadataValue; import org.bukkit.util.Vector; +import mineplex.core.Managers; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; @@ -67,9 +72,13 @@ import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTextBottom; import mineplex.core.common.util.UtilTime; import mineplex.core.itemstack.EnchantedBookBuilder; import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.leaderboard.Leaderboard; +import mineplex.core.leaderboard.LeaderboardManager; +import mineplex.core.leaderboard.LeaderboardRepository.LeaderboardSQLType; import mineplex.core.loot.ChestLoot; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; @@ -86,7 +95,7 @@ import nautilus.game.arcade.game.GemData; import nautilus.game.arcade.game.TeamGame; import nautilus.game.arcade.game.games.castlesiege.data.KillStreakData; import nautilus.game.arcade.game.games.castlesiege.data.ObjectiveTNTSpawner; -import nautilus.game.arcade.game.games.castlesiege.data.TeamBeacon; +import nautilus.game.arcade.game.games.castlesiege.data.TeamCrystal; import nautilus.game.arcade.game.games.castlesiege.data.TeamKing; import nautilus.game.arcade.game.games.castlesiege.shockkits.KitArcher; import nautilus.game.arcade.game.games.castlesiege.shockkits.KitDemolitionist; @@ -95,6 +104,7 @@ import nautilus.game.arcade.game.games.castlesiege.shockkits.KitPlayer; import nautilus.game.arcade.game.games.castlesiege.shockkits.KitTank; import nautilus.game.arcade.game.modules.compass.CompassModule; import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.managers.lobby.current.NewGameLobbyManager; public class ShockCastleSiege extends TeamGame { @@ -108,7 +118,7 @@ public class ShockCastleSiege extends TeamGame private ItemBuilder _wearableTnt; private Map _streakData = new WeakHashMap<>(); - private Map> _beacons = new HashMap<>(); + private Map> _crystals = new HashMap<>(); private Map _kings = new HashMap<>(); private List _tntCarry = new ArrayList<>(); @@ -145,12 +155,20 @@ public class ShockCastleSiege extends TeamGame //new KitNinja(manager), new KitTank(manager) }, - new String[] {"AlexTheCoder is awesome!"}); + new String[] + { + "Destroy enemy sentry crystals with running TNT", + "After the enemy crystals are destroyed you must slay their king", + "First team to kill the enemy king wins", + "Chests refill every 2 minutes", + "TNT Respawns every 1 minute" + } + ); _help = new String[] { - "Use the TNT spawning platforms to run TNT to the enemy beacons to destroy them!", - "The enemy king is invulnerable until you destroy the two sentry beacons on each sentry tower", + "Use the TNT spawning platforms to run TNT to the enemy crystals to destroy them!", + "The enemy king is invulnerable until you destroy the two sentry crystals on each sentry tower", "Go on Kill Streaks to earn Kill Streak Rewards to obtain better armor & weapons!", "Chests refill every 2 minutes with potions, golden applegates, fishing rods, and other useful PvP items!" }; @@ -172,7 +190,9 @@ public class ShockCastleSiege extends TeamGame this.AllowFlintAndSteel = true; this.BlockPlaceAllow.add(Material.FIRE.getId()); this.CrownsEnabled = true; + this.Leaderboards = true; this.FirstKillReward = 20; + this.GemKillDeathRespawn = 1; new CompassModule() .setGiveCompass(true) @@ -183,6 +203,34 @@ public class ShockCastleSiege extends TeamGame _flintAndSteel = new ItemBuilder(Material.FLINT_AND_STEEL).setData((short) (Material.FLINT_AND_STEEL.getMaxDurability() - MAX_FLINT_AND_STEEL_USES)); _wearableTnt = new ItemBuilder(Material.TNT).setTitle(C.cRed + "TNT").addLore(C.cRedB + "Right Click with Weapon to " + F.name("Detonate")); generateLoot(); + + if (manager.IsRewardStats()) + { + if (manager.GetLobby() instanceof NewGameLobbyManager) + { + Map> lobbyCustomLocs = ((NewGameLobbyManager)manager.GetLobby()).getCustomLocs(); + if (lobbyCustomLocs.containsKey("TOP_DAILY_WINS")) + { + Location loc = lobbyCustomLocs.get("TOP_DAILY_WINS").get(0); + Managers.get(LeaderboardManager.class).registerLeaderboard("TOP_CASTLESIEGE_DAILY_WINS", new Leaderboard("Top Daily Wins", new String[] {"Castle Siege New.Wins"}, LeaderboardSQLType.DAILY, loc, 10)); + } + if (lobbyCustomLocs.containsKey("TOP_DAILY_KILLS")) + { + Location loc = lobbyCustomLocs.get("TOP_DAILY_KILLS").get(0); + Managers.get(LeaderboardManager.class).registerLeaderboard("TOP_CASTLESIEGE_DAILY_KILLS", new Leaderboard("Top Daily Kills", new String[] {"Castle Siege New.Kills"}, LeaderboardSQLType.DAILY, loc, 10)); + } + if (lobbyCustomLocs.containsKey("TOP_WINS")) + { + Location loc = lobbyCustomLocs.get("TOP_WINS").get(0); + Managers.get(LeaderboardManager.class).registerLeaderboard("TOP_CASTLESIEGE_WINS", new Leaderboard("Top Wins", new String[] {"Castle Siege New.Wins"}, LeaderboardSQLType.ALL, loc, 10)); + } + if (lobbyCustomLocs.containsKey("TOP_KILLS")) + { + Location loc = lobbyCustomLocs.get("TOP_KILLS").get(0); + Managers.get(LeaderboardManager.class).registerLeaderboard("TOP_CASTLESIEGE_KILLS", new Leaderboard("Top Kills", new String[] {"Castle Siege New.Kills"}, LeaderboardSQLType.ALL, loc, 10)); + } + } + } } private void generateLoot() @@ -330,13 +378,13 @@ public class ShockCastleSiege extends TeamGame } Scoreboard.writeNewLine(); GameTeam red = GetTeam(ChatColor.RED); - long redBeacons = _beacons.get(red).stream().filter(TeamBeacon::isActive).count(); + long redCrystals = _crystals.get(red).stream().filter(TeamCrystal::isActive).count(); GameTeam blue = GetTeam(ChatColor.AQUA); - long blueBeacons = _beacons.get(blue).stream().filter(TeamBeacon::isActive).count(); - if (redBeacons > 0) + long blueCrystals = _crystals.get(blue).stream().filter(TeamCrystal::isActive).count(); + if (redCrystals > 0) { Scoreboard.write(_kings.get(red).getName(true)); - Scoreboard.write(redBeacons + "/2 Beacons Active"); + Scoreboard.write(redCrystals + "/2 Crystals Active"); } else { @@ -344,10 +392,10 @@ public class ShockCastleSiege extends TeamGame Scoreboard.write(_kings.get(red).getHealth() + ""); } Scoreboard.writeNewLine(); - if (blueBeacons > 0) + if (blueCrystals > 0) { Scoreboard.write(_kings.get(blue).getName(true)); - Scoreboard.write(blueBeacons + "/2 Beacons Active"); + Scoreboard.write(blueCrystals + "/2 Crystals Active"); } else { @@ -362,9 +410,9 @@ public class ShockCastleSiege extends TeamGame _writeScoreboard = false; Scoreboard.reset(); Scoreboard.writeNewLine(); - Scoreboard.write(deadKing + "'s " + C.cBlue + "castle has been conquered"); - Scoreboard.write(C.cBlue + "by " + winKing + "'s " + C.cBlue + "army with the help of"); - Scoreboard.write(warrior + C.cBlue + "!"); + Scoreboard.write(deadKing + "'s " + C.cWhite + "castle has been conquered"); + Scoreboard.write(C.cWhite + "by " + winKing + "'s " + C.cWhite + "army with the help of"); + Scoreboard.write(warrior + C.cWhite + "!"); Scoreboard.writeNewLine(); Scoreboard.draw(); @@ -390,11 +438,22 @@ public class ShockCastleSiege extends TeamGame redKing.setYaw(UtilAlg.GetYaw(redBlue)); blueKing.setPitch(UtilAlg.GetPitch(blueRed)); blueKing.setYaw(UtilAlg.GetYaw(blueRed)); - _beacons.put(red, Arrays.asList(new TeamBeacon(red, WorldData.GetDataLocs("PINK").get(0)), new TeamBeacon(red, WorldData.GetDataLocs("PINK").get(1)))); - _beacons.put(blue, Arrays.asList(new TeamBeacon(blue, WorldData.GetDataLocs("LIGHT_BLUE").get(0)), new TeamBeacon(blue, WorldData.GetDataLocs("LIGHT_BLUE").get(1)))); + _crystals.put(red, Arrays.asList(new TeamCrystal(red, WorldData.GetDataLocs("PINK").get(0)), new TeamCrystal(red, WorldData.GetDataLocs("PINK").get(1)))); + _crystals.put(blue, Arrays.asList(new TeamCrystal(blue, WorldData.GetDataLocs("LIGHT_BLUE").get(0)), new TeamCrystal(blue, WorldData.GetDataLocs("LIGHT_BLUE").get(1)))); this.CreatureAllowOverride = true; _kings.put(red, new TeamKing(red, "King Jon", redKing)); _kings.put(blue, new TeamKing(blue, "King Ryan", blueKing)); + int kitIndex = 0; + for (int i = 0; i < WorldData.GetDataLocs("WHITE").size(); i++) + { + if (kitIndex >= GetKits().length) + { + kitIndex = 0; + } + Entity ent = GetKits()[kitIndex].SpawnEntity(WorldData.GetDataLocs("WHITE").get(i)); + Manager.GetLobby().addKitLocation(ent, GetKits()[kitIndex], WorldData.GetDataLocs("WHITE").get(i)); + kitIndex++; + } this.CreatureAllowOverride = false; _tntSpawner = new ObjectiveTNTSpawner(WorldData.GetDataLocs("BLACK")); } @@ -444,10 +503,29 @@ public class ShockCastleSiege extends TeamGame AddGems(player, 10, "Participation", false, false); } - int streak = _streakData.getOrDefault(player, new KillStreakData()).getBestStreak(); - if (streak > 0) { - AddGems(player, streak, streak + " Player Kill Streak", false, false); + int crowns = 0; + for (GemData data : GetGems(player).values()) + { + crowns += data.Gems; + } + int streak = _streakData.getOrDefault(player, new KillStreakData()).getBestStreak(); + if (streak >= 2 && streak < 4) + { + AddGems(player, 0.5 * crowns, streak + " Player Kill Streak", false, false); + } + else if (streak >= 4 && streak < 6) + { + AddGems(player, crowns, streak + " Player Kill Streak", false, false); + } + else if (streak >= 6 && streak < 8) + { + AddGems(player, 1.5 * crowns, streak + " Player Kill Streak", false, false); + } + else if (streak >= 8) + { + AddGems(player, 2 * crowns, streak + " Player Kill Streak", false, false); + } } if (GetKit(player) != null) @@ -497,7 +575,7 @@ public class ShockCastleSiege extends TeamGame GameTeam blue = GetTeam(ChatColor.AQUA); TeamKing redKing = _kings.get(red); TeamKing blueKing = _kings.get(blue); - redKing.update(_beacons.get(red).stream().filter(TeamBeacon::isActive).count() > 0); + redKing.update(_crystals.get(red).stream().filter(TeamCrystal::isActive).count() > 0); if (redKing.isDead()) { AnnounceEnd(blue); @@ -546,7 +624,7 @@ public class ShockCastleSiege extends TeamGame SetState(GameState.End); return; } - blueKing.update(_beacons.get(blue).stream().filter(TeamBeacon::isActive).count() > 0); + blueKing.update(_crystals.get(blue).stream().filter(TeamCrystal::isActive).count() > 0); if (blueKing.isDead()) { AnnounceEnd(red); @@ -686,6 +764,23 @@ public class ShockCastleSiege extends TeamGame { event.setCancelled(true); } + if (event.getToBlock().getType() == Material.ICE) + { + event.setCancelled(true); + } + } + + @EventHandler + public void onBlockChange(BlockFormEvent e) + { + if (!IsLive()) + { + return; + } + if (e.getNewState().getType() == Material.ICE) + { + e.setCancelled(true); + } } @SuppressWarnings("deprecation") @@ -813,7 +908,6 @@ public class ShockCastleSiege extends TeamGame if (data.addKill(hardLine)) { AddStat(player, "KillStreak", 1, false, false); - player.sendMessage(C.cRedB + "You have received a Kill Streak Reward!"); ((KitPlayer)GetKit(player)).awardKillStreak(player, hardLine ? (data.getKills() + 1) : data.getKills()); } if (UtilMath.isEven(data.getKills())) @@ -890,26 +984,26 @@ public class ShockCastleSiege extends TeamGame if (event.getEntity().hasMetadata("OBJECTIVE_TNT")) { - List beacons = new ArrayList<>(); + List crystals = new ArrayList<>(); - for (List b : _beacons.values()) + for (List c : _crystals.values()) { - beacons.addAll(b); + crystals.addAll(c); } - for (TeamBeacon beacon : beacons) + for (TeamCrystal crystal : crystals) { - if (beacon.isActive() && !beacon.getOwner().HasPlayer(player) && UtilMath.offset(event.getEntity().getLocation(), beacon.getLocation()) <= radius) + if (crystal.isActive() && !crystal.getOwner().HasPlayer(player) && UtilMath.offset(event.getEntity().getLocation(), crystal.getLocation()) <= radius) { - beacon.destroy(); - AddGems(player, 40, "Beacon Destruction", false, true); - long remaining = beacons.stream().filter(b -> b.getOwner().GetColor() == beacon.getOwner().GetColor()).filter(TeamBeacon::isActive).count(); + crystal.destroy(); + AddGems(player, 40, "Crystal Destruction", false, true); + long remaining = crystals.stream().filter(b -> b.getOwner().GetColor() == crystal.getOwner().GetColor()).filter(TeamCrystal::isActive).count(); if (remaining > 0) { - Bukkit.broadcastMessage(F.main("Game", "One of " + F.elem(beacon.getOwner().GetFormattedName() + "'s Beacons") + " has been destroyed!")); + Bukkit.broadcastMessage(F.main("Game", "One of " + F.elem(crystal.getOwner().GetFormattedName() + "'s Crystals") + " has been destroyed!")); } else { - Bukkit.broadcastMessage(F.main("Game", "All of " + F.elem(beacon.getOwner().GetFormattedName() + "'s Beacons") + " has been destroyed and " + F.elem(_kings.get(beacon.getOwner()).getName(false)) + " is now vulnerable!")); + Bukkit.broadcastMessage(F.main("Game", "All of " + F.elem(crystal.getOwner().GetFormattedName() + "'s Crystals") + " has been destroyed and " + F.elem(_kings.get(crystal.getOwner()).getName(false)) + " is now vulnerable!")); } } } @@ -996,6 +1090,10 @@ public class ShockCastleSiege extends TeamGame teleport.setYaw(shooter.getLocation().getYaw()); shooter.teleport(teleport); } + if (event.getEntity() instanceof Arrow) + { + Manager.runSyncLater(event.getEntity()::remove, 1L); + } } @EventHandler @@ -1022,6 +1120,11 @@ public class ShockCastleSiege extends TeamGame { return; } + if (event.getEntity() instanceof EnderCrystal) + { + event.setCancelled(true); + return; + } if (event.getEntity() instanceof Zombie) { event.setCancelled(true); @@ -1040,9 +1143,9 @@ public class ShockCastleSiege extends TeamGame { return; } - if (_beacons.get(owner).stream().filter(TeamBeacon::isActive).count() > 0) + if (_crystals.get(owner).stream().filter(TeamCrystal::isActive).count() > 0) { - UtilPlayer.message(p, F.main("Game", "You cannot attack the enemy king until your team has destroyed his protective beacons!")); + UtilPlayer.message(p, F.main("Game", "You cannot attack the enemy king until your team has destroyed his protective crystals!")); return; } TeamKing king = _kings.get(owner); @@ -1203,6 +1306,7 @@ public class ShockCastleSiege extends TeamGame event.getPlayer().getInventory().setHelmet(_wearableTnt.build()); UtilPlayer.message(event.getPlayer(), F.main("Game", "You picked up " + F.skill("TNT") + ".")); UtilPlayer.message(event.getPlayer(), F.main("Game", F.elem("Right-Click") + " to detonate yourself.")); + UtilPlayer.message(event.getPlayer(), F.main("Game", "Run to the enemy Crystal and Detonate to destroy it.")); } } } @@ -1239,8 +1343,15 @@ public class ShockCastleSiege extends TeamGame @EventHandler public void TNTExpire(UpdateEvent event) { - if (event.getType() != UpdateType.FASTER) + if (!IsLive()) + { return; + } + + if (event.getType() != UpdateType.FASTER) + { + return; + } Iterator tntIterator = _tntCarry.iterator(); @@ -1265,7 +1376,34 @@ public class ShockCastleSiege extends TeamGame tntIterator.remove(); continue; } - + + List crystals = new ArrayList<>(); + + for (List c : _crystals.values()) + { + crystals.addAll(c); + } + for (TeamCrystal crystal : crystals) + { + if (crystal.isActive() && !crystal.getOwner().HasPlayer(player) && UtilMath.offset(player.getLocation(), crystal.getLocation()) <= 3) + { + TNTPrimed tnt = player.getWorld().spawn(player.getEyeLocation(), TNTPrimed.class); + UtilEnt.SetMetadata(tnt, "THROWER", player.getName()); + UtilEnt.SetMetadata(tnt, "OBJECTIVE_TNT", true); + tnt.setFuseTicks(0); + + if (!player.isDead()) + { + player.getInventory().setHelmet((ItemStack) player.getMetadata("OLD_HELM").get(0).value()); + } + player.removeMetadata("OLD_HELM", UtilServer.getPlugin()); + player.removeMetadata("TNT_START", UtilServer.getPlugin()); + + tntIterator.remove(); + } + } + + UtilTextBottom.display(GetTeam(player).GetColor() + player.getName() + " has the TNT!", UtilServer.getPlayers()); UtilFirework.playFirework(player.getEyeLocation(), Type.BURST, Color.RED, false, false); } } @@ -1291,4 +1429,13 @@ public class ShockCastleSiege extends TeamGame tnt.setFuseTicks(0); UtilPlayer.message(player, F.main("Game", "You used " + F.skill("Detonate") + ".")); } + + @EventHandler + public void onBlockPlace(BlockPlaceEvent event) + { + if (_tntSpawner.canPlaceFireAt(event.getBlock())) + { + event.setCancelled(true); + } + } } \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/data/ObjectiveTNTSpawner.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/data/ObjectiveTNTSpawner.java index 70f9e2484..18cb00cf5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/data/ObjectiveTNTSpawner.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/data/ObjectiveTNTSpawner.java @@ -3,9 +3,10 @@ package nautilus.game.arcade.game.games.castlesiege.data; import java.util.List; import org.bukkit.Color; +import org.bukkit.FireworkEffect.Type; import org.bukkit.Location; import org.bukkit.Material; -import org.bukkit.FireworkEffect.Type; +import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.entity.Item; import org.bukkit.inventory.ItemStack; @@ -40,6 +41,16 @@ public class ObjectiveTNTSpawner return _entity != null; } + public boolean canPlaceFireAt(Block block) + { + if (!isSpawned()) + { + return false; + } + + return UtilMath.offsetSquared(_lastSpawnLoc, block.getLocation()) <= 9; + } + public long getNextTNT() { return (_lastPickedUp + TNT_SPAWN_DELAY) - System.currentTimeMillis(); @@ -72,6 +83,10 @@ public class ObjectiveTNTSpawner else if (isSpawned()) { _entity.teleport(_lastSpawnLoc); + if (!_entity.isValid() || _entity.isDead()) + { + _entity = _lastSpawnLoc.getWorld().dropItem(_lastSpawnLoc, new ItemStack(Material.TNT)); + } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/data/TeamBeacon.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/data/TeamCrystal.java similarity index 57% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/data/TeamBeacon.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/data/TeamCrystal.java index 74469579d..8c2ebb0af 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/data/TeamBeacon.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/data/TeamCrystal.java @@ -2,16 +2,19 @@ package nautilus.game.arcade.game.games.castlesiege.data; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.EnderCrystal; import nautilus.game.arcade.game.GameTeam; -public class TeamBeacon +public class TeamCrystal { private Location _loc; private GameTeam _owner; + private EnderCrystal _crystal; private boolean _destroyed; - public TeamBeacon(GameTeam owner, Location loc) + public TeamCrystal(GameTeam owner, Location loc) { _owner = owner; _loc = loc; @@ -37,12 +40,15 @@ public class TeamBeacon public void spawn() { _destroyed = false; - _loc.getBlock().setType(Material.BEACON); + _crystal = _loc.getWorld().spawn(_loc, EnderCrystal.class); + _loc.getBlock().getRelative(0, -2, 0).setType(Material.BEACON); } public void destroy() { _destroyed = true; - _loc.getBlock().setType(Material.AIR); + _crystal.remove(); + _crystal = null; + _loc.getBlock().getRelative(0, -2, 0).setType(Material.SMOOTH_BRICK); } } \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitArcher.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitArcher.java index e8b0d5f4e..4ae56308e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitArcher.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitArcher.java @@ -115,18 +115,22 @@ public class KitArcher extends KitPlayer { if (streak == 2) { + player.sendMessage(C.cRedB + "You have received 8 Arrows as a Kill Streak Reward!"); player.getInventory().addItem(new ItemBuilder(Material.ARROW).setAmount(8).setTitle(F.item("Fletched Arrow")).build()); } else if (streak == 4) { + player.sendMessage(C.cRedB + "You have received a Power I book as a Kill Streak Reward!"); player.getInventory().addItem(new EnchantedBookBuilder(1).setLevel(Enchantment.ARROW_DAMAGE, 1).build()); } else if (streak == 6) { + player.sendMessage(C.cRedB + "You have received a Punch I book as a Kill Streak Reward!"); player.getInventory().addItem(new EnchantedBookBuilder(1).setLevel(Enchantment.ARROW_KNOCKBACK, 1).build()); } else if (streak == 8) { + player.sendMessage(C.cRedB + "You have received a Power I book as a Kill Streak Reward!"); player.getInventory().addItem(new EnchantedBookBuilder(1).setLevel(Enchantment.ARROW_DAMAGE, 1).build()); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitDemolitionist.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitDemolitionist.java index 91717d869..2a5731ee6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitDemolitionist.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitDemolitionist.java @@ -130,18 +130,22 @@ public class KitDemolitionist extends KitPlayer { if (streak == 2) { + player.sendMessage(C.cRedB + "You have received 2 Throwing TNT as a Kill Streak Reward!"); player.getInventory().addItem(new ItemBuilder(Material.TNT).setTitle(F.item("Throwing TNT")).setAmount(2).build()); } else if (streak == 4) { + player.sendMessage(C.cRedB + "You have received 3 Throwing TNT as a Kill Streak Reward!"); player.getInventory().addItem(new ItemBuilder(Material.TNT).setTitle(F.item("Throwing TNT")).setAmount(3).build()); } else if (streak == 6) { + player.sendMessage(C.cRedB + "You have received 4 Throwing TNT as a Kill Streak Reward!"); player.getInventory().addItem(new ItemBuilder(Material.TNT).setTitle(F.item("Throwing TNT")).setAmount(4).build()); } else if (streak == 8) { + player.sendMessage(C.cRedB + "You have received 5 Throwing TNT as a Kill Streak Reward!"); player.getInventory().addItem(new ItemBuilder(Material.TNT).setTitle(F.item("Throwing TNT")).setAmount(5).build()); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitFighter.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitFighter.java index 5579e0f7c..c961311ed 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitFighter.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitFighter.java @@ -108,18 +108,22 @@ public class KitFighter extends KitPlayer { if (streak == 2) { + player.sendMessage(C.cRedB + "You have received a Golden Applegate as a Kill Streak Reward!"); player.getInventory().addItem(new ItemBuilder(Material.GOLDEN_APPLE).setAmount(1).setTitle(C.cPurple + "Golden Applegate").build()); } else if (streak == 4) { - player.getInventory().addItem(new EnchantedBookBuilder(1).setLevel(Enchantment.DAMAGE_ALL, 1).build()); + player.sendMessage(C.cRedB + "You have received a Splash Healing II Potion as a Kill Streak Reward!"); + player.getInventory().addItem(new ItemBuilder(Material.POTION).setData((short)16421).build()); } else if (streak == 6) { - player.getInventory().addItem(new EnchantedBookBuilder(1).setLevel(Enchantment.DAMAGE_ALL, 1).build()); + player.sendMessage(C.cRedB + "You have received a Speed II Potion as a Kill Streak Reward!"); + player.getInventory().addItem(new ItemBuilder(Material.POTION).setData((short)8290).build()); } else if (streak == 8) { + player.sendMessage(C.cRedB + "You have received a Fire Aspect I book as a Kill Streak Reward!"); player.getInventory().addItem(new EnchantedBookBuilder(1).setLevel(Enchantment.FIRE_ASPECT, 1).build()); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitTank.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitTank.java index 67e71d8d3..cbd30bb10 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitTank.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitTank.java @@ -3,6 +3,10 @@ package nautilus.game.arcade.game.games.castlesiege.shockkits; import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.PotionMeta; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; import mineplex.core.common.util.C; import mineplex.core.itemstack.EnchantedBookBuilder; @@ -115,18 +119,27 @@ public class KitTank extends KitPlayer { if (streak == 2) { + player.sendMessage(C.cRedB + "You have received a Golden Applegate as a Kill Streak Reward!"); player.getInventory().addItem(new ItemBuilder(Material.GOLDEN_APPLE).setAmount(1).setTitle(C.cPurple + "Golden Applegate").build()); } else if (streak == 4) { - player.getInventory().addItem(new EnchantedBookBuilder(1).setLevel(Enchantment.PROTECTION_ENVIRONMENTAL, 1).build()); + player.sendMessage(C.cRedB + "You have received a Regeneration II Potion as a Kill Streak Reward!"); + player.getInventory().addItem(new ItemBuilder(Material.POTION).setData((short)8289).build()); } else if (streak == 6) { - player.getInventory().addItem(new EnchantedBookBuilder(1).setLevel(Enchantment.PROTECTION_ENVIRONMENTAL, 1).build()); + player.sendMessage(C.cRedB + "You have received a Resistance I Potion as a Kill Streak Reward!"); + ItemStack item = new ItemBuilder(Material.POTION).setData((short)8205).build(); + PotionMeta pm = (PotionMeta) item.getItemMeta(); + pm.clearCustomEffects(); + pm.addCustomEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 20 * 60, 0), true); + item.setItemMeta(pm); + player.getInventory().addItem(item); } else if (streak == 8) { + player.sendMessage(C.cRedB + "You have received a Thorns II book as a Kill Streak Reward!"); player.getInventory().addItem(new EnchantedBookBuilder(1).setLevel(Enchantment.THORNS, 2).build()); } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameStatManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameStatManager.java index 8e7128943..ce18f5910 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameStatManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameStatManager.java @@ -3,6 +3,16 @@ package nautilus.game.arcade.managers; import java.util.HashMap; import java.util.UUID; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.HandlerList; +import org.bukkit.event.Listener; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerQuitEvent; + +import mineplex.core.Managers; import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilMath; @@ -14,15 +24,6 @@ import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.stats.StatTracker; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.HandlerList; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerQuitEvent; - public class GameStatManager implements Listener { ArcadeManager Manager; @@ -74,10 +75,13 @@ public class GameStatManager implements Listener Manager.GetStatsManager().incrementStat(player, stat, value); - // Leaderboard hook for logging appropriate stat events - // Note: Rejects stat events that are not of the appropriate types. - int gameId = event.GetGame().GetType().getGameId(); - LeaderboardManager.getInstance().attemptStatEvent(player, stat.split("\\.")[1], gameId, value); + if (!event.GetGame().Leaderboards) + continue; + + if (stat.startsWith("Global.")) + continue; + + Managers.get(LeaderboardManager.class).handleStatIncrease(player, stat, value); } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/lobby/current/NewGameLobbyManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/lobby/current/NewGameLobbyManager.java index a0a07de20..11b970117 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/lobby/current/NewGameLobbyManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/lobby/current/NewGameLobbyManager.java @@ -1,24 +1,20 @@ package nautilus.game.arcade.managers.lobby.current; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; -import mineplex.core.common.util.MapUtil; -import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.timing.TimingManager; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.game.Game; -import nautilus.game.arcade.game.GameTeam; -import nautilus.game.arcade.game.games.deathtag.DeathTag; -import nautilus.game.arcade.game.games.hideseek.HideSeek; -import nautilus.game.arcade.game.games.smash.SuperSmash; -import nautilus.game.arcade.game.games.wither.WitherGame; -import nautilus.game.arcade.kit.Kit; -import nautilus.game.arcade.kit.KitAvailability; -import nautilus.game.arcade.kit.KitSorter; -import nautilus.game.arcade.kit.NullKit; -import nautilus.game.arcade.managers.LobbyEnt; -import nautilus.game.arcade.managers.lobby.LobbyManager; +import java.io.BufferedReader; +import java.io.DataInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.AbstractMap; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.stream.Collectors; + import org.bukkit.DyeColor; import org.bukkit.Location; import org.bukkit.Material; @@ -32,16 +28,26 @@ import org.bukkit.entity.Sheep; import org.bukkit.event.EventHandler; import org.bukkit.event.player.PlayerArmorStandManipulateEvent; -import java.io.BufferedReader; -import java.io.DataInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStreamReader; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; + +import mineplex.core.common.timing.TimingManager; +import mineplex.core.common.util.MapUtil; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.Game; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.games.deathtag.DeathTag; +import nautilus.game.arcade.game.games.hideseek.HideSeek; +import nautilus.game.arcade.game.games.smash.SuperSmash; +import nautilus.game.arcade.game.games.wither.WitherGame; +import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.kit.KitAvailability; +import nautilus.game.arcade.kit.KitSorter; +import nautilus.game.arcade.kit.NullKit; +import nautilus.game.arcade.managers.LobbyEnt; +import nautilus.game.arcade.managers.lobby.LobbyManager; /** * @@ -574,5 +580,15 @@ public class NewGameLobbyManager extends LobbyManager return null; } - -} + + public Map> getCustomLocs() + { + Map> ret = new HashMap<>(); + ret.putAll(_multipleLocs); + for (Entry singleEntry : _singleLocs.entrySet()) + { + ret.put(singleEntry.getKey(), Arrays.asList(singleEntry.getValue())); + } + return ret; + } +} \ No newline at end of file From 49575e794f60b8a72afdbeb58b5b5a8a3e846f52 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Mon, 8 May 2017 00:11:19 -0400 Subject: [PATCH 55/99] Clean up castle siege leaderboards upon game end --- .../game/arcade/game/games/castlesiege/ShockCastleSiege.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/ShockCastleSiege.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/ShockCastleSiege.java index 91f074691..fcd57e09b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/ShockCastleSiege.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/ShockCastleSiege.java @@ -704,6 +704,10 @@ public class ShockCastleSiege extends TeamGame Manager.GetDamage().SetEnabled(true); Manager.GetExplosion().setEnabled(true); Manager.GetCreature().SetDisableCustomDrops(false); + Managers.get(LeaderboardManager.class).unregisterLeaderboard("TOP_CASTLESIEGE_DAILY_WINS"); + Managers.get(LeaderboardManager.class).unregisterLeaderboard("TOP_CASTLESIEGE_DAILY_KILLS"); + Managers.get(LeaderboardManager.class).unregisterLeaderboard("TOP_CASTLESIEGE_WINS"); + Managers.get(LeaderboardManager.class).unregisterLeaderboard("TOP_CASTLESIEGE_KILLS"); } } From b9fd59737095eda9c5803e53aa78ac16021aaeb5 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Mon, 8 May 2017 01:14:17 -0400 Subject: [PATCH 56/99] Replace old castle siege with new castle siege --- .../core/achievement/Achievement.java | 16 +- .../core/achievement/AchievementCategory.java | 4 +- .../src/mineplex/core/game/GameDisplay.java | 5 +- .../hub/server/ui/ServerGameMenu.java | 9 +- .../src/nautilus/game/arcade/GameType.java | 4 +- .../game/games/castlesiege/CastleSiege.java | 2114 ++++++++++------- .../games/castlesiege/CastleSiegeClassic.java | 973 ++++++++ .../games/castlesiege/CastleSiegeTDM.java | 10 +- .../games/castlesiege/ShockCastleSiege.java | 1445 ----------- .../{kits => classickits}/KitHuman.java | 2 +- .../{kits => classickits}/KitHumanKnight.java | 2 +- .../KitHumanMarksman.java | 2 +- .../KitHumanPeasant.java | 2 +- .../{kits => classickits}/KitUndead.java | 2 +- .../KitUndeadArcher.java | 2 +- .../{kits => classickits}/KitUndeadGhoul.java | 2 +- .../KitUndeadZombie.java | 2 +- .../{shockkits => kits}/KitAlchemist.java | 2 +- .../{shockkits => kits}/KitArcher.java | 2 +- .../{shockkits => kits}/KitBuilder.java | 2 +- .../{shockkits => kits}/KitDemolitionist.java | 2 +- .../{shockkits => kits}/KitEnchanter.java | 2 +- .../{shockkits => kits}/KitFighter.java | 2 +- .../{shockkits => kits}/KitHardline.java | 2 +- .../{shockkits => kits}/KitNinja.java | 2 +- .../{shockkits => kits}/KitPlayer.java | 8 +- .../{shockkits => kits}/KitTank.java | 2 +- .../{shockkits => kits}/KitWorkman.java | 2 +- .../{shockkits => kits}/PerkBloodlust.java | 2 +- .../arcade/stats/BloodThirstyStatTracker.java | 2 +- .../arcade/stats/KingDamageStatTracker.java | 8 +- .../arcade/stats/KingSlayerStatTracker.java | 4 +- 32 files changed, 2319 insertions(+), 2321 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiegeClassic.java delete mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/ShockCastleSiege.java rename Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/{kits => classickits}/KitHuman.java (90%) rename Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/{kits => classickits}/KitHumanKnight.java (97%) rename Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/{kits => classickits}/KitHumanMarksman.java (97%) rename Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/{kits => classickits}/KitHumanPeasant.java (96%) rename Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/{kits => classickits}/KitUndead.java (93%) rename Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/{kits => classickits}/KitUndeadArcher.java (97%) rename Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/{kits => classickits}/KitUndeadGhoul.java (96%) rename Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/{kits => classickits}/KitUndeadZombie.java (96%) rename Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/{shockkits => kits}/KitAlchemist.java (95%) rename Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/{shockkits => kits}/KitArcher.java (98%) rename Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/{shockkits => kits}/KitBuilder.java (95%) rename Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/{shockkits => kits}/KitDemolitionist.java (98%) rename Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/{shockkits => kits}/KitEnchanter.java (96%) rename Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/{shockkits => kits}/KitFighter.java (98%) rename Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/{shockkits => kits}/KitHardline.java (94%) rename Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/{shockkits => kits}/KitNinja.java (95%) rename Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/{shockkits => kits}/KitPlayer.java (88%) rename Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/{shockkits => kits}/KitTank.java (99%) rename Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/{shockkits => kits}/KitWorkman.java (95%) rename Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/{shockkits => kits}/PerkBloodlust.java (97%) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java index 87b22ddad..ff7e2344b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java @@ -376,7 +376,7 @@ public enum Achievement //Castle Siege CASTLE_SIEGE_KILL_STREAK("Kill Streak", 0, - new String[]{"Castle Siege New.KillStreak", "Castle Siege TDM.KillStreak"}, + new String[]{"Castle Siege.KillStreak", "Castle Siege TDM.KillStreak"}, new String[]{"Earn Kill Streak Rewards"}, new int[][]{new int[]{0, 50, 500}, new int[]{0, 100, 750}, new int[]{0, 150, 1000}, new int[]{0, 200, 1500}, new int[]{0, 400, 2000}, new int[]{0, 500, 2500}, new int[]{0, 1000, 3000}, new int[]{0, 1500, 3500}, new int[]{0, 2000, 4000}, new int[]{0, 5000, 100000}}, new int[]{10, 20, 50, 100, 200, 250, 500, 750, 1000, 2000}, @@ -385,7 +385,7 @@ public enum Achievement AchievementCategory.CASTLE_SIEGE), CASTLE_SIEGE_FIRST_BLOOD("First Blood", 0, - new String[]{"Castle Siege New.FirstBlood", "Castle Siege TDM.FirstBlood"}, + new String[]{"Castle Siege.FirstBlood", "Castle Siege TDM.FirstBlood"}, new String[]{"Obtain the first kill in a Match"}, new int[][]{new int[]{0, 100, 100}, new int[]{0, 150, 200}, new int[]{0, 200, 300}, new int[]{0, 250, 400}, new int[]{0, 500, 500}}, new int[]{2, 5, 10, 25, 50}, @@ -394,7 +394,7 @@ public enum Achievement AchievementCategory.CASTLE_SIEGE), CASTLE_SIEGE_FIGHTER_KIT("Fighter", 0, - new String[]{"Castle Siege New.FighterKitKills", "Castle Siege TDM.FighterKitKills"}, + new String[]{"Castle Siege.FighterKitKills", "Castle Siege TDM.FighterKitKills"}, new String[]{"Kill opponents while wearing the Fighter Kit"}, new int[][]{new int[]{0, 100, 500}, new int[]{0, 150, 750}, new int[]{0, 250, 1000}, new int[]{0, 500, 1500}, new int[]{0, 1000, 2500}, new int[]{0, 1500, 3500}, new int[]{0, 2000, 4500}, new int[]{0, 3000, 6000}, new int[]{0, 5000, 10000}, new int[]{0, 10000, 100000}}, new int[]{50, 100, 250, 500, 1000, 1500, 3000, 5000, 10000, 20000}, @@ -403,7 +403,7 @@ public enum Achievement AchievementCategory.CASTLE_SIEGE), CASTLE_SIEGE_TANK_KIT("Tank", 0, - new String[]{"Castle Siege New.TankKitKills", "Castle Siege TDM.TankKitKills"}, + new String[]{"Castle Siege.TankKitKills", "Castle Siege TDM.TankKitKills"}, new String[]{"Kill opponents while wearing the Tank Kit"}, new int[][]{new int[]{0, 100, 500}, new int[]{0, 150, 750}, new int[]{0, 250, 1000}, new int[]{0, 500, 1500}, new int[]{0, 1000, 2500}, new int[]{0, 1500, 3500}, new int[]{0, 2000, 4500}, new int[]{0, 3000, 6000}, new int[]{0, 5000, 10000}, new int[]{0, 10000, 100000}}, new int[]{50, 100, 250, 500, 1000, 1500, 3000, 5000, 10000, 20000}, @@ -412,7 +412,7 @@ public enum Achievement AchievementCategory.CASTLE_SIEGE), CASTLE_SIEGE_ARCHER_KIT("Archer", 0, - new String[]{"Castle Siege New.ArcherKitKills", "Castle Siege TDM.ArcherKitKills"}, + new String[]{"Castle Siege.ArcherKitKills", "Castle Siege TDM.ArcherKitKills"}, new String[]{"Kill opponents while wearing the Archer Kit"}, new int[][]{new int[]{0, 100, 500}, new int[]{0, 150, 750}, new int[]{0, 250, 1000}, new int[]{0, 500, 1500}, new int[]{0, 1000, 2500}, new int[]{0, 1500, 3500}, new int[]{0, 2000, 4500}, new int[]{0, 3000, 6000}, new int[]{0, 5000, 10000}, new int[]{0, 10000, 100000}}, new int[]{50, 100, 250, 500, 1000, 1500, 3000, 5000, 10000, 20000}, @@ -421,7 +421,7 @@ public enum Achievement AchievementCategory.CASTLE_SIEGE), CASTLE_SIEGE_DEMOLITIONIST_KIT("Demolitionist", 0, - new String[]{"Castle Siege New.DemolitionistKitKills", "Castle Siege TDM.DemolitionistKitKills"}, + new String[]{"Castle Siege.DemolitionistKitKills", "Castle Siege TDM.DemolitionistKitKills"}, new String[]{"Kill opponents while wearing the Demolitionist Kit"}, new int[][]{new int[]{0, 100, 500}, new int[]{0, 150, 750}, new int[]{0, 250, 1000}, new int[]{0, 500, 1500}, new int[]{0, 1000, 2500}, new int[]{0, 1500, 3500}, new int[]{0, 2000, 4500}, new int[]{0, 3000, 6000}, new int[]{0, 5000, 10000}, new int[]{0, 10000, 100000}}, new int[]{50, 100, 250, 500, 1000, 1500, 3000, 5000, 10000, 20000}, @@ -430,7 +430,7 @@ public enum Achievement AchievementCategory.CASTLE_SIEGE), CASTLE_SIEGE_WINNER("Siege", 0, - new String[]{"Castle Siege New.Wins", "Castle Siege TDM.Wins"}, + new String[]{"Castle Siege.Wins", "Castle Siege TDM.Wins"}, new String[]{"Win games of Castle Siege"}, new int[][]{new int[]{0, 100, 500}, new int[]{0, 150, 750}, new int[]{0, 250, 1000}, new int[]{0, 500, 1500}, new int[]{0, 1000, 2500}, new int[]{0, 1500, 3500}, new int[]{0, 2000, 4500}, new int[]{0, 3000, 6000}, new int[]{0, 5000, 10000}, new int[]{0, 10000, 100000}}, new int[]{2, 5, 25, 50, 100, 150, 250, 500, 1000, 2000}, @@ -439,7 +439,7 @@ public enum Achievement AchievementCategory.CASTLE_SIEGE), CASTLE_SIEGE_MEDALIST("Medalist", 0, - new String[]{"Castle Siege New.MedalsEarned", "Castle Siege TDM.MedalsEarned"}, + new String[]{"Castle Siege.MedalsEarned", "Castle Siege TDM.MedalsEarned"}, new String[]{"Earn Bronze, Silver, or Gold Medals in Castle Siege Matches"}, new int[][]{new int[]{0, 100, 500}, new int[]{0, 150, 750}, new int[]{0, 250, 1000}, new int[]{0, 500, 1500}, new int[]{0, 1000, 2500}, new int[]{0, 1500, 3500}, new int[]{0, 2000, 4500}, new int[]{0, 3000, 6000}, new int[]{0, 5000, 10000}, new int[]{0, 10000, 100000}}, new int[]{2, 50, 150, 250, 500, 1000, 1500, 2500, 5000, 10000}, diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java index d6137618d..63cdf68c0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java @@ -85,9 +85,9 @@ public enum AchievementCategory new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, Material.BLAZE_ROD, 0, GameCategory.SURVIVAL, "Witch Doctor Kit", false, GameDisplay.Wizards.getGameId()), - CASTLE_SIEGE("Castle Siege", new String[] {"Castle Siege New", "Castle Siege TDM"}, + CASTLE_SIEGE("Castle Siege", new String[] {"Castle Siege", "Castle Siege TDM"}, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.CROWNS_EARNED }, - Material.DIAMOND_CHESTPLATE, 0, GameCategory.CLASSICS, null, false, GameDisplay.CastleSiegeNew.getGameId(), GameDisplay.CastleSiegeTDM.getGameId()), + Material.DIAMOND_CHESTPLATE, 0, GameCategory.CLASSICS, null, false, GameDisplay.CastleSiege.getGameId(), GameDisplay.CastleSiegeTDM.getGameId()), BAWK_BAWK_BATTLES("Bawk Bawk Battles", null, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.GEMS_EARNED }, diff --git a/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java b/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java index eeb057525..5a63e6100 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java @@ -14,9 +14,8 @@ public enum GameDisplay Barbarians("A Barbarians Life", Material.WOOD_AXE, (byte)0, GameCategory.EXTRA, 2, false), BossBattles("Boss Battles", Material.SKULL_ITEM, (byte) 0, GameCategory.EVENT, 55, false), Bridge("The Bridges", Material.IRON_PICKAXE, (byte)0, GameCategory.SURVIVAL, 3, true), - CastleSiege("Castle Siege", Material.DIAMOND_CHESTPLATE, (byte)0, GameCategory.CLASSICS, 4, true), - CastleSiegeNew("Castle Siege New", Material.DIAMOND_CHESTPLATE, (byte)0, GameCategory.CLASSICS, 67, true), - CastleSiegeTDM("Castle Siege TDM", Material.DIAMOND_CHESTPLATE, (byte)0, GameCategory.CLASSICS, 68, true), + CastleSiege("Castle Siege", Material.DIAMOND_CHESTPLATE, (byte)0, GameCategory.CLASSICS, 67, true), + CastleSiegeTDM("Castle Siege TDM", Material.DIAMOND_CHESTPLATE, (byte)0, GameCategory.CLASSICS, 68, false), ChampionsDominate("Champions Domination", "Champions", Material.BEACON, (byte)0, GameCategory.CHAMPIONS, 6, true), ChampionsTDM("Champions TDM", "Champions", Material.GOLD_SWORD, (byte)0, GameCategory.CHAMPIONS, 5, true), Christmas("Christmas Chaos", Material.SNOW_BALL, (byte)0, GameCategory.CLASSICS, 8, false), diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java index 5bfebcbdd..79d186558 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java @@ -154,12 +154,13 @@ public class ServerGameMenu extends ShopPageBase C.Reset + "last man standing.", }, "TDM", "Team_Deathmatch", new SelectTDMButton(this)); - add(24, Material.DIAMOND_CHESTPLATE, C.cYellowB + "Castle Siege " + C.cGray + "Team Game", new String[] + add(24, Material.DIAMOND_CHESTPLATE, C.cYellowB + "Castle Siege " + C.cGray + "Fast-Paced PvP", new String[] { + (_extraValue ? C.cAquaB : C.cWhiteB) + "MAJOR UPDATE/REWRITE", C.Reset + "", - C.Reset + "Defenders must protect King Sparklez", - C.Reset + "from the endless waves of Undead", - C.Reset + "until the sun rises!", + C.Reset + "Combatants must battle to", + C.Reset + "win the day for their king", + C.Reset + "at all costs!", }, "CS", "Castle_Siege", new SelectCSButton(this)); add(26, Material.GRASS, C.cYellowB + "Block Hunt " + C.cGray + "Cat and Mouse", new String[] diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java index b15bfdfb5..76e5c38bf 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java @@ -24,9 +24,8 @@ import nautilus.game.arcade.game.games.build.modes.DukesOfDecoration; import nautilus.game.arcade.game.games.build.modes.TeamBuild; import nautilus.game.arcade.game.games.buildmavericks.BuildMavericks; import nautilus.game.arcade.game.games.cards.Cards; -import nautilus.game.arcade.game.games.castlesiege.CastleSiege; import nautilus.game.arcade.game.games.castlesiege.CastleSiegeTDM; -import nautilus.game.arcade.game.games.castlesiege.ShockCastleSiege; +import nautilus.game.arcade.game.games.castlesiege.CastleSiege; import nautilus.game.arcade.game.games.champions.ChampionsCTF; import nautilus.game.arcade.game.games.champions.ChampionsDominate; import nautilus.game.arcade.game.games.champions.ChampionsTDM; @@ -132,7 +131,6 @@ public enum GameType BossBattles(BossBattles.class, GameDisplay.BossBattles), Bridge(Bridge.class, GameDisplay.Bridge), CastleSiege(CastleSiege.class, GameDisplay.CastleSiege), - CastleSiegeNew(ShockCastleSiege.class, GameDisplay.CastleSiegeNew), CastleSiegeTDM(CastleSiegeTDM.class, GameDisplay.CastleSiegeTDM), ChampionsCTF(ChampionsCTF.class, GameDisplay.ChampionsCTF), ChampionsDominate(ChampionsDominate.class, GameDisplay.ChampionsDominate), diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiege.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiege.java index a5a67d2d0..f17e43398 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiege.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiege.java @@ -1,973 +1,1445 @@ package nautilus.game.arcade.game.games.castlesiege; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; -import java.util.HashSet; import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.WeakHashMap; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Color; -import org.bukkit.Effect; -import org.bukkit.EntityEffect; import org.bukkit.FireworkEffect.Type; import org.bukkit.Location; import org.bukkit.Material; -import org.bukkit.Sound; import org.bukkit.block.Block; -import org.bukkit.entity.Creature; +import org.bukkit.block.BlockFace; +import org.bukkit.block.Chest; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.EnderCrystal; +import org.bukkit.entity.EnderPearl; import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.FallingBlock; -import org.bukkit.entity.Horse; -import org.bukkit.entity.Horse.Style; -import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.ItemFrame; +import org.bukkit.entity.Painting; import org.bukkit.entity.Player; import org.bukkit.entity.TNTPrimed; +import org.bukkit.entity.Zombie; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; -import org.bukkit.event.HandlerList; -import org.bukkit.event.block.Action; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import org.bukkit.event.entity.EntityTargetEvent; +import org.bukkit.event.block.BlockBurnEvent; +import org.bukkit.event.block.BlockDispenseEvent; +import org.bukkit.event.block.BlockFadeEvent; +import org.bukkit.event.block.BlockFormEvent; +import org.bukkit.event.block.BlockFromToEvent; +import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.event.block.LeavesDecayEvent; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.ExplosionPrimeEvent; +import org.bukkit.event.entity.ItemDespawnEvent; import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.entity.ProjectileHitEvent; -import org.bukkit.event.player.PlayerEvent; -import org.bukkit.event.player.PlayerInteractEntityEvent; +import org.bukkit.event.hanging.HangingBreakEvent; +import org.bukkit.event.inventory.InventoryAction; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.inventory.InventoryType; +import org.bukkit.event.inventory.PrepareItemCraftEvent; +import org.bukkit.event.player.PlayerBucketEmptyEvent; +import org.bukkit.event.player.PlayerBucketFillEvent; +import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.inventory.ItemStack; +import org.bukkit.material.Dispenser; +import org.bukkit.material.MaterialData; +import org.bukkit.metadata.FixedMetadataValue; +import org.bukkit.metadata.MetadataValue; +import org.bukkit.util.Vector; +import mineplex.core.Managers; import mineplex.core.common.util.C; import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilEvent; import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilFirework; +import mineplex.core.common.util.UtilInv; 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.UtilPlayer; import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTextBottom; import mineplex.core.common.util.UtilTime; +import mineplex.core.itemstack.EnchantedBookBuilder; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.leaderboard.Leaderboard; +import mineplex.core.leaderboard.LeaderboardManager; +import mineplex.core.leaderboard.LeaderboardRepository.LeaderboardSQLType; +import mineplex.core.loot.ChestLoot; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.combat.DeathMessageType; +import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; - import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; +import nautilus.game.arcade.events.FirstBloodEvent; import nautilus.game.arcade.events.GameStateChangeEvent; -import nautilus.game.arcade.events.PlayerGameRespawnEvent; import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.GemData; import nautilus.game.arcade.game.TeamGame; -import nautilus.game.arcade.game.games.castlesiege.kits.KitHumanKnight; -import nautilus.game.arcade.game.games.castlesiege.kits.KitHumanMarksman; -import nautilus.game.arcade.game.games.castlesiege.kits.KitHumanPeasant; -import nautilus.game.arcade.game.games.castlesiege.kits.KitUndeadArcher; -import nautilus.game.arcade.game.games.castlesiege.kits.KitUndeadGhoul; -import nautilus.game.arcade.game.games.castlesiege.kits.KitUndeadZombie; +import nautilus.game.arcade.game.games.castlesiege.data.KillStreakData; +import nautilus.game.arcade.game.games.castlesiege.data.ObjectiveTNTSpawner; +import nautilus.game.arcade.game.games.castlesiege.data.TeamCrystal; +import nautilus.game.arcade.game.games.castlesiege.data.TeamKing; +import nautilus.game.arcade.game.games.castlesiege.kits.KitArcher; +import nautilus.game.arcade.game.games.castlesiege.kits.KitDemolitionist; +import nautilus.game.arcade.game.games.castlesiege.kits.KitFighter; +import nautilus.game.arcade.game.games.castlesiege.kits.KitPlayer; +import nautilus.game.arcade.game.games.castlesiege.kits.KitTank; import nautilus.game.arcade.game.modules.compass.CompassModule; import nautilus.game.arcade.kit.Kit; -import nautilus.game.arcade.kit.NullKit; -import nautilus.game.arcade.stats.BloodThirstyStatTracker; -import nautilus.game.arcade.stats.KingDamageStatTracker; -import nautilus.game.arcade.stats.KingSlayerStatTracker; -import nautilus.game.arcade.stats.TeamDeathsStatTracker; -import nautilus.game.arcade.stats.TeamKillsStatTracker; -import nautilus.game.arcade.stats.WinAsTeamStatTracker; +import nautilus.game.arcade.managers.lobby.current.NewGameLobbyManager; public class CastleSiege extends TeamGame { - public static class KingDamageEvent extends PlayerEvent - { - private static final HandlerList handlers = new HandlerList(); - - public static HandlerList getHandlerList() - { - return handlers; - } - - @Override - public HandlerList getHandlers() - { - return getHandlerList(); - } - - private final double _damage; - - public KingDamageEvent(Player who, double damage) - { - super(who); - - _damage = damage; - } - - public double getDamage() - { - return _damage; - } - } - - public static class KingSlaughterEvent extends PlayerEvent - { - private static final HandlerList handlers = new HandlerList(); - - public static HandlerList getHandlerList() - { - return handlers; - } - - @Override - public HandlerList getHandlers() - { - return getHandlerList(); - } - - public KingSlaughterEvent(Player who) - { - super(who); - } - } - - private ArrayList _lastScoreboard = new ArrayList(); - - private long _tntSpawn = 0; - private ArrayList _tntSpawns = new ArrayList(); - private ArrayList _tntWeakness = new ArrayList(); - - private HashMap _tntCarry = new HashMap(); - private HashSet _tntCarryEnd = new HashSet(); - - private ArrayList _kingLocs; - private Creature _king; - private Location _kingLoc; - private String _kingName; - private Player _kingDamager = null; - private int _kingHealth = 40; - - private ArrayList _peasantSpawns; - private ArrayList _horseSpawns; - + private static final int MAX_FLINT_AND_STEEL_USES = 4; + private static final int ITEMS_PER_CHEST = 5; + private static final long TIME_TILL_REFILL = 2 * 60 * 1000; + + private long _lastRefill; + + private ItemBuilder _flintAndSteel; + private ItemBuilder _wearableTnt; + + private Map _streakData = new WeakHashMap<>(); + private Map> _crystals = new HashMap<>(); + private Map _kings = new HashMap<>(); + private List _tntCarry = new ArrayList<>(); + + private List _chests = new ArrayList<>(); + + private ChestLoot _diamondGearCommon = new ChestLoot(true); + private ChestLoot _diamondGearRare = new ChestLoot(true); + private ChestLoot _weaponGearCommon = new ChestLoot(true); + private ChestLoot _weaponGearRare = new ChestLoot(true); + private ChestLoot _rangedGear = new ChestLoot(true); + private ChestLoot _rodsAndGaps = new ChestLoot(true); + private ChestLoot _potionGearCommon = new ChestLoot(true); + private ChestLoot _potionGearRare = new ChestLoot(true); + private ChestLoot _enchantGearCommon = new ChestLoot(true); + private ChestLoot _enchantGearRare = new ChestLoot(true); + private ChestLoot _miscGear = new ChestLoot(); + + private ObjectiveTNTSpawner _tntSpawner; + + private boolean _writeScoreboard = true; + + @SuppressWarnings("deprecation") public CastleSiege(ArcadeManager manager) { - super(manager, GameType.CastleSiege, - - new Kit[] - { - new KitHumanMarksman(manager), - new KitHumanKnight(manager), - //new KitHumanBrawler(manager), - //new KitHumanAssassin(manager), - new NullKit(manager), - new KitHumanPeasant(manager), - new NullKit(manager), - new KitUndeadGhoul(manager), - new KitUndeadArcher(manager), - new KitUndeadZombie(manager), - }, - - new String[] - { - F.elem(C.cAqua + "Defenders") + C.cWhite + " must defend the King.", - F.elem(C.cAqua + "Defenders") + C.cWhite + " win when the sun rises.", - F.elem(C.cAqua + "Defenders") + C.cWhite + " respawn as wolves.", - "", - F.elem(C.cRed + "Undead") + C.cWhite + " must kill the King.", - F.elem(C.cRed + "Undead") + C.cWhite + " lose when the sun rises.", - - }); - - _help = new String[] - { - "Marksmen are extremely important to defence!", - "It's recommended 50%+ of defence are Marksmen.", - "Use Barricades to block the Undeads path.", - "Use TNT to destroy weak points in walls.", - "Weak points are marked by cracked stone brick.", - "Undead can break fences with their axes.", - "Undead Archers must pick up arrows from the ground.", - - }; - - this.StrictAntiHack = true; + super(manager, GameType.CastleSiegeNew, + new Kit[] + { + //new KitAlchemist(manager), + new KitArcher(manager), + new KitDemolitionist(manager), + //new KitEnchanter(manager), + new KitFighter(manager), + //new KitHardline(manager), + //new KitNinja(manager), + new KitTank(manager) + }, + new String[] + { + "Destroy enemy sentry crystals with running TNT", + "After the enemy crystals are destroyed you must slay their king", + "First team to kill the enemy king wins", + "Chests refill every 2 minutes", + "TNT Respawns every 1 minute" + } + ); + _help = new String[] + { + "Use the TNT spawning platforms to run TNT to the enemy crystals to destroy them!", + "The enemy king is invulnerable until you destroy the two sentry crystals on each sentry tower", + "Go on Kill Streaks to earn Kill Streak Rewards to obtain better armor & weapons!", + "Chests refill every 2 minutes with potions, golden applegates, fishing rods, and other useful PvP items!" + }; + + this.StrictAntiHack = true; this.HungerSet = 20; this.DeathOut = false; - this.WorldTimeSet = 14000; //14000 - this.BlockPlaceAllow.add(85); - - _kingName = C.cYellow + C.Bold + "King Sparklez"; - - GameTeam notRedTeam = null; - for (GameTeam team : GetTeamList()) - { - if (team.GetColor() != ChatColor.RED) - { - notRedTeam = team; - break; - } - } - - registerStatTrackers( - new KingSlayerStatTracker(this), - new BloodThirstyStatTracker(this), - new KingDamageStatTracker(this), - - new TeamDeathsStatTracker(this), - new TeamKillsStatTracker(this) - ); - - registerChatStats( - Kills, - Deaths, - KDRatio, - BlankLine, - Assists, - DamageDealt, - DamageTaken - ); - - registerChatStats(); - + this.DeathSpectateSecs = 5; + this.CreatureAllow = false; + this.DeathDropItems = false; + this.WorldWeatherEnabled = false; + this.AllowParticles = false; + this.SoupEnabled = false; + this.InventoryClick = true; + this.InventoryOpenChest = true; + this.InventoryOpenBlock = true; + this.ItemDrop = true; + this.ItemPickup = true; + this.AllowFlintAndSteel = true; + this.BlockPlaceAllow.add(Material.FIRE.getId()); + this.CrownsEnabled = true; + this.Leaderboards = true; + this.FirstKillReward = 20; + this.GemKillDeathRespawn = 1; + new CompassModule() - .setGiveCompass(true) - .setGiveCompassToSpecs(true) - .setGiveCompassToAlive(false) - .register(this); - } - - @Override - public void ParseData() - { - _tntSpawns = WorldData.GetDataLocs("RED"); - _tntWeakness = WorldData.GetDataLocs("BLACK"); - - _kingLocs = WorldData.GetDataLocs("YELLOW"); - - _peasantSpawns = WorldData.GetDataLocs("GREEN"); - _horseSpawns = WorldData.GetDataLocs("BROWN"); - } - - @Override - public void RestrictKits() - { - for (Kit kit : GetKits()) + .setGiveCompass(true) + .setGiveCompassToSpecs(true) + .setGiveCompassToAlive(false) + .register(this); + + _flintAndSteel = new ItemBuilder(Material.FLINT_AND_STEEL).setData((short) (Material.FLINT_AND_STEEL.getMaxDurability() - MAX_FLINT_AND_STEEL_USES)); + _wearableTnt = new ItemBuilder(Material.TNT).setTitle(C.cRed + "TNT").addLore(C.cRedB + "Right Click with Weapon to " + F.name("Detonate")); + generateLoot(); + + if (manager.IsRewardStats()) { - for (GameTeam team : GetTeamList()) + if (manager.GetLobby() instanceof NewGameLobbyManager) { - if (team.GetColor() == ChatColor.RED) + Map> lobbyCustomLocs = ((NewGameLobbyManager)manager.GetLobby()).getCustomLocs(); + if (lobbyCustomLocs.containsKey("TOP_DAILY_WINS")) { - if (kit.GetName().contains("Castle")) - team.GetRestrictedKits().add(kit); - - team.SetName("Undead"); + Location loc = lobbyCustomLocs.get("TOP_DAILY_WINS").get(0); + Managers.get(LeaderboardManager.class).registerLeaderboard("TOP_CASTLESIEGE_DAILY_WINS", new Leaderboard("Top Daily Wins", new String[] {"Castle Siege.Wins"}, LeaderboardSQLType.DAILY, loc, 10)); } - else + if (lobbyCustomLocs.containsKey("TOP_DAILY_KILLS")) { - if (kit.GetName().contains("Undead")) - team.GetRestrictedKits().add(kit); - - team.SetRespawnTime(8); - - team.SetName("Defenders"); + Location loc = lobbyCustomLocs.get("TOP_DAILY_KILLS").get(0); + Managers.get(LeaderboardManager.class).registerLeaderboard("TOP_CASTLESIEGE_DAILY_KILLS", new Leaderboard("Top Daily Kills", new String[] {"Castle Siege.Kills"}, LeaderboardSQLType.DAILY, loc, 10)); + } + if (lobbyCustomLocs.containsKey("TOP_WINS")) + { + Location loc = lobbyCustomLocs.get("TOP_WINS").get(0); + Managers.get(LeaderboardManager.class).registerLeaderboard("TOP_CASTLESIEGE_WINS", new Leaderboard("Top Wins", new String[] {"Castle Siege.Wins"}, LeaderboardSQLType.ALL, loc, 10)); + } + if (lobbyCustomLocs.containsKey("TOP_KILLS")) + { + Location loc = lobbyCustomLocs.get("TOP_KILLS").get(0); + Managers.get(LeaderboardManager.class).registerLeaderboard("TOP_CASTLESIEGE_KILLS", new Leaderboard("Top Kills", new String[] {"Castle Siege.Kills"}, LeaderboardSQLType.ALL, loc, 10)); } - } - } - } - - @EventHandler(priority = EventPriority.HIGH) - public void registerTeamTracker(GameStateChangeEvent event) - { - if (event.GetState() == GameState.Recruit) - { - GameTeam notRed = null; - - for (GameTeam team : GetTeamList()) - { - if (team.GetColor() == ChatColor.RED) - continue; - - notRed = team; - break; - } - - if (notRed != null) - { - registerStatTrackers(new WinAsTeamStatTracker(this, notRed, "ForTheKing")); - System.out.println("Successfully registered For the King StatTrak"); } } } - @EventHandler - public void MoveKits(GameStateChangeEvent event) + private void generateLoot() { - if (event.GetState() != GameState.Prepare) - return; - - for (int i = 0; i < WorldData.GetDataLocs("PINK").size() && i < 3; i++) { - if (GetKits().length <= 5 + i) - continue; - - this.CreatureAllowOverride = true; - Entity ent = GetKits()[5 + i].SpawnEntity(WorldData.GetDataLocs("PINK").get(i)); - this.CreatureAllowOverride = false; - - Manager.GetLobby().addKitLocation(ent, GetKits()[5 + i], WorldData.GetDataLocs("PINK").get(i)); + _diamondGearCommon.addLoot(new ItemStack(Material.DIAMOND_HELMET), 2); + _diamondGearCommon.addLoot(new ItemStack(Material.DIAMOND_CHESTPLATE), 2); + _diamondGearCommon.addLoot(new ItemStack(Material.DIAMOND_LEGGINGS), 2); + _diamondGearCommon.addLoot(new ItemStack(Material.DIAMOND_BOOTS), 2); + _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_HELMET).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1).build(), 1); + _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_CHESTPLATE).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1).build(), 1); + _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_LEGGINGS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1).build(), 1); + _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_BOOTS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1).build(), 1); + _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_HELMET).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).build(), 1); + _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_CHESTPLATE).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).build(), 1); + _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_LEGGINGS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).build(), 1); + _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_BOOTS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).build(), 1); + _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_HELMET).addEnchantment(Enchantment.PROTECTION_PROJECTILE, 3).build(), 1); + _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_CHESTPLATE).addEnchantment(Enchantment.PROTECTION_PROJECTILE, 3).build(), 1); + _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_LEGGINGS).addEnchantment(Enchantment.PROTECTION_PROJECTILE, 3).build(), 1); + _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_BOOTS).addEnchantment(Enchantment.PROTECTION_PROJECTILE, 3).build(), 1); + } + { + _diamondGearRare.addLoot(new ItemBuilder(Material.DIAMOND_HELMET).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4).build(), 1); + _diamondGearRare.addLoot(new ItemBuilder(Material.DIAMOND_CHESTPLATE).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4).build(), 1); + _diamondGearRare.addLoot(new ItemBuilder(Material.DIAMOND_LEGGINGS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4).build(), 1); + _diamondGearRare.addLoot(new ItemBuilder(Material.DIAMOND_BOOTS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4).build(), 1); + } + { + _weaponGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_SWORD).build(), 2); + _weaponGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_SWORD).addEnchantment(Enchantment.DAMAGE_ALL, 1).build(), 2); + } + { + _weaponGearRare.addLoot(new ItemBuilder(Material.DIAMOND_SWORD).addEnchantment(Enchantment.DAMAGE_ALL, 2).build(), 1); + } + { + _rangedGear.addLoot(new ItemStack(Material.BOW), 3); + _rangedGear.addLoot(Material.ARROW, 3, 8, 16); + } + { + _rodsAndGaps.addLoot(new ItemStack(Material.FISHING_ROD), 3); + _rodsAndGaps.addLoot(new ItemBuilder(Material.GOLDEN_APPLE).setTitle(C.cPurple + "Golden Applegate").build(), 3); + } + { + _potionGearCommon.addLoot(new ItemBuilder(Material.POTION).setData((short)16418).build(), 2); + _potionGearCommon.addLoot(new ItemBuilder(Material.POTION).setData((short)16417).build(), 2); + } + { + _potionGearRare.addLoot(new ItemBuilder(Material.POTION).setData((short)8193).build(), 2); + _potionGearRare.addLoot(new ItemBuilder(Material.POTION).setData((short)8195).build(), 2); + } + { + _enchantGearCommon.addLoot(new EnchantedBookBuilder(1).setLevel(Enchantment.PROTECTION_ENVIRONMENTAL, 1).build(), 2); + _enchantGearCommon.addLoot(new EnchantedBookBuilder(1).setLevel(Enchantment.DAMAGE_ALL, 1).build(), 2); + _enchantGearCommon.addLoot(new EnchantedBookBuilder(1).setLevel(Enchantment.ARROW_DAMAGE, 1).build(), 2); + _enchantGearCommon.addLoot(new ItemStack(Material.EXP_BOTTLE, 64), 1); + } + { + _enchantGearRare.addLoot(new EnchantedBookBuilder(1).setLevel(Enchantment.FIRE_ASPECT, 1).build(), 1); + } + { + _miscGear.addLoot(new ItemStack(Material.ENDER_PEARL), 2); + _miscGear.addLoot(new ItemStack(Material.WATER_BUCKET), 2); + _miscGear.addLoot(_flintAndSteel.build(), 2); + _miscGear.addLoot(new ItemStack(Material.SNOW_BALL, 16), 3); } } - - @EventHandler - public void HorseSpawn(GameStateChangeEvent event) + + private void fillChest(Block block) { - if (event.GetState() != GameState.Prepare) - return; - - for (Location loc : _horseSpawns) + if (block.getType() != Material.CHEST && block.getType() != Material.TRAPPED_CHEST) { - this.CreatureAllowOverride = true; - Horse horse = loc.getWorld().spawn(loc, Horse.class); - this.CreatureAllowOverride = false; - - horse.setAdult(); - horse.setAgeLock(true); - horse.setColor(org.bukkit.entity.Horse.Color.BLACK); - horse.setStyle(Style.BLACK_DOTS); - horse.setMaxDomestication(1); - horse.getInventory().setSaddle(new ItemStack(Material.SADDLE)); - horse.getInventory().setArmor(new ItemStack(Material.IRON_BARDING)); - - horse.setMaxHealth(60); - horse.setHealth(horse.getMaxHealth()); - - horse.setCustomName("War Horse"); + return; } - } - - @EventHandler - public void HorseInteract(PlayerInteractEntityEvent event) - { - if (!(event.getRightClicked() instanceof Horse)) - return; - - Player player = event.getPlayer(); - GameTeam team = GetTeam(player); - - if (team == null || team.GetColor() == ChatColor.RED || !IsAlive(player)) + Chest chest = (Chest) block.getState(); + + chest.getBlockInventory().clear(); + int[] slots = UtilMath.random.ints(ITEMS_PER_CHEST, 0, chest.getBlockInventory().getSize()).toArray(); + + for (int slot : slots) { - event.setCancelled(true); - } - } - - @EventHandler - public void HorseDamageCancel(CustomDamageEvent event) - { - if (!(event.GetDamageeEntity() instanceof Horse)) - return; - - Player player = event.GetDamagerPlayer(true); - if (player == null) - return; - - if (!IsAlive(player)) - return; - - if (GetTeam(player) == null) - return; - - if (GetTeam(player).GetColor() == ChatColor.RED) - return; - - event.SetCancelled("Horse Team Damage"); - } - - @EventHandler(priority = EventPriority.HIGH) - public void GameStateChange(GameStateChangeEvent event) - { - if (event.GetState() != GameState.Prepare) - return; - - //Spawn King - this.CreatureAllowOverride = true; - - _kingLoc = _kingLocs.get(UtilMath.r(_kingLocs.size())); - - _king = (Creature) _kingLoc.getWorld().spawnEntity(_kingLoc, EntityType.ZOMBIE); - - _king.getEquipment().setHelmet(new ItemStack(Material.DIAMOND_HELMET)); - _king.getEquipment().setChestplate(new ItemStack(Material.DIAMOND_CHESTPLATE)); - _king.getEquipment().setLeggings(new ItemStack(Material.DIAMOND_LEGGINGS)); - _king.getEquipment().setBoots(new ItemStack(Material.DIAMOND_BOOTS)); - _king.getEquipment().setItemInHand(new ItemStack(Material.DIAMOND_SWORD)); - - _king.setCustomName(_kingName); - _king.setCustomNameVisible(true); - - _king.setRemoveWhenFarAway(false); - - this.CreatureAllowOverride = false; - } - - @EventHandler(priority = EventPriority.HIGH) - public void SetDefenderRespawn(GameStateChangeEvent event) - { - if (event.GetState() != GameState.Live) - return; - - //Change to Peasant Spawns - this.GetTeam(ChatColor.AQUA).SetSpawns(_peasantSpawns); - } - - - @EventHandler - public void KingTarget(EntityTargetEvent event) - { - event.setCancelled(true); - } - - @EventHandler - public void KingDamage(CustomDamageEvent event) - { - if (_king == null || !_king.isValid()) - return; - - if (!event.GetDamageeEntity().equals(_king)) - return; - - event.SetCancelled("King Damage"); - - Player damager = event.GetDamagerPlayer(true); - if (damager == null) return; - - GameTeam team = GetTeam(damager); - - if (team != null && team.GetColor() == ChatColor.RED) - { - if (!Recharge.Instance.use(damager, "Damage King", 400, false, false)) - return; + double chance = UtilMath.random.nextDouble(); + double subChance = UtilMath.random.nextDouble(); - if (!IsAlive(damager)) + ChestLoot loot = _miscGear; + if (chance <= 0.6) { - return; + loot = _rodsAndGaps; } - - _king.playEffect(EntityEffect.HURT); - - _kingDamager = damager; - _kingHealth--; - - Bukkit.getPluginManager().callEvent(new KingDamageEvent(damager, 1)); - - if (_kingHealth < 0) - _kingHealth = 0; - - WriteScoreboard(); - - if (_kingHealth <= 0) - _king.damage(500); - - EndCheck(); - } - } - - @EventHandler - public void KingUpdate(UpdateEvent event) - { - if (GetState() != GameState.Live) - return; - - if (event.getType() != UpdateType.SEC) - return; - - if (_king == null) - return; - - if (UtilMath.offset(_king.getLocation(), _kingLoc) > 6) - { - _king.teleport(_kingLoc); - } - else - { - UtilEnt.CreatureMove(_king, _kingLoc, 1f); - } - } - - @EventHandler - public void PlayerDeath(PlayerGameRespawnEvent event) - { - if (GetTeam(ChatColor.AQUA).HasPlayer(event.GetPlayer())) - SetKit(event.GetPlayer(), GetKits()[3], true); - } - - @Override - @EventHandler - public void ScoreboardUpdate(UpdateEvent event) - { - if (event.getType() != UpdateType.FAST) - return; - - WriteScoreboard(); - } - - public void WriteScoreboard() - { - //Get Values - HashMap _scoreGroup = new HashMap(); - _scoreGroup.put(C.cAqua + "Defenders", 0); - _scoreGroup.put(C.cDAqua + "Wolves", 0); - _scoreGroup.put(C.cRed + "Undead", 0); - - for (Player player : UtilServer.getPlayers()) - { - if (!IsAlive(player)) - continue; - - Kit kit = GetKit(player); - if (kit == null) continue; - - if (kit.GetName().contains("Castle")) + if (chance <= 0.5) { - if (kit.GetName().contains("Wolf")) + loot = _potionGearCommon; + if (subChance <= 0.45) { - _scoreGroup.put(C.cDAqua + "Wolves", 1 + _scoreGroup.get(C.cDAqua + "Wolves")); - } - else - { - _scoreGroup.put(C.cAqua + "Defenders", 1 + _scoreGroup.get(C.cAqua + "Defenders")); + loot = _potionGearRare; } } - else if (kit.GetName().contains("Undead")) + if (chance <= 0.3) { - _scoreGroup.put(C.cRed + "Undead", 1 + _scoreGroup.get(C.cRed + "Undead")); + loot = _rangedGear; } + chest.getBlockInventory().setItem(slot, loot.getLoot()); + } + } + + public ItemStack getNewFlintAndSteel(boolean kitItem) + { + if (kitItem) + { + return _flintAndSteel.clone().setLore(C.cGold + "Kit Item").build(); + } + return _flintAndSteel.build(); + } + + public void writeScoreboard() + { + if (!_writeScoreboard) + { + return; } - - //Wipe Last Scoreboard.reset(); - - //Teams - for (String group : _scoreGroup.keySet()) + Scoreboard.write(C.cDRedB + GetName()); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cGreenB + "Chest Refill"); + long refillTime = _lastRefill + TIME_TILL_REFILL - System.currentTimeMillis(); + if (!IsLive()) { - Scoreboard.writeNewLine(); - Scoreboard.write(group); - Scoreboard.write(ChatColor.getLastColors(group) + _scoreGroup.get(group) + " Players"); + refillTime = TIME_TILL_REFILL; } - - //King - if (_king != null && _king.isValid()) + Scoreboard.write(UtilTime.MakeStr(refillTime)); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cGreenB + "TNT Spawn"); + long tntTime = _tntSpawner.getNextTNT(); + if (!IsLive()) { - Scoreboard.writeNewLine(); - Scoreboard.write(C.cYellow + C.Bold + "King"); - Scoreboard.write(_kingHealth + " Health"); + tntTime = 60000; } - - long timeLeft = 24000 - WorldTimeSet; - timeLeft = timeLeft / 20 * 1000; - - - if (timeLeft > 0) + if (_tntSpawner.isSpawned()) { - Scoreboard.writeNewLine(); - Scoreboard.write(C.cYellow + C.Bold + "Sun Rise"); - Scoreboard.write(UtilTime.MakeStr(timeLeft, 0)); + Scoreboard.write("Spawned"); } else { - Scoreboard.writeNewLine(); - Scoreboard.write(C.cYellow + C.Bold + "Sun Rise"); - Scoreboard.write("Undead Burning!"); - - for (Player player : GetTeam(ChatColor.RED).GetPlayers(true)) - Manager.GetCondition().Factory().Ignite("Sun Damage", player, player, 5, false, false); + Scoreboard.write(UtilTime.MakeStr(tntTime)); + } + Scoreboard.writeNewLine(); + GameTeam red = GetTeam(ChatColor.RED); + long redCrystals = _crystals.get(red).stream().filter(TeamCrystal::isActive).count(); + GameTeam blue = GetTeam(ChatColor.AQUA); + long blueCrystals = _crystals.get(blue).stream().filter(TeamCrystal::isActive).count(); + if (redCrystals > 0) + { + Scoreboard.write(_kings.get(red).getName(true)); + Scoreboard.write(redCrystals + "/2 Crystals Active"); + } + else + { + Scoreboard.write(_kings.get(red).getName(true) + " Health"); + Scoreboard.write(_kings.get(red).getHealth() + ""); + } + Scoreboard.writeNewLine(); + if (blueCrystals > 0) + { + Scoreboard.write(_kings.get(blue).getName(true)); + Scoreboard.write(blueCrystals + "/2 Crystals Active"); + } + else + { + Scoreboard.write(_kings.get(blue).getName(true) + " Health"); + Scoreboard.write(_kings.get(blue).getHealth() + ""); } - Scoreboard.draw(); } - + + public void writeFinalScoreboard(String deadKing, String winKing, String warrior) + { + _writeScoreboard = false; + Scoreboard.reset(); + Scoreboard.writeNewLine(); + Scoreboard.write(deadKing + "'s " + C.cWhite + "castle has been conquered"); + Scoreboard.write(C.cWhite + "by " + winKing + "'s " + C.cWhite + "army with the help of"); + Scoreboard.write(warrior + C.cWhite + "!"); + Scoreboard.writeNewLine(); + + Scoreboard.draw(); + } + + @Override + public void ParseData() + { + for (Location chestLoc : WorldData.GetDataLocs("BROWN")) + { + Block block = chestLoc.getBlock(); + block.setType(Material.CHEST); + fillChest(block); + _chests.add(block); + } + GameTeam red = GetTeam(ChatColor.RED); + GameTeam blue = GetTeam(ChatColor.AQUA); + Location redKing = WorldData.GetDataLocs("RED").get(0); + Location blueKing = WorldData.GetDataLocs("BLUE").get(0); + Vector redBlue = UtilAlg.getTrajectory(redKing, blueKing); + Vector blueRed = UtilAlg.getTrajectory(blueKing, redKing); + redKing.setPitch(UtilAlg.GetPitch(redBlue)); + redKing.setYaw(UtilAlg.GetYaw(redBlue)); + blueKing.setPitch(UtilAlg.GetPitch(blueRed)); + blueKing.setYaw(UtilAlg.GetYaw(blueRed)); + _crystals.put(red, Arrays.asList(new TeamCrystal(red, WorldData.GetDataLocs("PINK").get(0)), new TeamCrystal(red, WorldData.GetDataLocs("PINK").get(1)))); + _crystals.put(blue, Arrays.asList(new TeamCrystal(blue, WorldData.GetDataLocs("LIGHT_BLUE").get(0)), new TeamCrystal(blue, WorldData.GetDataLocs("LIGHT_BLUE").get(1)))); + this.CreatureAllowOverride = true; + _kings.put(red, new TeamKing(red, "King Jon", redKing)); + _kings.put(blue, new TeamKing(blue, "King Ryan", blueKing)); + int kitIndex = 0; + for (int i = 0; i < WorldData.GetDataLocs("WHITE").size(); i++) + { + if (kitIndex >= GetKits().length) + { + kitIndex = 0; + } + Entity ent = GetKits()[kitIndex].SpawnEntity(WorldData.GetDataLocs("WHITE").get(i)); + Manager.GetLobby().addKitLocation(ent, GetKits()[kitIndex], WorldData.GetDataLocs("WHITE").get(i)); + kitIndex++; + } + this.CreatureAllowOverride = false; + _tntSpawner = new ObjectiveTNTSpawner(WorldData.GetDataLocs("BLACK")); + } + @Override public void EndCheck() { if (!IsLive()) - return; - - if (this.WorldTimeSet > 24100 || GetTeam(ChatColor.RED).GetSize() == 0) { - SetCustomWinLine(_kingName + ChatColor.RESET + " has survived the siege!"); - - AnnounceEnd(GetTeam(ChatColor.AQUA)); - - for (GameTeam team : GetTeamList()) - { - if (WinnerTeam != null && team.equals(WinnerTeam)) - { - for (Player player : team.GetPlayers(false)) - { - AddGems(player, 10, "Winning Team", false, false); - } - } - - for (Player player : team.GetPlayers(false)) - if (player.isOnline()) - AddGems(player, 10, "Participation", false, false); - } - - SetState(GameState.End); + return; } - if (!_king.isValid() || GetTeam(ChatColor.AQUA).GetSize() == 0) + List teamsAlive = new ArrayList<>(); + + for (GameTeam team : GetTeamList()) { - if (_kingDamager != null) + if (team.GetPlayers(true).size() > 0) { - SetCustomWinLine(C.cRed + _kingDamager.getName() + C.cWhite + " slaughtered " + _kingName + ChatColor.RESET + "!"); - AddGems(_kingDamager, 20, "King Slayer", false, false); - - Bukkit.getPluginManager().callEvent(new KingSlaughterEvent(_kingDamager)); + teamsAlive.add(team); } - else - SetCustomWinLine(_kingName + ChatColor.RESET + " has died!"); + } - AnnounceEnd(GetTeam(ChatColor.RED)); - - for (GameTeam team : GetTeamList()) + if (teamsAlive.size() <= 1) + { + //Announce + if (teamsAlive.size() > 0) { - if (WinnerTeam != null && team.equals(WinnerTeam)) + GameTeam winner = teamsAlive.get(0); + TeamKing king = _kings.get(winner); + TeamKing dead = _kings.values().stream().filter(k -> k.getOwner().GetColor() != king.getOwner().GetColor()).findFirst().get(); + AnnounceEnd(winner); + writeFinalScoreboard(dead.getName(false), king.getName(false), dead.getOwner().GetColor() + "Quitters"); + for (GameTeam team : GetTeamList()) { - for (Player player : team.GetPlayers(false)) + for (Player player : team.GetPlayers(true)) { - AddGems(player, 10, "Winning Team", false, false); + if (team.GetColor() == winner.GetColor()) + { + AddGems(player, 100, "Winning Team", false, false); + } + else + { + AddGems(player, 50, "Losing Team", false, false); + } + if (player.isOnline()) + { + AddGems(player, 10, "Participation", false, false); + } + + { + int crowns = 0; + for (GemData data : GetGems(player).values()) + { + crowns += data.Gems; + } + int streak = _streakData.getOrDefault(player, new KillStreakData()).getBestStreak(); + if (streak >= 2 && streak < 4) + { + AddGems(player, 0.5 * crowns, streak + " Player Kill Streak", false, false); + } + else if (streak >= 4 && streak < 6) + { + AddGems(player, crowns, streak + " Player Kill Streak", false, false); + } + else if (streak >= 6 && streak < 8) + { + AddGems(player, 1.5 * crowns, streak + " Player Kill Streak", false, false); + } + else if (streak >= 8) + { + AddGems(player, 2 * crowns, streak + " Player Kill Streak", false, false); + } + } + + if (GetKit(player) != null) + { + KitPlayer kit = (KitPlayer) GetKit(player); + int kitLevel = kit.getUpgradeLevel(player.getUniqueId()); + if (kitLevel > 0) + { + int crowns = 0; + for (GemData data : GetGems(player).values()) + { + crowns += data.Gems; + } + + AddGems(player, (0.5 * kitLevel) * crowns, kit.GetName() + " Kit Level Bonus", false, false); + } + } } } - - for (Player player : team.GetPlayers(false)) - if (player.isOnline()) - AddGems(player, 10, "Participation", false, false); - } - - SetState(GameState.End); - } - } - - @EventHandler - public void TNTSpawn(UpdateEvent event) - { - if (GetState() != GameState.Live) - return; - - if (event.getType() != UpdateType.SEC) - return; - - if (!UtilTime.elapsed(this.GetStateTime(), 20000)) - return; - - if (!UtilTime.elapsed(_tntSpawn, 25000)) - return; - - if (_tntSpawns.isEmpty()) - return; - - Location loc = _tntSpawns.get(UtilMath.r(_tntSpawns.size())); - - if (loc.getBlock().getTypeId() == 46) - return; - - loc.getBlock().setTypeId(46); - _tntSpawn = System.currentTimeMillis(); - } - - @EventHandler(priority = EventPriority.LOW) - public void TNTPickup(PlayerInteractEvent event) - { - if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.LEFT_CLICK_BLOCK) - return; - - if (event.getClickedBlock().getTypeId() != 46) - return; - - event.setCancelled(true); - - Player player = event.getPlayer(); - - if (!IsAlive(player)) - return; - - if (!GetTeam(ChatColor.RED).HasPlayer(player)) - return; - - if (_tntCarry.containsKey(player)) - return; - - event.getClickedBlock().setTypeId(0); - - FallingBlock tnt = player.getWorld().spawnFallingBlock(player.getEyeLocation(), 46, (byte) 0); - - player.eject(); - player.setPassenger(tnt); - - _tntCarry.put(player, tnt); - - UtilPlayer.message(player, F.main("Game", "You picked up " + F.skill("TNT") + ".")); - UtilPlayer.message(player, F.main("Game", F.elem("Right-Click") + " to detonate yourself.")); - } - - @EventHandler(priority = EventPriority.NORMAL) - public void TNTUse(PlayerInteractEvent event) - { - if (event.isCancelled()) - return; - - if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.RIGHT_CLICK_AIR) - return; - - Player player = event.getPlayer(); - - if (!_tntCarry.containsKey(player)) - return; - - event.setCancelled(true); - - for (Location loc : _tntSpawns) - { - if (UtilMath.offset(player.getLocation(), loc) < 16) - { - UtilPlayer.message(player, F.main("Game", "You cannot " + F.skill("Detonate") + " so far from the Castle.")); + SetState(GameState.End); return; } } - - _tntCarry.remove(player).remove(); - - TNTPrimed tnt = player.getWorld().spawn(player.getEyeLocation(), TNTPrimed.class); - tnt.setFuseTicks(0); - UtilPlayer.message(player, F.main("Game", "You used " + F.skill("Detonate") + ".")); } - - @EventHandler(priority = EventPriority.LOWEST) - public void TNTDeath(PlayerDeathEvent event) + + @Override + @EventHandler + public void ScoreboardUpdate(UpdateEvent event) {}; + + @EventHandler + public void onUpdate(UpdateEvent event) { - Player player = event.getEntity(); - - if (!_tntCarry.containsKey(player)) - return; - - //Remove the TNT - _tntCarry.get(player).remove(); - - //Flag for Removal - _tntCarryEnd.add(player); - - - TNTPrimed tnt = player.getWorld().spawn(player.getEyeLocation(), TNTPrimed.class); - tnt.setFuseTicks(0); - UtilPlayer.message(player, F.main("Game", "You used " + F.skill("Detonate") + ".")); - } - - @EventHandler(priority = EventPriority.LOWEST) - public void TNTDamageDivert(ProjectileHitEvent event) - { - Iterator playerIterator = _tntCarry.keySet().iterator(); - - while (playerIterator.hasNext()) + if (event.getType() != UpdateType.FAST) { - Player player = playerIterator.next(); - - if (player.getPassenger() == null) - continue; - - double dist = UtilMath.offset(player.getPassenger().getLocation(), event.getEntity().getLocation().add(event.getEntity().getVelocity())); - - if (dist < 2) + return; + } + if (IsLive()) + { + if (UtilTime.elapsed(_lastRefill, TIME_TILL_REFILL)) { - int damage = (int) (5 * (event.getEntity().getVelocity().length() / 3d)); - - //Damage Event - Manager.GetDamage().NewDamageEvent(player, (LivingEntity)event.getEntity().getShooter(), event.getEntity(), - DamageCause.CUSTOM, damage, true, false, false, - null, GetName()); - - event.getEntity().remove(); + _lastRefill = System.currentTimeMillis(); + _chests.forEach(this::fillChest); + Bukkit.broadcastMessage(C.cGreenB + "Chests have refilled!"); } - - if (_tntCarryEnd.contains(player)) + + GameTeam red = GetTeam(ChatColor.RED); + GameTeam blue = GetTeam(ChatColor.AQUA); + TeamKing redKing = _kings.get(red); + TeamKing blueKing = _kings.get(blue); + redKing.update(_crystals.get(red).stream().filter(TeamCrystal::isActive).count() > 0); + if (redKing.isDead()) { - playerIterator.remove(); + AnnounceEnd(blue); + writeFinalScoreboard(redKing.getName(false), blueKing.getName(false), blue.GetColor() + redKing.getLastDamager()); + for (GameTeam team : GetTeamList()) + { + for (Player player : team.GetPlayers(true)) + { + if (player.getName().equals(redKing.getLastDamager())) + { + AddGems(player, 20, "King Slayer", false, false); + } + if (team.GetColor() == ChatColor.AQUA) + { + AddGems(player, 100, "Winning Team", false, false); + } + else + { + AddGems(player, 50, "Losing Team", false, false); + } + if (player.isOnline()) + { + AddGems(player, 10, "Participation", false, false); + } + + int streak = _streakData.getOrDefault(player, new KillStreakData()).getBestStreak(); + if (streak > 0) + { + AddGems(player, streak, streak + " Player Kill Streak", false, false); + } + + KitPlayer kit = (KitPlayer) GetKit(player); + int kitLevel = kit.getUpgradeLevel(player.getUniqueId()); + if (kitLevel > 0) + { + int crowns = 0; + for (GemData data : GetGems(player).values()) + { + crowns += data.Gems; + } + + AddGems(player, (0.5 * kitLevel) * crowns, kit.GetName() + " Kit Level Bonus", false, false); + } + } + } + SetState(GameState.End); + return; } + blueKing.update(_crystals.get(blue).stream().filter(TeamCrystal::isActive).count() > 0); + if (blueKing.isDead()) + { + AnnounceEnd(red); + writeFinalScoreboard(blueKing.getName(false), redKing.getName(false), red.GetColor() + blueKing.getLastDamager()); + for (GameTeam team : GetTeamList()) + { + for (Player player : team.GetPlayers(true)) + { + if (player.getName().equals(blueKing.getLastDamager())) + { + AddGems(player, 20, "King Slayer", false, false); + } + if (team.GetColor() == ChatColor.RED) + { + AddGems(player, 100, "Winning Team", false, false); + } + else + { + AddGems(player, 50, "Losing Team", false, false); + } + if (player.isOnline()) + { + AddGems(player, 10, "Participation", false, false); + } + + int streak = _streakData.getOrDefault(player, new KillStreakData()).getBestStreak(); + if (streak > 0) + { + AddGems(player, streak, streak + " Player Kill Streak", false, false); + } + + KitPlayer kit = (KitPlayer) GetKit(player); + int kitLevel = kit.getUpgradeLevel(player.getUniqueId()); + if (kitLevel > 0) + { + int crowns = 0; + for (GemData data : GetGems(player).values()) + { + crowns += data.Gems; + } + + AddGems(player, (0.5 * kitLevel) * crowns, kit.GetName() + " Kit Level Bonus", false, false); + } + } + } + SetState(GameState.End); + return; + } + + _tntSpawner.update(); + } + if (InProgress()) + { + writeScoreboard(); + } + } + + @EventHandler + public void onEditSettings(GameStateChangeEvent event) + { + if (event.GetGame() != this) + { + return; + } + + if (event.GetState() == GameState.Live) + { + _lastRefill = System.currentTimeMillis(); + _tntSpawner.onStart(); + Manager.GetDamage().SetEnabled(false); + Manager.GetExplosion().setEnabled(false); + Manager.GetCreature().SetDisableCustomDrops(true); + } + + if (event.GetState() == GameState.End) + { + Manager.GetDamage().SetEnabled(true); + Manager.GetExplosion().setEnabled(true); + Manager.GetCreature().SetDisableCustomDrops(false); + Managers.get(LeaderboardManager.class).unregisterLeaderboard("TOP_CASTLESIEGE_DAILY_WINS"); + Managers.get(LeaderboardManager.class).unregisterLeaderboard("TOP_CASTLESIEGE_DAILY_KILLS"); + Managers.get(LeaderboardManager.class).unregisterLeaderboard("TOP_CASTLESIEGE_WINS"); + Managers.get(LeaderboardManager.class).unregisterLeaderboard("TOP_CASTLESIEGE_KILLS"); + } + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void handleDeath(CombatDeathEvent event) + { + if (!IsLive()) + { + return; + } + + event.SetBroadcastType(DeathMessageType.Detailed); + } + + @EventHandler + public void disableDamageLevel(CustomDamageEvent event) + { + event.SetDamageToLevel(false); + } + + @EventHandler + public void BlockFade(BlockFadeEvent event) + { + event.setCancelled(true); + } + + @EventHandler + public void BlockBurn(BlockBurnEvent event) + { + event.setCancelled(true); + } + + @EventHandler + public void BlockDecay(LeavesDecayEvent event) + { + event.setCancelled(true); + } + + @EventHandler + public void hangingBreak(HangingBreakEvent event) + { + if (event.getEntity() instanceof ItemFrame || event.getEntity() instanceof Painting) + { + event.setCancelled(true); + } + } + + @EventHandler + public void noFlow(BlockFromToEvent event) + { + if (!IsLive()) + { + return; } - _tntCarryEnd.clear(); + Block block = event.getBlock(); + if (block.getType() == Material.WATER || block.getType() == Material.STATIONARY_WATER || block.getType() == Material.LAVA || block.getType() == Material.STATIONARY_LAVA) + { + event.setCancelled(true); + } + if (event.getToBlock().getType() == Material.ICE) + { + event.setCancelled(true); + } } + @EventHandler + public void onBlockChange(BlockFormEvent e) + { + if (!IsLive()) + { + return; + } + if (e.getNewState().getType() == Material.ICE) + { + e.setCancelled(true); + } + } + + @SuppressWarnings("deprecation") + @EventHandler(ignoreCancelled=true) + public void onPlayerEmptyBucket(PlayerBucketEmptyEvent event) + { + if (!IsLive()) + { + return; + } + + Player player = event.getPlayer(); + if (player.getItemInHand().getType() == Material.WATER_BUCKET) + { + player.getItemInHand().setType(Material.BUCKET); + Block block = event.getBlockClicked().getRelative(event.getBlockFace()); + if (block.getType().toString().contains("LAVA") || (block.getType().toString().contains("WATER") && block.getType() != Material.WATER_LILY)) + { + event.setCancelled(true); + player.sendBlockChange(block.getLocation(), block.getType(), block.getData()); + return; + } + for (BlockFace bf : BlockFace.values()) + { + Block relative = block.getRelative(bf); + if (relative.getType().toString().contains("LAVA") || (relative.getType().toString().contains("WATER") && relative.getType() != Material.WATER_LILY)) + { + event.setCancelled(true); + player.sendBlockChange(block.getLocation(), block.getType(), block.getData()); + } + } + } + else if (player.getItemInHand().getType() == Material.LAVA_BUCKET) + { + event.setCancelled(true); + Block block = event.getBlockClicked().getRelative(event.getBlockFace()); + player.sendBlockChange(block.getLocation(), block.getType(), block.getData()); + } + } + + @SuppressWarnings("deprecation") + @EventHandler(ignoreCancelled=true) + public void onPlayerEmptyBucket(PlayerBucketFillEvent event) + { + if (!IsLive()) + { + return; + } + + Player player = event.getPlayer(); + if (player.getItemInHand().getType() == Material.LAVA_BUCKET) + { + event.setCancelled(true); + Block block = event.getBlockClicked().getRelative(event.getBlockFace()); + player.sendBlockChange(block.getLocation(), block.getType(), block.getData()); + } + } + @EventHandler(ignoreCancelled=true) + public void onBlockDispense(BlockDispenseEvent event) + { + if (!IsLive()) + { + return; + } + + if (event.getItem().getType() == Material.WATER_BUCKET) + { + Block dispenser = event.getBlock(); + + MaterialData mat = dispenser.getState().getData(); + Dispenser disp_mat = (Dispenser)mat; + BlockFace face = disp_mat.getFacing(); + Block block = dispenser.getRelative(face); + if (block.getType().toString().contains("LAVA") || (block.getType().toString().contains("WATER") && block.getType() != Material.WATER_LILY)) + { + event.setCancelled(true); + return; + } + for (BlockFace bf : BlockFace.values()) + { + if (block.getRelative(bf).getType().toString().contains("LAVA") || (block.getRelative(bf).getType().toString().contains("WATER") && block.getRelative(bf).getType() != Material.WATER_LILY)) + { + event.setCancelled(true); + } + } + } + } + + @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) + public void onCombatDeath(CombatDeathEvent event) + { + if (!IsLive()) + { + return; + } + + if (event.GetLog().GetKiller() == null) + { + return; + } + + if (!event.GetLog().GetKiller().IsPlayer()) + { + return; + } + + Player player = UtilPlayer.searchExact(event.GetLog().GetKiller().GetName()); + if (player == null) + { + return; + } + + AddStat(player, GetKit(player).GetName() + "KitKills", 1, false, false); + + if (UtilPlayer.isSpectator(player)) + { + return; + } + + player.setLevel(player.getLevel() + 1); + player.getInventory().addItem(new ItemBuilder(Material.GOLDEN_APPLE).setTitle(C.cPurple + "Golden Applegate").build()); + KillStreakData data = _streakData.computeIfAbsent(player, (key) -> new KillStreakData()); + boolean hardLine = GetKit(player).GetName().equals("Hardline"); + if (data.addKill(hardLine)) + { + AddStat(player, "KillStreak", 1, false, false); + ((KitPlayer)GetKit(player)).awardKillStreak(player, hardLine ? (data.getKills() + 1) : data.getKills()); + } + if (UtilMath.isEven(data.getKills())) + { + Bukkit.broadcastMessage(F.main("Game", C.cGreen + C.Bold + player.getName() + ChatColor.RESET + " is on a " + F.elem(C.cDPurple + data.getKills() + " player Kill Streak") + "!")); + } + } + + @EventHandler + public void TNTExplosion(ExplosionPrimeEvent event) + { + if (!event.getEntity().hasMetadata("THROWER")) + { + return; + } + float radius = event.getRadius(); + event.setRadius(0f); + + Player player = UtilPlayer.searchExact(((MetadataValue)UtilEnt.GetMetadata(event.getEntity(), "THROWER")).asString()); + if (player == null) + { + return; + } + if (GetTeam(player) == null) + { + return; + } + if (GetKit(player).GetName().equals("Demolitionist")) + { + radius += 3; + } + + Map nearby = UtilPlayer.getInRadius(event.getEntity().getLocation(), radius); + for (Player near : nearby.keySet()) + { + if (UtilPlayer.isSpectator(near)) + { + continue; + } + if (near.getEntityId() != player.getEntityId() && GetTeam(near).GetColor() == GetTeam(player).GetColor()) + { + continue; + } + if (near.getEntityId() == player.getEntityId() && event.getEntity().hasMetadata("OBJECTIVE_TNT")) + { + continue; + } + + double mult = nearby.get(near); + + int highestBlastProt = 0; + int blastProtEPF = 0; + for (ItemStack item : near.getInventory().getArmorContents()) + { + if (item != null && item.getEnchantments().containsKey(Enchantment.PROTECTION_EXPLOSIONS)) + { + blastProtEPF += (2 * item.getEnchantmentLevel(Enchantment.PROTECTION_EXPLOSIONS)); + if (item.getEnchantmentLevel(Enchantment.PROTECTION_EXPLOSIONS) > highestBlastProt) + { + highestBlastProt = item.getEnchantmentLevel(Enchantment.PROTECTION_EXPLOSIONS); + } + } + } + blastProtEPF = Math.min(blastProtEPF, 20); + + double damage = 8 * mult; + damage = damage * (1 - (blastProtEPF / 25)); + + double knockbackReduction = 1 - (highestBlastProt * 0.15); + + near.damage(damage, event.getEntity()); + UtilAction.velocity(near, UtilAlg.getTrajectory(event.getEntity().getLocation(), near.getLocation()), 1 * mult * knockbackReduction, false, 0, mult * knockbackReduction, 10, true); + } + + if (event.getEntity().hasMetadata("OBJECTIVE_TNT")) + { + List crystals = new ArrayList<>(); + + for (List c : _crystals.values()) + { + crystals.addAll(c); + } + for (TeamCrystal crystal : crystals) + { + if (crystal.isActive() && !crystal.getOwner().HasPlayer(player) && UtilMath.offset(event.getEntity().getLocation(), crystal.getLocation()) <= radius) + { + crystal.destroy(); + AddGems(player, 40, "Crystal Destruction", false, true); + long remaining = crystals.stream().filter(b -> b.getOwner().GetColor() == crystal.getOwner().GetColor()).filter(TeamCrystal::isActive).count(); + if (remaining > 0) + { + Bukkit.broadcastMessage(F.main("Game", "One of " + F.elem(crystal.getOwner().GetFormattedName() + "'s Crystals") + " has been destroyed!")); + } + else + { + Bukkit.broadcastMessage(F.main("Game", "All of " + F.elem(crystal.getOwner().GetFormattedName() + "'s Crystals") + " has been destroyed and " + F.elem(_kings.get(crystal.getOwner()).getName(false)) + " is now vulnerable!")); + } + } + } + for (TeamKing king : _kings.values()) + { + if (king.isDead() && !king.getOwner().HasPlayer(player) && UtilMath.offset(event.getEntity().getLocation(), king.getLocation()) <= radius) + { + king.handleDamage(player.getName(), 50); + } + } + } + } + + @EventHandler + public void TNTThrow(PlayerInteractEvent event) + { + if (!IsLive()) + { + return; + } + + if (!UtilEvent.isAction(event, ActionType.L)) + { + return; + } + + Player player = event.getPlayer(); + + if (!UtilInv.IsItem(player.getItemInHand(), Material.TNT, (byte) 0)) + { + return; + } + + if (!IsAlive(player)) + { + return; + } + + event.setCancelled(true); + + if (!Manager.GetGame().CanThrowTNT(player.getLocation())) + { + // Inform + UtilPlayer.message(event.getPlayer(), F.main(GetName(), "You cannot use " + F.item("Throwing TNT") + " here.")); + return; + } + + UtilInv.remove(player, Material.TNT, (byte) 0, 1); + UtilInv.Update(player); + + TNTPrimed tnt = player.getWorld().spawn(player.getEyeLocation().add(player.getLocation().getDirection()), TNTPrimed.class); + + tnt.setFuseTicks(60); + + double throwMult = 1; + + if (GetKit(player).GetName().equals("Demolitionist")) + { + throwMult = ((KitDemolitionist)GetKit(player)).getThrowMultiplier(player); + } + + UtilAction.velocity(tnt, player.getLocation().getDirection(), 0.5 * throwMult, false, 0, 0.1, 10, false); + + UtilEnt.SetMetadata(tnt, "THROWER", player.getName()); + } + + @EventHandler + public void onLaunch(ProjectileHitEvent event) + { + if (!IsLive()) + { + return; + } + + if (event.getEntity() instanceof EnderPearl && event.getEntity().getShooter() != null && event.getEntity().getShooter() instanceof Entity) + { + Entity shooter = (Entity) event.getEntity().getShooter(); + if (_tntCarry.contains(shooter)) + { + return; + } + Location teleport = event.getEntity().getLocation(); + teleport.setPitch(shooter.getLocation().getPitch()); + teleport.setYaw(shooter.getLocation().getYaw()); + shooter.teleport(teleport); + } + if (event.getEntity() instanceof Arrow) + { + Manager.runSyncLater(event.getEntity()::remove, 1L); + } + } + + @EventHandler + public void onOpenChest(PlayerInteractEvent event) + { + if (!IsLive()) + { + return; + } + + if (event.getClickedBlock() != null && event.getClickedBlock().getType() == Material.CHEST) + { + if (UtilPlayer.isSpectator(event.getPlayer())) + { + event.setCancelled(true); + } + } + } + + @EventHandler(ignoreCancelled = true) + public void onDamage(EntityDamageEvent event) + { + if (!IsLive()) + { + return; + } + if (event.getEntity() instanceof EnderCrystal) + { + event.setCancelled(true); + return; + } + if (event.getEntity() instanceof Zombie) + { + event.setCancelled(true); + if (event instanceof EntityDamageByEntityEvent) + { + GameTeam owner = event.getEntity().getCustomName().contains("Ryan") ? GetTeam(ChatColor.AQUA) : GetTeam(ChatColor.RED); + EntityDamageByEntityEvent e = (EntityDamageByEntityEvent) event; + if (e.getDamager() instanceof Player) + { + Player p = (Player) e.getDamager(); + if (UtilPlayer.isSpectator(p)) + { + return; + } + if (owner.HasPlayer(p)) + { + return; + } + if (_crystals.get(owner).stream().filter(TeamCrystal::isActive).count() > 0) + { + UtilPlayer.message(p, F.main("Game", "You cannot attack the enemy king until your team has destroyed his protective crystals!")); + return; + } + TeamKing king = _kings.get(owner); + if (king.handleDamage(p.getName(), e.getDamage())) + { + for (Player alert : owner.GetPlayers(true)) + { + if (Recharge.Instance.use(alert, "KingDamageAlert", 5000, false, false)) + { + alert.sendMessage(king.getName(true) + " is under attack!"); + } + } + } + } + } + } + } + + @EventHandler + public void onDrop(PlayerDropItemEvent event) + { + if (!IsLive()) + { + return; + } + + ItemStack drop = event.getItemDrop().getItemStack(); + if (drop.hasItemMeta() && drop.getItemMeta().hasLore() && drop.getItemMeta().getLore().stream().map(ChatColor::stripColor).anyMatch(lore -> lore.equals("Kit Item"))) + { + event.setCancelled(true); + return; + } + + event.getItemDrop().remove(); + } + + @EventHandler + public void craftItem(PrepareItemCraftEvent event) + { + if (!IsLive()) + { + return; + } + + if (event.getInventory().getResult().getType() == Material.FLINT_AND_STEEL) + { + event.getInventory().setResult(_flintAndSteel.build()); + } + } + + @EventHandler + public void onInvClick(InventoryClickEvent event) + { + if (!IsLive()) + { + return; + } + ItemStack current = event.getCurrentItem(); + if (event.getAction() == InventoryAction.HOTBAR_SWAP || event.getAction() == InventoryAction.HOTBAR_MOVE_AND_READD) + { + current = event.getWhoClicked().getInventory().getItem(event.getHotbarButton()); + } + if (current == null || !current.hasItemMeta()) + { + return; + } + if (current.getItemMeta().hasDisplayName() && current.getItemMeta().getDisplayName().equals(C.cRed + "TNT")) + { + event.setCancelled(true); + return; + } + if (event.getView().getTopInventory() != null && event.getView().getTopInventory().getType() == InventoryType.CHEST) + { + if (current.getItemMeta().hasLore()) + { + for (String lore : current.getItemMeta().getLore()) + { + if (ChatColor.stripColor(lore).equalsIgnoreCase("Kit Item")) + { + event.setCancelled(true); + break; + } + } + } + + } + } + + @EventHandler + public void onFirstBlood(FirstBloodEvent event) + { + if (!IsLive()) + { + return; + } + + AddStat(event.getPlayer(), "FirstBlood", 1, true, false); + } + + @EventHandler + public void onPearl(PlayerInteractEvent event) + { + if (!IsLive()) + { + return; + } + + if (!UtilEvent.isAction(event, ActionType.R)) + { + return; + } + + if (event.getItem() != null && event.getItem().getType() == Material.ENDER_PEARL) + { + Player player = (Player) event.getPlayer(); + if (!Recharge.Instance.use(player, "Enderpearl", 4000, true, true)) + { + event.setCancelled(true); + player.updateInventory(); + } + } + } + + @EventHandler + public void onItemDespawn(ItemDespawnEvent event) + { + if (!IsLive()) + { + return; + } + + if (_tntSpawner.isSpawned()) + { + if (_tntSpawner.getItem().getEntityId() == event.getEntity().getEntityId()) + { + event.setCancelled(true); + } + } + } + + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onPickup(PlayerPickupItemEvent event) + { + if (!IsLive()) + { + return; + } + + if (_tntSpawner.isSpawned() && event.getItem().getEntityId() == _tntSpawner.getItem().getEntityId()) + { + event.setCancelled(true); + if (!_tntCarry.contains(event.getPlayer())) + { + _tntSpawner.pickup(); + _tntCarry.add(event.getPlayer()); + event.getPlayer().setMetadata("OLD_HELM", new FixedMetadataValue(UtilServer.getPlugin(), event.getPlayer().getInventory().getHelmet())); + event.getPlayer().setMetadata("TNT_START", new FixedMetadataValue(UtilServer.getPlugin(), System.currentTimeMillis())); + event.getPlayer().getInventory().setHelmet(_wearableTnt.build()); + UtilPlayer.message(event.getPlayer(), F.main("Game", "You picked up " + F.skill("TNT") + ".")); + UtilPlayer.message(event.getPlayer(), F.main("Game", F.elem("Right-Click") + " to detonate yourself.")); + UtilPlayer.message(event.getPlayer(), F.main("Game", "Run to the enemy Crystal and Detonate to destroy it.")); + } + } + } + + @EventHandler(ignoreCancelled = true) + public void TNTUse(PlayerInteractEvent event) + { + Player player = event.getPlayer(); + + if (!_tntCarry.contains(player)) + { + return; + } + + if (!UtilEvent.isAction(event, ActionType.R)) + { + return; + } + + event.setCancelled(true); + + player.getInventory().setHelmet((ItemStack) player.getMetadata("OLD_HELM").get(0).value()); + player.removeMetadata("OLD_HELM", UtilServer.getPlugin()); + player.removeMetadata("TNT_START", UtilServer.getPlugin()); + _tntCarry.remove(player); + + TNTPrimed tnt = player.getWorld().spawn(player.getEyeLocation(), TNTPrimed.class); + UtilEnt.SetMetadata(tnt, "THROWER", player.getName()); + UtilEnt.SetMetadata(tnt, "OBJECTIVE_TNT", true); + tnt.setFuseTicks(0); + UtilPlayer.message(player, F.main("Game", "You used " + F.skill("Detonate") + ".")); + } + @EventHandler public void TNTExpire(UpdateEvent event) { - if (event.getType() != UpdateType.FASTER) + if (!IsLive()) + { return; + } + + if (event.getType() != UpdateType.FASTER) + { + return; + } - Iterator tntIterator = _tntCarry.keySet().iterator(); + Iterator tntIterator = _tntCarry.iterator(); while (tntIterator.hasNext()) { Player player = tntIterator.next(); - FallingBlock block = _tntCarry.get(player); - - if (player.isDead() || !block.isValid() || block.getTicksLived() > 1500) + + if (player.isDead() || UtilTime.elapsed(player.getMetadata("TNT_START").get(0).asLong(), 60000)) { - player.eject(); - block.remove(); - TNTPrimed tnt = player.getWorld().spawn(player.getEyeLocation(), TNTPrimed.class); + UtilEnt.SetMetadata(tnt, "THROWER", player.getName()); + UtilEnt.SetMetadata(tnt, "OBJECTIVE_TNT", true); tnt.setFuseTicks(0); - + + if (!player.isDead()) + { + player.getInventory().setHelmet((ItemStack) player.getMetadata("OLD_HELM").get(0).value()); + } + player.removeMetadata("OLD_HELM", UtilServer.getPlugin()); + player.removeMetadata("TNT_START", UtilServer.getPlugin()); + tntIterator.remove(); continue; } - - //Firework + + List crystals = new ArrayList<>(); + + for (List c : _crystals.values()) + { + crystals.addAll(c); + } + for (TeamCrystal crystal : crystals) + { + if (crystal.isActive() && !crystal.getOwner().HasPlayer(player) && UtilMath.offset(player.getLocation(), crystal.getLocation()) <= 3) + { + TNTPrimed tnt = player.getWorld().spawn(player.getEyeLocation(), TNTPrimed.class); + UtilEnt.SetMetadata(tnt, "THROWER", player.getName()); + UtilEnt.SetMetadata(tnt, "OBJECTIVE_TNT", true); + tnt.setFuseTicks(0); + + if (!player.isDead()) + { + player.getInventory().setHelmet((ItemStack) player.getMetadata("OLD_HELM").get(0).value()); + } + player.removeMetadata("OLD_HELM", UtilServer.getPlugin()); + player.removeMetadata("TNT_START", UtilServer.getPlugin()); + + tntIterator.remove(); + } + } + + UtilTextBottom.display(GetTeam(player).GetColor() + player.getName() + " has the TNT!", UtilServer.getPlayers()); UtilFirework.playFirework(player.getEyeLocation(), Type.BURST, Color.RED, false, false); } } - - @EventHandler - public void TNTWeakness(ExplosionPrimeEvent event) - { - Location weakness = null; - for (Location loc : _tntWeakness) - { - if (UtilMath.offset(loc, event.getEntity().getLocation()) < 4) - { - weakness = loc; - break; - } - } - - if (weakness == null) - return; - - _tntWeakness.remove(weakness); - - final Location extra = weakness; - - for (int i = 0; i < 10; i++) - { - Manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable() - { - public void run() - { - TNTPrimed tnt = extra.getWorld().spawn(extra.clone().add(3 - UtilMath.r(6), 5 + UtilMath.r(2), 3 - UtilMath.r(6)), TNTPrimed.class); - tnt.setFuseTicks(0); - tnt.setIsIncendiary(true); - } - }, i * 3); - } - - weakness.getWorld().playSound(weakness, Sound.EXPLODE, 16f, 0.8f); - } - - @EventHandler(priority = EventPriority.HIGH) - public void AttackerBlockBreak(org.bukkit.event.block.BlockBreakEvent event) - { - GameTeam team = GetTeam(event.getPlayer()); - if (team == null) - return; - - if (team.GetColor() != ChatColor.RED) - return; - - if (event.getBlock().getTypeId() == 85) - event.setCancelled(false); - } - - @EventHandler - public void DefenderBlockPlace(org.bukkit.event.block.BlockPlaceEvent event) - { - GameTeam team = GetTeam(event.getPlayer()); - if (team == null) - return; - - if (team.GetColor() != ChatColor.AQUA) - return; - - if (event.getBlock().getTypeId() != 85) - return; - - for (Block block : UtilBlock.getSurrounding(event.getBlock(), false)) - { - if (block.isLiquid()) - { - event.setCancelled(true); - UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot place " + F.elem("Barricade") + " in water.")); - } - } - - if (event.getBlockAgainst().getTypeId() == 85) - { - event.setCancelled(true); - UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot place " + F.elem("Barricade") + " on each other.")); - } - - if (_king != null && UtilMath.offset(_king.getLocation(), event.getBlock().getLocation().add(0.5, 0.5, 0.5)) < 4) - { - event.setCancelled(true); - UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot place " + F.elem("Barricade") + " near " + F.elem(C.cAqua + _kingName) + ".")); - } - } @EventHandler - public void DefenderBlockInteract(PlayerInteractEvent event) + public void onDeath(PlayerDeathEvent event) { - if (!UtilEvent.isAction(event, ActionType.R_BLOCK)) - return; + Player player = event.getEntity(); - GameTeam team = GetTeam(event.getPlayer()); - if (team == null) + _streakData.getOrDefault(player, new KillStreakData()).reset(); + + if (!_tntCarry.contains(player)) + { return; + } + + player.removeMetadata("OLD_HELM", UtilServer.getPlugin()); + player.removeMetadata("TNT_START", UtilServer.getPlugin()); + _tntCarry.remove(player); + TNTPrimed tnt = player.getWorld().spawn(player.getEyeLocation(), TNTPrimed.class); + UtilEnt.SetMetadata(tnt, "THROWER", player.getName()); + UtilEnt.SetMetadata(tnt, "OBJECTIVE_TNT", true); + tnt.setFuseTicks(0); + UtilPlayer.message(player, F.main("Game", "You used " + F.skill("Detonate") + ".")); + } - if (team.GetColor() != ChatColor.AQUA) - return; - - if (event.getClickedBlock() == null || event.getClickedBlock().getTypeId() != 85) - return; - - UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, event.getClickedBlock().getLocation().add(0.5, 0.5, 0.5), 0, 0, 0, 0, 1, - ViewDist.LONG, UtilServer.getPlayers()); - event.getClickedBlock().getWorld().playSound(event.getClickedBlock().getLocation(), Sound.NOTE_STICKS, 2f, 1f); - Manager.GetBlockRestore().add(event.getClickedBlock(), 0, (byte) 0, 1000); - } - @EventHandler - public void DayTimer(UpdateEvent event) + public void onBlockPlace(BlockPlaceEvent event) { - if (GetState() != GameState.Live) - return; - - if (event.getType() != UpdateType.TICK) - return; - - WorldTimeSet = (WorldTimeSet + 1); + if (_tntSpawner.canPlaceFireAt(event.getBlock())) + { + event.setCancelled(true); + } } - - @EventHandler - public void SnowDamage(UpdateEvent event) - { - if (GetState() != GameState.Live) - return; - - if (event.getType() != UpdateType.FAST) - return; - - for (Player player : GetPlayers(true)) - if (player.getLocation().getBlock().getTypeId() == 78) - { - //Damage Event - Manager.GetDamage().NewDamageEvent(player, null, null, - DamageCause.DROWNING, 2, false, true, false, - "Snow", "Snow Damage"); - - player.getWorld().playEffect(player.getLocation(), Effect.STEP_SOUND, 80); - } - } -} +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiegeClassic.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiegeClassic.java new file mode 100644 index 000000000..76e0d0f7c --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiegeClassic.java @@ -0,0 +1,973 @@ +package nautilus.game.arcade.game.games.castlesiege; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Color; +import org.bukkit.Effect; +import org.bukkit.EntityEffect; +import org.bukkit.FireworkEffect.Type; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.Sound; +import org.bukkit.block.Block; +import org.bukkit.entity.Creature; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.FallingBlock; +import org.bukkit.entity.Horse; +import org.bukkit.entity.Horse.Style; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.TNTPrimed; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.HandlerList; +import org.bukkit.event.block.Action; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.EntityTargetEvent; +import org.bukkit.event.entity.ExplosionPrimeEvent; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.entity.ProjectileHitEvent; +import org.bukkit.event.player.PlayerEvent; +import org.bukkit.event.player.PlayerInteractEntityEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilBlock; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilFirework; +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.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTime; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; + +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.GameType; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.events.PlayerGameRespawnEvent; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.TeamGame; +import nautilus.game.arcade.game.games.castlesiege.classickits.KitHumanKnight; +import nautilus.game.arcade.game.games.castlesiege.classickits.KitHumanMarksman; +import nautilus.game.arcade.game.games.castlesiege.classickits.KitHumanPeasant; +import nautilus.game.arcade.game.games.castlesiege.classickits.KitUndeadArcher; +import nautilus.game.arcade.game.games.castlesiege.classickits.KitUndeadGhoul; +import nautilus.game.arcade.game.games.castlesiege.classickits.KitUndeadZombie; +import nautilus.game.arcade.game.modules.compass.CompassModule; +import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.kit.NullKit; +import nautilus.game.arcade.stats.BloodThirstyStatTracker; +import nautilus.game.arcade.stats.KingDamageStatTracker; +import nautilus.game.arcade.stats.KingSlayerStatTracker; +import nautilus.game.arcade.stats.TeamDeathsStatTracker; +import nautilus.game.arcade.stats.TeamKillsStatTracker; +import nautilus.game.arcade.stats.WinAsTeamStatTracker; + +public class CastleSiegeClassic extends TeamGame +{ + public static class KingDamageEvent extends PlayerEvent + { + private static final HandlerList handlers = new HandlerList(); + + public static HandlerList getHandlerList() + { + return handlers; + } + + @Override + public HandlerList getHandlers() + { + return getHandlerList(); + } + + private final double _damage; + + public KingDamageEvent(Player who, double damage) + { + super(who); + + _damage = damage; + } + + public double getDamage() + { + return _damage; + } + } + + public static class KingSlaughterEvent extends PlayerEvent + { + private static final HandlerList handlers = new HandlerList(); + + public static HandlerList getHandlerList() + { + return handlers; + } + + @Override + public HandlerList getHandlers() + { + return getHandlerList(); + } + + public KingSlaughterEvent(Player who) + { + super(who); + } + } + + private ArrayList _lastScoreboard = new ArrayList(); + + private long _tntSpawn = 0; + private ArrayList _tntSpawns = new ArrayList(); + private ArrayList _tntWeakness = new ArrayList(); + + private HashMap _tntCarry = new HashMap(); + private HashSet _tntCarryEnd = new HashSet(); + + private ArrayList _kingLocs; + private Creature _king; + private Location _kingLoc; + private String _kingName; + private Player _kingDamager = null; + private int _kingHealth = 40; + + private ArrayList _peasantSpawns; + private ArrayList _horseSpawns; + + public CastleSiegeClassic(ArcadeManager manager) + { + super(manager, GameType.CastleSiege, + + new Kit[] + { + new KitHumanMarksman(manager), + new KitHumanKnight(manager), + //new KitHumanBrawler(manager), + //new KitHumanAssassin(manager), + new NullKit(manager), + new KitHumanPeasant(manager), + new NullKit(manager), + new KitUndeadGhoul(manager), + new KitUndeadArcher(manager), + new KitUndeadZombie(manager), + }, + + new String[] + { + F.elem(C.cAqua + "Defenders") + C.cWhite + " must defend the King.", + F.elem(C.cAqua + "Defenders") + C.cWhite + " win when the sun rises.", + F.elem(C.cAqua + "Defenders") + C.cWhite + " respawn as wolves.", + "", + F.elem(C.cRed + "Undead") + C.cWhite + " must kill the King.", + F.elem(C.cRed + "Undead") + C.cWhite + " lose when the sun rises.", + + }); + + _help = new String[] + { + "Marksmen are extremely important to defence!", + "It's recommended 50%+ of defence are Marksmen.", + "Use Barricades to block the Undeads path.", + "Use TNT to destroy weak points in walls.", + "Weak points are marked by cracked stone brick.", + "Undead can break fences with their axes.", + "Undead Archers must pick up arrows from the ground.", + + }; + + this.StrictAntiHack = true; + + this.HungerSet = 20; + this.DeathOut = false; + this.WorldTimeSet = 14000; //14000 + this.BlockPlaceAllow.add(85); + + _kingName = C.cYellow + C.Bold + "King Sparklez"; + + GameTeam notRedTeam = null; + for (GameTeam team : GetTeamList()) + { + if (team.GetColor() != ChatColor.RED) + { + notRedTeam = team; + break; + } + } + + registerStatTrackers( + new KingSlayerStatTracker(this), + new BloodThirstyStatTracker(this), + new KingDamageStatTracker(this), + + new TeamDeathsStatTracker(this), + new TeamKillsStatTracker(this) + ); + + registerChatStats( + Kills, + Deaths, + KDRatio, + BlankLine, + Assists, + DamageDealt, + DamageTaken + ); + + registerChatStats(); + + new CompassModule() + .setGiveCompass(true) + .setGiveCompassToSpecs(true) + .setGiveCompassToAlive(false) + .register(this); + } + + @Override + public void ParseData() + { + _tntSpawns = WorldData.GetDataLocs("RED"); + _tntWeakness = WorldData.GetDataLocs("BLACK"); + + _kingLocs = WorldData.GetDataLocs("YELLOW"); + + _peasantSpawns = WorldData.GetDataLocs("GREEN"); + _horseSpawns = WorldData.GetDataLocs("BROWN"); + } + + @Override + public void RestrictKits() + { + for (Kit kit : GetKits()) + { + for (GameTeam team : GetTeamList()) + { + if (team.GetColor() == ChatColor.RED) + { + if (kit.GetName().contains("Castle")) + team.GetRestrictedKits().add(kit); + + team.SetName("Undead"); + } + else + { + if (kit.GetName().contains("Undead")) + team.GetRestrictedKits().add(kit); + + team.SetRespawnTime(8); + + team.SetName("Defenders"); + } + } + } + } + + @EventHandler(priority = EventPriority.HIGH) + public void registerTeamTracker(GameStateChangeEvent event) + { + if (event.GetState() == GameState.Recruit) + { + GameTeam notRed = null; + + for (GameTeam team : GetTeamList()) + { + if (team.GetColor() == ChatColor.RED) + continue; + + notRed = team; + break; + } + + if (notRed != null) + { + registerStatTrackers(new WinAsTeamStatTracker(this, notRed, "ForTheKing")); + System.out.println("Successfully registered For the King StatTrak"); + } + } + } + + @EventHandler + public void MoveKits(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Prepare) + return; + + for (int i = 0; i < WorldData.GetDataLocs("PINK").size() && i < 3; i++) + { + if (GetKits().length <= 5 + i) + continue; + + this.CreatureAllowOverride = true; + Entity ent = GetKits()[5 + i].SpawnEntity(WorldData.GetDataLocs("PINK").get(i)); + this.CreatureAllowOverride = false; + + Manager.GetLobby().addKitLocation(ent, GetKits()[5 + i], WorldData.GetDataLocs("PINK").get(i)); + } + } + + @EventHandler + public void HorseSpawn(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Prepare) + return; + + for (Location loc : _horseSpawns) + { + this.CreatureAllowOverride = true; + Horse horse = loc.getWorld().spawn(loc, Horse.class); + this.CreatureAllowOverride = false; + + horse.setAdult(); + horse.setAgeLock(true); + horse.setColor(org.bukkit.entity.Horse.Color.BLACK); + horse.setStyle(Style.BLACK_DOTS); + horse.setMaxDomestication(1); + horse.getInventory().setSaddle(new ItemStack(Material.SADDLE)); + horse.getInventory().setArmor(new ItemStack(Material.IRON_BARDING)); + + horse.setMaxHealth(60); + horse.setHealth(horse.getMaxHealth()); + + horse.setCustomName("War Horse"); + } + } + + @EventHandler + public void HorseInteract(PlayerInteractEntityEvent event) + { + if (!(event.getRightClicked() instanceof Horse)) + return; + + Player player = event.getPlayer(); + GameTeam team = GetTeam(player); + + if (team == null || team.GetColor() == ChatColor.RED || !IsAlive(player)) + { + event.setCancelled(true); + } + } + + @EventHandler + public void HorseDamageCancel(CustomDamageEvent event) + { + if (!(event.GetDamageeEntity() instanceof Horse)) + return; + + Player player = event.GetDamagerPlayer(true); + if (player == null) + return; + + if (!IsAlive(player)) + return; + + if (GetTeam(player) == null) + return; + + if (GetTeam(player).GetColor() == ChatColor.RED) + return; + + event.SetCancelled("Horse Team Damage"); + } + + @EventHandler(priority = EventPriority.HIGH) + public void GameStateChange(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Prepare) + return; + + //Spawn King + this.CreatureAllowOverride = true; + + _kingLoc = _kingLocs.get(UtilMath.r(_kingLocs.size())); + + _king = (Creature) _kingLoc.getWorld().spawnEntity(_kingLoc, EntityType.ZOMBIE); + + _king.getEquipment().setHelmet(new ItemStack(Material.DIAMOND_HELMET)); + _king.getEquipment().setChestplate(new ItemStack(Material.DIAMOND_CHESTPLATE)); + _king.getEquipment().setLeggings(new ItemStack(Material.DIAMOND_LEGGINGS)); + _king.getEquipment().setBoots(new ItemStack(Material.DIAMOND_BOOTS)); + _king.getEquipment().setItemInHand(new ItemStack(Material.DIAMOND_SWORD)); + + _king.setCustomName(_kingName); + _king.setCustomNameVisible(true); + + _king.setRemoveWhenFarAway(false); + + this.CreatureAllowOverride = false; + } + + @EventHandler(priority = EventPriority.HIGH) + public void SetDefenderRespawn(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Live) + return; + + //Change to Peasant Spawns + this.GetTeam(ChatColor.AQUA).SetSpawns(_peasantSpawns); + } + + + @EventHandler + public void KingTarget(EntityTargetEvent event) + { + event.setCancelled(true); + } + + @EventHandler + public void KingDamage(CustomDamageEvent event) + { + if (_king == null || !_king.isValid()) + return; + + if (!event.GetDamageeEntity().equals(_king)) + return; + + event.SetCancelled("King Damage"); + + Player damager = event.GetDamagerPlayer(true); + if (damager == null) return; + + GameTeam team = GetTeam(damager); + + if (team != null && team.GetColor() == ChatColor.RED) + { + if (!Recharge.Instance.use(damager, "Damage King", 400, false, false)) + return; + + if (!IsAlive(damager)) + { + return; + } + + _king.playEffect(EntityEffect.HURT); + + _kingDamager = damager; + _kingHealth--; + + Bukkit.getPluginManager().callEvent(new KingDamageEvent(damager, 1)); + + if (_kingHealth < 0) + _kingHealth = 0; + + WriteScoreboard(); + + if (_kingHealth <= 0) + _king.damage(500); + + EndCheck(); + } + } + + @EventHandler + public void KingUpdate(UpdateEvent event) + { + if (GetState() != GameState.Live) + return; + + if (event.getType() != UpdateType.SEC) + return; + + if (_king == null) + return; + + if (UtilMath.offset(_king.getLocation(), _kingLoc) > 6) + { + _king.teleport(_kingLoc); + } + else + { + UtilEnt.CreatureMove(_king, _kingLoc, 1f); + } + } + + @EventHandler + public void PlayerDeath(PlayerGameRespawnEvent event) + { + if (GetTeam(ChatColor.AQUA).HasPlayer(event.GetPlayer())) + SetKit(event.GetPlayer(), GetKits()[3], true); + } + + @Override + @EventHandler + public void ScoreboardUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + return; + + WriteScoreboard(); + } + + public void WriteScoreboard() + { + //Get Values + HashMap _scoreGroup = new HashMap(); + _scoreGroup.put(C.cAqua + "Defenders", 0); + _scoreGroup.put(C.cDAqua + "Wolves", 0); + _scoreGroup.put(C.cRed + "Undead", 0); + + for (Player player : UtilServer.getPlayers()) + { + if (!IsAlive(player)) + continue; + + Kit kit = GetKit(player); + if (kit == null) continue; + + if (kit.GetName().contains("Castle")) + { + if (kit.GetName().contains("Wolf")) + { + _scoreGroup.put(C.cDAqua + "Wolves", 1 + _scoreGroup.get(C.cDAqua + "Wolves")); + } + else + { + _scoreGroup.put(C.cAqua + "Defenders", 1 + _scoreGroup.get(C.cAqua + "Defenders")); + } + } + else if (kit.GetName().contains("Undead")) + { + _scoreGroup.put(C.cRed + "Undead", 1 + _scoreGroup.get(C.cRed + "Undead")); + } + } + + //Wipe Last + Scoreboard.reset(); + + //Teams + for (String group : _scoreGroup.keySet()) + { + Scoreboard.writeNewLine(); + Scoreboard.write(group); + Scoreboard.write(ChatColor.getLastColors(group) + _scoreGroup.get(group) + " Players"); + } + + //King + if (_king != null && _king.isValid()) + { + Scoreboard.writeNewLine(); + Scoreboard.write(C.cYellow + C.Bold + "King"); + Scoreboard.write(_kingHealth + " Health"); + } + + long timeLeft = 24000 - WorldTimeSet; + timeLeft = timeLeft / 20 * 1000; + + + if (timeLeft > 0) + { + Scoreboard.writeNewLine(); + Scoreboard.write(C.cYellow + C.Bold + "Sun Rise"); + Scoreboard.write(UtilTime.MakeStr(timeLeft, 0)); + } + else + { + Scoreboard.writeNewLine(); + Scoreboard.write(C.cYellow + C.Bold + "Sun Rise"); + Scoreboard.write("Undead Burning!"); + + for (Player player : GetTeam(ChatColor.RED).GetPlayers(true)) + Manager.GetCondition().Factory().Ignite("Sun Damage", player, player, 5, false, false); + } + + Scoreboard.draw(); + } + + @Override + public void EndCheck() + { + if (!IsLive()) + return; + + if (this.WorldTimeSet > 24100 || GetTeam(ChatColor.RED).GetSize() == 0) + { + SetCustomWinLine(_kingName + ChatColor.RESET + " has survived the siege!"); + + AnnounceEnd(GetTeam(ChatColor.AQUA)); + + for (GameTeam team : GetTeamList()) + { + if (WinnerTeam != null && team.equals(WinnerTeam)) + { + for (Player player : team.GetPlayers(false)) + { + AddGems(player, 10, "Winning Team", false, false); + } + } + + for (Player player : team.GetPlayers(false)) + if (player.isOnline()) + AddGems(player, 10, "Participation", false, false); + } + + SetState(GameState.End); + } + + if (!_king.isValid() || GetTeam(ChatColor.AQUA).GetSize() == 0) + { + if (_kingDamager != null) + { + SetCustomWinLine(C.cRed + _kingDamager.getName() + C.cWhite + " slaughtered " + _kingName + ChatColor.RESET + "!"); + AddGems(_kingDamager, 20, "King Slayer", false, false); + + Bukkit.getPluginManager().callEvent(new KingSlaughterEvent(_kingDamager)); + } + else + SetCustomWinLine(_kingName + ChatColor.RESET + " has died!"); + + AnnounceEnd(GetTeam(ChatColor.RED)); + + for (GameTeam team : GetTeamList()) + { + if (WinnerTeam != null && team.equals(WinnerTeam)) + { + for (Player player : team.GetPlayers(false)) + { + AddGems(player, 10, "Winning Team", false, false); + } + } + + for (Player player : team.GetPlayers(false)) + if (player.isOnline()) + AddGems(player, 10, "Participation", false, false); + } + + SetState(GameState.End); + } + } + + @EventHandler + public void TNTSpawn(UpdateEvent event) + { + if (GetState() != GameState.Live) + return; + + if (event.getType() != UpdateType.SEC) + return; + + if (!UtilTime.elapsed(this.GetStateTime(), 20000)) + return; + + if (!UtilTime.elapsed(_tntSpawn, 25000)) + return; + + if (_tntSpawns.isEmpty()) + return; + + Location loc = _tntSpawns.get(UtilMath.r(_tntSpawns.size())); + + if (loc.getBlock().getTypeId() == 46) + return; + + loc.getBlock().setTypeId(46); + _tntSpawn = System.currentTimeMillis(); + } + + @EventHandler(priority = EventPriority.LOW) + public void TNTPickup(PlayerInteractEvent event) + { + if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.LEFT_CLICK_BLOCK) + return; + + if (event.getClickedBlock().getTypeId() != 46) + return; + + event.setCancelled(true); + + Player player = event.getPlayer(); + + if (!IsAlive(player)) + return; + + if (!GetTeam(ChatColor.RED).HasPlayer(player)) + return; + + if (_tntCarry.containsKey(player)) + return; + + event.getClickedBlock().setTypeId(0); + + FallingBlock tnt = player.getWorld().spawnFallingBlock(player.getEyeLocation(), 46, (byte) 0); + + player.eject(); + player.setPassenger(tnt); + + _tntCarry.put(player, tnt); + + UtilPlayer.message(player, F.main("Game", "You picked up " + F.skill("TNT") + ".")); + UtilPlayer.message(player, F.main("Game", F.elem("Right-Click") + " to detonate yourself.")); + } + + @EventHandler(priority = EventPriority.NORMAL) + public void TNTUse(PlayerInteractEvent event) + { + if (event.isCancelled()) + return; + + if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.RIGHT_CLICK_AIR) + return; + + Player player = event.getPlayer(); + + if (!_tntCarry.containsKey(player)) + return; + + event.setCancelled(true); + + for (Location loc : _tntSpawns) + { + if (UtilMath.offset(player.getLocation(), loc) < 16) + { + UtilPlayer.message(player, F.main("Game", "You cannot " + F.skill("Detonate") + " so far from the Castle.")); + return; + } + } + + _tntCarry.remove(player).remove(); + + TNTPrimed tnt = player.getWorld().spawn(player.getEyeLocation(), TNTPrimed.class); + tnt.setFuseTicks(0); + UtilPlayer.message(player, F.main("Game", "You used " + F.skill("Detonate") + ".")); + } + + @EventHandler(priority = EventPriority.LOWEST) + public void TNTDeath(PlayerDeathEvent event) + { + Player player = event.getEntity(); + + if (!_tntCarry.containsKey(player)) + return; + + //Remove the TNT + _tntCarry.get(player).remove(); + + //Flag for Removal + _tntCarryEnd.add(player); + + + TNTPrimed tnt = player.getWorld().spawn(player.getEyeLocation(), TNTPrimed.class); + tnt.setFuseTicks(0); + UtilPlayer.message(player, F.main("Game", "You used " + F.skill("Detonate") + ".")); + } + + @EventHandler(priority = EventPriority.LOWEST) + public void TNTDamageDivert(ProjectileHitEvent event) + { + Iterator playerIterator = _tntCarry.keySet().iterator(); + + while (playerIterator.hasNext()) + { + Player player = playerIterator.next(); + + if (player.getPassenger() == null) + continue; + + double dist = UtilMath.offset(player.getPassenger().getLocation(), event.getEntity().getLocation().add(event.getEntity().getVelocity())); + + if (dist < 2) + { + int damage = (int) (5 * (event.getEntity().getVelocity().length() / 3d)); + + //Damage Event + Manager.GetDamage().NewDamageEvent(player, (LivingEntity)event.getEntity().getShooter(), event.getEntity(), + DamageCause.CUSTOM, damage, true, false, false, + null, GetName()); + + event.getEntity().remove(); + } + + if (_tntCarryEnd.contains(player)) + { + playerIterator.remove(); + } + } + + _tntCarryEnd.clear(); + } + + + @EventHandler + public void TNTExpire(UpdateEvent event) + { + if (event.getType() != UpdateType.FASTER) + return; + + Iterator tntIterator = _tntCarry.keySet().iterator(); + + while (tntIterator.hasNext()) + { + Player player = tntIterator.next(); + FallingBlock block = _tntCarry.get(player); + + if (player.isDead() || !block.isValid() || block.getTicksLived() > 1500) + { + player.eject(); + block.remove(); + + TNTPrimed tnt = player.getWorld().spawn(player.getEyeLocation(), TNTPrimed.class); + tnt.setFuseTicks(0); + + tntIterator.remove(); + continue; + } + + //Firework + UtilFirework.playFirework(player.getEyeLocation(), Type.BURST, Color.RED, false, false); + } + } + + @EventHandler + public void TNTWeakness(ExplosionPrimeEvent event) + { + Location weakness = null; + for (Location loc : _tntWeakness) + { + if (UtilMath.offset(loc, event.getEntity().getLocation()) < 4) + { + weakness = loc; + break; + } + } + + if (weakness == null) + return; + + _tntWeakness.remove(weakness); + + final Location extra = weakness; + + for (int i = 0; i < 10; i++) + { + Manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable() + { + public void run() + { + TNTPrimed tnt = extra.getWorld().spawn(extra.clone().add(3 - UtilMath.r(6), 5 + UtilMath.r(2), 3 - UtilMath.r(6)), TNTPrimed.class); + tnt.setFuseTicks(0); + tnt.setIsIncendiary(true); + } + }, i * 3); + } + + weakness.getWorld().playSound(weakness, Sound.EXPLODE, 16f, 0.8f); + } + + @EventHandler(priority = EventPriority.HIGH) + public void AttackerBlockBreak(org.bukkit.event.block.BlockBreakEvent event) + { + GameTeam team = GetTeam(event.getPlayer()); + if (team == null) + return; + + if (team.GetColor() != ChatColor.RED) + return; + + if (event.getBlock().getTypeId() == 85) + event.setCancelled(false); + } + + @EventHandler + public void DefenderBlockPlace(org.bukkit.event.block.BlockPlaceEvent event) + { + GameTeam team = GetTeam(event.getPlayer()); + if (team == null) + return; + + if (team.GetColor() != ChatColor.AQUA) + return; + + if (event.getBlock().getTypeId() != 85) + return; + + for (Block block : UtilBlock.getSurrounding(event.getBlock(), false)) + { + if (block.isLiquid()) + { + event.setCancelled(true); + UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot place " + F.elem("Barricade") + " in water.")); + } + } + + if (event.getBlockAgainst().getTypeId() == 85) + { + event.setCancelled(true); + UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot place " + F.elem("Barricade") + " on each other.")); + } + + if (_king != null && UtilMath.offset(_king.getLocation(), event.getBlock().getLocation().add(0.5, 0.5, 0.5)) < 4) + { + event.setCancelled(true); + UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot place " + F.elem("Barricade") + " near " + F.elem(C.cAqua + _kingName) + ".")); + } + } + + @EventHandler + public void DefenderBlockInteract(PlayerInteractEvent event) + { + if (!UtilEvent.isAction(event, ActionType.R_BLOCK)) + return; + + GameTeam team = GetTeam(event.getPlayer()); + if (team == null) + return; + + if (team.GetColor() != ChatColor.AQUA) + return; + + if (event.getClickedBlock() == null || event.getClickedBlock().getTypeId() != 85) + return; + + UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, event.getClickedBlock().getLocation().add(0.5, 0.5, 0.5), 0, 0, 0, 0, 1, + ViewDist.LONG, UtilServer.getPlayers()); + event.getClickedBlock().getWorld().playSound(event.getClickedBlock().getLocation(), Sound.NOTE_STICKS, 2f, 1f); + Manager.GetBlockRestore().add(event.getClickedBlock(), 0, (byte) 0, 1000); + } + + @EventHandler + public void DayTimer(UpdateEvent event) + { + if (GetState() != GameState.Live) + return; + + if (event.getType() != UpdateType.TICK) + return; + + WorldTimeSet = (WorldTimeSet + 1); + } + + @EventHandler + public void SnowDamage(UpdateEvent event) + { + if (GetState() != GameState.Live) + return; + + if (event.getType() != UpdateType.FAST) + return; + + for (Player player : GetPlayers(true)) + if (player.getLocation().getBlock().getTypeId() == 78) + { + //Damage Event + Manager.GetDamage().NewDamageEvent(player, null, null, + DamageCause.DROWNING, 2, false, true, false, + "Snow", "Snow Damage"); + + player.getWorld().playEffect(player.getLocation(), Effect.STEP_SOUND, 80); + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiegeTDM.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiegeTDM.java index a87b6195a..f5c443c60 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiegeTDM.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiegeTDM.java @@ -75,12 +75,12 @@ import nautilus.game.arcade.game.TeamGame; import nautilus.game.arcade.game.games.castlesiege.data.KillStreakData; import nautilus.game.arcade.game.games.castlesiege.data.medals.MedalData; import nautilus.game.arcade.game.games.castlesiege.data.medals.MedalData.MedalLevel; +import nautilus.game.arcade.game.games.castlesiege.kits.KitArcher; +import nautilus.game.arcade.game.games.castlesiege.kits.KitDemolitionist; +import nautilus.game.arcade.game.games.castlesiege.kits.KitFighter; +import nautilus.game.arcade.game.games.castlesiege.kits.KitPlayer; +import nautilus.game.arcade.game.games.castlesiege.kits.KitTank; import nautilus.game.arcade.game.games.castlesiege.data.medals.MedalType; -import nautilus.game.arcade.game.games.castlesiege.shockkits.KitArcher; -import nautilus.game.arcade.game.games.castlesiege.shockkits.KitDemolitionist; -import nautilus.game.arcade.game.games.castlesiege.shockkits.KitFighter; -import nautilus.game.arcade.game.games.castlesiege.shockkits.KitPlayer; -import nautilus.game.arcade.game.games.castlesiege.shockkits.KitTank; import nautilus.game.arcade.game.modules.compass.CompassModule; import nautilus.game.arcade.kit.Kit; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/ShockCastleSiege.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/ShockCastleSiege.java deleted file mode 100644 index fcd57e09b..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/ShockCastleSiege.java +++ /dev/null @@ -1,1445 +0,0 @@ -package nautilus.game.arcade.game.games.castlesiege; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.WeakHashMap; - -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Color; -import org.bukkit.FireworkEffect.Type; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; -import org.bukkit.block.Chest; -import org.bukkit.enchantments.Enchantment; -import org.bukkit.entity.Arrow; -import org.bukkit.entity.EnderCrystal; -import org.bukkit.entity.EnderPearl; -import org.bukkit.entity.Entity; -import org.bukkit.entity.ItemFrame; -import org.bukkit.entity.Painting; -import org.bukkit.entity.Player; -import org.bukkit.entity.TNTPrimed; -import org.bukkit.entity.Zombie; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.block.BlockBurnEvent; -import org.bukkit.event.block.BlockDispenseEvent; -import org.bukkit.event.block.BlockFadeEvent; -import org.bukkit.event.block.BlockFormEvent; -import org.bukkit.event.block.BlockFromToEvent; -import org.bukkit.event.block.BlockPlaceEvent; -import org.bukkit.event.block.LeavesDecayEvent; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.event.entity.EntityDamageEvent; -import org.bukkit.event.entity.ExplosionPrimeEvent; -import org.bukkit.event.entity.ItemDespawnEvent; -import org.bukkit.event.entity.PlayerDeathEvent; -import org.bukkit.event.entity.ProjectileHitEvent; -import org.bukkit.event.hanging.HangingBreakEvent; -import org.bukkit.event.inventory.InventoryAction; -import org.bukkit.event.inventory.InventoryClickEvent; -import org.bukkit.event.inventory.InventoryType; -import org.bukkit.event.inventory.PrepareItemCraftEvent; -import org.bukkit.event.player.PlayerBucketEmptyEvent; -import org.bukkit.event.player.PlayerBucketFillEvent; -import org.bukkit.event.player.PlayerDropItemEvent; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.player.PlayerPickupItemEvent; -import org.bukkit.inventory.ItemStack; -import org.bukkit.material.Dispenser; -import org.bukkit.material.MaterialData; -import org.bukkit.metadata.FixedMetadataValue; -import org.bukkit.metadata.MetadataValue; -import org.bukkit.util.Vector; - -import mineplex.core.Managers; -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilAction; -import mineplex.core.common.util.UtilAlg; -import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilEvent; -import mineplex.core.common.util.UtilEvent.ActionType; -import mineplex.core.common.util.UtilFirework; -import mineplex.core.common.util.UtilInv; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTextBottom; -import mineplex.core.common.util.UtilTime; -import mineplex.core.itemstack.EnchantedBookBuilder; -import mineplex.core.itemstack.ItemBuilder; -import mineplex.core.leaderboard.Leaderboard; -import mineplex.core.leaderboard.LeaderboardManager; -import mineplex.core.leaderboard.LeaderboardRepository.LeaderboardSQLType; -import mineplex.core.loot.ChestLoot; -import mineplex.core.recharge.Recharge; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.minecraft.game.core.combat.DeathMessageType; -import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.GameType; -import nautilus.game.arcade.events.FirstBloodEvent; -import nautilus.game.arcade.events.GameStateChangeEvent; -import nautilus.game.arcade.game.GameTeam; -import nautilus.game.arcade.game.GemData; -import nautilus.game.arcade.game.TeamGame; -import nautilus.game.arcade.game.games.castlesiege.data.KillStreakData; -import nautilus.game.arcade.game.games.castlesiege.data.ObjectiveTNTSpawner; -import nautilus.game.arcade.game.games.castlesiege.data.TeamCrystal; -import nautilus.game.arcade.game.games.castlesiege.data.TeamKing; -import nautilus.game.arcade.game.games.castlesiege.shockkits.KitArcher; -import nautilus.game.arcade.game.games.castlesiege.shockkits.KitDemolitionist; -import nautilus.game.arcade.game.games.castlesiege.shockkits.KitFighter; -import nautilus.game.arcade.game.games.castlesiege.shockkits.KitPlayer; -import nautilus.game.arcade.game.games.castlesiege.shockkits.KitTank; -import nautilus.game.arcade.game.modules.compass.CompassModule; -import nautilus.game.arcade.kit.Kit; -import nautilus.game.arcade.managers.lobby.current.NewGameLobbyManager; - -public class ShockCastleSiege extends TeamGame -{ - private static final int MAX_FLINT_AND_STEEL_USES = 4; - private static final int ITEMS_PER_CHEST = 5; - private static final long TIME_TILL_REFILL = 2 * 60 * 1000; - - private long _lastRefill; - - private ItemBuilder _flintAndSteel; - private ItemBuilder _wearableTnt; - - private Map _streakData = new WeakHashMap<>(); - private Map> _crystals = new HashMap<>(); - private Map _kings = new HashMap<>(); - private List _tntCarry = new ArrayList<>(); - - private List _chests = new ArrayList<>(); - - private ChestLoot _diamondGearCommon = new ChestLoot(true); - private ChestLoot _diamondGearRare = new ChestLoot(true); - private ChestLoot _weaponGearCommon = new ChestLoot(true); - private ChestLoot _weaponGearRare = new ChestLoot(true); - private ChestLoot _rangedGear = new ChestLoot(true); - private ChestLoot _rodsAndGaps = new ChestLoot(true); - private ChestLoot _potionGearCommon = new ChestLoot(true); - private ChestLoot _potionGearRare = new ChestLoot(true); - private ChestLoot _enchantGearCommon = new ChestLoot(true); - private ChestLoot _enchantGearRare = new ChestLoot(true); - private ChestLoot _miscGear = new ChestLoot(); - - private ObjectiveTNTSpawner _tntSpawner; - - private boolean _writeScoreboard = true; - - @SuppressWarnings("deprecation") - public ShockCastleSiege(ArcadeManager manager) - { - super(manager, GameType.CastleSiegeNew, - new Kit[] - { - //new KitAlchemist(manager), - new KitArcher(manager), - new KitDemolitionist(manager), - //new KitEnchanter(manager), - new KitFighter(manager), - //new KitHardline(manager), - //new KitNinja(manager), - new KitTank(manager) - }, - new String[] - { - "Destroy enemy sentry crystals with running TNT", - "After the enemy crystals are destroyed you must slay their king", - "First team to kill the enemy king wins", - "Chests refill every 2 minutes", - "TNT Respawns every 1 minute" - } - ); - - _help = new String[] - { - "Use the TNT spawning platforms to run TNT to the enemy crystals to destroy them!", - "The enemy king is invulnerable until you destroy the two sentry crystals on each sentry tower", - "Go on Kill Streaks to earn Kill Streak Rewards to obtain better armor & weapons!", - "Chests refill every 2 minutes with potions, golden applegates, fishing rods, and other useful PvP items!" - }; - - this.StrictAntiHack = true; - this.HungerSet = 20; - this.DeathOut = false; - this.DeathSpectateSecs = 5; - this.CreatureAllow = false; - this.DeathDropItems = false; - this.WorldWeatherEnabled = false; - this.AllowParticles = false; - this.SoupEnabled = false; - this.InventoryClick = true; - this.InventoryOpenChest = true; - this.InventoryOpenBlock = true; - this.ItemDrop = true; - this.ItemPickup = true; - this.AllowFlintAndSteel = true; - this.BlockPlaceAllow.add(Material.FIRE.getId()); - this.CrownsEnabled = true; - this.Leaderboards = true; - this.FirstKillReward = 20; - this.GemKillDeathRespawn = 1; - - new CompassModule() - .setGiveCompass(true) - .setGiveCompassToSpecs(true) - .setGiveCompassToAlive(false) - .register(this); - - _flintAndSteel = new ItemBuilder(Material.FLINT_AND_STEEL).setData((short) (Material.FLINT_AND_STEEL.getMaxDurability() - MAX_FLINT_AND_STEEL_USES)); - _wearableTnt = new ItemBuilder(Material.TNT).setTitle(C.cRed + "TNT").addLore(C.cRedB + "Right Click with Weapon to " + F.name("Detonate")); - generateLoot(); - - if (manager.IsRewardStats()) - { - if (manager.GetLobby() instanceof NewGameLobbyManager) - { - Map> lobbyCustomLocs = ((NewGameLobbyManager)manager.GetLobby()).getCustomLocs(); - if (lobbyCustomLocs.containsKey("TOP_DAILY_WINS")) - { - Location loc = lobbyCustomLocs.get("TOP_DAILY_WINS").get(0); - Managers.get(LeaderboardManager.class).registerLeaderboard("TOP_CASTLESIEGE_DAILY_WINS", new Leaderboard("Top Daily Wins", new String[] {"Castle Siege New.Wins"}, LeaderboardSQLType.DAILY, loc, 10)); - } - if (lobbyCustomLocs.containsKey("TOP_DAILY_KILLS")) - { - Location loc = lobbyCustomLocs.get("TOP_DAILY_KILLS").get(0); - Managers.get(LeaderboardManager.class).registerLeaderboard("TOP_CASTLESIEGE_DAILY_KILLS", new Leaderboard("Top Daily Kills", new String[] {"Castle Siege New.Kills"}, LeaderboardSQLType.DAILY, loc, 10)); - } - if (lobbyCustomLocs.containsKey("TOP_WINS")) - { - Location loc = lobbyCustomLocs.get("TOP_WINS").get(0); - Managers.get(LeaderboardManager.class).registerLeaderboard("TOP_CASTLESIEGE_WINS", new Leaderboard("Top Wins", new String[] {"Castle Siege New.Wins"}, LeaderboardSQLType.ALL, loc, 10)); - } - if (lobbyCustomLocs.containsKey("TOP_KILLS")) - { - Location loc = lobbyCustomLocs.get("TOP_KILLS").get(0); - Managers.get(LeaderboardManager.class).registerLeaderboard("TOP_CASTLESIEGE_KILLS", new Leaderboard("Top Kills", new String[] {"Castle Siege New.Kills"}, LeaderboardSQLType.ALL, loc, 10)); - } - } - } - } - - private void generateLoot() - { - { - _diamondGearCommon.addLoot(new ItemStack(Material.DIAMOND_HELMET), 2); - _diamondGearCommon.addLoot(new ItemStack(Material.DIAMOND_CHESTPLATE), 2); - _diamondGearCommon.addLoot(new ItemStack(Material.DIAMOND_LEGGINGS), 2); - _diamondGearCommon.addLoot(new ItemStack(Material.DIAMOND_BOOTS), 2); - _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_HELMET).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1).build(), 1); - _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_CHESTPLATE).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1).build(), 1); - _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_LEGGINGS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1).build(), 1); - _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_BOOTS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1).build(), 1); - _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_HELMET).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).build(), 1); - _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_CHESTPLATE).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).build(), 1); - _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_LEGGINGS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).build(), 1); - _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_BOOTS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).build(), 1); - _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_HELMET).addEnchantment(Enchantment.PROTECTION_PROJECTILE, 3).build(), 1); - _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_CHESTPLATE).addEnchantment(Enchantment.PROTECTION_PROJECTILE, 3).build(), 1); - _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_LEGGINGS).addEnchantment(Enchantment.PROTECTION_PROJECTILE, 3).build(), 1); - _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_BOOTS).addEnchantment(Enchantment.PROTECTION_PROJECTILE, 3).build(), 1); - } - { - _diamondGearRare.addLoot(new ItemBuilder(Material.DIAMOND_HELMET).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4).build(), 1); - _diamondGearRare.addLoot(new ItemBuilder(Material.DIAMOND_CHESTPLATE).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4).build(), 1); - _diamondGearRare.addLoot(new ItemBuilder(Material.DIAMOND_LEGGINGS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4).build(), 1); - _diamondGearRare.addLoot(new ItemBuilder(Material.DIAMOND_BOOTS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4).build(), 1); - } - { - _weaponGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_SWORD).build(), 2); - _weaponGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_SWORD).addEnchantment(Enchantment.DAMAGE_ALL, 1).build(), 2); - } - { - _weaponGearRare.addLoot(new ItemBuilder(Material.DIAMOND_SWORD).addEnchantment(Enchantment.DAMAGE_ALL, 2).build(), 1); - } - { - _rangedGear.addLoot(new ItemStack(Material.BOW), 3); - _rangedGear.addLoot(Material.ARROW, 3, 8, 16); - } - { - _rodsAndGaps.addLoot(new ItemStack(Material.FISHING_ROD), 3); - _rodsAndGaps.addLoot(new ItemBuilder(Material.GOLDEN_APPLE).setTitle(C.cPurple + "Golden Applegate").build(), 3); - } - { - _potionGearCommon.addLoot(new ItemBuilder(Material.POTION).setData((short)16418).build(), 2); - _potionGearCommon.addLoot(new ItemBuilder(Material.POTION).setData((short)16417).build(), 2); - } - { - _potionGearRare.addLoot(new ItemBuilder(Material.POTION).setData((short)8193).build(), 2); - _potionGearRare.addLoot(new ItemBuilder(Material.POTION).setData((short)8195).build(), 2); - } - { - _enchantGearCommon.addLoot(new EnchantedBookBuilder(1).setLevel(Enchantment.PROTECTION_ENVIRONMENTAL, 1).build(), 2); - _enchantGearCommon.addLoot(new EnchantedBookBuilder(1).setLevel(Enchantment.DAMAGE_ALL, 1).build(), 2); - _enchantGearCommon.addLoot(new EnchantedBookBuilder(1).setLevel(Enchantment.ARROW_DAMAGE, 1).build(), 2); - _enchantGearCommon.addLoot(new ItemStack(Material.EXP_BOTTLE, 64), 1); - } - { - _enchantGearRare.addLoot(new EnchantedBookBuilder(1).setLevel(Enchantment.FIRE_ASPECT, 1).build(), 1); - } - { - _miscGear.addLoot(new ItemStack(Material.ENDER_PEARL), 2); - _miscGear.addLoot(new ItemStack(Material.WATER_BUCKET), 2); - _miscGear.addLoot(_flintAndSteel.build(), 2); - _miscGear.addLoot(new ItemStack(Material.SNOW_BALL, 16), 3); - } - } - - private void fillChest(Block block) - { - if (block.getType() != Material.CHEST && block.getType() != Material.TRAPPED_CHEST) - { - return; - } - Chest chest = (Chest) block.getState(); - - chest.getBlockInventory().clear(); - int[] slots = UtilMath.random.ints(ITEMS_PER_CHEST, 0, chest.getBlockInventory().getSize()).toArray(); - - for (int slot : slots) - { - double chance = UtilMath.random.nextDouble(); - double subChance = UtilMath.random.nextDouble(); - - ChestLoot loot = _miscGear; - if (chance <= 0.6) - { - loot = _rodsAndGaps; - } - if (chance <= 0.5) - { - loot = _potionGearCommon; - if (subChance <= 0.45) - { - loot = _potionGearRare; - } - } - if (chance <= 0.3) - { - loot = _rangedGear; - } - chest.getBlockInventory().setItem(slot, loot.getLoot()); - } - } - - public ItemStack getNewFlintAndSteel(boolean kitItem) - { - if (kitItem) - { - return _flintAndSteel.clone().setLore(C.cGold + "Kit Item").build(); - } - return _flintAndSteel.build(); - } - - public void writeScoreboard() - { - if (!_writeScoreboard) - { - return; - } - Scoreboard.reset(); - Scoreboard.write(C.cDRedB + GetName()); - Scoreboard.writeNewLine(); - Scoreboard.write(C.cGreenB + "Chest Refill"); - long refillTime = _lastRefill + TIME_TILL_REFILL - System.currentTimeMillis(); - if (!IsLive()) - { - refillTime = TIME_TILL_REFILL; - } - Scoreboard.write(UtilTime.MakeStr(refillTime)); - Scoreboard.writeNewLine(); - Scoreboard.write(C.cGreenB + "TNT Spawn"); - long tntTime = _tntSpawner.getNextTNT(); - if (!IsLive()) - { - tntTime = 60000; - } - if (_tntSpawner.isSpawned()) - { - Scoreboard.write("Spawned"); - } - else - { - Scoreboard.write(UtilTime.MakeStr(tntTime)); - } - Scoreboard.writeNewLine(); - GameTeam red = GetTeam(ChatColor.RED); - long redCrystals = _crystals.get(red).stream().filter(TeamCrystal::isActive).count(); - GameTeam blue = GetTeam(ChatColor.AQUA); - long blueCrystals = _crystals.get(blue).stream().filter(TeamCrystal::isActive).count(); - if (redCrystals > 0) - { - Scoreboard.write(_kings.get(red).getName(true)); - Scoreboard.write(redCrystals + "/2 Crystals Active"); - } - else - { - Scoreboard.write(_kings.get(red).getName(true) + " Health"); - Scoreboard.write(_kings.get(red).getHealth() + ""); - } - Scoreboard.writeNewLine(); - if (blueCrystals > 0) - { - Scoreboard.write(_kings.get(blue).getName(true)); - Scoreboard.write(blueCrystals + "/2 Crystals Active"); - } - else - { - Scoreboard.write(_kings.get(blue).getName(true) + " Health"); - Scoreboard.write(_kings.get(blue).getHealth() + ""); - } - Scoreboard.draw(); - } - - public void writeFinalScoreboard(String deadKing, String winKing, String warrior) - { - _writeScoreboard = false; - Scoreboard.reset(); - Scoreboard.writeNewLine(); - Scoreboard.write(deadKing + "'s " + C.cWhite + "castle has been conquered"); - Scoreboard.write(C.cWhite + "by " + winKing + "'s " + C.cWhite + "army with the help of"); - Scoreboard.write(warrior + C.cWhite + "!"); - Scoreboard.writeNewLine(); - - Scoreboard.draw(); - } - - @Override - public void ParseData() - { - for (Location chestLoc : WorldData.GetDataLocs("BROWN")) - { - Block block = chestLoc.getBlock(); - block.setType(Material.CHEST); - fillChest(block); - _chests.add(block); - } - GameTeam red = GetTeam(ChatColor.RED); - GameTeam blue = GetTeam(ChatColor.AQUA); - Location redKing = WorldData.GetDataLocs("RED").get(0); - Location blueKing = WorldData.GetDataLocs("BLUE").get(0); - Vector redBlue = UtilAlg.getTrajectory(redKing, blueKing); - Vector blueRed = UtilAlg.getTrajectory(blueKing, redKing); - redKing.setPitch(UtilAlg.GetPitch(redBlue)); - redKing.setYaw(UtilAlg.GetYaw(redBlue)); - blueKing.setPitch(UtilAlg.GetPitch(blueRed)); - blueKing.setYaw(UtilAlg.GetYaw(blueRed)); - _crystals.put(red, Arrays.asList(new TeamCrystal(red, WorldData.GetDataLocs("PINK").get(0)), new TeamCrystal(red, WorldData.GetDataLocs("PINK").get(1)))); - _crystals.put(blue, Arrays.asList(new TeamCrystal(blue, WorldData.GetDataLocs("LIGHT_BLUE").get(0)), new TeamCrystal(blue, WorldData.GetDataLocs("LIGHT_BLUE").get(1)))); - this.CreatureAllowOverride = true; - _kings.put(red, new TeamKing(red, "King Jon", redKing)); - _kings.put(blue, new TeamKing(blue, "King Ryan", blueKing)); - int kitIndex = 0; - for (int i = 0; i < WorldData.GetDataLocs("WHITE").size(); i++) - { - if (kitIndex >= GetKits().length) - { - kitIndex = 0; - } - Entity ent = GetKits()[kitIndex].SpawnEntity(WorldData.GetDataLocs("WHITE").get(i)); - Manager.GetLobby().addKitLocation(ent, GetKits()[kitIndex], WorldData.GetDataLocs("WHITE").get(i)); - kitIndex++; - } - this.CreatureAllowOverride = false; - _tntSpawner = new ObjectiveTNTSpawner(WorldData.GetDataLocs("BLACK")); - } - - @Override - public void EndCheck() - { - if (!IsLive()) - { - return; - } - - List teamsAlive = new ArrayList<>(); - - for (GameTeam team : GetTeamList()) - { - if (team.GetPlayers(true).size() > 0) - { - teamsAlive.add(team); - } - } - - if (teamsAlive.size() <= 1) - { - //Announce - if (teamsAlive.size() > 0) - { - GameTeam winner = teamsAlive.get(0); - TeamKing king = _kings.get(winner); - TeamKing dead = _kings.values().stream().filter(k -> k.getOwner().GetColor() != king.getOwner().GetColor()).findFirst().get(); - AnnounceEnd(winner); - writeFinalScoreboard(dead.getName(false), king.getName(false), dead.getOwner().GetColor() + "Quitters"); - for (GameTeam team : GetTeamList()) - { - for (Player player : team.GetPlayers(true)) - { - if (team.GetColor() == winner.GetColor()) - { - AddGems(player, 100, "Winning Team", false, false); - } - else - { - AddGems(player, 50, "Losing Team", false, false); - } - if (player.isOnline()) - { - AddGems(player, 10, "Participation", false, false); - } - - { - int crowns = 0; - for (GemData data : GetGems(player).values()) - { - crowns += data.Gems; - } - int streak = _streakData.getOrDefault(player, new KillStreakData()).getBestStreak(); - if (streak >= 2 && streak < 4) - { - AddGems(player, 0.5 * crowns, streak + " Player Kill Streak", false, false); - } - else if (streak >= 4 && streak < 6) - { - AddGems(player, crowns, streak + " Player Kill Streak", false, false); - } - else if (streak >= 6 && streak < 8) - { - AddGems(player, 1.5 * crowns, streak + " Player Kill Streak", false, false); - } - else if (streak >= 8) - { - AddGems(player, 2 * crowns, streak + " Player Kill Streak", false, false); - } - } - - if (GetKit(player) != null) - { - KitPlayer kit = (KitPlayer) GetKit(player); - int kitLevel = kit.getUpgradeLevel(player.getUniqueId()); - if (kitLevel > 0) - { - int crowns = 0; - for (GemData data : GetGems(player).values()) - { - crowns += data.Gems; - } - - AddGems(player, (0.5 * kitLevel) * crowns, kit.GetName() + " Kit Level Bonus", false, false); - } - } - } - } - SetState(GameState.End); - return; - } - } - } - - @Override - @EventHandler - public void ScoreboardUpdate(UpdateEvent event) {}; - - @EventHandler - public void onUpdate(UpdateEvent event) - { - if (event.getType() != UpdateType.FAST) - { - return; - } - if (IsLive()) - { - if (UtilTime.elapsed(_lastRefill, TIME_TILL_REFILL)) - { - _lastRefill = System.currentTimeMillis(); - _chests.forEach(this::fillChest); - Bukkit.broadcastMessage(C.cGreenB + "Chests have refilled!"); - } - - GameTeam red = GetTeam(ChatColor.RED); - GameTeam blue = GetTeam(ChatColor.AQUA); - TeamKing redKing = _kings.get(red); - TeamKing blueKing = _kings.get(blue); - redKing.update(_crystals.get(red).stream().filter(TeamCrystal::isActive).count() > 0); - if (redKing.isDead()) - { - AnnounceEnd(blue); - writeFinalScoreboard(redKing.getName(false), blueKing.getName(false), blue.GetColor() + redKing.getLastDamager()); - for (GameTeam team : GetTeamList()) - { - for (Player player : team.GetPlayers(true)) - { - if (player.getName().equals(redKing.getLastDamager())) - { - AddGems(player, 20, "King Slayer", false, false); - } - if (team.GetColor() == ChatColor.AQUA) - { - AddGems(player, 100, "Winning Team", false, false); - } - else - { - AddGems(player, 50, "Losing Team", false, false); - } - if (player.isOnline()) - { - AddGems(player, 10, "Participation", false, false); - } - - int streak = _streakData.getOrDefault(player, new KillStreakData()).getBestStreak(); - if (streak > 0) - { - AddGems(player, streak, streak + " Player Kill Streak", false, false); - } - - KitPlayer kit = (KitPlayer) GetKit(player); - int kitLevel = kit.getUpgradeLevel(player.getUniqueId()); - if (kitLevel > 0) - { - int crowns = 0; - for (GemData data : GetGems(player).values()) - { - crowns += data.Gems; - } - - AddGems(player, (0.5 * kitLevel) * crowns, kit.GetName() + " Kit Level Bonus", false, false); - } - } - } - SetState(GameState.End); - return; - } - blueKing.update(_crystals.get(blue).stream().filter(TeamCrystal::isActive).count() > 0); - if (blueKing.isDead()) - { - AnnounceEnd(red); - writeFinalScoreboard(blueKing.getName(false), redKing.getName(false), red.GetColor() + blueKing.getLastDamager()); - for (GameTeam team : GetTeamList()) - { - for (Player player : team.GetPlayers(true)) - { - if (player.getName().equals(blueKing.getLastDamager())) - { - AddGems(player, 20, "King Slayer", false, false); - } - if (team.GetColor() == ChatColor.RED) - { - AddGems(player, 100, "Winning Team", false, false); - } - else - { - AddGems(player, 50, "Losing Team", false, false); - } - if (player.isOnline()) - { - AddGems(player, 10, "Participation", false, false); - } - - int streak = _streakData.getOrDefault(player, new KillStreakData()).getBestStreak(); - if (streak > 0) - { - AddGems(player, streak, streak + " Player Kill Streak", false, false); - } - - KitPlayer kit = (KitPlayer) GetKit(player); - int kitLevel = kit.getUpgradeLevel(player.getUniqueId()); - if (kitLevel > 0) - { - int crowns = 0; - for (GemData data : GetGems(player).values()) - { - crowns += data.Gems; - } - - AddGems(player, (0.5 * kitLevel) * crowns, kit.GetName() + " Kit Level Bonus", false, false); - } - } - } - SetState(GameState.End); - return; - } - - _tntSpawner.update(); - } - if (InProgress()) - { - writeScoreboard(); - } - } - - @EventHandler - public void onEditSettings(GameStateChangeEvent event) - { - if (event.GetGame() != this) - { - return; - } - - if (event.GetState() == GameState.Live) - { - _lastRefill = System.currentTimeMillis(); - _tntSpawner.onStart(); - Manager.GetDamage().SetEnabled(false); - Manager.GetExplosion().setEnabled(false); - Manager.GetCreature().SetDisableCustomDrops(true); - } - - if (event.GetState() == GameState.End) - { - Manager.GetDamage().SetEnabled(true); - Manager.GetExplosion().setEnabled(true); - Manager.GetCreature().SetDisableCustomDrops(false); - Managers.get(LeaderboardManager.class).unregisterLeaderboard("TOP_CASTLESIEGE_DAILY_WINS"); - Managers.get(LeaderboardManager.class).unregisterLeaderboard("TOP_CASTLESIEGE_DAILY_KILLS"); - Managers.get(LeaderboardManager.class).unregisterLeaderboard("TOP_CASTLESIEGE_WINS"); - Managers.get(LeaderboardManager.class).unregisterLeaderboard("TOP_CASTLESIEGE_KILLS"); - } - } - - @EventHandler(priority = EventPriority.HIGHEST) - public void handleDeath(CombatDeathEvent event) - { - if (!IsLive()) - { - return; - } - - event.SetBroadcastType(DeathMessageType.Detailed); - } - - @EventHandler - public void disableDamageLevel(CustomDamageEvent event) - { - event.SetDamageToLevel(false); - } - - @EventHandler - public void BlockFade(BlockFadeEvent event) - { - event.setCancelled(true); - } - - @EventHandler - public void BlockBurn(BlockBurnEvent event) - { - event.setCancelled(true); - } - - @EventHandler - public void BlockDecay(LeavesDecayEvent event) - { - event.setCancelled(true); - } - - @EventHandler - public void hangingBreak(HangingBreakEvent event) - { - if (event.getEntity() instanceof ItemFrame || event.getEntity() instanceof Painting) - { - event.setCancelled(true); - } - } - - @EventHandler - public void noFlow(BlockFromToEvent event) - { - if (!IsLive()) - { - return; - } - - Block block = event.getBlock(); - if (block.getType() == Material.WATER || block.getType() == Material.STATIONARY_WATER || block.getType() == Material.LAVA || block.getType() == Material.STATIONARY_LAVA) - { - event.setCancelled(true); - } - if (event.getToBlock().getType() == Material.ICE) - { - event.setCancelled(true); - } - } - - @EventHandler - public void onBlockChange(BlockFormEvent e) - { - if (!IsLive()) - { - return; - } - if (e.getNewState().getType() == Material.ICE) - { - e.setCancelled(true); - } - } - - @SuppressWarnings("deprecation") - @EventHandler(ignoreCancelled=true) - public void onPlayerEmptyBucket(PlayerBucketEmptyEvent event) - { - if (!IsLive()) - { - return; - } - - Player player = event.getPlayer(); - if (player.getItemInHand().getType() == Material.WATER_BUCKET) - { - player.getItemInHand().setType(Material.BUCKET); - Block block = event.getBlockClicked().getRelative(event.getBlockFace()); - if (block.getType().toString().contains("LAVA") || (block.getType().toString().contains("WATER") && block.getType() != Material.WATER_LILY)) - { - event.setCancelled(true); - player.sendBlockChange(block.getLocation(), block.getType(), block.getData()); - return; - } - for (BlockFace bf : BlockFace.values()) - { - Block relative = block.getRelative(bf); - if (relative.getType().toString().contains("LAVA") || (relative.getType().toString().contains("WATER") && relative.getType() != Material.WATER_LILY)) - { - event.setCancelled(true); - player.sendBlockChange(block.getLocation(), block.getType(), block.getData()); - } - } - } - else if (player.getItemInHand().getType() == Material.LAVA_BUCKET) - { - event.setCancelled(true); - Block block = event.getBlockClicked().getRelative(event.getBlockFace()); - player.sendBlockChange(block.getLocation(), block.getType(), block.getData()); - } - } - - @SuppressWarnings("deprecation") - @EventHandler(ignoreCancelled=true) - public void onPlayerEmptyBucket(PlayerBucketFillEvent event) - { - if (!IsLive()) - { - return; - } - - Player player = event.getPlayer(); - if (player.getItemInHand().getType() == Material.LAVA_BUCKET) - { - event.setCancelled(true); - Block block = event.getBlockClicked().getRelative(event.getBlockFace()); - player.sendBlockChange(block.getLocation(), block.getType(), block.getData()); - } - } - - @EventHandler(ignoreCancelled=true) - public void onBlockDispense(BlockDispenseEvent event) - { - if (!IsLive()) - { - return; - } - - if (event.getItem().getType() == Material.WATER_BUCKET) - { - Block dispenser = event.getBlock(); - - MaterialData mat = dispenser.getState().getData(); - Dispenser disp_mat = (Dispenser)mat; - BlockFace face = disp_mat.getFacing(); - Block block = dispenser.getRelative(face); - if (block.getType().toString().contains("LAVA") || (block.getType().toString().contains("WATER") && block.getType() != Material.WATER_LILY)) - { - event.setCancelled(true); - return; - } - for (BlockFace bf : BlockFace.values()) - { - if (block.getRelative(bf).getType().toString().contains("LAVA") || (block.getRelative(bf).getType().toString().contains("WATER") && block.getRelative(bf).getType() != Material.WATER_LILY)) - { - event.setCancelled(true); - } - } - } - } - - @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) - public void onCombatDeath(CombatDeathEvent event) - { - if (!IsLive()) - { - return; - } - - if (event.GetLog().GetKiller() == null) - { - return; - } - - if (!event.GetLog().GetKiller().IsPlayer()) - { - return; - } - - Player player = UtilPlayer.searchExact(event.GetLog().GetKiller().GetName()); - if (player == null) - { - return; - } - - AddStat(player, GetKit(player).GetName() + "KitKills", 1, false, false); - - if (UtilPlayer.isSpectator(player)) - { - return; - } - - player.setLevel(player.getLevel() + 1); - player.getInventory().addItem(new ItemBuilder(Material.GOLDEN_APPLE).setTitle(C.cPurple + "Golden Applegate").build()); - KillStreakData data = _streakData.computeIfAbsent(player, (key) -> new KillStreakData()); - boolean hardLine = GetKit(player).GetName().equals("Hardline"); - if (data.addKill(hardLine)) - { - AddStat(player, "KillStreak", 1, false, false); - ((KitPlayer)GetKit(player)).awardKillStreak(player, hardLine ? (data.getKills() + 1) : data.getKills()); - } - if (UtilMath.isEven(data.getKills())) - { - Bukkit.broadcastMessage(F.main("Game", C.cGreen + C.Bold + player.getName() + ChatColor.RESET + " is on a " + F.elem(C.cDPurple + data.getKills() + " player Kill Streak") + "!")); - } - } - - @EventHandler - public void TNTExplosion(ExplosionPrimeEvent event) - { - if (!event.getEntity().hasMetadata("THROWER")) - { - return; - } - float radius = event.getRadius(); - event.setRadius(0f); - - Player player = UtilPlayer.searchExact(((MetadataValue)UtilEnt.GetMetadata(event.getEntity(), "THROWER")).asString()); - if (player == null) - { - return; - } - if (GetTeam(player) == null) - { - return; - } - if (GetKit(player).GetName().equals("Demolitionist")) - { - radius += 3; - } - - Map nearby = UtilPlayer.getInRadius(event.getEntity().getLocation(), radius); - for (Player near : nearby.keySet()) - { - if (UtilPlayer.isSpectator(near)) - { - continue; - } - if (near.getEntityId() != player.getEntityId() && GetTeam(near).GetColor() == GetTeam(player).GetColor()) - { - continue; - } - if (near.getEntityId() == player.getEntityId() && event.getEntity().hasMetadata("OBJECTIVE_TNT")) - { - continue; - } - - double mult = nearby.get(near); - - int highestBlastProt = 0; - int blastProtEPF = 0; - for (ItemStack item : near.getInventory().getArmorContents()) - { - if (item != null && item.getEnchantments().containsKey(Enchantment.PROTECTION_EXPLOSIONS)) - { - blastProtEPF += (2 * item.getEnchantmentLevel(Enchantment.PROTECTION_EXPLOSIONS)); - if (item.getEnchantmentLevel(Enchantment.PROTECTION_EXPLOSIONS) > highestBlastProt) - { - highestBlastProt = item.getEnchantmentLevel(Enchantment.PROTECTION_EXPLOSIONS); - } - } - } - blastProtEPF = Math.min(blastProtEPF, 20); - - double damage = 8 * mult; - damage = damage * (1 - (blastProtEPF / 25)); - - double knockbackReduction = 1 - (highestBlastProt * 0.15); - - near.damage(damage, event.getEntity()); - UtilAction.velocity(near, UtilAlg.getTrajectory(event.getEntity().getLocation(), near.getLocation()), 1 * mult * knockbackReduction, false, 0, mult * knockbackReduction, 10, true); - } - - if (event.getEntity().hasMetadata("OBJECTIVE_TNT")) - { - List crystals = new ArrayList<>(); - - for (List c : _crystals.values()) - { - crystals.addAll(c); - } - for (TeamCrystal crystal : crystals) - { - if (crystal.isActive() && !crystal.getOwner().HasPlayer(player) && UtilMath.offset(event.getEntity().getLocation(), crystal.getLocation()) <= radius) - { - crystal.destroy(); - AddGems(player, 40, "Crystal Destruction", false, true); - long remaining = crystals.stream().filter(b -> b.getOwner().GetColor() == crystal.getOwner().GetColor()).filter(TeamCrystal::isActive).count(); - if (remaining > 0) - { - Bukkit.broadcastMessage(F.main("Game", "One of " + F.elem(crystal.getOwner().GetFormattedName() + "'s Crystals") + " has been destroyed!")); - } - else - { - Bukkit.broadcastMessage(F.main("Game", "All of " + F.elem(crystal.getOwner().GetFormattedName() + "'s Crystals") + " has been destroyed and " + F.elem(_kings.get(crystal.getOwner()).getName(false)) + " is now vulnerable!")); - } - } - } - for (TeamKing king : _kings.values()) - { - if (king.isDead() && !king.getOwner().HasPlayer(player) && UtilMath.offset(event.getEntity().getLocation(), king.getLocation()) <= radius) - { - king.handleDamage(player.getName(), 50); - } - } - } - } - - @EventHandler - public void TNTThrow(PlayerInteractEvent event) - { - if (!IsLive()) - { - return; - } - - if (!UtilEvent.isAction(event, ActionType.L)) - { - return; - } - - Player player = event.getPlayer(); - - if (!UtilInv.IsItem(player.getItemInHand(), Material.TNT, (byte) 0)) - { - return; - } - - if (!IsAlive(player)) - { - return; - } - - event.setCancelled(true); - - if (!Manager.GetGame().CanThrowTNT(player.getLocation())) - { - // Inform - UtilPlayer.message(event.getPlayer(), F.main(GetName(), "You cannot use " + F.item("Throwing TNT") + " here.")); - return; - } - - UtilInv.remove(player, Material.TNT, (byte) 0, 1); - UtilInv.Update(player); - - TNTPrimed tnt = player.getWorld().spawn(player.getEyeLocation().add(player.getLocation().getDirection()), TNTPrimed.class); - - tnt.setFuseTicks(60); - - double throwMult = 1; - - if (GetKit(player).GetName().equals("Demolitionist")) - { - throwMult = ((KitDemolitionist)GetKit(player)).getThrowMultiplier(player); - } - - UtilAction.velocity(tnt, player.getLocation().getDirection(), 0.5 * throwMult, false, 0, 0.1, 10, false); - - UtilEnt.SetMetadata(tnt, "THROWER", player.getName()); - } - - @EventHandler - public void onLaunch(ProjectileHitEvent event) - { - if (!IsLive()) - { - return; - } - - if (event.getEntity() instanceof EnderPearl && event.getEntity().getShooter() != null && event.getEntity().getShooter() instanceof Entity) - { - Entity shooter = (Entity) event.getEntity().getShooter(); - if (_tntCarry.contains(shooter)) - { - return; - } - Location teleport = event.getEntity().getLocation(); - teleport.setPitch(shooter.getLocation().getPitch()); - teleport.setYaw(shooter.getLocation().getYaw()); - shooter.teleport(teleport); - } - if (event.getEntity() instanceof Arrow) - { - Manager.runSyncLater(event.getEntity()::remove, 1L); - } - } - - @EventHandler - public void onOpenChest(PlayerInteractEvent event) - { - if (!IsLive()) - { - return; - } - - if (event.getClickedBlock() != null && event.getClickedBlock().getType() == Material.CHEST) - { - if (UtilPlayer.isSpectator(event.getPlayer())) - { - event.setCancelled(true); - } - } - } - - @EventHandler(ignoreCancelled = true) - public void onDamage(EntityDamageEvent event) - { - if (!IsLive()) - { - return; - } - if (event.getEntity() instanceof EnderCrystal) - { - event.setCancelled(true); - return; - } - if (event.getEntity() instanceof Zombie) - { - event.setCancelled(true); - if (event instanceof EntityDamageByEntityEvent) - { - GameTeam owner = event.getEntity().getCustomName().contains("Ryan") ? GetTeam(ChatColor.AQUA) : GetTeam(ChatColor.RED); - EntityDamageByEntityEvent e = (EntityDamageByEntityEvent) event; - if (e.getDamager() instanceof Player) - { - Player p = (Player) e.getDamager(); - if (UtilPlayer.isSpectator(p)) - { - return; - } - if (owner.HasPlayer(p)) - { - return; - } - if (_crystals.get(owner).stream().filter(TeamCrystal::isActive).count() > 0) - { - UtilPlayer.message(p, F.main("Game", "You cannot attack the enemy king until your team has destroyed his protective crystals!")); - return; - } - TeamKing king = _kings.get(owner); - if (king.handleDamage(p.getName(), e.getDamage())) - { - for (Player alert : owner.GetPlayers(true)) - { - if (Recharge.Instance.use(alert, "KingDamageAlert", 5000, false, false)) - { - alert.sendMessage(king.getName(true) + " is under attack!"); - } - } - } - } - } - } - } - - @EventHandler - public void onDrop(PlayerDropItemEvent event) - { - if (!IsLive()) - { - return; - } - - ItemStack drop = event.getItemDrop().getItemStack(); - if (drop.hasItemMeta() && drop.getItemMeta().hasLore() && drop.getItemMeta().getLore().stream().map(ChatColor::stripColor).anyMatch(lore -> lore.equals("Kit Item"))) - { - event.setCancelled(true); - return; - } - - event.getItemDrop().remove(); - } - - @EventHandler - public void craftItem(PrepareItemCraftEvent event) - { - if (!IsLive()) - { - return; - } - - if (event.getInventory().getResult().getType() == Material.FLINT_AND_STEEL) - { - event.getInventory().setResult(_flintAndSteel.build()); - } - } - - @EventHandler - public void onInvClick(InventoryClickEvent event) - { - if (!IsLive()) - { - return; - } - ItemStack current = event.getCurrentItem(); - if (event.getAction() == InventoryAction.HOTBAR_SWAP || event.getAction() == InventoryAction.HOTBAR_MOVE_AND_READD) - { - current = event.getWhoClicked().getInventory().getItem(event.getHotbarButton()); - } - if (current == null || !current.hasItemMeta()) - { - return; - } - if (current.getItemMeta().hasDisplayName() && current.getItemMeta().getDisplayName().equals(C.cRed + "TNT")) - { - event.setCancelled(true); - return; - } - if (event.getView().getTopInventory() != null && event.getView().getTopInventory().getType() == InventoryType.CHEST) - { - if (current.getItemMeta().hasLore()) - { - for (String lore : current.getItemMeta().getLore()) - { - if (ChatColor.stripColor(lore).equalsIgnoreCase("Kit Item")) - { - event.setCancelled(true); - break; - } - } - } - - } - } - - @EventHandler - public void onFirstBlood(FirstBloodEvent event) - { - if (!IsLive()) - { - return; - } - - AddStat(event.getPlayer(), "FirstBlood", 1, true, false); - } - - @EventHandler - public void onPearl(PlayerInteractEvent event) - { - if (!IsLive()) - { - return; - } - - if (!UtilEvent.isAction(event, ActionType.R)) - { - return; - } - - if (event.getItem() != null && event.getItem().getType() == Material.ENDER_PEARL) - { - Player player = (Player) event.getPlayer(); - if (!Recharge.Instance.use(player, "Enderpearl", 4000, true, true)) - { - event.setCancelled(true); - player.updateInventory(); - } - } - } - - @EventHandler - public void onItemDespawn(ItemDespawnEvent event) - { - if (!IsLive()) - { - return; - } - - if (_tntSpawner.isSpawned()) - { - if (_tntSpawner.getItem().getEntityId() == event.getEntity().getEntityId()) - { - event.setCancelled(true); - } - } - } - - @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) - public void onPickup(PlayerPickupItemEvent event) - { - if (!IsLive()) - { - return; - } - - if (_tntSpawner.isSpawned() && event.getItem().getEntityId() == _tntSpawner.getItem().getEntityId()) - { - event.setCancelled(true); - if (!_tntCarry.contains(event.getPlayer())) - { - _tntSpawner.pickup(); - _tntCarry.add(event.getPlayer()); - event.getPlayer().setMetadata("OLD_HELM", new FixedMetadataValue(UtilServer.getPlugin(), event.getPlayer().getInventory().getHelmet())); - event.getPlayer().setMetadata("TNT_START", new FixedMetadataValue(UtilServer.getPlugin(), System.currentTimeMillis())); - event.getPlayer().getInventory().setHelmet(_wearableTnt.build()); - UtilPlayer.message(event.getPlayer(), F.main("Game", "You picked up " + F.skill("TNT") + ".")); - UtilPlayer.message(event.getPlayer(), F.main("Game", F.elem("Right-Click") + " to detonate yourself.")); - UtilPlayer.message(event.getPlayer(), F.main("Game", "Run to the enemy Crystal and Detonate to destroy it.")); - } - } - } - - @EventHandler(ignoreCancelled = true) - public void TNTUse(PlayerInteractEvent event) - { - Player player = event.getPlayer(); - - if (!_tntCarry.contains(player)) - { - return; - } - - if (!UtilEvent.isAction(event, ActionType.R)) - { - return; - } - - event.setCancelled(true); - - player.getInventory().setHelmet((ItemStack) player.getMetadata("OLD_HELM").get(0).value()); - player.removeMetadata("OLD_HELM", UtilServer.getPlugin()); - player.removeMetadata("TNT_START", UtilServer.getPlugin()); - _tntCarry.remove(player); - - TNTPrimed tnt = player.getWorld().spawn(player.getEyeLocation(), TNTPrimed.class); - UtilEnt.SetMetadata(tnt, "THROWER", player.getName()); - UtilEnt.SetMetadata(tnt, "OBJECTIVE_TNT", true); - tnt.setFuseTicks(0); - UtilPlayer.message(player, F.main("Game", "You used " + F.skill("Detonate") + ".")); - } - - @EventHandler - public void TNTExpire(UpdateEvent event) - { - if (!IsLive()) - { - return; - } - - if (event.getType() != UpdateType.FASTER) - { - return; - } - - Iterator tntIterator = _tntCarry.iterator(); - - while (tntIterator.hasNext()) - { - Player player = tntIterator.next(); - - if (player.isDead() || UtilTime.elapsed(player.getMetadata("TNT_START").get(0).asLong(), 60000)) - { - TNTPrimed tnt = player.getWorld().spawn(player.getEyeLocation(), TNTPrimed.class); - UtilEnt.SetMetadata(tnt, "THROWER", player.getName()); - UtilEnt.SetMetadata(tnt, "OBJECTIVE_TNT", true); - tnt.setFuseTicks(0); - - if (!player.isDead()) - { - player.getInventory().setHelmet((ItemStack) player.getMetadata("OLD_HELM").get(0).value()); - } - player.removeMetadata("OLD_HELM", UtilServer.getPlugin()); - player.removeMetadata("TNT_START", UtilServer.getPlugin()); - - tntIterator.remove(); - continue; - } - - List crystals = new ArrayList<>(); - - for (List c : _crystals.values()) - { - crystals.addAll(c); - } - for (TeamCrystal crystal : crystals) - { - if (crystal.isActive() && !crystal.getOwner().HasPlayer(player) && UtilMath.offset(player.getLocation(), crystal.getLocation()) <= 3) - { - TNTPrimed tnt = player.getWorld().spawn(player.getEyeLocation(), TNTPrimed.class); - UtilEnt.SetMetadata(tnt, "THROWER", player.getName()); - UtilEnt.SetMetadata(tnt, "OBJECTIVE_TNT", true); - tnt.setFuseTicks(0); - - if (!player.isDead()) - { - player.getInventory().setHelmet((ItemStack) player.getMetadata("OLD_HELM").get(0).value()); - } - player.removeMetadata("OLD_HELM", UtilServer.getPlugin()); - player.removeMetadata("TNT_START", UtilServer.getPlugin()); - - tntIterator.remove(); - } - } - - UtilTextBottom.display(GetTeam(player).GetColor() + player.getName() + " has the TNT!", UtilServer.getPlayers()); - UtilFirework.playFirework(player.getEyeLocation(), Type.BURST, Color.RED, false, false); - } - } - - @EventHandler - public void onDeath(PlayerDeathEvent event) - { - Player player = event.getEntity(); - - _streakData.getOrDefault(player, new KillStreakData()).reset(); - - if (!_tntCarry.contains(player)) - { - return; - } - - player.removeMetadata("OLD_HELM", UtilServer.getPlugin()); - player.removeMetadata("TNT_START", UtilServer.getPlugin()); - _tntCarry.remove(player); - TNTPrimed tnt = player.getWorld().spawn(player.getEyeLocation(), TNTPrimed.class); - UtilEnt.SetMetadata(tnt, "THROWER", player.getName()); - UtilEnt.SetMetadata(tnt, "OBJECTIVE_TNT", true); - tnt.setFuseTicks(0); - UtilPlayer.message(player, F.main("Game", "You used " + F.skill("Detonate") + ".")); - } - - @EventHandler - public void onBlockPlace(BlockPlaceEvent event) - { - if (_tntSpawner.canPlaceFireAt(event.getBlock())) - { - event.setCancelled(true); - } - } -} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitHuman.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/classickits/KitHuman.java similarity index 90% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitHuman.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/classickits/KitHuman.java index 6c4da8994..0adab2c1b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitHuman.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/classickits/KitHuman.java @@ -1,4 +1,4 @@ -package nautilus.game.arcade.game.games.castlesiege.kits; +package nautilus.game.arcade.game.games.castlesiege.classickits; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.kit.KitAvailability; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitHumanKnight.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/classickits/KitHumanKnight.java similarity index 97% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitHumanKnight.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/classickits/KitHumanKnight.java index ec8a3ddbc..e1387e91f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitHumanKnight.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/classickits/KitHumanKnight.java @@ -1,4 +1,4 @@ -package nautilus.game.arcade.game.games.castlesiege.kits; +package nautilus.game.arcade.game.games.castlesiege.classickits; import mineplex.core.common.util.C; import mineplex.core.common.util.F; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitHumanMarksman.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/classickits/KitHumanMarksman.java similarity index 97% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitHumanMarksman.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/classickits/KitHumanMarksman.java index fcd021465..d2687a1ea 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitHumanMarksman.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/classickits/KitHumanMarksman.java @@ -1,4 +1,4 @@ -package nautilus.game.arcade.game.games.castlesiege.kits; +package nautilus.game.arcade.game.games.castlesiege.classickits; import org.bukkit.Material; import org.bukkit.entity.EntityType; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitHumanPeasant.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/classickits/KitHumanPeasant.java similarity index 96% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitHumanPeasant.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/classickits/KitHumanPeasant.java index c1ec3e24f..a59843e3e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitHumanPeasant.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/classickits/KitHumanPeasant.java @@ -1,4 +1,4 @@ -package nautilus.game.arcade.game.games.castlesiege.kits; +package nautilus.game.arcade.game.games.castlesiege.classickits; import mineplex.core.disguise.disguises.DisguiseWolf; import mineplex.core.itemstack.ItemStackFactory; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitUndead.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/classickits/KitUndead.java similarity index 93% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitUndead.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/classickits/KitUndead.java index 31db5ed38..035385d90 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitUndead.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/classickits/KitUndead.java @@ -1,4 +1,4 @@ -package nautilus.game.arcade.game.games.castlesiege.kits; +package nautilus.game.arcade.game.games.castlesiege.classickits; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.kit.KitAvailability; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitUndeadArcher.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/classickits/KitUndeadArcher.java similarity index 97% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitUndeadArcher.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/classickits/KitUndeadArcher.java index ebdefc25a..481b7249e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitUndeadArcher.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/classickits/KitUndeadArcher.java @@ -1,4 +1,4 @@ -package nautilus.game.arcade.game.games.castlesiege.kits; +package nautilus.game.arcade.game.games.castlesiege.classickits; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilInv; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitUndeadGhoul.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/classickits/KitUndeadGhoul.java similarity index 96% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitUndeadGhoul.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/classickits/KitUndeadGhoul.java index 1c893a7a6..ec56ec3f4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitUndeadGhoul.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/classickits/KitUndeadGhoul.java @@ -1,4 +1,4 @@ -package nautilus.game.arcade.game.games.castlesiege.kits; +package nautilus.game.arcade.game.games.castlesiege.classickits; import mineplex.core.common.util.C; import mineplex.core.disguise.disguises.DisguisePigZombie; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitUndeadZombie.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/classickits/KitUndeadZombie.java similarity index 96% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitUndeadZombie.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/classickits/KitUndeadZombie.java index 9d9eb4b75..f45fc539f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitUndeadZombie.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/classickits/KitUndeadZombie.java @@ -1,4 +1,4 @@ -package nautilus.game.arcade.game.games.castlesiege.kits; +package nautilus.game.arcade.game.games.castlesiege.classickits; import mineplex.core.common.util.C; import mineplex.core.disguise.disguises.DisguiseZombie; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitAlchemist.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitAlchemist.java similarity index 95% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitAlchemist.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitAlchemist.java index 31d0dec71..50c4f443d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitAlchemist.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitAlchemist.java @@ -1,4 +1,4 @@ -package nautilus.game.arcade.game.games.castlesiege.shockkits; +package nautilus.game.arcade.game.games.castlesiege.kits; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitArcher.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitArcher.java similarity index 98% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitArcher.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitArcher.java index 4ae56308e..9638a2a60 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitArcher.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitArcher.java @@ -1,4 +1,4 @@ -package nautilus.game.arcade.game.games.castlesiege.shockkits; +package nautilus.game.arcade.game.games.castlesiege.kits; import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitBuilder.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitBuilder.java similarity index 95% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitBuilder.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitBuilder.java index d69929bf1..67d2c8872 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitBuilder.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitBuilder.java @@ -1,4 +1,4 @@ -package nautilus.game.arcade.game.games.castlesiege.shockkits; +package nautilus.game.arcade.game.games.castlesiege.kits; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitDemolitionist.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitDemolitionist.java similarity index 98% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitDemolitionist.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitDemolitionist.java index 2a5731ee6..16588ff54 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitDemolitionist.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitDemolitionist.java @@ -1,4 +1,4 @@ -package nautilus.game.arcade.game.games.castlesiege.shockkits; +package nautilus.game.arcade.game.games.castlesiege.kits; import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitEnchanter.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitEnchanter.java similarity index 96% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitEnchanter.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitEnchanter.java index f25217ad6..d92d12c30 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitEnchanter.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitEnchanter.java @@ -1,4 +1,4 @@ -package nautilus.game.arcade.game.games.castlesiege.shockkits; +package nautilus.game.arcade.game.games.castlesiege.kits; import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitFighter.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitFighter.java similarity index 98% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitFighter.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitFighter.java index c961311ed..abf6ad397 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitFighter.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitFighter.java @@ -1,4 +1,4 @@ -package nautilus.game.arcade.game.games.castlesiege.shockkits; +package nautilus.game.arcade.game.games.castlesiege.kits; import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitHardline.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitHardline.java similarity index 94% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitHardline.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitHardline.java index e80e62e65..9154b7a45 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitHardline.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitHardline.java @@ -1,4 +1,4 @@ -package nautilus.game.arcade.game.games.castlesiege.shockkits; +package nautilus.game.arcade.game.games.castlesiege.kits; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitNinja.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitNinja.java similarity index 95% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitNinja.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitNinja.java index 20b712abb..898091c80 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitNinja.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitNinja.java @@ -1,4 +1,4 @@ -package nautilus.game.arcade.game.games.castlesiege.shockkits; +package nautilus.game.arcade.game.games.castlesiege.kits; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitPlayer.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitPlayer.java similarity index 88% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitPlayer.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitPlayer.java index b270e8310..53cc7b7e1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitPlayer.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitPlayer.java @@ -1,4 +1,4 @@ -package nautilus.game.arcade.game.games.castlesiege.shockkits; +package nautilus.game.arcade.game.games.castlesiege.kits; import org.bukkit.Material; import org.bukkit.entity.EntityType; @@ -9,7 +9,7 @@ import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.game.games.castlesiege.ShockCastleSiege; +import nautilus.game.arcade.game.games.castlesiege.CastleSiege; import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.Perk; import nautilus.game.arcade.kit.ProgressingKit; @@ -32,9 +32,9 @@ public abstract class KitPlayer extends ProgressingKit public abstract void awardKillStreak(Player player, int streak); - protected ShockCastleSiege getGame() + protected CastleSiege getGame() { - return (ShockCastleSiege) Manager.GetGame(); + return (CastleSiege) Manager.GetGame(); } protected void giveRegeneration(Player player) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitTank.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitTank.java similarity index 99% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitTank.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitTank.java index cbd30bb10..3549ffb12 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitTank.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitTank.java @@ -1,4 +1,4 @@ -package nautilus.game.arcade.game.games.castlesiege.shockkits; +package nautilus.game.arcade.game.games.castlesiege.kits; import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitWorkman.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitWorkman.java similarity index 95% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitWorkman.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitWorkman.java index 83e9ec555..e3359c66d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/KitWorkman.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitWorkman.java @@ -1,4 +1,4 @@ -package nautilus.game.arcade.game.games.castlesiege.shockkits; +package nautilus.game.arcade.game.games.castlesiege.kits; import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/PerkBloodlust.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/PerkBloodlust.java similarity index 97% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/PerkBloodlust.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/PerkBloodlust.java index 7ab56e1b3..8c9c84484 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/shockkits/PerkBloodlust.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/PerkBloodlust.java @@ -1,4 +1,4 @@ -package nautilus.game.arcade.game.games.castlesiege.shockkits; +package nautilus.game.arcade.game.games.castlesiege.kits; import java.util.Map; import java.util.WeakHashMap; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/BloodThirstyStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/BloodThirstyStatTracker.java index c6df42427..82ea187e8 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/BloodThirstyStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/BloodThirstyStatTracker.java @@ -11,7 +11,7 @@ import org.bukkit.event.EventPriority; import mineplex.core.common.util.UtilPlayer; import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; import nautilus.game.arcade.game.Game; -import nautilus.game.arcade.game.games.castlesiege.kits.KitUndead; +import nautilus.game.arcade.game.games.castlesiege.classickits.KitUndead; import nautilus.game.arcade.game.games.hideseek.kits.KitSeeker; public class BloodThirstyStatTracker extends StatTracker diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/KingDamageStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/KingDamageStatTracker.java index 5b84ac9af..bf5053000 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/KingDamageStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/KingDamageStatTracker.java @@ -10,20 +10,20 @@ import org.bukkit.event.EventPriority; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.Game; -import nautilus.game.arcade.game.games.castlesiege.CastleSiege; +import nautilus.game.arcade.game.games.castlesiege.CastleSiegeClassic; -public class KingDamageStatTracker extends StatTracker +public class KingDamageStatTracker extends StatTracker { private final Map _kingDamage = new HashMap<>(); private double _totalKingDamage = 0; - public KingDamageStatTracker(CastleSiege game) + public KingDamageStatTracker(CastleSiegeClassic game) { super(game); } @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) - public void onKingDamage(CastleSiege.KingDamageEvent event) + public void onKingDamage(CastleSiegeClassic.KingDamageEvent event) { if (getGame().GetState() != Game.GameState.Live) return; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/KingSlayerStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/KingSlayerStatTracker.java index c229272e5..8f3e7f287 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/KingSlayerStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/KingSlayerStatTracker.java @@ -3,7 +3,7 @@ package nautilus.game.arcade.stats; import org.bukkit.event.EventHandler; import nautilus.game.arcade.game.Game; -import nautilus.game.arcade.game.games.castlesiege.CastleSiege; +import nautilus.game.arcade.game.games.castlesiege.CastleSiegeClassic; public class KingSlayerStatTracker extends StatTracker { @@ -13,7 +13,7 @@ public class KingSlayerStatTracker extends StatTracker } @EventHandler - public void onKingSlaughtered(CastleSiege.KingSlaughterEvent event) + public void onKingSlaughtered(CastleSiegeClassic.KingSlaughterEvent event) { if (getGame().GetState() != Game.GameState.Live) return; From 6ef7608f207e848a3c4f57f7694b44bea066b074 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Mon, 8 May 2017 01:24:52 -0400 Subject: [PATCH 57/99] Fix incorrect repository method name --- .../src/mineplex/core/donation/crown/CrownRepository.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/donation/crown/CrownRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/donation/crown/CrownRepository.java index 1a449f565..49fd9364d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/donation/crown/CrownRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/donation/crown/CrownRepository.java @@ -82,7 +82,7 @@ public class CrownRepository }); } - public void setGold(final Callback callback, final int accountId, final int crowns) + public void setCrowns(final Callback callback, final int accountId, final int crowns) { if (crowns < 0) { From 49aaaa5301c11ec119ba629d17432d7db882e83d Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Mon, 8 May 2017 02:08:03 -0400 Subject: [PATCH 58/99] Leaderboard changes --- .../core/leaderboard/Leaderboard.java | 25 +++++++---- .../core/leaderboard/LeaderboardManager.java | 23 +++-------- .../leaderboard/LeaderboardRepository.java | 41 +++++++++---------- .../game/games/castlesiege/CastleSiege.java | 10 ++--- 4 files changed, 48 insertions(+), 51 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/Leaderboard.java b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/Leaderboard.java index 047b0cf6d..29087eb56 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/Leaderboard.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/Leaderboard.java @@ -1,6 +1,9 @@ package mineplex.core.leaderboard; +import java.util.LinkedHashMap; import java.util.LinkedList; +import java.util.Map; +import java.util.Map.Entry; import org.bukkit.Location; @@ -11,22 +14,23 @@ import mineplex.core.leaderboard.LeaderboardRepository.LeaderboardSQLType; public class Leaderboard { - private String _display; + private String _display, _statDisplay; private String[] _statIds; private int _size; private LeaderboardSQLType _type; private Location _loc; private Hologram _holo; - public Leaderboard(String display, String[] statIds, LeaderboardSQLType type, Location displayLoc, int size) + public Leaderboard(String display, String statDisplayName, String[] statIds, LeaderboardSQLType type, Location displayLoc, int size) { _display = display; + _statDisplay = statDisplayName; _statIds = statIds; _type = type; _size = size; _loc = displayLoc; - update(new LinkedList<>()); + update(new LinkedHashMap<>()); } public int getSize() @@ -44,12 +48,19 @@ public class Leaderboard return _type; } - public void update(LinkedList names) + public void update(Map names) { deconstruct(); - names.addFirst(C.cRed + " "); - names.addFirst(C.cAqua + _display); - _holo = new Hologram(Managers.get(LeaderboardManager.class).getHologramManager(), _loc, names.toArray(new String[names.size()])).start(); + LinkedList display = new LinkedList<>(); + display.add(C.cAqua + _display); + display.add(C.cRed + " "); + int place = 1; + for (Entry entry : names.entrySet()) + { + display.add(C.cGreen + "#" + place + " " + entry.getKey() + C.cRed + " " + entry.getValue() + " " + _statDisplay); + place++; + } + _holo = new Hologram(Managers.get(LeaderboardManager.class).getHologramManager(), _loc, display.toArray(new String[display.size()])).start(); } public void deconstruct() diff --git a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardManager.java b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardManager.java index 9d50dd388..c9e66f1a8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardManager.java @@ -16,7 +16,6 @@ import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilMath; import mineplex.core.hologram.HologramManager; -import mineplex.core.leaderboard.LeaderboardRepository.LeaderboardSQLType; public class LeaderboardManager extends MiniPlugin { @@ -49,23 +48,13 @@ public class LeaderboardManager extends MiniPlugin private void refreshBoards() { - int arrayLength = _leaderboards.size(); - Leaderboard[] boards = _leaderboards.values().toArray(new Leaderboard[arrayLength]); - List statIds = new ArrayList<>(); - int[] sizes = new int[arrayLength]; - LeaderboardSQLType[] types = new LeaderboardSQLType[arrayLength]; - for (int i = 0; i < arrayLength; i++) + List leaderboards = new ArrayList<>(); + leaderboards.addAll(_leaderboards.values()); + _repo.loadLeaderboards(_leaderboards.values(), boards -> { - statIds.add(boards[i].getStatIds()); - sizes[i] = boards[i].getSize(); - types[i] = boards[i].getType(); - } - - _repo.loadLeaderboards(statIds, sizes, types, nameArray -> - { - for (int i = 0; i < nameArray.length && i < boards.length; i++) + for (int i = 0; i < boards.length && i < leaderboards.size(); i++) { - boards[i].update(nameArray[i]); + leaderboards.get(i).update(boards[i]); } }); } @@ -97,7 +86,7 @@ public class LeaderboardManager extends MiniPlugin return; } _leaderboards.put(identifier, board); - _repo.loadLeaderboard(board.getStatIds(), board.getSize(), board.getType(), board::update); + _repo.loadLeaderboard(board, board::update); } public void unregisterLeaderboard(String boardIdentifier) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardRepository.java index a35e71649..188103c5a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardRepository.java @@ -5,13 +5,13 @@ import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; -import java.util.LinkedList; -import java.util.List; +import java.util.Collection; +import java.util.LinkedHashMap; +import java.util.Map; import java.util.function.Consumer; import org.bukkit.plugin.java.JavaPlugin; -import mineplex.core.common.util.C; import mineplex.core.common.util.UtilServer; import mineplex.serverdata.database.DBPool; import mineplex.serverdata.database.RepositoryBase; @@ -42,19 +42,17 @@ public class LeaderboardRepository extends RepositoryBase }); } - public void loadLeaderboard(String[] statIds, int size, LeaderboardSQLType type, Consumer> leaderboard) + public void loadLeaderboard(Leaderboard board, Consumer> leaderboard) { UtilServer.runAsync(() -> { try (Connection c = getConnection()) { - LinkedList names = new LinkedList<>(); - ResultSet rs = type.getStatement(c, statIds, size).executeQuery(); - int place = 1; + Map names = new LinkedHashMap<>(); + ResultSet rs = board.getType().getStatement(c, board.getStatIds(), board.getSize()).executeQuery(); while (rs.next()) { - names.add(C.cGreen + "#" + place + " " + rs.getString(1) + C.cRed + " " + rs.getInt(2)); - place++; + names.put(rs.getString("name"), rs.getInt("value")); } UtilServer.runSync(() -> leaderboard.accept(names)); @@ -67,21 +65,22 @@ public class LeaderboardRepository extends RepositoryBase } @SuppressWarnings("unchecked") - public void loadLeaderboards(List statIdArray, int[] sizes, LeaderboardSQLType[] types, Consumer[]> leaderboard) + public void loadLeaderboards(Collection boards, Consumer[]> leaderboard) { UtilServer.runAsync(() -> { try (Connection c = getConnection()) { - LinkedList[] nameArray = new LinkedList[statIdArray.size()]; + Map[] leaderboards = new Map[boards.size()]; StringBuilder queryBuilder = new StringBuilder(); - for (int i = 0; i < statIdArray.size() && i < sizes.length && i < types.length; i++) { - String[] statIds = statIdArray.get(i); - int size = sizes[i]; - LeaderboardSQLType type = types[i]; - queryBuilder.append(type.getMultiStatement(statIds, size)); - nameArray[i] = new LinkedList<>(); + int i = 0; + for (Leaderboard board : boards) + { + queryBuilder.append(board.getType().getMultiStatement(board.getStatIds(), board.getSize())); + leaderboards[i] = new LinkedHashMap<>(); + i++; + } } if (queryBuilder.length() > 0) @@ -89,14 +88,12 @@ public class LeaderboardRepository extends RepositoryBase Statement s = c.createStatement(); s.execute(queryBuilder.toString()); - for (int i = 0; i < nameArray.length; i++) + for (int i = 0; i < boards.size(); i++) { ResultSet rs = s.getResultSet(); - int place = 1; while (rs.next()) { - nameArray[i].add(C.cGreen + "#" + place + " " + rs.getString(1) + C.cRed + " " + rs.getInt(2)); - place++; + leaderboards[i].put(rs.getString("name"), rs.getInt("value")); } if (!s.getMoreResults()) @@ -106,7 +103,7 @@ public class LeaderboardRepository extends RepositoryBase } } - UtilServer.runSync(() -> leaderboard.accept(nameArray)); + UtilServer.runSync(() -> leaderboard.accept(leaderboards)); } catch (SQLException ex) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiege.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiege.java index f17e43398..e4e1f4620 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiege.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiege.java @@ -143,7 +143,7 @@ public class CastleSiege extends TeamGame @SuppressWarnings("deprecation") public CastleSiege(ArcadeManager manager) { - super(manager, GameType.CastleSiegeNew, + super(manager, GameType.CastleSiege, new Kit[] { //new KitAlchemist(manager), @@ -212,22 +212,22 @@ public class CastleSiege extends TeamGame if (lobbyCustomLocs.containsKey("TOP_DAILY_WINS")) { Location loc = lobbyCustomLocs.get("TOP_DAILY_WINS").get(0); - Managers.get(LeaderboardManager.class).registerLeaderboard("TOP_CASTLESIEGE_DAILY_WINS", new Leaderboard("Top Daily Wins", new String[] {"Castle Siege.Wins"}, LeaderboardSQLType.DAILY, loc, 10)); + Managers.get(LeaderboardManager.class).registerLeaderboard("TOP_CASTLESIEGE_DAILY_WINS", new Leaderboard("Top Daily Wins", "Wins", new String[] {"Castle Siege.Wins"}, LeaderboardSQLType.DAILY, loc, 10)); } if (lobbyCustomLocs.containsKey("TOP_DAILY_KILLS")) { Location loc = lobbyCustomLocs.get("TOP_DAILY_KILLS").get(0); - Managers.get(LeaderboardManager.class).registerLeaderboard("TOP_CASTLESIEGE_DAILY_KILLS", new Leaderboard("Top Daily Kills", new String[] {"Castle Siege.Kills"}, LeaderboardSQLType.DAILY, loc, 10)); + Managers.get(LeaderboardManager.class).registerLeaderboard("TOP_CASTLESIEGE_DAILY_KILLS", new Leaderboard("Top Daily Kills", "Kills", new String[] {"Castle Siege.Kills"}, LeaderboardSQLType.DAILY, loc, 10)); } if (lobbyCustomLocs.containsKey("TOP_WINS")) { Location loc = lobbyCustomLocs.get("TOP_WINS").get(0); - Managers.get(LeaderboardManager.class).registerLeaderboard("TOP_CASTLESIEGE_WINS", new Leaderboard("Top Wins", new String[] {"Castle Siege.Wins"}, LeaderboardSQLType.ALL, loc, 10)); + Managers.get(LeaderboardManager.class).registerLeaderboard("TOP_CASTLESIEGE_WINS", new Leaderboard("Top Wins", "Wins", new String[] {"Castle Siege.Wins"}, LeaderboardSQLType.ALL, loc, 10)); } if (lobbyCustomLocs.containsKey("TOP_KILLS")) { Location loc = lobbyCustomLocs.get("TOP_KILLS").get(0); - Managers.get(LeaderboardManager.class).registerLeaderboard("TOP_CASTLESIEGE_KILLS", new Leaderboard("Top Kills", new String[] {"Castle Siege.Kills"}, LeaderboardSQLType.ALL, loc, 10)); + Managers.get(LeaderboardManager.class).registerLeaderboard("TOP_CASTLESIEGE_KILLS", new Leaderboard("Top Kills", "Kills", new String[] {"Castle Siege.Kills"}, LeaderboardSQLType.ALL, loc, 10)); } } } From 452eaeeba98d6546699d89315fd90f71333cf672 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Mon, 8 May 2017 02:08:45 -0400 Subject: [PATCH 59/99] Fix incorrect GameType association with TDM --- .../game/arcade/game/games/castlesiege/CastleSiegeTDM.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiegeTDM.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiegeTDM.java index f5c443c60..50e9a7d65 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiegeTDM.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiegeTDM.java @@ -118,7 +118,7 @@ public class CastleSiegeTDM extends TeamGame @SuppressWarnings("deprecation") public CastleSiegeTDM(ArcadeManager manager) { - super(manager, GameType.CastleSiegeNew, + super(manager, GameType.CastleSiegeTDM, new Kit[] { //new KitAlchemist(manager), From 5c265cfd66d19cff2ea21ae31d02c7ed640c4627 Mon Sep 17 00:00:00 2001 From: LCastr0 Date: Mon, 8 May 2017 10:35:21 -0300 Subject: [PATCH 60/99] Lock to other ranks, unlock on join --- .../wineffect/rankrooms/WinEffectRankBased.java | 4 +--- .../rankrooms/rankwineffects/WinEffectRankEternal.java | 10 ++++++++++ .../rankrooms/rankwineffects/WinEffectRankHero.java | 10 ++++++++++ .../rankrooms/rankwineffects/WinEffectRankLegend.java | 10 ++++++++++ .../rankrooms/rankwineffects/WinEffectRankTitan.java | 10 ++++++++++ .../rankrooms/rankwineffects/WinEffectRankUltra.java | 10 ++++++++++ 6 files changed, 51 insertions(+), 3 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/WinEffectRankBased.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/WinEffectRankBased.java index 35993d8ca..080848ec0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/WinEffectRankBased.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/WinEffectRankBased.java @@ -25,9 +25,7 @@ public abstract class WinEffectRankBased extends WinEffectGadget */ public WinEffectRankBased(GadgetManager manager, String name, String[] lore, Material material, byte data, Rank rank, WinEffectType winEffectType, String... alternativeSalepackageNames) { - super(manager, name, lore, - (rank.equals(Rank.ETERNAL) ? -15 : (rank.equals(Rank.TITAN) ? -13 : (rank.equals(Rank.LEGEND) ? -12 : (rank.equals(Rank.HERO) ? -11 : -10)))), - material, data, true, alternativeSalepackageNames); + super(manager, name, lore, -2, material, data, true, alternativeSalepackageNames); _rank = rank; _winEffectType = winEffectType; _schematicName = winEffectType.getSchematic().replace("%r%", rank.getRawTag()); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankEternal.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankEternal.java index 2b80a5573..a37b06837 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankEternal.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankEternal.java @@ -10,6 +10,7 @@ import org.bukkit.entity.FallingBlock; import org.bukkit.entity.Guardian; import org.bukkit.entity.LivingEntity; import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.util.Vector; import mineplex.core.common.MaterialData; @@ -127,4 +128,13 @@ public class WinEffectRankEternal extends WinEffectRankBased armorStand.setHealth(0); } + @EventHandler + public void eternalOwner(PlayerJoinEvent event) + { + if (Manager.getClientManager().Get(event.getPlayer()).GetRank().equals(Rank.ETERNAL)) + { + Manager.getDonationManager().Get(event.getPlayer()).addOwnedUnknownSalesPackage(getName()); + } + } + } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankHero.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankHero.java index 678f1cc61..f81017555 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankHero.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankHero.java @@ -10,6 +10,7 @@ import org.bukkit.entity.ArmorStand; import org.bukkit.entity.EnderDragon; import org.bukkit.entity.FallingBlock; import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.util.Vector; import mineplex.core.common.MaterialData; @@ -127,4 +128,13 @@ public class WinEffectRankHero extends WinEffectRankBased armorStand.setHealth(0); } + @EventHandler + public void heroOwner(PlayerJoinEvent event) + { + if (Manager.getClientManager().Get(event.getPlayer()).GetRank().equals(Rank.HERO)) + { + Manager.getDonationManager().Get(event.getPlayer()).addOwnedUnknownSalesPackage(getName()); + } + } + } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankLegend.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankLegend.java index d8266b2c8..036df0e4f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankLegend.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankLegend.java @@ -10,6 +10,7 @@ import org.bukkit.entity.FallingBlock; import org.bukkit.entity.Wither; import org.bukkit.entity.WitherSkull; import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.util.Vector; import mineplex.core.common.MaterialData; @@ -125,4 +126,13 @@ public class WinEffectRankLegend extends WinEffectRankBased armorStand.setHealth(0); } + @EventHandler + public void legendOwner(PlayerJoinEvent event) + { + if (Manager.getClientManager().Get(event.getPlayer()).GetRank().equals(Rank.LEGEND)) + { + Manager.getDonationManager().Get(event.getPlayer()).addOwnedUnknownSalesPackage(getName()); + } + } + } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankTitan.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankTitan.java index b6b611bfc..ade554798 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankTitan.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankTitan.java @@ -10,6 +10,7 @@ import org.bukkit.entity.FallingBlock; import org.bukkit.entity.Giant; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.player.PlayerJoinEvent; import mineplex.core.common.MaterialData; import mineplex.core.common.Rank; @@ -88,4 +89,13 @@ public class WinEffectRankTitan extends WinEffectRankBased } } + @EventHandler + public void titanOwner(PlayerJoinEvent event) + { + if (Manager.getClientManager().Get(event.getPlayer()).GetRank().equals(Rank.TITAN)) + { + Manager.getDonationManager().Get(event.getPlayer()).addOwnedUnknownSalesPackage(getName()); + } + } + } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankUltra.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankUltra.java index 2e8f43dc3..1102f3ae9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankUltra.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankUltra.java @@ -11,6 +11,7 @@ import org.bukkit.entity.FallingBlock; import org.bukkit.entity.LivingEntity; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityExplodeEvent; +import org.bukkit.event.player.PlayerJoinEvent; import mineplex.core.common.MaterialData; import mineplex.core.common.Rank; @@ -85,4 +86,13 @@ public class WinEffectRankUltra extends WinEffectRankBased } } + @EventHandler + public void ultraOwner(PlayerJoinEvent event) + { + if (Manager.getClientManager().Get(event.getPlayer()).GetRank().equals(Rank.ULTRA)) + { + Manager.getDonationManager().Get(event.getPlayer()).addOwnedUnknownSalesPackage(getName()); + } + } + } From 00981cf846d276e349530d5572fc5989f46915ed Mon Sep 17 00:00:00 2001 From: LCastr0 Date: Mon, 8 May 2017 14:56:33 -0300 Subject: [PATCH 61/99] Fixed all ranks having all win effects --- .../core/cosmetic/ui/page/WinEffectPage.java | 18 +++++++++++++++++- .../rankrooms/WinEffectRankBased.java | 2 +- .../rankwineffects/WinEffectRankEternal.java | 10 ---------- .../rankwineffects/WinEffectRankHero.java | 10 ---------- .../rankwineffects/WinEffectRankLegend.java | 10 ---------- .../rankwineffects/WinEffectRankTitan.java | 10 ---------- .../rankwineffects/WinEffectRankUltra.java | 10 ---------- 7 files changed, 18 insertions(+), 52 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/WinEffectPage.java b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/WinEffectPage.java index 03580ec3f..cc116cbac 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/WinEffectPage.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/cosmetic/ui/page/WinEffectPage.java @@ -9,6 +9,7 @@ import mineplex.core.common.util.C; import mineplex.core.cosmetic.CosmeticManager; import mineplex.core.cosmetic.ui.CosmeticShop; import mineplex.core.donation.DonationManager; +import mineplex.core.gadget.gadgets.wineffect.rankrooms.WinEffectRankBased; import mineplex.core.gadget.types.Gadget; import mineplex.core.gadget.types.GadgetType; import mineplex.core.shop.item.IButton; @@ -30,7 +31,22 @@ public class WinEffectPage extends GadgetPage for (Gadget gadget : getPlugin().getGadgetManager().getGadgets(GadgetType.WIN_EFFECT)) { - addGadget(gadget, slot); + if (gadget instanceof WinEffectRankBased) + { + WinEffectRankBased rankBased = (WinEffectRankBased) gadget; + if (getClientManager().Get(getPlayer()).GetRank().has(rankBased.getRank())) + { + addGadget(gadget, slot); + } + else + { + addGadget(gadget, slot, true); + } + } + else + { + addGadget(gadget, slot); + } if (getPlugin().getGadgetManager().getActive(getPlayer(), GadgetType.WIN_EFFECT) == gadget) addGlow(slot); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/WinEffectRankBased.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/WinEffectRankBased.java index 080848ec0..48381aafa 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/WinEffectRankBased.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/WinEffectRankBased.java @@ -25,7 +25,7 @@ public abstract class WinEffectRankBased extends WinEffectGadget */ public WinEffectRankBased(GadgetManager manager, String name, String[] lore, Material material, byte data, Rank rank, WinEffectType winEffectType, String... alternativeSalepackageNames) { - super(manager, name, lore, -2, material, data, true, alternativeSalepackageNames); + super(manager, name, lore, -1, material, data, true, alternativeSalepackageNames); _rank = rank; _winEffectType = winEffectType; _schematicName = winEffectType.getSchematic().replace("%r%", rank.getRawTag()); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankEternal.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankEternal.java index a37b06837..2b80a5573 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankEternal.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankEternal.java @@ -10,7 +10,6 @@ import org.bukkit.entity.FallingBlock; import org.bukkit.entity.Guardian; import org.bukkit.entity.LivingEntity; import org.bukkit.event.EventHandler; -import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.util.Vector; import mineplex.core.common.MaterialData; @@ -128,13 +127,4 @@ public class WinEffectRankEternal extends WinEffectRankBased armorStand.setHealth(0); } - @EventHandler - public void eternalOwner(PlayerJoinEvent event) - { - if (Manager.getClientManager().Get(event.getPlayer()).GetRank().equals(Rank.ETERNAL)) - { - Manager.getDonationManager().Get(event.getPlayer()).addOwnedUnknownSalesPackage(getName()); - } - } - } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankHero.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankHero.java index f81017555..678f1cc61 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankHero.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankHero.java @@ -10,7 +10,6 @@ import org.bukkit.entity.ArmorStand; import org.bukkit.entity.EnderDragon; import org.bukkit.entity.FallingBlock; import org.bukkit.event.EventHandler; -import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.util.Vector; import mineplex.core.common.MaterialData; @@ -128,13 +127,4 @@ public class WinEffectRankHero extends WinEffectRankBased armorStand.setHealth(0); } - @EventHandler - public void heroOwner(PlayerJoinEvent event) - { - if (Manager.getClientManager().Get(event.getPlayer()).GetRank().equals(Rank.HERO)) - { - Manager.getDonationManager().Get(event.getPlayer()).addOwnedUnknownSalesPackage(getName()); - } - } - } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankLegend.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankLegend.java index 036df0e4f..d8266b2c8 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankLegend.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankLegend.java @@ -10,7 +10,6 @@ import org.bukkit.entity.FallingBlock; import org.bukkit.entity.Wither; import org.bukkit.entity.WitherSkull; import org.bukkit.event.EventHandler; -import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.util.Vector; import mineplex.core.common.MaterialData; @@ -126,13 +125,4 @@ public class WinEffectRankLegend extends WinEffectRankBased armorStand.setHealth(0); } - @EventHandler - public void legendOwner(PlayerJoinEvent event) - { - if (Manager.getClientManager().Get(event.getPlayer()).GetRank().equals(Rank.LEGEND)) - { - Manager.getDonationManager().Get(event.getPlayer()).addOwnedUnknownSalesPackage(getName()); - } - } - } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankTitan.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankTitan.java index ade554798..b6b611bfc 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankTitan.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankTitan.java @@ -10,7 +10,6 @@ import org.bukkit.entity.FallingBlock; import org.bukkit.entity.Giant; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityDamageEvent; -import org.bukkit.event.player.PlayerJoinEvent; import mineplex.core.common.MaterialData; import mineplex.core.common.Rank; @@ -89,13 +88,4 @@ public class WinEffectRankTitan extends WinEffectRankBased } } - @EventHandler - public void titanOwner(PlayerJoinEvent event) - { - if (Manager.getClientManager().Get(event.getPlayer()).GetRank().equals(Rank.TITAN)) - { - Manager.getDonationManager().Get(event.getPlayer()).addOwnedUnknownSalesPackage(getName()); - } - } - } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankUltra.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankUltra.java index 1102f3ae9..2e8f43dc3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankUltra.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankUltra.java @@ -11,7 +11,6 @@ import org.bukkit.entity.FallingBlock; import org.bukkit.entity.LivingEntity; import org.bukkit.event.EventHandler; import org.bukkit.event.entity.EntityExplodeEvent; -import org.bukkit.event.player.PlayerJoinEvent; import mineplex.core.common.MaterialData; import mineplex.core.common.Rank; @@ -86,13 +85,4 @@ public class WinEffectRankUltra extends WinEffectRankBased } } - @EventHandler - public void ultraOwner(PlayerJoinEvent event) - { - if (Manager.getClientManager().Get(event.getPlayer()).GetRank().equals(Rank.ULTRA)) - { - Manager.getDonationManager().Get(event.getPlayer()).addOwnedUnknownSalesPackage(getName()); - } - } - } From d13610251fac994f8d11f762c1a4cb35c6793942 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Mon, 8 May 2017 17:05:30 -0400 Subject: [PATCH 62/99] Rename Castle Siege 2.0 to Castle Assault and re-implement the old game --- .../core/achievement/Achievement.java | 80 +- .../core/achievement/AchievementCategory.java | 11 +- .../src/mineplex/core/game/GameDisplay.java | 5 +- .../core/leaderboard/Leaderboard.java | 17 +- .../preferences/ui/PreferenceMainMenu.java | 2 +- .../src/nautilus/game/arcade/GameType.java | 6 +- .../games/castleassault/CastleAssault.java | 1446 +++++++++++ .../CastleAssaultTDM.java} | 26 +- .../data/CapturePoint.java | 140 +- .../data/KillStreakData.java | 92 +- .../data/ObjectiveTNTSpawner.java | 195 +- .../data/TeamCrystal.java | 106 +- .../data/TeamKing.java | 242 +- .../data/medals/MedalData.java | 2 +- .../data/medals/MedalType.java | 2 +- .../kits/KitAlchemist.java | 2 +- .../kits/KitArcher.java | 10 +- .../kits/KitBuilder.java | 2 +- .../kits/KitDemolitionist.java | 2 +- .../kits/KitEnchanter.java | 2 +- .../kits/KitFighter.java | 2 +- .../kits/KitHardline.java | 2 +- .../kits/KitNinja.java | 2 +- .../kits/KitPlayer.java | 8 +- .../kits/KitTank.java | 2 +- .../kits/KitWorkman.java | 2 +- .../kits/PerkBloodlust.java | 2 +- .../game/games/castlesiege/CastleSiege.java | 2116 +++++++---------- .../games/castlesiege/CastleSiegeClassic.java | 973 -------- .../{classickits => kits}/KitHuman.java | 2 +- .../{classickits => kits}/KitHumanKnight.java | 2 +- .../KitHumanMarksman.java | 2 +- .../KitHumanPeasant.java | 2 +- .../{classickits => kits}/KitUndead.java | 2 +- .../KitUndeadArcher.java | 2 +- .../{classickits => kits}/KitUndeadGhoul.java | 2 +- .../KitUndeadZombie.java | 2 +- .../arcade/stats/BloodThirstyStatTracker.java | 2 +- .../arcade/stats/KingDamageStatTracker.java | 8 +- .../arcade/stats/KingSlayerStatTracker.java | 4 +- 40 files changed, 2783 insertions(+), 2746 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java rename Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/{castlesiege/CastleSiegeTDM.java => castleassault/CastleAssaultTDM.java} (97%) rename Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/{castlesiege => castleassault}/data/CapturePoint.java (90%) rename Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/{castlesiege => castleassault}/data/KillStreakData.java (85%) rename Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/{castlesiege => castleassault}/data/ObjectiveTNTSpawner.java (87%) rename Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/{castlesiege => castleassault}/data/TeamCrystal.java (89%) rename Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/{castlesiege => castleassault}/data/TeamKing.java (93%) rename Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/{castlesiege => castleassault}/data/medals/MedalData.java (93%) rename Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/{castlesiege => castleassault}/data/medals/MedalType.java (78%) rename Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/{castlesiege => castleassault}/kits/KitAlchemist.java (95%) rename Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/{castlesiege => castleassault}/kits/KitArcher.java (91%) rename Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/{castlesiege => castleassault}/kits/KitBuilder.java (95%) rename Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/{castlesiege => castleassault}/kits/KitDemolitionist.java (98%) rename Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/{castlesiege => castleassault}/kits/KitEnchanter.java (96%) rename Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/{castlesiege => castleassault}/kits/KitFighter.java (99%) rename Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/{castlesiege => castleassault}/kits/KitHardline.java (94%) rename Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/{castlesiege => castleassault}/kits/KitNinja.java (95%) rename Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/{castlesiege => castleassault}/kits/KitPlayer.java (88%) rename Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/{castlesiege => castleassault}/kits/KitTank.java (99%) rename Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/{castlesiege => castleassault}/kits/KitWorkman.java (95%) rename Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/{castlesiege => castleassault}/kits/PerkBloodlust.java (97%) delete mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiegeClassic.java rename Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/{classickits => kits}/KitHuman.java (90%) rename Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/{classickits => kits}/KitHumanKnight.java (97%) rename Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/{classickits => kits}/KitHumanMarksman.java (97%) rename Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/{classickits => kits}/KitHumanPeasant.java (96%) rename Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/{classickits => kits}/KitUndead.java (93%) rename Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/{classickits => kits}/KitUndeadArcher.java (97%) rename Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/{classickits => kits}/KitUndeadGhoul.java (96%) rename Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/{classickits => kits}/KitUndeadZombie.java (96%) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java index ff7e2344b..17b03158f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/Achievement.java @@ -373,79 +373,95 @@ public enum Achievement new String[]{"Win 30 games of Master Builders"}, new int[]{30}, AchievementCategory.MASTER_BUILDERS), - + //Castle Siege - CASTLE_SIEGE_KILL_STREAK("Kill Streak", 0, - new String[]{"Castle Siege.KillStreak", "Castle Siege TDM.KillStreak"}, + CASTLE_SIEGE_WINS("FOR THE KING!", 600, + new String[]{"Castle Siege.ForTheKing"}, + new String[]{"Win as Defenders 50 times"}, + new int[]{50}, + AchievementCategory.CASTLE_SIEGE), + + CASTLE_SIEGE_KINGSLAYER("Kingslayer", 800, + new String[]{"Castle Siege.KingSlayer"}, + new String[]{"Get the killing blow on the King"}, + new int[]{1}, + AchievementCategory.CASTLE_SIEGE), + + CASTLE_SIEGE_BLOOD_THIRSTY("Blood Thirsty", 1200, + new String[]{"Castle Siege.BloodThirsty"}, + new String[]{"Kill 50 Undead in a single game"}, + new int[]{1}, + AchievementCategory.CASTLE_SIEGE), + + CASTLE_SIEGE_ASSASSIN("Assassin", 1000, + new String[]{"Castle Siege.Assassin"}, + new String[]{"Do 50% or more of the damage to the king"}, + new int[]{1}, + AchievementCategory.CASTLE_SIEGE), + + //Castle Assault + CASTLE_ASSAULT_KILL_STREAK("Kill Streak", 0, + new String[]{"Castle Assault.KillStreak", "Castle Assault TDM.KillStreak"}, new String[]{"Earn Kill Streak Rewards"}, new int[][]{new int[]{0, 50, 500}, new int[]{0, 100, 750}, new int[]{0, 150, 1000}, new int[]{0, 200, 1500}, new int[]{0, 400, 2000}, new int[]{0, 500, 2500}, new int[]{0, 1000, 3000}, new int[]{0, 1500, 3500}, new int[]{0, 2000, 4000}, new int[]{0, 5000, 100000}}, new int[]{10, 20, 50, 100, 200, 250, 500, 750, 1000, 2000}, "Novice I", new String[]{"Novice II", "Novice III", "Novice IV", "Novice V", "Master I", "Master II", "Master III", "Master IV", "GRANDMASTER"}, - AchievementCategory.CASTLE_SIEGE), + AchievementCategory.CASTLE_ASSAULT), - CASTLE_SIEGE_FIRST_BLOOD("First Blood", 0, - new String[]{"Castle Siege.FirstBlood", "Castle Siege TDM.FirstBlood"}, + CASTLE_ASSAULT_FIRST_BLOOD("First Blood", 0, + new String[]{"Castle Assault.FirstBlood", "Castle Assault TDM.FirstBlood"}, new String[]{"Obtain the first kill in a Match"}, new int[][]{new int[]{0, 100, 100}, new int[]{0, 150, 200}, new int[]{0, 200, 300}, new int[]{0, 250, 400}, new int[]{0, 500, 500}}, new int[]{2, 5, 10, 25, 50}, "Novice I", new String[]{"Novice II", "Novice III", "Novice IV", "Novice V"}, - AchievementCategory.CASTLE_SIEGE), + AchievementCategory.CASTLE_ASSAULT), - CASTLE_SIEGE_FIGHTER_KIT("Fighter", 0, - new String[]{"Castle Siege.FighterKitKills", "Castle Siege TDM.FighterKitKills"}, + CASTLE_ASSAULT_FIGHTER_KIT("Fighter", 0, + new String[]{"Castle Assault.FighterKitKills", "Castle Assault TDM.FighterKitKills"}, new String[]{"Kill opponents while wearing the Fighter Kit"}, new int[][]{new int[]{0, 100, 500}, new int[]{0, 150, 750}, new int[]{0, 250, 1000}, new int[]{0, 500, 1500}, new int[]{0, 1000, 2500}, new int[]{0, 1500, 3500}, new int[]{0, 2000, 4500}, new int[]{0, 3000, 6000}, new int[]{0, 5000, 10000}, new int[]{0, 10000, 100000}}, new int[]{50, 100, 250, 500, 1000, 1500, 3000, 5000, 10000, 20000}, "Novice I", new String[]{"Novice II", "Novice III", "Novice IV", "Novice V", "Master I", "Master II", "Master III", "Master IV", "GRANDMASTER"}, - AchievementCategory.CASTLE_SIEGE), + AchievementCategory.CASTLE_ASSAULT), - CASTLE_SIEGE_TANK_KIT("Tank", 0, - new String[]{"Castle Siege.TankKitKills", "Castle Siege TDM.TankKitKills"}, + CASTLE_ASSAULT_TANK_KIT("Tank", 0, + new String[]{"Castle Assault.TankKitKills", "Castle Assault TDM.TankKitKills"}, new String[]{"Kill opponents while wearing the Tank Kit"}, new int[][]{new int[]{0, 100, 500}, new int[]{0, 150, 750}, new int[]{0, 250, 1000}, new int[]{0, 500, 1500}, new int[]{0, 1000, 2500}, new int[]{0, 1500, 3500}, new int[]{0, 2000, 4500}, new int[]{0, 3000, 6000}, new int[]{0, 5000, 10000}, new int[]{0, 10000, 100000}}, new int[]{50, 100, 250, 500, 1000, 1500, 3000, 5000, 10000, 20000}, "Novice I", new String[]{"Novice II", "Novice III", "Novice IV", "Novice V", "Master I", "Master II", "Master III", "Master IV", "GRANDMASTER"}, - AchievementCategory.CASTLE_SIEGE), + AchievementCategory.CASTLE_ASSAULT), - CASTLE_SIEGE_ARCHER_KIT("Archer", 0, - new String[]{"Castle Siege.ArcherKitKills", "Castle Siege TDM.ArcherKitKills"}, + CASTLE_ASSAULT_ARCHER_KIT("Archer", 0, + new String[]{"Castle Assault.ArcherKitKills", "Castle Assault TDM.ArcherKitKills"}, new String[]{"Kill opponents while wearing the Archer Kit"}, new int[][]{new int[]{0, 100, 500}, new int[]{0, 150, 750}, new int[]{0, 250, 1000}, new int[]{0, 500, 1500}, new int[]{0, 1000, 2500}, new int[]{0, 1500, 3500}, new int[]{0, 2000, 4500}, new int[]{0, 3000, 6000}, new int[]{0, 5000, 10000}, new int[]{0, 10000, 100000}}, new int[]{50, 100, 250, 500, 1000, 1500, 3000, 5000, 10000, 20000}, "Novice I", new String[]{"Novice II", "Novice III", "Novice IV", "Novice V", "Master I", "Master II", "Master III", "Master IV", "GRANDMASTER"}, - AchievementCategory.CASTLE_SIEGE), + AchievementCategory.CASTLE_ASSAULT), - CASTLE_SIEGE_DEMOLITIONIST_KIT("Demolitionist", 0, - new String[]{"Castle Siege.DemolitionistKitKills", "Castle Siege TDM.DemolitionistKitKills"}, + CASTLE_ASSAULT_DEMOLITIONIST_KIT("Demolitionist", 0, + new String[]{"Castle Assault.DemolitionistKitKills", "Castle Assault TDM.DemolitionistKitKills"}, new String[]{"Kill opponents while wearing the Demolitionist Kit"}, new int[][]{new int[]{0, 100, 500}, new int[]{0, 150, 750}, new int[]{0, 250, 1000}, new int[]{0, 500, 1500}, new int[]{0, 1000, 2500}, new int[]{0, 1500, 3500}, new int[]{0, 2000, 4500}, new int[]{0, 3000, 6000}, new int[]{0, 5000, 10000}, new int[]{0, 10000, 100000}}, new int[]{50, 100, 250, 500, 1000, 1500, 3000, 5000, 10000, 20000}, "Novice I", new String[]{"Novice II", "Novice III", "Novice IV", "Novice V", "Master I", "Master II", "Master III", "Master IV", "GRANDMASTER"}, - AchievementCategory.CASTLE_SIEGE), + AchievementCategory.CASTLE_ASSAULT), - CASTLE_SIEGE_WINNER("Siege", 0, - new String[]{"Castle Siege.Wins", "Castle Siege TDM.Wins"}, - new String[]{"Win games of Castle Siege"}, + CASTLE_ASSAULT_WINNER("Assault", 0, + new String[]{"Castle Assault.Wins", "Castle Assault TDM.Wins"}, + new String[]{"Win games of Castle Assault"}, new int[][]{new int[]{0, 100, 500}, new int[]{0, 150, 750}, new int[]{0, 250, 1000}, new int[]{0, 500, 1500}, new int[]{0, 1000, 2500}, new int[]{0, 1500, 3500}, new int[]{0, 2000, 4500}, new int[]{0, 3000, 6000}, new int[]{0, 5000, 10000}, new int[]{0, 10000, 100000}}, new int[]{2, 5, 25, 50, 100, 150, 250, 500, 1000, 2000}, "Novice I", new String[]{"Novice II", "Novice III", "Novice IV", "Novice V", "Master I", "Master II", "Master III", "Master IV", "GRANDMASTER"}, - AchievementCategory.CASTLE_SIEGE), - - CASTLE_SIEGE_MEDALIST("Medalist", 0, - new String[]{"Castle Siege.MedalsEarned", "Castle Siege TDM.MedalsEarned"}, - new String[]{"Earn Bronze, Silver, or Gold Medals in Castle Siege Matches"}, - new int[][]{new int[]{0, 100, 500}, new int[]{0, 150, 750}, new int[]{0, 250, 1000}, new int[]{0, 500, 1500}, new int[]{0, 1000, 2500}, new int[]{0, 1500, 3500}, new int[]{0, 2000, 4500}, new int[]{0, 3000, 6000}, new int[]{0, 5000, 10000}, new int[]{0, 10000, 100000}}, - new int[]{2, 50, 150, 250, 500, 1000, 1500, 2500, 5000, 10000}, - "Novice I", - new String[]{"Novice II", "Novice III", "Novice IV", "Novice V", "Master I", "Master II", "Master III", "Master IV", "GRANDMASTER"}, - AchievementCategory.CASTLE_SIEGE), + AchievementCategory.CASTLE_ASSAULT), //Champions CHAMPIONS_WINS("Champion", 600, diff --git a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java index 63cdf68c0..3a2d752df 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/achievement/AchievementCategory.java @@ -84,10 +84,15 @@ public enum AchievementCategory WIZARDS("Wizards", null, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, Material.BLAZE_ROD, 0, GameCategory.SURVIVAL, "Witch Doctor Kit", false, GameDisplay.Wizards.getGameId()), - - CASTLE_SIEGE("Castle Siege", new String[] {"Castle Siege", "Castle Siege TDM"}, + + CASTLE_ASSAULT("Castle Assault", new String[] {"Castle Assault", "Castle Assault TDM"}, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.CROWNS_EARNED }, - Material.DIAMOND_CHESTPLATE, 0, GameCategory.CLASSICS, null, false, GameDisplay.CastleSiege.getGameId(), GameDisplay.CastleSiegeTDM.getGameId()), + Material.DIAMOND_CHESTPLATE, 0, GameCategory.CLASSICS, null, false, GameDisplay.CastleAssault.getGameId(), GameDisplay.CastleAssaultTDM.getGameId()), + + CASTLE_SIEGE("Castle Siege", null, + new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, new StatDisplay("Kills as Defenders"), new StatDisplay("Deaths as Defenders"), + new StatDisplay("Kills as Undead"), new StatDisplay("Deaths as Undead"), StatDisplay.GEMS_EARNED }, + Material.DIAMOND_CHESTPLATE, 0, GameCategory.CLASSICS, null, false, GameDisplay.CastleSiege.getGameId()), BAWK_BAWK_BATTLES("Bawk Bawk Battles", null, new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.GEMS_EARNED }, diff --git a/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java b/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java index 5a63e6100..8de5d53a7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/game/GameDisplay.java @@ -14,8 +14,9 @@ public enum GameDisplay Barbarians("A Barbarians Life", Material.WOOD_AXE, (byte)0, GameCategory.EXTRA, 2, false), BossBattles("Boss Battles", Material.SKULL_ITEM, (byte) 0, GameCategory.EVENT, 55, false), Bridge("The Bridges", Material.IRON_PICKAXE, (byte)0, GameCategory.SURVIVAL, 3, true), - CastleSiege("Castle Siege", Material.DIAMOND_CHESTPLATE, (byte)0, GameCategory.CLASSICS, 67, true), - CastleSiegeTDM("Castle Siege TDM", Material.DIAMOND_CHESTPLATE, (byte)0, GameCategory.CLASSICS, 68, false), + CastleAssault("Castle Assault", Material.DIAMOND_CHESTPLATE, (byte)0, GameCategory.CLASSICS, 67, true), + CastleAssaultTDM("Castle Assault TDM", Material.DIAMOND_CHESTPLATE, (byte)0, GameCategory.CLASSICS, 68, false), + CastleSiege("Castle Siege", Material.DIAMOND_CHESTPLATE, (byte)0, GameCategory.CLASSICS, 4, true), ChampionsDominate("Champions Domination", "Champions", Material.BEACON, (byte)0, GameCategory.CHAMPIONS, 6, true), ChampionsTDM("Champions TDM", "Champions", Material.GOLD_SWORD, (byte)0, GameCategory.CHAMPIONS, 5, true), Christmas("Christmas Chaos", Material.SNOW_BALL, (byte)0, GameCategory.CLASSICS, 8, false), diff --git a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/Leaderboard.java b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/Leaderboard.java index 29087eb56..7b717f6ff 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/Leaderboard.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/Leaderboard.java @@ -8,23 +8,25 @@ import java.util.Map.Entry; import org.bukkit.Location; import mineplex.core.Managers; +import mineplex.core.common.Pair; import mineplex.core.common.util.C; import mineplex.core.hologram.Hologram; import mineplex.core.leaderboard.LeaderboardRepository.LeaderboardSQLType; public class Leaderboard { - private String _display, _statDisplay; + private String _display; + private Pair _statDisplay; private String[] _statIds; private int _size; private LeaderboardSQLType _type; private Location _loc; private Hologram _holo; - public Leaderboard(String display, String statDisplayName, String[] statIds, LeaderboardSQLType type, Location displayLoc, int size) + public Leaderboard(String display, Pair statDisplayNames, String[] statIds, LeaderboardSQLType type, Location displayLoc, int size) { _display = display; - _statDisplay = statDisplayName; + _statDisplay = statDisplayNames; _statIds = statIds; _type = type; _size = size; @@ -57,7 +59,14 @@ public class Leaderboard int place = 1; for (Entry entry : names.entrySet()) { - display.add(C.cGreen + "#" + place + " " + entry.getKey() + C.cRed + " " + entry.getValue() + " " + _statDisplay); + if (entry.getValue() == 1) + { + display.add(C.cGreen + "#" + place + " " + entry.getKey() + C.cRed + " " + entry.getValue() + " " + _statDisplay.getLeft()); + } + else + { + display.add(C.cGreen + "#" + place + " " + entry.getKey() + C.cRed + " " + entry.getValue() + " " + _statDisplay.getRight()); + } place++; } _holo = new Hologram(Managers.get(LeaderboardManager.class).getHologramManager(), _loc, display.toArray(new String[display.size()])).start(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/PreferenceMainMenu.java b/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/PreferenceMainMenu.java index ab07a6d8f..d8ee17525 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/PreferenceMainMenu.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/preferences/ui/PreferenceMainMenu.java @@ -30,7 +30,7 @@ public class PreferenceMainMenu extends Menu protected Button[] setUp(Player player) { Rank rank = getPlugin().getClientManager().Get(player).GetRank(); - boolean exclusive = rank.has(Rank.HELPER) || rank == Rank.YOUTUBE_SMALL || rank == Rank.YOUTUBE || rank == Rank.TWITCH; + boolean exclusive = rank.has(Rank.MAPDEV) || rank == Rank.YOUTUBE_SMALL || rank == Rank.YOUTUBE || rank == Rank.TWITCH; Button[] buttons = new Button[exclusive ? INV_SIZE_MAX : INV_SIZE_MIN]; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java index 76e5c38bf..dd64be771 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/GameType.java @@ -24,7 +24,8 @@ import nautilus.game.arcade.game.games.build.modes.DukesOfDecoration; import nautilus.game.arcade.game.games.build.modes.TeamBuild; import nautilus.game.arcade.game.games.buildmavericks.BuildMavericks; import nautilus.game.arcade.game.games.cards.Cards; -import nautilus.game.arcade.game.games.castlesiege.CastleSiegeTDM; +import nautilus.game.arcade.game.games.castleassault.CastleAssault; +import nautilus.game.arcade.game.games.castleassault.CastleAssaultTDM; import nautilus.game.arcade.game.games.castlesiege.CastleSiege; import nautilus.game.arcade.game.games.champions.ChampionsCTF; import nautilus.game.arcade.game.games.champions.ChampionsDominate; @@ -130,8 +131,9 @@ public enum GameType Basketball(Basketball.class, GameDisplay.Basketball), BossBattles(BossBattles.class, GameDisplay.BossBattles), Bridge(Bridge.class, GameDisplay.Bridge), + CastleAssault(CastleAssault.class, GameDisplay.CastleAssault), + CastleAssaultTDM(CastleAssaultTDM.class, GameDisplay.CastleAssaultTDM), CastleSiege(CastleSiege.class, GameDisplay.CastleSiege), - CastleSiegeTDM(CastleSiegeTDM.class, GameDisplay.CastleSiegeTDM), ChampionsCTF(ChampionsCTF.class, GameDisplay.ChampionsCTF), ChampionsDominate(ChampionsDominate.class, GameDisplay.ChampionsDominate), ChampionsTDM(ChampionsTDM.class, GameDisplay.ChampionsTDM), diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java new file mode 100644 index 000000000..d327f19d4 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java @@ -0,0 +1,1446 @@ +package nautilus.game.arcade.game.games.castleassault; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.WeakHashMap; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Color; +import org.bukkit.FireworkEffect.Type; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.block.Chest; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.EnderCrystal; +import org.bukkit.entity.EnderPearl; +import org.bukkit.entity.Entity; +import org.bukkit.entity.ItemFrame; +import org.bukkit.entity.Painting; +import org.bukkit.entity.Player; +import org.bukkit.entity.TNTPrimed; +import org.bukkit.entity.Zombie; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.block.BlockBurnEvent; +import org.bukkit.event.block.BlockDispenseEvent; +import org.bukkit.event.block.BlockFadeEvent; +import org.bukkit.event.block.BlockFormEvent; +import org.bukkit.event.block.BlockFromToEvent; +import org.bukkit.event.block.BlockPlaceEvent; +import org.bukkit.event.block.LeavesDecayEvent; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.entity.ExplosionPrimeEvent; +import org.bukkit.event.entity.ItemDespawnEvent; +import org.bukkit.event.entity.PlayerDeathEvent; +import org.bukkit.event.entity.ProjectileHitEvent; +import org.bukkit.event.hanging.HangingBreakEvent; +import org.bukkit.event.inventory.InventoryAction; +import org.bukkit.event.inventory.InventoryClickEvent; +import org.bukkit.event.inventory.InventoryType; +import org.bukkit.event.inventory.PrepareItemCraftEvent; +import org.bukkit.event.player.PlayerBucketEmptyEvent; +import org.bukkit.event.player.PlayerBucketFillEvent; +import org.bukkit.event.player.PlayerDropItemEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerPickupItemEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.material.Dispenser; +import org.bukkit.material.MaterialData; +import org.bukkit.metadata.FixedMetadataValue; +import org.bukkit.metadata.MetadataValue; +import org.bukkit.util.Vector; + +import mineplex.core.Managers; +import mineplex.core.common.Pair; +import mineplex.core.common.util.C; +import mineplex.core.common.util.F; +import mineplex.core.common.util.UtilAction; +import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilEvent.ActionType; +import mineplex.core.common.util.UtilFirework; +import mineplex.core.common.util.UtilInv; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilServer; +import mineplex.core.common.util.UtilTextBottom; +import mineplex.core.common.util.UtilTime; +import mineplex.core.itemstack.EnchantedBookBuilder; +import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.leaderboard.Leaderboard; +import mineplex.core.leaderboard.LeaderboardManager; +import mineplex.core.leaderboard.LeaderboardRepository.LeaderboardSQLType; +import mineplex.core.loot.ChestLoot; +import mineplex.core.recharge.Recharge; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; +import mineplex.minecraft.game.core.combat.DeathMessageType; +import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; +import mineplex.minecraft.game.core.damage.CustomDamageEvent; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.GameType; +import nautilus.game.arcade.events.FirstBloodEvent; +import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.game.GameTeam; +import nautilus.game.arcade.game.GemData; +import nautilus.game.arcade.game.TeamGame; +import nautilus.game.arcade.game.games.castleassault.data.KillStreakData; +import nautilus.game.arcade.game.games.castleassault.data.ObjectiveTNTSpawner; +import nautilus.game.arcade.game.games.castleassault.data.TeamCrystal; +import nautilus.game.arcade.game.games.castleassault.data.TeamKing; +import nautilus.game.arcade.game.games.castleassault.kits.KitArcher; +import nautilus.game.arcade.game.games.castleassault.kits.KitDemolitionist; +import nautilus.game.arcade.game.games.castleassault.kits.KitFighter; +import nautilus.game.arcade.game.games.castleassault.kits.KitPlayer; +import nautilus.game.arcade.game.games.castleassault.kits.KitTank; +import nautilus.game.arcade.game.modules.compass.CompassModule; +import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.managers.lobby.current.NewGameLobbyManager; + +public class CastleAssault extends TeamGame +{ + private static final int MAX_FLINT_AND_STEEL_USES = 4; + private static final int ITEMS_PER_CHEST = 5; + private static final long TIME_TILL_REFILL = 2 * 60 * 1000; + + private long _lastRefill; + + private ItemBuilder _flintAndSteel; + private ItemBuilder _wearableTnt; + + private Map _streakData = new WeakHashMap<>(); + private Map> _crystals = new HashMap<>(); + private Map _kings = new HashMap<>(); + private List _tntCarry = new ArrayList<>(); + + private List _chests = new ArrayList<>(); + + private ChestLoot _diamondGearCommon = new ChestLoot(true); + private ChestLoot _diamondGearRare = new ChestLoot(true); + private ChestLoot _weaponGearCommon = new ChestLoot(true); + private ChestLoot _weaponGearRare = new ChestLoot(true); + private ChestLoot _rangedGear = new ChestLoot(true); + private ChestLoot _rodsAndGaps = new ChestLoot(true); + private ChestLoot _potionGearCommon = new ChestLoot(true); + private ChestLoot _potionGearRare = new ChestLoot(true); + private ChestLoot _enchantGearCommon = new ChestLoot(true); + private ChestLoot _enchantGearRare = new ChestLoot(true); + private ChestLoot _miscGear = new ChestLoot(); + + private ObjectiveTNTSpawner _tntSpawner; + + private boolean _writeScoreboard = true; + + @SuppressWarnings("deprecation") + public CastleAssault(ArcadeManager manager) + { + super(manager, GameType.CastleAssault, + new Kit[] + { + //new KitAlchemist(manager), + new KitArcher(manager), + new KitDemolitionist(manager), + //new KitEnchanter(manager), + new KitFighter(manager), + //new KitHardline(manager), + //new KitNinja(manager), + new KitTank(manager) + }, + new String[] + { + "Destroy enemy sentry crystals with running TNT", + "After the crystals are destroyed you must slay their king", + "First team to kill the enemy king wins", + "Chests refill every 2 minutes", + "TNT Respawns every 1 minute" + } + ); + + _help = new String[] + { + "Use the TNT spawning platforms to run TNT to the enemy crystals to destroy them!", + "The enemy king is invulnerable until you destroy the two sentry crystals on each sentry tower", + "Go on Kill Streaks to earn Kill Streak Rewards to obtain better armor & weapons!", + "Chests refill every 2 minutes with potions, golden applegates, fishing rods, and other useful PvP items!" + }; + + this.StrictAntiHack = true; + this.HungerSet = 20; + this.DeathOut = false; + this.DeathSpectateSecs = 5; + this.CreatureAllow = false; + this.DeathDropItems = false; + this.WorldWeatherEnabled = false; + this.AllowParticles = false; + this.SoupEnabled = false; + this.InventoryClick = true; + this.InventoryOpenChest = true; + this.InventoryOpenBlock = true; + this.ItemDrop = true; + this.ItemPickup = true; + this.AllowFlintAndSteel = true; + this.BlockPlaceAllow.add(Material.FIRE.getId()); + this.CrownsEnabled = true; + this.Leaderboards = true; + this.FirstKillReward = 20; + this.GemKillDeathRespawn = 1; + + new CompassModule() + .setGiveCompass(true) + .setGiveCompassToSpecs(true) + .setGiveCompassToAlive(false) + .register(this); + + _flintAndSteel = new ItemBuilder(Material.FLINT_AND_STEEL).setData((short) (Material.FLINT_AND_STEEL.getMaxDurability() - MAX_FLINT_AND_STEEL_USES)); + _wearableTnt = new ItemBuilder(Material.TNT).setTitle(C.cRed + "TNT").addLore(C.cRedB + "Right Click with Weapon to " + F.name("Detonate")); + generateLoot(); + + if (manager.IsRewardStats()) + { + if (manager.GetLobby() instanceof NewGameLobbyManager) + { + Map> lobbyCustomLocs = ((NewGameLobbyManager)manager.GetLobby()).getCustomLocs(); + if (lobbyCustomLocs.containsKey("TOP_DAILY_WINS")) + { + Location loc = lobbyCustomLocs.get("TOP_DAILY_WINS").get(0); + Managers.get(LeaderboardManager.class).registerLeaderboard("TOP_CASTLEASSAULT_DAILY_WINS", new Leaderboard("Top Daily Wins", Pair.create("Win", "Wins"), new String[] {"Castle Assault.Wins"}, LeaderboardSQLType.DAILY, loc, 10)); + } + if (lobbyCustomLocs.containsKey("TOP_DAILY_KILLS")) + { + Location loc = lobbyCustomLocs.get("TOP_DAILY_KILLS").get(0); + Managers.get(LeaderboardManager.class).registerLeaderboard("TOP_CASTLEASSAULT_DAILY_KILLS", new Leaderboard("Top Daily Kills", Pair.create("Kill", "Kills"), new String[] {"Castle Assault.Kills"}, LeaderboardSQLType.DAILY, loc, 10)); + } + if (lobbyCustomLocs.containsKey("TOP_WINS")) + { + Location loc = lobbyCustomLocs.get("TOP_WINS").get(0); + Managers.get(LeaderboardManager.class).registerLeaderboard("TOP_CASTLEASSAULT_WINS", new Leaderboard("Top Wins", Pair.create("Win", "Wins"), new String[] {"Castle Assault.Wins"}, LeaderboardSQLType.ALL, loc, 10)); + } + if (lobbyCustomLocs.containsKey("TOP_KILLS")) + { + Location loc = lobbyCustomLocs.get("TOP_KILLS").get(0); + Managers.get(LeaderboardManager.class).registerLeaderboard("TOP_CASTLEASSAULT_KILLS", new Leaderboard("Top Kills", Pair.create("Kill", "Kills"), new String[] {"Castle Assault.Kills"}, LeaderboardSQLType.ALL, loc, 10)); + } + } + } + } + + private void generateLoot() + { + { + _diamondGearCommon.addLoot(new ItemStack(Material.DIAMOND_HELMET), 2); + _diamondGearCommon.addLoot(new ItemStack(Material.DIAMOND_CHESTPLATE), 2); + _diamondGearCommon.addLoot(new ItemStack(Material.DIAMOND_LEGGINGS), 2); + _diamondGearCommon.addLoot(new ItemStack(Material.DIAMOND_BOOTS), 2); + _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_HELMET).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1).build(), 1); + _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_CHESTPLATE).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1).build(), 1); + _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_LEGGINGS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1).build(), 1); + _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_BOOTS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1).build(), 1); + _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_HELMET).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).build(), 1); + _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_CHESTPLATE).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).build(), 1); + _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_LEGGINGS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).build(), 1); + _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_BOOTS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).build(), 1); + _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_HELMET).addEnchantment(Enchantment.PROTECTION_PROJECTILE, 3).build(), 1); + _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_CHESTPLATE).addEnchantment(Enchantment.PROTECTION_PROJECTILE, 3).build(), 1); + _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_LEGGINGS).addEnchantment(Enchantment.PROTECTION_PROJECTILE, 3).build(), 1); + _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_BOOTS).addEnchantment(Enchantment.PROTECTION_PROJECTILE, 3).build(), 1); + } + { + _diamondGearRare.addLoot(new ItemBuilder(Material.DIAMOND_HELMET).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4).build(), 1); + _diamondGearRare.addLoot(new ItemBuilder(Material.DIAMOND_CHESTPLATE).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4).build(), 1); + _diamondGearRare.addLoot(new ItemBuilder(Material.DIAMOND_LEGGINGS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4).build(), 1); + _diamondGearRare.addLoot(new ItemBuilder(Material.DIAMOND_BOOTS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4).build(), 1); + } + { + _weaponGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_SWORD).build(), 2); + _weaponGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_SWORD).addEnchantment(Enchantment.DAMAGE_ALL, 1).build(), 2); + } + { + _weaponGearRare.addLoot(new ItemBuilder(Material.DIAMOND_SWORD).addEnchantment(Enchantment.DAMAGE_ALL, 2).build(), 1); + } + { + _rangedGear.addLoot(new ItemStack(Material.BOW), 3); + _rangedGear.addLoot(Material.ARROW, 3, 8, 16); + } + { + _rodsAndGaps.addLoot(new ItemStack(Material.FISHING_ROD), 3); + _rodsAndGaps.addLoot(new ItemBuilder(Material.GOLDEN_APPLE).setTitle(C.cPurple + "Golden Applegate").build(), 3); + } + { + _potionGearCommon.addLoot(new ItemBuilder(Material.POTION).setData((short)16418).build(), 2); + _potionGearCommon.addLoot(new ItemBuilder(Material.POTION).setData((short)16417).build(), 2); + } + { + _potionGearRare.addLoot(new ItemBuilder(Material.POTION).setData((short)8193).build(), 2); + _potionGearRare.addLoot(new ItemBuilder(Material.POTION).setData((short)8195).build(), 2); + } + { + _enchantGearCommon.addLoot(new EnchantedBookBuilder(1).setLevel(Enchantment.PROTECTION_ENVIRONMENTAL, 1).build(), 2); + _enchantGearCommon.addLoot(new EnchantedBookBuilder(1).setLevel(Enchantment.DAMAGE_ALL, 1).build(), 2); + _enchantGearCommon.addLoot(new EnchantedBookBuilder(1).setLevel(Enchantment.ARROW_DAMAGE, 1).build(), 2); + _enchantGearCommon.addLoot(new ItemStack(Material.EXP_BOTTLE, 64), 1); + } + { + _enchantGearRare.addLoot(new EnchantedBookBuilder(1).setLevel(Enchantment.FIRE_ASPECT, 1).build(), 1); + } + { + _miscGear.addLoot(new ItemStack(Material.ENDER_PEARL), 2); + _miscGear.addLoot(new ItemStack(Material.WATER_BUCKET), 2); + _miscGear.addLoot(_flintAndSteel.build(), 2); + _miscGear.addLoot(new ItemStack(Material.SNOW_BALL, 16), 3); + } + } + + private void fillChest(Block block) + { + if (block.getType() != Material.CHEST && block.getType() != Material.TRAPPED_CHEST) + { + return; + } + Chest chest = (Chest) block.getState(); + + chest.getBlockInventory().clear(); + int[] slots = UtilMath.random.ints(ITEMS_PER_CHEST, 0, chest.getBlockInventory().getSize()).toArray(); + + for (int slot : slots) + { + double chance = UtilMath.random.nextDouble(); + double subChance = UtilMath.random.nextDouble(); + + ChestLoot loot = _miscGear; + if (chance <= 0.6) + { + loot = _rodsAndGaps; + } + if (chance <= 0.5) + { + loot = _potionGearCommon; + if (subChance <= 0.45) + { + loot = _potionGearRare; + } + } + if (chance <= 0.3) + { + loot = _rangedGear; + } + chest.getBlockInventory().setItem(slot, loot.getLoot()); + } + } + + public ItemStack getNewFlintAndSteel(boolean kitItem) + { + if (kitItem) + { + return _flintAndSteel.clone().setLore(C.cGold + "Kit Item").build(); + } + return _flintAndSteel.build(); + } + + public void writeScoreboard() + { + if (!_writeScoreboard) + { + return; + } + Scoreboard.reset(); + Scoreboard.write(C.cDRedB + GetName()); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cGreenB + "Chest Refill"); + long refillTime = _lastRefill + TIME_TILL_REFILL - System.currentTimeMillis(); + if (!IsLive()) + { + refillTime = TIME_TILL_REFILL; + } + Scoreboard.write(UtilTime.MakeStr(refillTime)); + Scoreboard.writeNewLine(); + Scoreboard.write(C.cGreenB + "TNT Spawn"); + long tntTime = _tntSpawner.getNextTNT(); + if (!IsLive()) + { + tntTime = 60000; + } + if (_tntSpawner.isSpawned()) + { + Scoreboard.write("Spawned"); + } + else + { + Scoreboard.write(UtilTime.MakeStr(tntTime)); + } + Scoreboard.writeNewLine(); + GameTeam red = GetTeam(ChatColor.RED); + long redCrystals = _crystals.get(red).stream().filter(TeamCrystal::isActive).count(); + GameTeam blue = GetTeam(ChatColor.AQUA); + long blueCrystals = _crystals.get(blue).stream().filter(TeamCrystal::isActive).count(); + if (redCrystals > 0) + { + Scoreboard.write(_kings.get(red).getName(true)); + Scoreboard.write(redCrystals + "/2 Crystals Active"); + } + else + { + Scoreboard.write(_kings.get(red).getName(true) + " Health"); + Scoreboard.write(_kings.get(red).getHealth() + ""); + } + Scoreboard.writeNewLine(); + if (blueCrystals > 0) + { + Scoreboard.write(_kings.get(blue).getName(true)); + Scoreboard.write(blueCrystals + "/2 Crystals Active"); + } + else + { + Scoreboard.write(_kings.get(blue).getName(true) + " Health"); + Scoreboard.write(_kings.get(blue).getHealth() + ""); + } + Scoreboard.draw(); + } + + public void writeFinalScoreboard(String deadKing, String winKing, String warrior) + { + _writeScoreboard = false; + Scoreboard.reset(); + Scoreboard.writeNewLine(); + Scoreboard.write(deadKing + "'s " + C.cWhite + "castle has been conquered"); + Scoreboard.write(C.cWhite + "by " + winKing + "'s " + C.cWhite + "army with the help of"); + Scoreboard.write(warrior + C.cWhite + "!"); + Scoreboard.writeNewLine(); + + Scoreboard.draw(); + } + + @Override + public void ParseData() + { + for (Location chestLoc : WorldData.GetDataLocs("BROWN")) + { + Block block = chestLoc.getBlock(); + block.setType(Material.CHEST); + fillChest(block); + _chests.add(block); + } + GameTeam red = GetTeam(ChatColor.RED); + GameTeam blue = GetTeam(ChatColor.AQUA); + Location redKing = WorldData.GetDataLocs("RED").get(0); + Location blueKing = WorldData.GetDataLocs("BLUE").get(0); + Vector redBlue = UtilAlg.getTrajectory(redKing, blueKing); + Vector blueRed = UtilAlg.getTrajectory(blueKing, redKing); + redKing.setPitch(UtilAlg.GetPitch(redBlue)); + redKing.setYaw(UtilAlg.GetYaw(redBlue)); + blueKing.setPitch(UtilAlg.GetPitch(blueRed)); + blueKing.setYaw(UtilAlg.GetYaw(blueRed)); + _crystals.put(red, Arrays.asList(new TeamCrystal(red, WorldData.GetDataLocs("PINK").get(0)), new TeamCrystal(red, WorldData.GetDataLocs("PINK").get(1)))); + _crystals.put(blue, Arrays.asList(new TeamCrystal(blue, WorldData.GetDataLocs("LIGHT_BLUE").get(0)), new TeamCrystal(blue, WorldData.GetDataLocs("LIGHT_BLUE").get(1)))); + this.CreatureAllowOverride = true; + _kings.put(red, new TeamKing(red, "King Jon", redKing)); + _kings.put(blue, new TeamKing(blue, "King Ryan", blueKing)); + int kitIndex = 0; + for (int i = 0; i < WorldData.GetDataLocs("WHITE").size(); i++) + { + if (kitIndex >= GetKits().length) + { + kitIndex = 0; + } + Entity ent = GetKits()[kitIndex].SpawnEntity(WorldData.GetDataLocs("WHITE").get(i)); + Manager.GetLobby().addKitLocation(ent, GetKits()[kitIndex], WorldData.GetDataLocs("WHITE").get(i)); + kitIndex++; + } + this.CreatureAllowOverride = false; + _tntSpawner = new ObjectiveTNTSpawner(WorldData.GetDataLocs("BLACK")); + } + + @Override + public void EndCheck() + { + if (!IsLive()) + { + return; + } + + List teamsAlive = new ArrayList<>(); + + for (GameTeam team : GetTeamList()) + { + if (team.GetPlayers(true).size() > 0) + { + teamsAlive.add(team); + } + } + + if (teamsAlive.size() <= 1) + { + //Announce + if (teamsAlive.size() > 0) + { + GameTeam winner = teamsAlive.get(0); + TeamKing king = _kings.get(winner); + TeamKing dead = _kings.values().stream().filter(k -> k.getOwner().GetColor() != king.getOwner().GetColor()).findFirst().get(); + AnnounceEnd(winner); + writeFinalScoreboard(dead.getName(false), king.getName(false), dead.getOwner().GetColor() + "Quitters"); + for (GameTeam team : GetTeamList()) + { + for (Player player : team.GetPlayers(true)) + { + if (team.GetColor() == winner.GetColor()) + { + AddGems(player, 100, "Winning Team", false, false); + } + else + { + AddGems(player, 50, "Losing Team", false, false); + } + if (player.isOnline()) + { + AddGems(player, 10, "Participation", false, false); + } + + { + int crowns = 0; + for (GemData data : GetGems(player).values()) + { + crowns += data.Gems; + } + int streak = _streakData.getOrDefault(player, new KillStreakData()).getBestStreak(); + if (streak >= 2 && streak < 4) + { + AddGems(player, 0.5 * crowns, streak + " Player Kill Streak", false, false); + } + else if (streak >= 4 && streak < 6) + { + AddGems(player, crowns, streak + " Player Kill Streak", false, false); + } + else if (streak >= 6 && streak < 8) + { + AddGems(player, 1.5 * crowns, streak + " Player Kill Streak", false, false); + } + else if (streak >= 8) + { + AddGems(player, 2 * crowns, streak + " Player Kill Streak", false, false); + } + } + + if (GetKit(player) != null) + { + KitPlayer kit = (KitPlayer) GetKit(player); + int kitLevel = kit.getUpgradeLevel(player.getUniqueId()); + if (kitLevel > 0) + { + int crowns = 0; + for (GemData data : GetGems(player).values()) + { + crowns += data.Gems; + } + + AddGems(player, (0.5 * kitLevel) * crowns, kit.GetName() + " Kit Level Bonus", false, false); + } + } + } + } + SetState(GameState.End); + return; + } + } + } + + @Override + @EventHandler + public void ScoreboardUpdate(UpdateEvent event) {}; + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + { + return; + } + if (IsLive()) + { + if (UtilTime.elapsed(_lastRefill, TIME_TILL_REFILL)) + { + _lastRefill = System.currentTimeMillis(); + _chests.forEach(this::fillChest); + Bukkit.broadcastMessage(C.cGreenB + "Chests have refilled!"); + } + + GameTeam red = GetTeam(ChatColor.RED); + GameTeam blue = GetTeam(ChatColor.AQUA); + TeamKing redKing = _kings.get(red); + TeamKing blueKing = _kings.get(blue); + redKing.update(_crystals.get(red).stream().filter(TeamCrystal::isActive).count() > 0); + if (redKing.isDead()) + { + AnnounceEnd(blue); + writeFinalScoreboard(redKing.getName(false), blueKing.getName(false), blue.GetColor() + redKing.getLastDamager()); + for (GameTeam team : GetTeamList()) + { + for (Player player : team.GetPlayers(true)) + { + if (player.getName().equals(redKing.getLastDamager())) + { + AddGems(player, 20, "King Slayer", false, false); + } + if (team.GetColor() == ChatColor.AQUA) + { + AddGems(player, 100, "Winning Team", false, false); + } + else + { + AddGems(player, 50, "Losing Team", false, false); + } + if (player.isOnline()) + { + AddGems(player, 10, "Participation", false, false); + } + + int streak = _streakData.getOrDefault(player, new KillStreakData()).getBestStreak(); + if (streak > 0) + { + AddGems(player, streak, streak + " Player Kill Streak", false, false); + } + + KitPlayer kit = (KitPlayer) GetKit(player); + int kitLevel = kit.getUpgradeLevel(player.getUniqueId()); + if (kitLevel > 0) + { + int crowns = 0; + for (GemData data : GetGems(player).values()) + { + crowns += data.Gems; + } + + AddGems(player, (0.5 * kitLevel) * crowns, kit.GetName() + " Kit Level Bonus", false, false); + } + } + } + SetState(GameState.End); + return; + } + blueKing.update(_crystals.get(blue).stream().filter(TeamCrystal::isActive).count() > 0); + if (blueKing.isDead()) + { + AnnounceEnd(red); + writeFinalScoreboard(blueKing.getName(false), redKing.getName(false), red.GetColor() + blueKing.getLastDamager()); + for (GameTeam team : GetTeamList()) + { + for (Player player : team.GetPlayers(true)) + { + if (player.getName().equals(blueKing.getLastDamager())) + { + AddGems(player, 20, "King Slayer", false, false); + } + if (team.GetColor() == ChatColor.RED) + { + AddGems(player, 100, "Winning Team", false, false); + } + else + { + AddGems(player, 50, "Losing Team", false, false); + } + if (player.isOnline()) + { + AddGems(player, 10, "Participation", false, false); + } + + int streak = _streakData.getOrDefault(player, new KillStreakData()).getBestStreak(); + if (streak > 0) + { + AddGems(player, streak, streak + " Player Kill Streak", false, false); + } + + KitPlayer kit = (KitPlayer) GetKit(player); + int kitLevel = kit.getUpgradeLevel(player.getUniqueId()); + if (kitLevel > 0) + { + int crowns = 0; + for (GemData data : GetGems(player).values()) + { + crowns += data.Gems; + } + + AddGems(player, (0.5 * kitLevel) * crowns, kit.GetName() + " Kit Level Bonus", false, false); + } + } + } + SetState(GameState.End); + return; + } + + _tntSpawner.update(); + } + if (InProgress()) + { + writeScoreboard(); + } + } + + @EventHandler + public void onEditSettings(GameStateChangeEvent event) + { + if (event.GetGame() != this) + { + return; + } + + if (event.GetState() == GameState.Live) + { + _lastRefill = System.currentTimeMillis(); + _tntSpawner.onStart(); + Manager.GetDamage().SetEnabled(false); + Manager.GetExplosion().setEnabled(false); + Manager.GetCreature().SetDisableCustomDrops(true); + } + + if (event.GetState() == GameState.End) + { + Manager.GetDamage().SetEnabled(true); + Manager.GetExplosion().setEnabled(true); + Manager.GetCreature().SetDisableCustomDrops(false); + Managers.get(LeaderboardManager.class).unregisterLeaderboard("TOP_CASTLEASSAULT_DAILY_WINS"); + Managers.get(LeaderboardManager.class).unregisterLeaderboard("TOP_CASTLEASSAULT_DAILY_KILLS"); + Managers.get(LeaderboardManager.class).unregisterLeaderboard("TOP_CASTLEASSAULT_WINS"); + Managers.get(LeaderboardManager.class).unregisterLeaderboard("TOP_CASTLEASSAULT_KILLS"); + } + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void handleDeath(CombatDeathEvent event) + { + if (!IsLive()) + { + return; + } + + event.SetBroadcastType(DeathMessageType.Detailed); + } + + @EventHandler + public void disableDamageLevel(CustomDamageEvent event) + { + event.SetDamageToLevel(false); + } + + @EventHandler + public void BlockFade(BlockFadeEvent event) + { + event.setCancelled(true); + } + + @EventHandler + public void BlockBurn(BlockBurnEvent event) + { + event.setCancelled(true); + } + + @EventHandler + public void BlockDecay(LeavesDecayEvent event) + { + event.setCancelled(true); + } + + @EventHandler + public void hangingBreak(HangingBreakEvent event) + { + if (event.getEntity() instanceof ItemFrame || event.getEntity() instanceof Painting) + { + event.setCancelled(true); + } + } + + @EventHandler + public void noFlow(BlockFromToEvent event) + { + if (!IsLive()) + { + return; + } + + Block block = event.getBlock(); + if (block.getType() == Material.WATER || block.getType() == Material.STATIONARY_WATER || block.getType() == Material.LAVA || block.getType() == Material.STATIONARY_LAVA) + { + event.setCancelled(true); + } + if (event.getToBlock().getType() == Material.ICE) + { + event.setCancelled(true); + } + } + + @EventHandler + public void onBlockChange(BlockFormEvent e) + { + if (!IsLive()) + { + return; + } + if (e.getNewState().getType() == Material.ICE) + { + e.setCancelled(true); + } + } + + @SuppressWarnings("deprecation") + @EventHandler(ignoreCancelled=true) + public void onPlayerEmptyBucket(PlayerBucketEmptyEvent event) + { + if (!IsLive()) + { + return; + } + + Player player = event.getPlayer(); + if (player.getItemInHand().getType() == Material.WATER_BUCKET) + { + player.getItemInHand().setType(Material.BUCKET); + Block block = event.getBlockClicked().getRelative(event.getBlockFace()); + if (block.getType().toString().contains("LAVA") || (block.getType().toString().contains("WATER") && block.getType() != Material.WATER_LILY)) + { + event.setCancelled(true); + player.sendBlockChange(block.getLocation(), block.getType(), block.getData()); + return; + } + for (BlockFace bf : BlockFace.values()) + { + Block relative = block.getRelative(bf); + if (relative.getType().toString().contains("LAVA") || (relative.getType().toString().contains("WATER") && relative.getType() != Material.WATER_LILY)) + { + event.setCancelled(true); + player.sendBlockChange(block.getLocation(), block.getType(), block.getData()); + } + } + } + else if (player.getItemInHand().getType() == Material.LAVA_BUCKET) + { + event.setCancelled(true); + Block block = event.getBlockClicked().getRelative(event.getBlockFace()); + player.sendBlockChange(block.getLocation(), block.getType(), block.getData()); + } + } + + @SuppressWarnings("deprecation") + @EventHandler(ignoreCancelled=true) + public void onPlayerEmptyBucket(PlayerBucketFillEvent event) + { + if (!IsLive()) + { + return; + } + + Player player = event.getPlayer(); + if (player.getItemInHand().getType() == Material.LAVA_BUCKET) + { + event.setCancelled(true); + Block block = event.getBlockClicked().getRelative(event.getBlockFace()); + player.sendBlockChange(block.getLocation(), block.getType(), block.getData()); + } + } + + @EventHandler(ignoreCancelled=true) + public void onBlockDispense(BlockDispenseEvent event) + { + if (!IsLive()) + { + return; + } + + if (event.getItem().getType() == Material.WATER_BUCKET) + { + Block dispenser = event.getBlock(); + + MaterialData mat = dispenser.getState().getData(); + Dispenser disp_mat = (Dispenser)mat; + BlockFace face = disp_mat.getFacing(); + Block block = dispenser.getRelative(face); + if (block.getType().toString().contains("LAVA") || (block.getType().toString().contains("WATER") && block.getType() != Material.WATER_LILY)) + { + event.setCancelled(true); + return; + } + for (BlockFace bf : BlockFace.values()) + { + if (block.getRelative(bf).getType().toString().contains("LAVA") || (block.getRelative(bf).getType().toString().contains("WATER") && block.getRelative(bf).getType() != Material.WATER_LILY)) + { + event.setCancelled(true); + } + } + } + } + + @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) + public void onCombatDeath(CombatDeathEvent event) + { + if (!IsLive()) + { + return; + } + + if (event.GetLog().GetKiller() == null) + { + return; + } + + if (!event.GetLog().GetKiller().IsPlayer()) + { + return; + } + + Player player = UtilPlayer.searchExact(event.GetLog().GetKiller().GetName()); + if (player == null) + { + return; + } + + AddStat(player, GetKit(player).GetName() + "KitKills", 1, false, false); + + if (UtilPlayer.isSpectator(player)) + { + return; + } + + player.setLevel(player.getLevel() + 1); + player.getInventory().addItem(new ItemBuilder(Material.GOLDEN_APPLE).setTitle(C.cPurple + "Golden Applegate").build()); + KillStreakData data = _streakData.computeIfAbsent(player, (key) -> new KillStreakData()); + boolean hardLine = GetKit(player).GetName().equals("Hardline"); + if (data.addKill(hardLine)) + { + AddStat(player, "KillStreak", 1, false, false); + ((KitPlayer)GetKit(player)).awardKillStreak(player, hardLine ? (data.getKills() + 1) : data.getKills()); + } + if (UtilMath.isEven(data.getKills())) + { + Bukkit.broadcastMessage(F.main("Game", C.cGreen + C.Bold + player.getName() + ChatColor.RESET + " is on a " + F.elem(C.cDPurple + data.getKills() + " player Kill Streak") + "!")); + } + } + + @EventHandler + public void TNTExplosion(ExplosionPrimeEvent event) + { + if (!event.getEntity().hasMetadata("THROWER")) + { + return; + } + float radius = event.getRadius(); + event.setRadius(0f); + + Player player = UtilPlayer.searchExact(((MetadataValue)UtilEnt.GetMetadata(event.getEntity(), "THROWER")).asString()); + if (player == null) + { + return; + } + if (GetTeam(player) == null) + { + return; + } + if (GetKit(player).GetName().equals("Demolitionist")) + { + radius += 3; + } + + Map nearby = UtilPlayer.getInRadius(event.getEntity().getLocation(), radius); + for (Player near : nearby.keySet()) + { + if (UtilPlayer.isSpectator(near)) + { + continue; + } + if (near.getEntityId() != player.getEntityId() && GetTeam(near).GetColor() == GetTeam(player).GetColor()) + { + continue; + } + if (near.getEntityId() == player.getEntityId() && event.getEntity().hasMetadata("OBJECTIVE_TNT")) + { + continue; + } + + double mult = nearby.get(near); + + int highestBlastProt = 0; + int blastProtEPF = 0; + for (ItemStack item : near.getInventory().getArmorContents()) + { + if (item != null && item.getEnchantments().containsKey(Enchantment.PROTECTION_EXPLOSIONS)) + { + blastProtEPF += (2 * item.getEnchantmentLevel(Enchantment.PROTECTION_EXPLOSIONS)); + if (item.getEnchantmentLevel(Enchantment.PROTECTION_EXPLOSIONS) > highestBlastProt) + { + highestBlastProt = item.getEnchantmentLevel(Enchantment.PROTECTION_EXPLOSIONS); + } + } + } + blastProtEPF = Math.min(blastProtEPF, 20); + + double damage = 8 * mult; + damage = damage * (1 - (blastProtEPF / 25)); + + double knockbackReduction = 1 - (highestBlastProt * 0.15); + + near.damage(damage, event.getEntity()); + UtilAction.velocity(near, UtilAlg.getTrajectory(event.getEntity().getLocation(), near.getLocation()), 1 * mult * knockbackReduction, false, 0, mult * knockbackReduction, 10, true); + } + + if (event.getEntity().hasMetadata("OBJECTIVE_TNT")) + { + List crystals = new ArrayList<>(); + + for (List c : _crystals.values()) + { + crystals.addAll(c); + } + for (TeamCrystal crystal : crystals) + { + if (crystal.isActive() && !crystal.getOwner().HasPlayer(player) && UtilMath.offset(event.getEntity().getLocation(), crystal.getLocation()) <= radius) + { + crystal.destroy(); + AddGems(player, 40, "Crystal Destruction", false, true); + long remaining = crystals.stream().filter(b -> b.getOwner().GetColor() == crystal.getOwner().GetColor()).filter(TeamCrystal::isActive).count(); + if (remaining > 0) + { + Bukkit.broadcastMessage(F.main("Game", "One of " + F.elem(crystal.getOwner().GetFormattedName() + "'s Crystals") + " has been destroyed!")); + } + else + { + Bukkit.broadcastMessage(F.main("Game", "All of " + F.elem(crystal.getOwner().GetFormattedName() + "'s Crystals") + " has been destroyed and " + F.elem(_kings.get(crystal.getOwner()).getName(false)) + " is now vulnerable!")); + } + } + } + for (TeamKing king : _kings.values()) + { + if (king.isDead() && !king.getOwner().HasPlayer(player) && UtilMath.offset(event.getEntity().getLocation(), king.getLocation()) <= radius) + { + king.handleDamage(player.getName(), 50); + } + } + } + } + + @EventHandler + public void TNTThrow(PlayerInteractEvent event) + { + if (!IsLive()) + { + return; + } + + if (!UtilEvent.isAction(event, ActionType.L)) + { + return; + } + + Player player = event.getPlayer(); + + if (!UtilInv.IsItem(player.getItemInHand(), Material.TNT, (byte) 0)) + { + return; + } + + if (!IsAlive(player)) + { + return; + } + + event.setCancelled(true); + + if (!Manager.GetGame().CanThrowTNT(player.getLocation())) + { + // Inform + UtilPlayer.message(event.getPlayer(), F.main(GetName(), "You cannot use " + F.item("Throwing TNT") + " here.")); + return; + } + + UtilInv.remove(player, Material.TNT, (byte) 0, 1); + UtilInv.Update(player); + + TNTPrimed tnt = player.getWorld().spawn(player.getEyeLocation().add(player.getLocation().getDirection()), TNTPrimed.class); + + tnt.setFuseTicks(60); + + double throwMult = 1; + + if (GetKit(player).GetName().equals("Demolitionist")) + { + throwMult = ((KitDemolitionist)GetKit(player)).getThrowMultiplier(player); + } + + UtilAction.velocity(tnt, player.getLocation().getDirection(), 0.5 * throwMult, false, 0, 0.1, 10, false); + + UtilEnt.SetMetadata(tnt, "THROWER", player.getName()); + } + + @EventHandler + public void onLaunch(ProjectileHitEvent event) + { + if (!IsLive()) + { + return; + } + + if (event.getEntity() instanceof EnderPearl && event.getEntity().getShooter() != null && event.getEntity().getShooter() instanceof Entity) + { + Entity shooter = (Entity) event.getEntity().getShooter(); + if (_tntCarry.contains(shooter)) + { + return; + } + Location teleport = event.getEntity().getLocation(); + teleport.setPitch(shooter.getLocation().getPitch()); + teleport.setYaw(shooter.getLocation().getYaw()); + shooter.teleport(teleport); + } + if (event.getEntity() instanceof Arrow) + { + Manager.runSyncLater(event.getEntity()::remove, 1L); + } + } + + @EventHandler + public void onOpenChest(PlayerInteractEvent event) + { + if (!IsLive()) + { + return; + } + + if (event.getClickedBlock() != null && event.getClickedBlock().getType() == Material.CHEST) + { + if (UtilPlayer.isSpectator(event.getPlayer())) + { + event.setCancelled(true); + } + } + } + + @EventHandler(ignoreCancelled = true) + public void onDamage(EntityDamageEvent event) + { + if (!IsLive()) + { + return; + } + if (event.getEntity() instanceof EnderCrystal) + { + event.setCancelled(true); + return; + } + if (event.getEntity() instanceof Zombie) + { + event.setCancelled(true); + if (event instanceof EntityDamageByEntityEvent) + { + GameTeam owner = event.getEntity().getCustomName().contains("Ryan") ? GetTeam(ChatColor.AQUA) : GetTeam(ChatColor.RED); + EntityDamageByEntityEvent e = (EntityDamageByEntityEvent) event; + if (e.getDamager() instanceof Player) + { + Player p = (Player) e.getDamager(); + if (UtilPlayer.isSpectator(p)) + { + return; + } + if (owner.HasPlayer(p)) + { + return; + } + if (_crystals.get(owner).stream().filter(TeamCrystal::isActive).count() > 0) + { + UtilPlayer.message(p, F.main("Game", "You cannot attack the enemy king until your team has destroyed his protective crystals!")); + return; + } + TeamKing king = _kings.get(owner); + if (king.handleDamage(p.getName(), e.getDamage())) + { + for (Player alert : owner.GetPlayers(true)) + { + if (Recharge.Instance.use(alert, "KingDamageAlert", 5000, false, false)) + { + alert.sendMessage(king.getName(true) + " is under attack!"); + } + } + } + } + } + } + } + + @EventHandler + public void onDrop(PlayerDropItemEvent event) + { + if (!IsLive()) + { + return; + } + + ItemStack drop = event.getItemDrop().getItemStack(); + if (drop.hasItemMeta() && drop.getItemMeta().hasLore() && drop.getItemMeta().getLore().stream().map(ChatColor::stripColor).anyMatch(lore -> lore.equals("Kit Item"))) + { + event.setCancelled(true); + return; + } + + event.getItemDrop().remove(); + } + + @EventHandler + public void craftItem(PrepareItemCraftEvent event) + { + if (!IsLive()) + { + return; + } + + if (event.getInventory().getResult().getType() == Material.FLINT_AND_STEEL) + { + event.getInventory().setResult(_flintAndSteel.build()); + } + } + + @EventHandler + public void onInvClick(InventoryClickEvent event) + { + if (!IsLive()) + { + return; + } + ItemStack current = event.getCurrentItem(); + if (event.getAction() == InventoryAction.HOTBAR_SWAP || event.getAction() == InventoryAction.HOTBAR_MOVE_AND_READD) + { + current = event.getWhoClicked().getInventory().getItem(event.getHotbarButton()); + } + if (current == null || !current.hasItemMeta()) + { + return; + } + if (current.getItemMeta().hasDisplayName() && current.getItemMeta().getDisplayName().equals(C.cRed + "TNT")) + { + event.setCancelled(true); + return; + } + if (event.getView().getTopInventory() != null && event.getView().getTopInventory().getType() == InventoryType.CHEST) + { + if (current.getItemMeta().hasLore()) + { + for (String lore : current.getItemMeta().getLore()) + { + if (ChatColor.stripColor(lore).equalsIgnoreCase("Kit Item")) + { + event.setCancelled(true); + break; + } + } + } + + } + } + + @EventHandler + public void onFirstBlood(FirstBloodEvent event) + { + if (!IsLive()) + { + return; + } + + AddStat(event.getPlayer(), "FirstBlood", 1, true, false); + } + + @EventHandler + public void onPearl(PlayerInteractEvent event) + { + if (!IsLive()) + { + return; + } + + if (!UtilEvent.isAction(event, ActionType.R)) + { + return; + } + + if (event.getItem() != null && event.getItem().getType() == Material.ENDER_PEARL) + { + Player player = (Player) event.getPlayer(); + if (!Recharge.Instance.use(player, "Enderpearl", 4000, true, true)) + { + event.setCancelled(true); + player.updateInventory(); + } + } + } + + @EventHandler + public void onItemDespawn(ItemDespawnEvent event) + { + if (!IsLive()) + { + return; + } + + if (_tntSpawner.isSpawned()) + { + if (_tntSpawner.getItem().getEntityId() == event.getEntity().getEntityId()) + { + event.setCancelled(true); + } + } + } + + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + public void onPickup(PlayerPickupItemEvent event) + { + if (!IsLive()) + { + return; + } + + if (_tntSpawner.isSpawned() && event.getItem().getEntityId() == _tntSpawner.getItem().getEntityId()) + { + event.setCancelled(true); + if (!_tntCarry.contains(event.getPlayer())) + { + _tntSpawner.pickup(); + _tntCarry.add(event.getPlayer()); + event.getPlayer().setMetadata("OLD_HELM", new FixedMetadataValue(UtilServer.getPlugin(), event.getPlayer().getInventory().getHelmet())); + event.getPlayer().setMetadata("TNT_START", new FixedMetadataValue(UtilServer.getPlugin(), System.currentTimeMillis())); + event.getPlayer().getInventory().setHelmet(_wearableTnt.build()); + UtilPlayer.message(event.getPlayer(), F.main("Game", "You picked up " + F.skill("TNT") + ".")); + UtilPlayer.message(event.getPlayer(), F.main("Game", F.elem("Right-Click") + " to detonate yourself.")); + UtilPlayer.message(event.getPlayer(), F.main("Game", "Run to the enemy Crystal and Detonate to destroy it.")); + } + } + } + + @EventHandler(ignoreCancelled = true) + public void TNTUse(PlayerInteractEvent event) + { + Player player = event.getPlayer(); + + if (!_tntCarry.contains(player)) + { + return; + } + + if (!UtilEvent.isAction(event, ActionType.R)) + { + return; + } + + event.setCancelled(true); + + player.getInventory().setHelmet((ItemStack) player.getMetadata("OLD_HELM").get(0).value()); + player.removeMetadata("OLD_HELM", UtilServer.getPlugin()); + player.removeMetadata("TNT_START", UtilServer.getPlugin()); + _tntCarry.remove(player); + + TNTPrimed tnt = player.getWorld().spawn(player.getEyeLocation(), TNTPrimed.class); + UtilEnt.SetMetadata(tnt, "THROWER", player.getName()); + UtilEnt.SetMetadata(tnt, "OBJECTIVE_TNT", true); + tnt.setFuseTicks(0); + UtilPlayer.message(player, F.main("Game", "You used " + F.skill("Detonate") + ".")); + } + + @EventHandler + public void TNTExpire(UpdateEvent event) + { + if (!IsLive()) + { + return; + } + + if (event.getType() != UpdateType.FASTER) + { + return; + } + + Iterator tntIterator = _tntCarry.iterator(); + + while (tntIterator.hasNext()) + { + Player player = tntIterator.next(); + + if (player.isDead() || UtilTime.elapsed(player.getMetadata("TNT_START").get(0).asLong(), 60000)) + { + TNTPrimed tnt = player.getWorld().spawn(player.getEyeLocation(), TNTPrimed.class); + UtilEnt.SetMetadata(tnt, "THROWER", player.getName()); + UtilEnt.SetMetadata(tnt, "OBJECTIVE_TNT", true); + tnt.setFuseTicks(0); + + if (!player.isDead()) + { + player.getInventory().setHelmet((ItemStack) player.getMetadata("OLD_HELM").get(0).value()); + } + player.removeMetadata("OLD_HELM", UtilServer.getPlugin()); + player.removeMetadata("TNT_START", UtilServer.getPlugin()); + + tntIterator.remove(); + continue; + } + + List crystals = new ArrayList<>(); + + for (List c : _crystals.values()) + { + crystals.addAll(c); + } + for (TeamCrystal crystal : crystals) + { + if (crystal.isActive() && !crystal.getOwner().HasPlayer(player) && UtilMath.offset(player.getLocation(), crystal.getLocation()) <= 3) + { + TNTPrimed tnt = player.getWorld().spawn(player.getEyeLocation(), TNTPrimed.class); + UtilEnt.SetMetadata(tnt, "THROWER", player.getName()); + UtilEnt.SetMetadata(tnt, "OBJECTIVE_TNT", true); + tnt.setFuseTicks(0); + + if (!player.isDead()) + { + player.getInventory().setHelmet((ItemStack) player.getMetadata("OLD_HELM").get(0).value()); + } + player.removeMetadata("OLD_HELM", UtilServer.getPlugin()); + player.removeMetadata("TNT_START", UtilServer.getPlugin()); + + tntIterator.remove(); + } + } + + UtilTextBottom.display(GetTeam(player).GetColor() + player.getName() + " has the TNT!", UtilServer.getPlayers()); + UtilFirework.playFirework(player.getEyeLocation(), Type.BURST, Color.RED, false, false); + } + } + + @EventHandler + public void onDeath(PlayerDeathEvent event) + { + Player player = event.getEntity(); + + _streakData.getOrDefault(player, new KillStreakData()).reset(); + + if (!_tntCarry.contains(player)) + { + return; + } + + player.removeMetadata("OLD_HELM", UtilServer.getPlugin()); + player.removeMetadata("TNT_START", UtilServer.getPlugin()); + _tntCarry.remove(player); + TNTPrimed tnt = player.getWorld().spawn(player.getEyeLocation(), TNTPrimed.class); + UtilEnt.SetMetadata(tnt, "THROWER", player.getName()); + UtilEnt.SetMetadata(tnt, "OBJECTIVE_TNT", true); + tnt.setFuseTicks(0); + UtilPlayer.message(player, F.main("Game", "You used " + F.skill("Detonate") + ".")); + } + + @EventHandler + public void onBlockPlace(BlockPlaceEvent event) + { + if (!_tntSpawner.canPlaceFireAt(event.getBlock())) + { + event.setCancelled(true); + } + } +} \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiegeTDM.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssaultTDM.java similarity index 97% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiegeTDM.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssaultTDM.java index 50e9a7d65..a64fff374 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiegeTDM.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssaultTDM.java @@ -1,4 +1,4 @@ -package nautilus.game.arcade.game.games.castlesiege; +package nautilus.game.arcade.game.games.castleassault; import java.util.ArrayList; import java.util.HashMap; @@ -72,19 +72,19 @@ import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.GemData; import nautilus.game.arcade.game.TeamGame; -import nautilus.game.arcade.game.games.castlesiege.data.KillStreakData; -import nautilus.game.arcade.game.games.castlesiege.data.medals.MedalData; -import nautilus.game.arcade.game.games.castlesiege.data.medals.MedalData.MedalLevel; -import nautilus.game.arcade.game.games.castlesiege.kits.KitArcher; -import nautilus.game.arcade.game.games.castlesiege.kits.KitDemolitionist; -import nautilus.game.arcade.game.games.castlesiege.kits.KitFighter; -import nautilus.game.arcade.game.games.castlesiege.kits.KitPlayer; -import nautilus.game.arcade.game.games.castlesiege.kits.KitTank; -import nautilus.game.arcade.game.games.castlesiege.data.medals.MedalType; +import nautilus.game.arcade.game.games.castleassault.data.KillStreakData; +import nautilus.game.arcade.game.games.castleassault.data.medals.MedalData; +import nautilus.game.arcade.game.games.castleassault.data.medals.MedalData.MedalLevel; +import nautilus.game.arcade.game.games.castleassault.data.medals.MedalType; +import nautilus.game.arcade.game.games.castleassault.kits.KitArcher; +import nautilus.game.arcade.game.games.castleassault.kits.KitDemolitionist; +import nautilus.game.arcade.game.games.castleassault.kits.KitFighter; +import nautilus.game.arcade.game.games.castleassault.kits.KitPlayer; +import nautilus.game.arcade.game.games.castleassault.kits.KitTank; import nautilus.game.arcade.game.modules.compass.CompassModule; import nautilus.game.arcade.kit.Kit; -public class CastleSiegeTDM extends TeamGame +public class CastleAssaultTDM extends TeamGame { private static final int MAX_FLINT_AND_STEEL_USES = 4; private static final int ITEMS_PER_CHEST = 5; @@ -116,9 +116,9 @@ public class CastleSiegeTDM extends TeamGame private boolean _writeScoreboard = true; @SuppressWarnings("deprecation") - public CastleSiegeTDM(ArcadeManager manager) + public CastleAssaultTDM(ArcadeManager manager) { - super(manager, GameType.CastleSiegeTDM, + super(manager, GameType.CastleAssaultTDM, new Kit[] { //new KitAlchemist(manager), diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/data/CapturePoint.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/data/CapturePoint.java similarity index 90% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/data/CapturePoint.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/data/CapturePoint.java index 3952467e6..43709f165 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/data/CapturePoint.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/data/CapturePoint.java @@ -1,71 +1,71 @@ -package nautilus.game.arcade.game.games.castlesiege.data; - -import org.bukkit.Location; -import org.bukkit.entity.Player; - -import mineplex.core.common.util.UtilPlayer; -import mineplex.core.common.util.UtilTime; -import nautilus.game.arcade.game.GameTeam; - -public class CapturePoint -{ - private static final int POINTS_TO_CAPTURE = 100; - private static final long TIME_PER_POINT = 1000; - private static final int POINTS_PER_TICK = 1; - - private Location _loc; - - private long _lastCap; - private int _points = 0; - private GameTeam _owner = null; - - public CapturePoint(GameTeam owner, Location loc) - { - _owner = owner; - - _loc = loc; - } - - public int getMaxPoints() - { - return POINTS_TO_CAPTURE; - } - - public int getPoints() - { - return _points; - } - - public boolean isCaptured() - { - return _points >= POINTS_TO_CAPTURE; - } - - public void update() - { - if (!UtilTime.elapsed(_lastCap, TIME_PER_POINT)) - { - return; - } - - int capping = 0; - for (Player player : UtilPlayer.getInRadius(_loc, 3.5).keySet()) - { - if (UtilPlayer.isSpectator(player)) - { - continue; - } - if (_owner.HasPlayer(player)) - { - continue; - } - capping++; - } - - if (capping > 0 && _points < POINTS_TO_CAPTURE) - { - _lastCap = System.currentTimeMillis(); - _points += POINTS_PER_TICK; - } - } +package nautilus.game.arcade.game.games.castleassault.data; + +import org.bukkit.Location; +import org.bukkit.entity.Player; + +import mineplex.core.common.util.UtilPlayer; +import mineplex.core.common.util.UtilTime; +import nautilus.game.arcade.game.GameTeam; + +public class CapturePoint +{ + private static final int POINTS_TO_CAPTURE = 100; + private static final long TIME_PER_POINT = 1000; + private static final int POINTS_PER_TICK = 1; + + private Location _loc; + + private long _lastCap; + private int _points = 0; + private GameTeam _owner = null; + + public CapturePoint(GameTeam owner, Location loc) + { + _owner = owner; + + _loc = loc; + } + + public int getMaxPoints() + { + return POINTS_TO_CAPTURE; + } + + public int getPoints() + { + return _points; + } + + public boolean isCaptured() + { + return _points >= POINTS_TO_CAPTURE; + } + + public void update() + { + if (!UtilTime.elapsed(_lastCap, TIME_PER_POINT)) + { + return; + } + + int capping = 0; + for (Player player : UtilPlayer.getInRadius(_loc, 3.5).keySet()) + { + if (UtilPlayer.isSpectator(player)) + { + continue; + } + if (_owner.HasPlayer(player)) + { + continue; + } + capping++; + } + + if (capping > 0 && _points < POINTS_TO_CAPTURE) + { + _lastCap = System.currentTimeMillis(); + _points += POINTS_PER_TICK; + } + } } \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/data/KillStreakData.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/data/KillStreakData.java similarity index 85% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/data/KillStreakData.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/data/KillStreakData.java index 2735f5026..1e86d8266 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/data/KillStreakData.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/data/KillStreakData.java @@ -1,47 +1,47 @@ -package nautilus.game.arcade.game.games.castlesiege.data; - -public class KillStreakData -{ - private static final int[] REWARDED_STREAKS = {2, 4, 6, 8}; - private int _kills; - private int _bestStreak; - - public KillStreakData() - { - _kills = 0; - _bestStreak = 0; - } - - public int getKills() - { - return _kills; - } - - public int getBestStreak() - { - return Math.max(_bestStreak, _kills); - } - - public boolean addKill(boolean hardLine) - { - _kills++; - for (int streak : REWARDED_STREAKS) - { - if ((_kills + (hardLine ? 1 : 0)) == streak) - { - return true; - } - } - - return false; - } - - public void reset() - { - if (_kills > _bestStreak) - { - _bestStreak = _kills; - } - _kills = 0; - } +package nautilus.game.arcade.game.games.castleassault.data; + +public class KillStreakData +{ + private static final int[] REWARDED_STREAKS = {2, 4, 6, 8}; + private int _kills; + private int _bestStreak; + + public KillStreakData() + { + _kills = 0; + _bestStreak = 0; + } + + public int getKills() + { + return _kills; + } + + public int getBestStreak() + { + return Math.max(_bestStreak, _kills); + } + + public boolean addKill(boolean hardLine) + { + _kills++; + for (int streak : REWARDED_STREAKS) + { + if ((_kills + (hardLine ? 1 : 0)) == streak) + { + return true; + } + } + + return false; + } + + public void reset() + { + if (_kills > _bestStreak) + { + _bestStreak = _kills; + } + _kills = 0; + } } \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/data/ObjectiveTNTSpawner.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/data/ObjectiveTNTSpawner.java similarity index 87% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/data/ObjectiveTNTSpawner.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/data/ObjectiveTNTSpawner.java index 18cb00cf5..076913cf1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/data/ObjectiveTNTSpawner.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/data/ObjectiveTNTSpawner.java @@ -1,97 +1,100 @@ -package nautilus.game.arcade.game.games.castlesiege.data; - -import java.util.List; - -import org.bukkit.Color; -import org.bukkit.FireworkEffect.Type; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; -import org.bukkit.entity.Item; -import org.bukkit.inventory.ItemStack; - -import mineplex.core.common.util.UtilFirework; -import mineplex.core.common.util.UtilMath; -import mineplex.core.common.util.UtilTime; - -public class ObjectiveTNTSpawner -{ - private static final long TNT_SPAWN_DELAY = 60000; - private List _locs; - private Location _lastSpawnLoc; - private Item _entity; - private long _lastPickedUp; - - public ObjectiveTNTSpawner(List locs) - { - _locs = locs; - _lastSpawnLoc = null; - _entity = null; - _lastPickedUp = System.currentTimeMillis(); - } - - public Item getItem() - { - return _entity; - } - - public boolean isSpawned() - { - return _entity != null; - } - - public boolean canPlaceFireAt(Block block) - { - if (!isSpawned()) - { - return false; - } - - return UtilMath.offsetSquared(_lastSpawnLoc, block.getLocation()) <= 9; - } - - public long getNextTNT() - { - return (_lastPickedUp + TNT_SPAWN_DELAY) - System.currentTimeMillis(); - } - - public void spawn() - { - Location spawn = _locs.get(UtilMath.r(_locs.size())); - spawn.getBlock().getRelative(BlockFace.DOWN).setType(Material.REDSTONE_BLOCK); - _lastSpawnLoc = spawn.clone(); - _entity = spawn.getWorld().dropItem(spawn, new ItemStack(Material.TNT)); - UtilFirework.playFirework(spawn, Type.BURST, Color.RED, false, false); - } - - public void pickup() - { - _entity.getLocation().getBlock().getRelative(BlockFace.DOWN).setType(Material.IRON_BLOCK); - _entity.remove(); - _entity = null; - _lastSpawnLoc = null; - _lastPickedUp = System.currentTimeMillis(); - } - - public void update() - { - if (!isSpawned() && UtilTime.elapsed(_lastPickedUp, TNT_SPAWN_DELAY)) - { - spawn(); - } - else if (isSpawned()) - { - _entity.teleport(_lastSpawnLoc); - if (!_entity.isValid() || _entity.isDead()) - { - _entity = _lastSpawnLoc.getWorld().dropItem(_lastSpawnLoc, new ItemStack(Material.TNT)); - } - } - } - - public void onStart() - { - _lastPickedUp = System.currentTimeMillis(); - } +package nautilus.game.arcade.game.games.castleassault.data; + +import java.util.List; + +import org.bukkit.Color; +import org.bukkit.FireworkEffect.Type; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.Item; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.common.util.UtilFirework; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilTime; + +public class ObjectiveTNTSpawner +{ + private static final long TNT_SPAWN_DELAY = 60000; + private List _locs; + private Location _lastSpawnLoc; + private Item _entity; + private long _lastPickedUp; + + public ObjectiveTNTSpawner(List locs) + { + _locs = locs; + _lastSpawnLoc = null; + _entity = null; + _lastPickedUp = System.currentTimeMillis(); + } + + public Item getItem() + { + return _entity; + } + + public boolean isSpawned() + { + return _entity != null; + } + + public boolean canPlaceFireAt(Block block) + { + for (Location loc : _locs) + { + if (UtilMath.offsetSquared(loc, block.getLocation()) <= 9) + { + return false; + } + } + + return true; + } + + public long getNextTNT() + { + return (_lastPickedUp + TNT_SPAWN_DELAY) - System.currentTimeMillis(); + } + + public void spawn() + { + Location spawn = _locs.get(UtilMath.r(_locs.size())); + spawn.getBlock().getRelative(BlockFace.DOWN).setType(Material.REDSTONE_BLOCK); + _lastSpawnLoc = spawn.clone(); + _entity = spawn.getWorld().dropItem(spawn, new ItemStack(Material.TNT)); + UtilFirework.playFirework(spawn, Type.BURST, Color.RED, false, false); + } + + public void pickup() + { + _entity.getLocation().getBlock().getRelative(BlockFace.DOWN).setType(Material.IRON_BLOCK); + _entity.remove(); + _entity = null; + _lastSpawnLoc = null; + _lastPickedUp = System.currentTimeMillis(); + } + + public void update() + { + if (!isSpawned() && UtilTime.elapsed(_lastPickedUp, TNT_SPAWN_DELAY)) + { + spawn(); + } + else if (isSpawned()) + { + _entity.teleport(_lastSpawnLoc); + if (!_entity.isValid() || _entity.isDead()) + { + _entity = _lastSpawnLoc.getWorld().dropItem(_lastSpawnLoc, new ItemStack(Material.TNT)); + } + } + } + + public void onStart() + { + _lastPickedUp = System.currentTimeMillis(); + } } \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/data/TeamCrystal.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/data/TeamCrystal.java similarity index 89% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/data/TeamCrystal.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/data/TeamCrystal.java index 8c2ebb0af..e44bc9e9a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/data/TeamCrystal.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/data/TeamCrystal.java @@ -1,54 +1,54 @@ -package nautilus.game.arcade.game.games.castlesiege.data; - -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.block.BlockFace; -import org.bukkit.entity.EnderCrystal; - -import nautilus.game.arcade.game.GameTeam; - -public class TeamCrystal -{ - private Location _loc; - private GameTeam _owner; - private EnderCrystal _crystal; - private boolean _destroyed; - - public TeamCrystal(GameTeam owner, Location loc) - { - _owner = owner; - _loc = loc; - - spawn(); - } - - public GameTeam getOwner() - { - return _owner; - } - - public Location getLocation() - { - return _loc; - } - - public boolean isActive() - { - return !_destroyed; - } - - public void spawn() - { - _destroyed = false; - _crystal = _loc.getWorld().spawn(_loc, EnderCrystal.class); - _loc.getBlock().getRelative(0, -2, 0).setType(Material.BEACON); - } - - public void destroy() - { - _destroyed = true; - _crystal.remove(); - _crystal = null; - _loc.getBlock().getRelative(0, -2, 0).setType(Material.SMOOTH_BRICK); - } +package nautilus.game.arcade.game.games.castleassault.data; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.BlockFace; +import org.bukkit.entity.EnderCrystal; + +import nautilus.game.arcade.game.GameTeam; + +public class TeamCrystal +{ + private Location _loc; + private GameTeam _owner; + private EnderCrystal _crystal; + private boolean _destroyed; + + public TeamCrystal(GameTeam owner, Location loc) + { + _owner = owner; + _loc = loc; + + spawn(); + } + + public GameTeam getOwner() + { + return _owner; + } + + public Location getLocation() + { + return _loc; + } + + public boolean isActive() + { + return !_destroyed; + } + + public void spawn() + { + _destroyed = false; + _crystal = _loc.getWorld().spawn(_loc, EnderCrystal.class); + _loc.getBlock().getRelative(0, -2, 0).setType(Material.BEACON); + } + + public void destroy() + { + _destroyed = true; + _crystal.remove(); + _crystal = null; + _loc.getBlock().getRelative(0, -2, 0).setType(Material.SMOOTH_BRICK); + } } \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/data/TeamKing.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/data/TeamKing.java similarity index 93% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/data/TeamKing.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/data/TeamKing.java index a925064dd..af9fad64a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/data/TeamKing.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/data/TeamKing.java @@ -1,122 +1,122 @@ -package nautilus.game.arcade.game.games.castlesiege.data; - -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Zombie; - -import mineplex.core.common.util.C; -import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilTime; -import mineplex.core.itemstack.ItemBuilder; -import nautilus.game.arcade.game.GameTeam; - -public class TeamKing -{ - private static final int MAX_HEALTH = 600; - private Location _loc; - private String _name; - private GameTeam _owner; - private Zombie _entity; - private int _health; - private String _lastDamager; - private long _lastDamage; - - public TeamKing(GameTeam owner, String name, Location loc) - { - _owner = owner; - _loc = loc; - _name = name; - _health = MAX_HEALTH; - _entity = (Zombie) loc.getWorld().spawnEntity(loc, EntityType.ZOMBIE); - UtilEnt.vegetate(_entity, true); - _entity.getEquipment().setHelmet(new ItemBuilder(Material.DIAMOND_HELMET).setUnbreakable(true).build()); - _entity.getEquipment().setChestplate(new ItemBuilder(Material.DIAMOND_CHESTPLATE).setUnbreakable(true).build()); - _entity.getEquipment().setLeggings(new ItemBuilder(Material.DIAMOND_LEGGINGS).setUnbreakable(true).build()); - _entity.getEquipment().setBoots(new ItemBuilder(Material.DIAMOND_BOOTS).setUnbreakable(true).build()); - _entity.setRemoveWhenFarAway(false); - _entity.setCustomName(owner.GetColor() + name); - } - - public GameTeam getOwner() - { - return _owner; - } - - public Location getLocation() - { - return _loc; - } - - public String getName(boolean bold) - { - return _owner.GetColor() + (bold ? C.Bold : "") + _name; - } - - public String getLastDamager() - { - return _lastDamager; - } - - public int getHealth() - { - return Math.max(_health, 0); - } - - public boolean isDead() - { - return getHealth() <= 0; - } - - public void update(boolean beaconsAlive) - { - _entity.teleport(_loc); - for (int y = 0; y <= 4; y++) - { - for (int x = -4; x <= 4; x++) - { - for (int z = -4; z <= 4; z++) - { - Block block = _loc.clone().add(x, y, z).getBlock(); - if ((block.getType() != Material.IRON_FENCE && block.getType() != Material.IRON_BLOCK) || !beaconsAlive) - { - block.setType(Material.AIR); - } - if (beaconsAlive) - { - if (x == -4 || x == 4 || z == -4 || z == 4) - { - if (y != 4) - { - block.setType(Material.IRON_FENCE); - } - } - if (y == 4) - { - block.setType(Material.IRON_BLOCK); - } - } - } - } - } - } - - public boolean handleDamage(String player, double damage) - { - if (!UtilTime.elapsed(_lastDamage, 400)) - { - return false; - } - _lastDamager = player; - _lastDamage = System.currentTimeMillis(); - - int dmg = (int)Math.ceil(damage); - - _health -= dmg; - - UtilEnt.PlayDamageSound(_entity); - - return true; - } +package nautilus.game.arcade.game.games.castleassault.data; + +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Zombie; + +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilEnt; +import mineplex.core.common.util.UtilTime; +import mineplex.core.itemstack.ItemBuilder; +import nautilus.game.arcade.game.GameTeam; + +public class TeamKing +{ + private static final int MAX_HEALTH = 600; + private Location _loc; + private String _name; + private GameTeam _owner; + private Zombie _entity; + private int _health; + private String _lastDamager; + private long _lastDamage; + + public TeamKing(GameTeam owner, String name, Location loc) + { + _owner = owner; + _loc = loc; + _name = name; + _health = MAX_HEALTH; + _entity = (Zombie) loc.getWorld().spawnEntity(loc, EntityType.ZOMBIE); + UtilEnt.vegetate(_entity, true); + _entity.getEquipment().setHelmet(new ItemBuilder(Material.DIAMOND_HELMET).setUnbreakable(true).build()); + _entity.getEquipment().setChestplate(new ItemBuilder(Material.DIAMOND_CHESTPLATE).setUnbreakable(true).build()); + _entity.getEquipment().setLeggings(new ItemBuilder(Material.DIAMOND_LEGGINGS).setUnbreakable(true).build()); + _entity.getEquipment().setBoots(new ItemBuilder(Material.DIAMOND_BOOTS).setUnbreakable(true).build()); + _entity.setRemoveWhenFarAway(false); + _entity.setCustomName(owner.GetColor() + name); + } + + public GameTeam getOwner() + { + return _owner; + } + + public Location getLocation() + { + return _loc; + } + + public String getName(boolean bold) + { + return _owner.GetColor() + (bold ? C.Bold : "") + _name; + } + + public String getLastDamager() + { + return _lastDamager; + } + + public int getHealth() + { + return Math.max(_health, 0); + } + + public boolean isDead() + { + return getHealth() <= 0; + } + + public void update(boolean beaconsAlive) + { + _entity.teleport(_loc); + for (int y = 0; y <= 4; y++) + { + for (int x = -4; x <= 4; x++) + { + for (int z = -4; z <= 4; z++) + { + Block block = _loc.clone().add(x, y, z).getBlock(); + if ((block.getType() != Material.IRON_FENCE && block.getType() != Material.IRON_BLOCK) || !beaconsAlive) + { + block.setType(Material.AIR); + } + if (beaconsAlive) + { + if (x == -4 || x == 4 || z == -4 || z == 4) + { + if (y != 4) + { + block.setType(Material.IRON_FENCE); + } + } + if (y == 4) + { + block.setType(Material.IRON_BLOCK); + } + } + } + } + } + } + + public boolean handleDamage(String player, double damage) + { + if (!UtilTime.elapsed(_lastDamage, 400)) + { + return false; + } + _lastDamager = player; + _lastDamage = System.currentTimeMillis(); + + int dmg = (int)Math.ceil(damage); + + _health -= dmg; + + UtilEnt.PlayDamageSound(_entity); + + return true; + } } \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/data/medals/MedalData.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/data/medals/MedalData.java similarity index 93% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/data/medals/MedalData.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/data/medals/MedalData.java index 2943d761a..a64e7f68c 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/data/medals/MedalData.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/data/medals/MedalData.java @@ -1,4 +1,4 @@ -package nautilus.game.arcade.game.games.castlesiege.data.medals; +package nautilus.game.arcade.game.games.castleassault.data.medals; import java.util.HashMap; import java.util.Map; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/data/medals/MedalType.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/data/medals/MedalType.java similarity index 78% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/data/medals/MedalType.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/data/medals/MedalType.java index e12f1bb36..47abb13c9 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/data/medals/MedalType.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/data/medals/MedalType.java @@ -1,4 +1,4 @@ -package nautilus.game.arcade.game.games.castlesiege.data.medals; +package nautilus.game.arcade.game.games.castleassault.data.medals; public enum MedalType { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitAlchemist.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitAlchemist.java similarity index 95% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitAlchemist.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitAlchemist.java index 50c4f443d..d42c40ae0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitAlchemist.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitAlchemist.java @@ -1,4 +1,4 @@ -package nautilus.game.arcade.game.games.castlesiege.kits; +package nautilus.game.arcade.game.games.castleassault.kits; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitArcher.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitArcher.java similarity index 91% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitArcher.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitArcher.java index 9638a2a60..94efc77d0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitArcher.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitArcher.java @@ -1,4 +1,4 @@ -package nautilus.game.arcade.game.games.castlesiege.kits; +package nautilus.game.arcade.game.games.castleassault.kits; import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; @@ -120,8 +120,8 @@ public class KitArcher extends KitPlayer } else if (streak == 4) { - player.sendMessage(C.cRedB + "You have received a Power I book as a Kill Streak Reward!"); - player.getInventory().addItem(new EnchantedBookBuilder(1).setLevel(Enchantment.ARROW_DAMAGE, 1).build()); + player.sendMessage(C.cRedB + "You have received 12 Arrows as a Kill Streak Reward!"); + player.getInventory().addItem(new ItemBuilder(Material.ARROW).setAmount(12).setTitle(F.item("Fletched Arrow")).build()); } else if (streak == 6) { @@ -130,8 +130,8 @@ public class KitArcher extends KitPlayer } else if (streak == 8) { - player.sendMessage(C.cRedB + "You have received a Power I book as a Kill Streak Reward!"); - player.getInventory().addItem(new EnchantedBookBuilder(1).setLevel(Enchantment.ARROW_DAMAGE, 1).build()); + player.sendMessage(C.cRedB + "You have received 32 Arrows as a Kill Streak Reward!"); + player.getInventory().addItem(new ItemBuilder(Material.ARROW).setAmount(32).setTitle(F.item("Fletched Arrow")).build()); } } } \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitBuilder.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitBuilder.java similarity index 95% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitBuilder.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitBuilder.java index 67d2c8872..9e3134e75 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitBuilder.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitBuilder.java @@ -1,4 +1,4 @@ -package nautilus.game.arcade.game.games.castlesiege.kits; +package nautilus.game.arcade.game.games.castleassault.kits; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitDemolitionist.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitDemolitionist.java similarity index 98% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitDemolitionist.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitDemolitionist.java index 16588ff54..5af012192 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitDemolitionist.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitDemolitionist.java @@ -1,4 +1,4 @@ -package nautilus.game.arcade.game.games.castlesiege.kits; +package nautilus.game.arcade.game.games.castleassault.kits; import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitEnchanter.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitEnchanter.java similarity index 96% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitEnchanter.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitEnchanter.java index d92d12c30..fc15f48ba 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitEnchanter.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitEnchanter.java @@ -1,4 +1,4 @@ -package nautilus.game.arcade.game.games.castlesiege.kits; +package nautilus.game.arcade.game.games.castleassault.kits; import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitFighter.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitFighter.java similarity index 99% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitFighter.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitFighter.java index abf6ad397..d5b49974d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitFighter.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitFighter.java @@ -1,4 +1,4 @@ -package nautilus.game.arcade.game.games.castlesiege.kits; +package nautilus.game.arcade.game.games.castleassault.kits; import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitHardline.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitHardline.java similarity index 94% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitHardline.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitHardline.java index 9154b7a45..7cb59e5f4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitHardline.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitHardline.java @@ -1,4 +1,4 @@ -package nautilus.game.arcade.game.games.castlesiege.kits; +package nautilus.game.arcade.game.games.castleassault.kits; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitNinja.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitNinja.java similarity index 95% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitNinja.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitNinja.java index 898091c80..acb2f4590 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitNinja.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitNinja.java @@ -1,4 +1,4 @@ -package nautilus.game.arcade.game.games.castlesiege.kits; +package nautilus.game.arcade.game.games.castleassault.kits; import org.bukkit.Material; import org.bukkit.entity.Player; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitPlayer.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitPlayer.java similarity index 88% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitPlayer.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitPlayer.java index 53cc7b7e1..c9fdaf1c6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitPlayer.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitPlayer.java @@ -1,4 +1,4 @@ -package nautilus.game.arcade.game.games.castlesiege.kits; +package nautilus.game.arcade.game.games.castleassault.kits; import org.bukkit.Material; import org.bukkit.entity.EntityType; @@ -9,7 +9,7 @@ import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.game.games.castlesiege.CastleSiege; +import nautilus.game.arcade.game.games.castleassault.CastleAssault; import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.Perk; import nautilus.game.arcade.kit.ProgressingKit; @@ -32,9 +32,9 @@ public abstract class KitPlayer extends ProgressingKit public abstract void awardKillStreak(Player player, int streak); - protected CastleSiege getGame() + protected CastleAssault getGame() { - return (CastleSiege) Manager.GetGame(); + return (CastleAssault) Manager.GetGame(); } protected void giveRegeneration(Player player) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitTank.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitTank.java similarity index 99% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitTank.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitTank.java index 3549ffb12..710781ebc 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitTank.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitTank.java @@ -1,4 +1,4 @@ -package nautilus.game.arcade.game.games.castlesiege.kits; +package nautilus.game.arcade.game.games.castleassault.kits; import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitWorkman.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitWorkman.java similarity index 95% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitWorkman.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitWorkman.java index e3359c66d..0cb37d4e1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitWorkman.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitWorkman.java @@ -1,4 +1,4 @@ -package nautilus.game.arcade.game.games.castlesiege.kits; +package nautilus.game.arcade.game.games.castleassault.kits; import org.bukkit.Material; import org.bukkit.enchantments.Enchantment; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/PerkBloodlust.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/PerkBloodlust.java similarity index 97% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/PerkBloodlust.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/PerkBloodlust.java index 8c9c84484..9dc21c017 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/PerkBloodlust.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/PerkBloodlust.java @@ -1,4 +1,4 @@ -package nautilus.game.arcade.game.games.castlesiege.kits; +package nautilus.game.arcade.game.games.castleassault.kits; import java.util.Map; import java.util.WeakHashMap; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiege.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiege.java index e4e1f4620..a5a67d2d0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiege.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiege.java @@ -1,1445 +1,973 @@ package nautilus.game.arcade.game.games.castlesiege; import java.util.ArrayList; -import java.util.Arrays; import java.util.HashMap; +import java.util.HashSet; import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.WeakHashMap; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Color; +import org.bukkit.Effect; +import org.bukkit.EntityEffect; import org.bukkit.FireworkEffect.Type; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.Sound; import org.bukkit.block.Block; -import org.bukkit.block.BlockFace; -import org.bukkit.block.Chest; -import org.bukkit.enchantments.Enchantment; -import org.bukkit.entity.Arrow; -import org.bukkit.entity.EnderCrystal; -import org.bukkit.entity.EnderPearl; +import org.bukkit.entity.Creature; import org.bukkit.entity.Entity; -import org.bukkit.entity.ItemFrame; -import org.bukkit.entity.Painting; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.FallingBlock; +import org.bukkit.entity.Horse; +import org.bukkit.entity.Horse.Style; +import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.TNTPrimed; -import org.bukkit.entity.Zombie; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; -import org.bukkit.event.block.BlockBurnEvent; -import org.bukkit.event.block.BlockDispenseEvent; -import org.bukkit.event.block.BlockFadeEvent; -import org.bukkit.event.block.BlockFormEvent; -import org.bukkit.event.block.BlockFromToEvent; -import org.bukkit.event.block.BlockPlaceEvent; -import org.bukkit.event.block.LeavesDecayEvent; -import org.bukkit.event.entity.EntityDamageByEntityEvent; -import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.HandlerList; +import org.bukkit.event.block.Action; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; +import org.bukkit.event.entity.EntityTargetEvent; import org.bukkit.event.entity.ExplosionPrimeEvent; -import org.bukkit.event.entity.ItemDespawnEvent; import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.entity.ProjectileHitEvent; -import org.bukkit.event.hanging.HangingBreakEvent; -import org.bukkit.event.inventory.InventoryAction; -import org.bukkit.event.inventory.InventoryClickEvent; -import org.bukkit.event.inventory.InventoryType; -import org.bukkit.event.inventory.PrepareItemCraftEvent; -import org.bukkit.event.player.PlayerBucketEmptyEvent; -import org.bukkit.event.player.PlayerBucketFillEvent; -import org.bukkit.event.player.PlayerDropItemEvent; +import org.bukkit.event.player.PlayerEvent; +import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.inventory.ItemStack; -import org.bukkit.material.Dispenser; -import org.bukkit.material.MaterialData; -import org.bukkit.metadata.FixedMetadataValue; -import org.bukkit.metadata.MetadataValue; -import org.bukkit.util.Vector; -import mineplex.core.Managers; import mineplex.core.common.util.C; import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilAction; -import mineplex.core.common.util.UtilAlg; +import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilEvent; import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilFirework; -import mineplex.core.common.util.UtilInv; 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.UtilPlayer; import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTextBottom; import mineplex.core.common.util.UtilTime; -import mineplex.core.itemstack.EnchantedBookBuilder; -import mineplex.core.itemstack.ItemBuilder; -import mineplex.core.leaderboard.Leaderboard; -import mineplex.core.leaderboard.LeaderboardManager; -import mineplex.core.leaderboard.LeaderboardRepository.LeaderboardSQLType; -import mineplex.core.loot.ChestLoot; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; import mineplex.core.updater.event.UpdateEvent; -import mineplex.minecraft.game.core.combat.DeathMessageType; -import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent; + import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; -import nautilus.game.arcade.events.FirstBloodEvent; import nautilus.game.arcade.events.GameStateChangeEvent; +import nautilus.game.arcade.events.PlayerGameRespawnEvent; import nautilus.game.arcade.game.GameTeam; -import nautilus.game.arcade.game.GemData; import nautilus.game.arcade.game.TeamGame; -import nautilus.game.arcade.game.games.castlesiege.data.KillStreakData; -import nautilus.game.arcade.game.games.castlesiege.data.ObjectiveTNTSpawner; -import nautilus.game.arcade.game.games.castlesiege.data.TeamCrystal; -import nautilus.game.arcade.game.games.castlesiege.data.TeamKing; -import nautilus.game.arcade.game.games.castlesiege.kits.KitArcher; -import nautilus.game.arcade.game.games.castlesiege.kits.KitDemolitionist; -import nautilus.game.arcade.game.games.castlesiege.kits.KitFighter; -import nautilus.game.arcade.game.games.castlesiege.kits.KitPlayer; -import nautilus.game.arcade.game.games.castlesiege.kits.KitTank; +import nautilus.game.arcade.game.games.castlesiege.kits.KitHumanKnight; +import nautilus.game.arcade.game.games.castlesiege.kits.KitHumanMarksman; +import nautilus.game.arcade.game.games.castlesiege.kits.KitHumanPeasant; +import nautilus.game.arcade.game.games.castlesiege.kits.KitUndeadArcher; +import nautilus.game.arcade.game.games.castlesiege.kits.KitUndeadGhoul; +import nautilus.game.arcade.game.games.castlesiege.kits.KitUndeadZombie; import nautilus.game.arcade.game.modules.compass.CompassModule; import nautilus.game.arcade.kit.Kit; -import nautilus.game.arcade.managers.lobby.current.NewGameLobbyManager; +import nautilus.game.arcade.kit.NullKit; +import nautilus.game.arcade.stats.BloodThirstyStatTracker; +import nautilus.game.arcade.stats.KingDamageStatTracker; +import nautilus.game.arcade.stats.KingSlayerStatTracker; +import nautilus.game.arcade.stats.TeamDeathsStatTracker; +import nautilus.game.arcade.stats.TeamKillsStatTracker; +import nautilus.game.arcade.stats.WinAsTeamStatTracker; public class CastleSiege extends TeamGame { - private static final int MAX_FLINT_AND_STEEL_USES = 4; - private static final int ITEMS_PER_CHEST = 5; - private static final long TIME_TILL_REFILL = 2 * 60 * 1000; - - private long _lastRefill; - - private ItemBuilder _flintAndSteel; - private ItemBuilder _wearableTnt; - - private Map _streakData = new WeakHashMap<>(); - private Map> _crystals = new HashMap<>(); - private Map _kings = new HashMap<>(); - private List _tntCarry = new ArrayList<>(); - - private List _chests = new ArrayList<>(); - - private ChestLoot _diamondGearCommon = new ChestLoot(true); - private ChestLoot _diamondGearRare = new ChestLoot(true); - private ChestLoot _weaponGearCommon = new ChestLoot(true); - private ChestLoot _weaponGearRare = new ChestLoot(true); - private ChestLoot _rangedGear = new ChestLoot(true); - private ChestLoot _rodsAndGaps = new ChestLoot(true); - private ChestLoot _potionGearCommon = new ChestLoot(true); - private ChestLoot _potionGearRare = new ChestLoot(true); - private ChestLoot _enchantGearCommon = new ChestLoot(true); - private ChestLoot _enchantGearRare = new ChestLoot(true); - private ChestLoot _miscGear = new ChestLoot(); - - private ObjectiveTNTSpawner _tntSpawner; - - private boolean _writeScoreboard = true; - - @SuppressWarnings("deprecation") + public static class KingDamageEvent extends PlayerEvent + { + private static final HandlerList handlers = new HandlerList(); + + public static HandlerList getHandlerList() + { + return handlers; + } + + @Override + public HandlerList getHandlers() + { + return getHandlerList(); + } + + private final double _damage; + + public KingDamageEvent(Player who, double damage) + { + super(who); + + _damage = damage; + } + + public double getDamage() + { + return _damage; + } + } + + public static class KingSlaughterEvent extends PlayerEvent + { + private static final HandlerList handlers = new HandlerList(); + + public static HandlerList getHandlerList() + { + return handlers; + } + + @Override + public HandlerList getHandlers() + { + return getHandlerList(); + } + + public KingSlaughterEvent(Player who) + { + super(who); + } + } + + private ArrayList _lastScoreboard = new ArrayList(); + + private long _tntSpawn = 0; + private ArrayList _tntSpawns = new ArrayList(); + private ArrayList _tntWeakness = new ArrayList(); + + private HashMap _tntCarry = new HashMap(); + private HashSet _tntCarryEnd = new HashSet(); + + private ArrayList _kingLocs; + private Creature _king; + private Location _kingLoc; + private String _kingName; + private Player _kingDamager = null; + private int _kingHealth = 40; + + private ArrayList _peasantSpawns; + private ArrayList _horseSpawns; + public CastleSiege(ArcadeManager manager) { super(manager, GameType.CastleSiege, - new Kit[] - { - //new KitAlchemist(manager), - new KitArcher(manager), - new KitDemolitionist(manager), - //new KitEnchanter(manager), - new KitFighter(manager), - //new KitHardline(manager), - //new KitNinja(manager), - new KitTank(manager) - }, - new String[] - { - "Destroy enemy sentry crystals with running TNT", - "After the enemy crystals are destroyed you must slay their king", - "First team to kill the enemy king wins", - "Chests refill every 2 minutes", - "TNT Respawns every 1 minute" - } - ); - + + new Kit[] + { + new KitHumanMarksman(manager), + new KitHumanKnight(manager), + //new KitHumanBrawler(manager), + //new KitHumanAssassin(manager), + new NullKit(manager), + new KitHumanPeasant(manager), + new NullKit(manager), + new KitUndeadGhoul(manager), + new KitUndeadArcher(manager), + new KitUndeadZombie(manager), + }, + + new String[] + { + F.elem(C.cAqua + "Defenders") + C.cWhite + " must defend the King.", + F.elem(C.cAqua + "Defenders") + C.cWhite + " win when the sun rises.", + F.elem(C.cAqua + "Defenders") + C.cWhite + " respawn as wolves.", + "", + F.elem(C.cRed + "Undead") + C.cWhite + " must kill the King.", + F.elem(C.cRed + "Undead") + C.cWhite + " lose when the sun rises.", + + }); + _help = new String[] - { - "Use the TNT spawning platforms to run TNT to the enemy crystals to destroy them!", - "The enemy king is invulnerable until you destroy the two sentry crystals on each sentry tower", - "Go on Kill Streaks to earn Kill Streak Rewards to obtain better armor & weapons!", - "Chests refill every 2 minutes with potions, golden applegates, fishing rods, and other useful PvP items!" - }; - + { + "Marksmen are extremely important to defence!", + "It's recommended 50%+ of defence are Marksmen.", + "Use Barricades to block the Undeads path.", + "Use TNT to destroy weak points in walls.", + "Weak points are marked by cracked stone brick.", + "Undead can break fences with their axes.", + "Undead Archers must pick up arrows from the ground.", + + }; + this.StrictAntiHack = true; + this.HungerSet = 20; this.DeathOut = false; - this.DeathSpectateSecs = 5; - this.CreatureAllow = false; - this.DeathDropItems = false; - this.WorldWeatherEnabled = false; - this.AllowParticles = false; - this.SoupEnabled = false; - this.InventoryClick = true; - this.InventoryOpenChest = true; - this.InventoryOpenBlock = true; - this.ItemDrop = true; - this.ItemPickup = true; - this.AllowFlintAndSteel = true; - this.BlockPlaceAllow.add(Material.FIRE.getId()); - this.CrownsEnabled = true; - this.Leaderboards = true; - this.FirstKillReward = 20; - this.GemKillDeathRespawn = 1; - + this.WorldTimeSet = 14000; //14000 + this.BlockPlaceAllow.add(85); + + _kingName = C.cYellow + C.Bold + "King Sparklez"; + + GameTeam notRedTeam = null; + for (GameTeam team : GetTeamList()) + { + if (team.GetColor() != ChatColor.RED) + { + notRedTeam = team; + break; + } + } + + registerStatTrackers( + new KingSlayerStatTracker(this), + new BloodThirstyStatTracker(this), + new KingDamageStatTracker(this), + + new TeamDeathsStatTracker(this), + new TeamKillsStatTracker(this) + ); + + registerChatStats( + Kills, + Deaths, + KDRatio, + BlankLine, + Assists, + DamageDealt, + DamageTaken + ); + + registerChatStats(); + new CompassModule() - .setGiveCompass(true) - .setGiveCompassToSpecs(true) - .setGiveCompassToAlive(false) - .register(this); - - _flintAndSteel = new ItemBuilder(Material.FLINT_AND_STEEL).setData((short) (Material.FLINT_AND_STEEL.getMaxDurability() - MAX_FLINT_AND_STEEL_USES)); - _wearableTnt = new ItemBuilder(Material.TNT).setTitle(C.cRed + "TNT").addLore(C.cRedB + "Right Click with Weapon to " + F.name("Detonate")); - generateLoot(); - - if (manager.IsRewardStats()) - { - if (manager.GetLobby() instanceof NewGameLobbyManager) - { - Map> lobbyCustomLocs = ((NewGameLobbyManager)manager.GetLobby()).getCustomLocs(); - if (lobbyCustomLocs.containsKey("TOP_DAILY_WINS")) - { - Location loc = lobbyCustomLocs.get("TOP_DAILY_WINS").get(0); - Managers.get(LeaderboardManager.class).registerLeaderboard("TOP_CASTLESIEGE_DAILY_WINS", new Leaderboard("Top Daily Wins", "Wins", new String[] {"Castle Siege.Wins"}, LeaderboardSQLType.DAILY, loc, 10)); - } - if (lobbyCustomLocs.containsKey("TOP_DAILY_KILLS")) - { - Location loc = lobbyCustomLocs.get("TOP_DAILY_KILLS").get(0); - Managers.get(LeaderboardManager.class).registerLeaderboard("TOP_CASTLESIEGE_DAILY_KILLS", new Leaderboard("Top Daily Kills", "Kills", new String[] {"Castle Siege.Kills"}, LeaderboardSQLType.DAILY, loc, 10)); - } - if (lobbyCustomLocs.containsKey("TOP_WINS")) - { - Location loc = lobbyCustomLocs.get("TOP_WINS").get(0); - Managers.get(LeaderboardManager.class).registerLeaderboard("TOP_CASTLESIEGE_WINS", new Leaderboard("Top Wins", "Wins", new String[] {"Castle Siege.Wins"}, LeaderboardSQLType.ALL, loc, 10)); - } - if (lobbyCustomLocs.containsKey("TOP_KILLS")) - { - Location loc = lobbyCustomLocs.get("TOP_KILLS").get(0); - Managers.get(LeaderboardManager.class).registerLeaderboard("TOP_CASTLESIEGE_KILLS", new Leaderboard("Top Kills", "Kills", new String[] {"Castle Siege.Kills"}, LeaderboardSQLType.ALL, loc, 10)); - } - } - } + .setGiveCompass(true) + .setGiveCompassToSpecs(true) + .setGiveCompassToAlive(false) + .register(this); } - - private void generateLoot() - { - { - _diamondGearCommon.addLoot(new ItemStack(Material.DIAMOND_HELMET), 2); - _diamondGearCommon.addLoot(new ItemStack(Material.DIAMOND_CHESTPLATE), 2); - _diamondGearCommon.addLoot(new ItemStack(Material.DIAMOND_LEGGINGS), 2); - _diamondGearCommon.addLoot(new ItemStack(Material.DIAMOND_BOOTS), 2); - _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_HELMET).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1).build(), 1); - _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_CHESTPLATE).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1).build(), 1); - _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_LEGGINGS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1).build(), 1); - _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_BOOTS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1).build(), 1); - _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_HELMET).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).build(), 1); - _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_CHESTPLATE).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).build(), 1); - _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_LEGGINGS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).build(), 1); - _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_BOOTS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).build(), 1); - _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_HELMET).addEnchantment(Enchantment.PROTECTION_PROJECTILE, 3).build(), 1); - _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_CHESTPLATE).addEnchantment(Enchantment.PROTECTION_PROJECTILE, 3).build(), 1); - _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_LEGGINGS).addEnchantment(Enchantment.PROTECTION_PROJECTILE, 3).build(), 1); - _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_BOOTS).addEnchantment(Enchantment.PROTECTION_PROJECTILE, 3).build(), 1); - } - { - _diamondGearRare.addLoot(new ItemBuilder(Material.DIAMOND_HELMET).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4).build(), 1); - _diamondGearRare.addLoot(new ItemBuilder(Material.DIAMOND_CHESTPLATE).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4).build(), 1); - _diamondGearRare.addLoot(new ItemBuilder(Material.DIAMOND_LEGGINGS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4).build(), 1); - _diamondGearRare.addLoot(new ItemBuilder(Material.DIAMOND_BOOTS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4).build(), 1); - } - { - _weaponGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_SWORD).build(), 2); - _weaponGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_SWORD).addEnchantment(Enchantment.DAMAGE_ALL, 1).build(), 2); - } - { - _weaponGearRare.addLoot(new ItemBuilder(Material.DIAMOND_SWORD).addEnchantment(Enchantment.DAMAGE_ALL, 2).build(), 1); - } - { - _rangedGear.addLoot(new ItemStack(Material.BOW), 3); - _rangedGear.addLoot(Material.ARROW, 3, 8, 16); - } - { - _rodsAndGaps.addLoot(new ItemStack(Material.FISHING_ROD), 3); - _rodsAndGaps.addLoot(new ItemBuilder(Material.GOLDEN_APPLE).setTitle(C.cPurple + "Golden Applegate").build(), 3); - } - { - _potionGearCommon.addLoot(new ItemBuilder(Material.POTION).setData((short)16418).build(), 2); - _potionGearCommon.addLoot(new ItemBuilder(Material.POTION).setData((short)16417).build(), 2); - } - { - _potionGearRare.addLoot(new ItemBuilder(Material.POTION).setData((short)8193).build(), 2); - _potionGearRare.addLoot(new ItemBuilder(Material.POTION).setData((short)8195).build(), 2); - } - { - _enchantGearCommon.addLoot(new EnchantedBookBuilder(1).setLevel(Enchantment.PROTECTION_ENVIRONMENTAL, 1).build(), 2); - _enchantGearCommon.addLoot(new EnchantedBookBuilder(1).setLevel(Enchantment.DAMAGE_ALL, 1).build(), 2); - _enchantGearCommon.addLoot(new EnchantedBookBuilder(1).setLevel(Enchantment.ARROW_DAMAGE, 1).build(), 2); - _enchantGearCommon.addLoot(new ItemStack(Material.EXP_BOTTLE, 64), 1); - } - { - _enchantGearRare.addLoot(new EnchantedBookBuilder(1).setLevel(Enchantment.FIRE_ASPECT, 1).build(), 1); - } - { - _miscGear.addLoot(new ItemStack(Material.ENDER_PEARL), 2); - _miscGear.addLoot(new ItemStack(Material.WATER_BUCKET), 2); - _miscGear.addLoot(_flintAndSteel.build(), 2); - _miscGear.addLoot(new ItemStack(Material.SNOW_BALL, 16), 3); - } - } - - private void fillChest(Block block) - { - if (block.getType() != Material.CHEST && block.getType() != Material.TRAPPED_CHEST) - { - return; - } - Chest chest = (Chest) block.getState(); - - chest.getBlockInventory().clear(); - int[] slots = UtilMath.random.ints(ITEMS_PER_CHEST, 0, chest.getBlockInventory().getSize()).toArray(); - - for (int slot : slots) - { - double chance = UtilMath.random.nextDouble(); - double subChance = UtilMath.random.nextDouble(); - - ChestLoot loot = _miscGear; - if (chance <= 0.6) - { - loot = _rodsAndGaps; - } - if (chance <= 0.5) - { - loot = _potionGearCommon; - if (subChance <= 0.45) - { - loot = _potionGearRare; - } - } - if (chance <= 0.3) - { - loot = _rangedGear; - } - chest.getBlockInventory().setItem(slot, loot.getLoot()); - } - } - - public ItemStack getNewFlintAndSteel(boolean kitItem) - { - if (kitItem) - { - return _flintAndSteel.clone().setLore(C.cGold + "Kit Item").build(); - } - return _flintAndSteel.build(); - } - - public void writeScoreboard() - { - if (!_writeScoreboard) - { - return; - } - Scoreboard.reset(); - Scoreboard.write(C.cDRedB + GetName()); - Scoreboard.writeNewLine(); - Scoreboard.write(C.cGreenB + "Chest Refill"); - long refillTime = _lastRefill + TIME_TILL_REFILL - System.currentTimeMillis(); - if (!IsLive()) - { - refillTime = TIME_TILL_REFILL; - } - Scoreboard.write(UtilTime.MakeStr(refillTime)); - Scoreboard.writeNewLine(); - Scoreboard.write(C.cGreenB + "TNT Spawn"); - long tntTime = _tntSpawner.getNextTNT(); - if (!IsLive()) - { - tntTime = 60000; - } - if (_tntSpawner.isSpawned()) - { - Scoreboard.write("Spawned"); - } - else - { - Scoreboard.write(UtilTime.MakeStr(tntTime)); - } - Scoreboard.writeNewLine(); - GameTeam red = GetTeam(ChatColor.RED); - long redCrystals = _crystals.get(red).stream().filter(TeamCrystal::isActive).count(); - GameTeam blue = GetTeam(ChatColor.AQUA); - long blueCrystals = _crystals.get(blue).stream().filter(TeamCrystal::isActive).count(); - if (redCrystals > 0) - { - Scoreboard.write(_kings.get(red).getName(true)); - Scoreboard.write(redCrystals + "/2 Crystals Active"); - } - else - { - Scoreboard.write(_kings.get(red).getName(true) + " Health"); - Scoreboard.write(_kings.get(red).getHealth() + ""); - } - Scoreboard.writeNewLine(); - if (blueCrystals > 0) - { - Scoreboard.write(_kings.get(blue).getName(true)); - Scoreboard.write(blueCrystals + "/2 Crystals Active"); - } - else - { - Scoreboard.write(_kings.get(blue).getName(true) + " Health"); - Scoreboard.write(_kings.get(blue).getHealth() + ""); - } - Scoreboard.draw(); - } - - public void writeFinalScoreboard(String deadKing, String winKing, String warrior) - { - _writeScoreboard = false; - Scoreboard.reset(); - Scoreboard.writeNewLine(); - Scoreboard.write(deadKing + "'s " + C.cWhite + "castle has been conquered"); - Scoreboard.write(C.cWhite + "by " + winKing + "'s " + C.cWhite + "army with the help of"); - Scoreboard.write(warrior + C.cWhite + "!"); - Scoreboard.writeNewLine(); - - Scoreboard.draw(); - } - + @Override public void ParseData() { - for (Location chestLoc : WorldData.GetDataLocs("BROWN")) + _tntSpawns = WorldData.GetDataLocs("RED"); + _tntWeakness = WorldData.GetDataLocs("BLACK"); + + _kingLocs = WorldData.GetDataLocs("YELLOW"); + + _peasantSpawns = WorldData.GetDataLocs("GREEN"); + _horseSpawns = WorldData.GetDataLocs("BROWN"); + } + + @Override + public void RestrictKits() + { + for (Kit kit : GetKits()) { - Block block = chestLoc.getBlock(); - block.setType(Material.CHEST); - fillChest(block); - _chests.add(block); - } - GameTeam red = GetTeam(ChatColor.RED); - GameTeam blue = GetTeam(ChatColor.AQUA); - Location redKing = WorldData.GetDataLocs("RED").get(0); - Location blueKing = WorldData.GetDataLocs("BLUE").get(0); - Vector redBlue = UtilAlg.getTrajectory(redKing, blueKing); - Vector blueRed = UtilAlg.getTrajectory(blueKing, redKing); - redKing.setPitch(UtilAlg.GetPitch(redBlue)); - redKing.setYaw(UtilAlg.GetYaw(redBlue)); - blueKing.setPitch(UtilAlg.GetPitch(blueRed)); - blueKing.setYaw(UtilAlg.GetYaw(blueRed)); - _crystals.put(red, Arrays.asList(new TeamCrystal(red, WorldData.GetDataLocs("PINK").get(0)), new TeamCrystal(red, WorldData.GetDataLocs("PINK").get(1)))); - _crystals.put(blue, Arrays.asList(new TeamCrystal(blue, WorldData.GetDataLocs("LIGHT_BLUE").get(0)), new TeamCrystal(blue, WorldData.GetDataLocs("LIGHT_BLUE").get(1)))); - this.CreatureAllowOverride = true; - _kings.put(red, new TeamKing(red, "King Jon", redKing)); - _kings.put(blue, new TeamKing(blue, "King Ryan", blueKing)); - int kitIndex = 0; - for (int i = 0; i < WorldData.GetDataLocs("WHITE").size(); i++) - { - if (kitIndex >= GetKits().length) + for (GameTeam team : GetTeamList()) { - kitIndex = 0; + if (team.GetColor() == ChatColor.RED) + { + if (kit.GetName().contains("Castle")) + team.GetRestrictedKits().add(kit); + + team.SetName("Undead"); + } + else + { + if (kit.GetName().contains("Undead")) + team.GetRestrictedKits().add(kit); + + team.SetRespawnTime(8); + + team.SetName("Defenders"); + } + } + } + } + + @EventHandler(priority = EventPriority.HIGH) + public void registerTeamTracker(GameStateChangeEvent event) + { + if (event.GetState() == GameState.Recruit) + { + GameTeam notRed = null; + + for (GameTeam team : GetTeamList()) + { + if (team.GetColor() == ChatColor.RED) + continue; + + notRed = team; + break; + } + + if (notRed != null) + { + registerStatTrackers(new WinAsTeamStatTracker(this, notRed, "ForTheKing")); + System.out.println("Successfully registered For the King StatTrak"); } - Entity ent = GetKits()[kitIndex].SpawnEntity(WorldData.GetDataLocs("WHITE").get(i)); - Manager.GetLobby().addKitLocation(ent, GetKits()[kitIndex], WorldData.GetDataLocs("WHITE").get(i)); - kitIndex++; } - this.CreatureAllowOverride = false; - _tntSpawner = new ObjectiveTNTSpawner(WorldData.GetDataLocs("BLACK")); } + @EventHandler + public void MoveKits(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Prepare) + return; + + for (int i = 0; i < WorldData.GetDataLocs("PINK").size() && i < 3; i++) + { + if (GetKits().length <= 5 + i) + continue; + + this.CreatureAllowOverride = true; + Entity ent = GetKits()[5 + i].SpawnEntity(WorldData.GetDataLocs("PINK").get(i)); + this.CreatureAllowOverride = false; + + Manager.GetLobby().addKitLocation(ent, GetKits()[5 + i], WorldData.GetDataLocs("PINK").get(i)); + } + } + + @EventHandler + public void HorseSpawn(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Prepare) + return; + + for (Location loc : _horseSpawns) + { + this.CreatureAllowOverride = true; + Horse horse = loc.getWorld().spawn(loc, Horse.class); + this.CreatureAllowOverride = false; + + horse.setAdult(); + horse.setAgeLock(true); + horse.setColor(org.bukkit.entity.Horse.Color.BLACK); + horse.setStyle(Style.BLACK_DOTS); + horse.setMaxDomestication(1); + horse.getInventory().setSaddle(new ItemStack(Material.SADDLE)); + horse.getInventory().setArmor(new ItemStack(Material.IRON_BARDING)); + + horse.setMaxHealth(60); + horse.setHealth(horse.getMaxHealth()); + + horse.setCustomName("War Horse"); + } + } + + @EventHandler + public void HorseInteract(PlayerInteractEntityEvent event) + { + if (!(event.getRightClicked() instanceof Horse)) + return; + + Player player = event.getPlayer(); + GameTeam team = GetTeam(player); + + if (team == null || team.GetColor() == ChatColor.RED || !IsAlive(player)) + { + event.setCancelled(true); + } + } + + @EventHandler + public void HorseDamageCancel(CustomDamageEvent event) + { + if (!(event.GetDamageeEntity() instanceof Horse)) + return; + + Player player = event.GetDamagerPlayer(true); + if (player == null) + return; + + if (!IsAlive(player)) + return; + + if (GetTeam(player) == null) + return; + + if (GetTeam(player).GetColor() == ChatColor.RED) + return; + + event.SetCancelled("Horse Team Damage"); + } + + @EventHandler(priority = EventPriority.HIGH) + public void GameStateChange(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Prepare) + return; + + //Spawn King + this.CreatureAllowOverride = true; + + _kingLoc = _kingLocs.get(UtilMath.r(_kingLocs.size())); + + _king = (Creature) _kingLoc.getWorld().spawnEntity(_kingLoc, EntityType.ZOMBIE); + + _king.getEquipment().setHelmet(new ItemStack(Material.DIAMOND_HELMET)); + _king.getEquipment().setChestplate(new ItemStack(Material.DIAMOND_CHESTPLATE)); + _king.getEquipment().setLeggings(new ItemStack(Material.DIAMOND_LEGGINGS)); + _king.getEquipment().setBoots(new ItemStack(Material.DIAMOND_BOOTS)); + _king.getEquipment().setItemInHand(new ItemStack(Material.DIAMOND_SWORD)); + + _king.setCustomName(_kingName); + _king.setCustomNameVisible(true); + + _king.setRemoveWhenFarAway(false); + + this.CreatureAllowOverride = false; + } + + @EventHandler(priority = EventPriority.HIGH) + public void SetDefenderRespawn(GameStateChangeEvent event) + { + if (event.GetState() != GameState.Live) + return; + + //Change to Peasant Spawns + this.GetTeam(ChatColor.AQUA).SetSpawns(_peasantSpawns); + } + + + @EventHandler + public void KingTarget(EntityTargetEvent event) + { + event.setCancelled(true); + } + + @EventHandler + public void KingDamage(CustomDamageEvent event) + { + if (_king == null || !_king.isValid()) + return; + + if (!event.GetDamageeEntity().equals(_king)) + return; + + event.SetCancelled("King Damage"); + + Player damager = event.GetDamagerPlayer(true); + if (damager == null) return; + + GameTeam team = GetTeam(damager); + + if (team != null && team.GetColor() == ChatColor.RED) + { + if (!Recharge.Instance.use(damager, "Damage King", 400, false, false)) + return; + + if (!IsAlive(damager)) + { + return; + } + + _king.playEffect(EntityEffect.HURT); + + _kingDamager = damager; + _kingHealth--; + + Bukkit.getPluginManager().callEvent(new KingDamageEvent(damager, 1)); + + if (_kingHealth < 0) + _kingHealth = 0; + + WriteScoreboard(); + + if (_kingHealth <= 0) + _king.damage(500); + + EndCheck(); + } + } + + @EventHandler + public void KingUpdate(UpdateEvent event) + { + if (GetState() != GameState.Live) + return; + + if (event.getType() != UpdateType.SEC) + return; + + if (_king == null) + return; + + if (UtilMath.offset(_king.getLocation(), _kingLoc) > 6) + { + _king.teleport(_kingLoc); + } + else + { + UtilEnt.CreatureMove(_king, _kingLoc, 1f); + } + } + + @EventHandler + public void PlayerDeath(PlayerGameRespawnEvent event) + { + if (GetTeam(ChatColor.AQUA).HasPlayer(event.GetPlayer())) + SetKit(event.GetPlayer(), GetKits()[3], true); + } + + @Override + @EventHandler + public void ScoreboardUpdate(UpdateEvent event) + { + if (event.getType() != UpdateType.FAST) + return; + + WriteScoreboard(); + } + + public void WriteScoreboard() + { + //Get Values + HashMap _scoreGroup = new HashMap(); + _scoreGroup.put(C.cAqua + "Defenders", 0); + _scoreGroup.put(C.cDAqua + "Wolves", 0); + _scoreGroup.put(C.cRed + "Undead", 0); + + for (Player player : UtilServer.getPlayers()) + { + if (!IsAlive(player)) + continue; + + Kit kit = GetKit(player); + if (kit == null) continue; + + if (kit.GetName().contains("Castle")) + { + if (kit.GetName().contains("Wolf")) + { + _scoreGroup.put(C.cDAqua + "Wolves", 1 + _scoreGroup.get(C.cDAqua + "Wolves")); + } + else + { + _scoreGroup.put(C.cAqua + "Defenders", 1 + _scoreGroup.get(C.cAqua + "Defenders")); + } + } + else if (kit.GetName().contains("Undead")) + { + _scoreGroup.put(C.cRed + "Undead", 1 + _scoreGroup.get(C.cRed + "Undead")); + } + } + + //Wipe Last + Scoreboard.reset(); + + //Teams + for (String group : _scoreGroup.keySet()) + { + Scoreboard.writeNewLine(); + Scoreboard.write(group); + Scoreboard.write(ChatColor.getLastColors(group) + _scoreGroup.get(group) + " Players"); + } + + //King + if (_king != null && _king.isValid()) + { + Scoreboard.writeNewLine(); + Scoreboard.write(C.cYellow + C.Bold + "King"); + Scoreboard.write(_kingHealth + " Health"); + } + + long timeLeft = 24000 - WorldTimeSet; + timeLeft = timeLeft / 20 * 1000; + + + if (timeLeft > 0) + { + Scoreboard.writeNewLine(); + Scoreboard.write(C.cYellow + C.Bold + "Sun Rise"); + Scoreboard.write(UtilTime.MakeStr(timeLeft, 0)); + } + else + { + Scoreboard.writeNewLine(); + Scoreboard.write(C.cYellow + C.Bold + "Sun Rise"); + Scoreboard.write("Undead Burning!"); + + for (Player player : GetTeam(ChatColor.RED).GetPlayers(true)) + Manager.GetCondition().Factory().Ignite("Sun Damage", player, player, 5, false, false); + } + + Scoreboard.draw(); + } + @Override public void EndCheck() { if (!IsLive()) - { return; - } - List teamsAlive = new ArrayList<>(); - - for (GameTeam team : GetTeamList()) + if (this.WorldTimeSet > 24100 || GetTeam(ChatColor.RED).GetSize() == 0) { - if (team.GetPlayers(true).size() > 0) - { - teamsAlive.add(team); - } - } + SetCustomWinLine(_kingName + ChatColor.RESET + " has survived the siege!"); - if (teamsAlive.size() <= 1) - { - //Announce - if (teamsAlive.size() > 0) + AnnounceEnd(GetTeam(ChatColor.AQUA)); + + for (GameTeam team : GetTeamList()) { - GameTeam winner = teamsAlive.get(0); - TeamKing king = _kings.get(winner); - TeamKing dead = _kings.values().stream().filter(k -> k.getOwner().GetColor() != king.getOwner().GetColor()).findFirst().get(); - AnnounceEnd(winner); - writeFinalScoreboard(dead.getName(false), king.getName(false), dead.getOwner().GetColor() + "Quitters"); - for (GameTeam team : GetTeamList()) + if (WinnerTeam != null && team.equals(WinnerTeam)) { - for (Player player : team.GetPlayers(true)) + for (Player player : team.GetPlayers(false)) { - if (team.GetColor() == winner.GetColor()) - { - AddGems(player, 100, "Winning Team", false, false); - } - else - { - AddGems(player, 50, "Losing Team", false, false); - } - if (player.isOnline()) - { - AddGems(player, 10, "Participation", false, false); - } - - { - int crowns = 0; - for (GemData data : GetGems(player).values()) - { - crowns += data.Gems; - } - int streak = _streakData.getOrDefault(player, new KillStreakData()).getBestStreak(); - if (streak >= 2 && streak < 4) - { - AddGems(player, 0.5 * crowns, streak + " Player Kill Streak", false, false); - } - else if (streak >= 4 && streak < 6) - { - AddGems(player, crowns, streak + " Player Kill Streak", false, false); - } - else if (streak >= 6 && streak < 8) - { - AddGems(player, 1.5 * crowns, streak + " Player Kill Streak", false, false); - } - else if (streak >= 8) - { - AddGems(player, 2 * crowns, streak + " Player Kill Streak", false, false); - } - } - - if (GetKit(player) != null) - { - KitPlayer kit = (KitPlayer) GetKit(player); - int kitLevel = kit.getUpgradeLevel(player.getUniqueId()); - if (kitLevel > 0) - { - int crowns = 0; - for (GemData data : GetGems(player).values()) - { - crowns += data.Gems; - } - - AddGems(player, (0.5 * kitLevel) * crowns, kit.GetName() + " Kit Level Bonus", false, false); - } - } + AddGems(player, 10, "Winning Team", false, false); } } - SetState(GameState.End); - return; + + for (Player player : team.GetPlayers(false)) + if (player.isOnline()) + AddGems(player, 10, "Participation", false, false); } + + SetState(GameState.End); } - } - - @Override - @EventHandler - public void ScoreboardUpdate(UpdateEvent event) {}; - - @EventHandler - public void onUpdate(UpdateEvent event) - { - if (event.getType() != UpdateType.FAST) + + if (!_king.isValid() || GetTeam(ChatColor.AQUA).GetSize() == 0) { - return; - } - if (IsLive()) - { - if (UtilTime.elapsed(_lastRefill, TIME_TILL_REFILL)) + if (_kingDamager != null) { - _lastRefill = System.currentTimeMillis(); - _chests.forEach(this::fillChest); - Bukkit.broadcastMessage(C.cGreenB + "Chests have refilled!"); + SetCustomWinLine(C.cRed + _kingDamager.getName() + C.cWhite + " slaughtered " + _kingName + ChatColor.RESET + "!"); + AddGems(_kingDamager, 20, "King Slayer", false, false); + + Bukkit.getPluginManager().callEvent(new KingSlaughterEvent(_kingDamager)); } - - GameTeam red = GetTeam(ChatColor.RED); - GameTeam blue = GetTeam(ChatColor.AQUA); - TeamKing redKing = _kings.get(red); - TeamKing blueKing = _kings.get(blue); - redKing.update(_crystals.get(red).stream().filter(TeamCrystal::isActive).count() > 0); - if (redKing.isDead()) + else + SetCustomWinLine(_kingName + ChatColor.RESET + " has died!"); + + AnnounceEnd(GetTeam(ChatColor.RED)); + + for (GameTeam team : GetTeamList()) { - AnnounceEnd(blue); - writeFinalScoreboard(redKing.getName(false), blueKing.getName(false), blue.GetColor() + redKing.getLastDamager()); - for (GameTeam team : GetTeamList()) + if (WinnerTeam != null && team.equals(WinnerTeam)) { - for (Player player : team.GetPlayers(true)) + for (Player player : team.GetPlayers(false)) { - if (player.getName().equals(redKing.getLastDamager())) - { - AddGems(player, 20, "King Slayer", false, false); - } - if (team.GetColor() == ChatColor.AQUA) - { - AddGems(player, 100, "Winning Team", false, false); - } - else - { - AddGems(player, 50, "Losing Team", false, false); - } - if (player.isOnline()) - { - AddGems(player, 10, "Participation", false, false); - } - - int streak = _streakData.getOrDefault(player, new KillStreakData()).getBestStreak(); - if (streak > 0) - { - AddGems(player, streak, streak + " Player Kill Streak", false, false); - } - - KitPlayer kit = (KitPlayer) GetKit(player); - int kitLevel = kit.getUpgradeLevel(player.getUniqueId()); - if (kitLevel > 0) - { - int crowns = 0; - for (GemData data : GetGems(player).values()) - { - crowns += data.Gems; - } - - AddGems(player, (0.5 * kitLevel) * crowns, kit.GetName() + " Kit Level Bonus", false, false); - } + AddGems(player, 10, "Winning Team", false, false); } } - SetState(GameState.End); - return; + + for (Player player : team.GetPlayers(false)) + if (player.isOnline()) + AddGems(player, 10, "Participation", false, false); } - blueKing.update(_crystals.get(blue).stream().filter(TeamCrystal::isActive).count() > 0); - if (blueKing.isDead()) - { - AnnounceEnd(red); - writeFinalScoreboard(blueKing.getName(false), redKing.getName(false), red.GetColor() + blueKing.getLastDamager()); - for (GameTeam team : GetTeamList()) - { - for (Player player : team.GetPlayers(true)) - { - if (player.getName().equals(blueKing.getLastDamager())) - { - AddGems(player, 20, "King Slayer", false, false); - } - if (team.GetColor() == ChatColor.RED) - { - AddGems(player, 100, "Winning Team", false, false); - } - else - { - AddGems(player, 50, "Losing Team", false, false); - } - if (player.isOnline()) - { - AddGems(player, 10, "Participation", false, false); - } - - int streak = _streakData.getOrDefault(player, new KillStreakData()).getBestStreak(); - if (streak > 0) - { - AddGems(player, streak, streak + " Player Kill Streak", false, false); - } - - KitPlayer kit = (KitPlayer) GetKit(player); - int kitLevel = kit.getUpgradeLevel(player.getUniqueId()); - if (kitLevel > 0) - { - int crowns = 0; - for (GemData data : GetGems(player).values()) - { - crowns += data.Gems; - } - - AddGems(player, (0.5 * kitLevel) * crowns, kit.GetName() + " Kit Level Bonus", false, false); - } - } - } - SetState(GameState.End); - return; - } - - _tntSpawner.update(); - } - if (InProgress()) - { - writeScoreboard(); + + SetState(GameState.End); } } - + @EventHandler - public void onEditSettings(GameStateChangeEvent event) + public void TNTSpawn(UpdateEvent event) { - if (event.GetGame() != this) - { + if (GetState() != GameState.Live) return; - } - - if (event.GetState() == GameState.Live) - { - _lastRefill = System.currentTimeMillis(); - _tntSpawner.onStart(); - Manager.GetDamage().SetEnabled(false); - Manager.GetExplosion().setEnabled(false); - Manager.GetCreature().SetDisableCustomDrops(true); - } - - if (event.GetState() == GameState.End) - { - Manager.GetDamage().SetEnabled(true); - Manager.GetExplosion().setEnabled(true); - Manager.GetCreature().SetDisableCustomDrops(false); - Managers.get(LeaderboardManager.class).unregisterLeaderboard("TOP_CASTLESIEGE_DAILY_WINS"); - Managers.get(LeaderboardManager.class).unregisterLeaderboard("TOP_CASTLESIEGE_DAILY_KILLS"); - Managers.get(LeaderboardManager.class).unregisterLeaderboard("TOP_CASTLESIEGE_WINS"); - Managers.get(LeaderboardManager.class).unregisterLeaderboard("TOP_CASTLESIEGE_KILLS"); - } - } - - @EventHandler(priority = EventPriority.HIGHEST) - public void handleDeath(CombatDeathEvent event) - { - if (!IsLive()) - { + + if (event.getType() != UpdateType.SEC) return; - } - - event.SetBroadcastType(DeathMessageType.Detailed); + + if (!UtilTime.elapsed(this.GetStateTime(), 20000)) + return; + + if (!UtilTime.elapsed(_tntSpawn, 25000)) + return; + + if (_tntSpawns.isEmpty()) + return; + + Location loc = _tntSpawns.get(UtilMath.r(_tntSpawns.size())); + + if (loc.getBlock().getTypeId() == 46) + return; + + loc.getBlock().setTypeId(46); + _tntSpawn = System.currentTimeMillis(); } - - @EventHandler - public void disableDamageLevel(CustomDamageEvent event) - { - event.SetDamageToLevel(false); - } - - @EventHandler - public void BlockFade(BlockFadeEvent event) + + @EventHandler(priority = EventPriority.LOW) + public void TNTPickup(PlayerInteractEvent event) { + if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.LEFT_CLICK_BLOCK) + return; + + if (event.getClickedBlock().getTypeId() != 46) + return; + event.setCancelled(true); - } - - @EventHandler - public void BlockBurn(BlockBurnEvent event) - { - event.setCancelled(true); - } - - @EventHandler - public void BlockDecay(LeavesDecayEvent event) - { - event.setCancelled(true); - } - - @EventHandler - public void hangingBreak(HangingBreakEvent event) - { - if (event.getEntity() instanceof ItemFrame || event.getEntity() instanceof Painting) - { - event.setCancelled(true); - } - } - - @EventHandler - public void noFlow(BlockFromToEvent event) - { - if (!IsLive()) - { - return; - } - - Block block = event.getBlock(); - if (block.getType() == Material.WATER || block.getType() == Material.STATIONARY_WATER || block.getType() == Material.LAVA || block.getType() == Material.STATIONARY_LAVA) - { - event.setCancelled(true); - } - if (event.getToBlock().getType() == Material.ICE) - { - event.setCancelled(true); - } - } - - @EventHandler - public void onBlockChange(BlockFormEvent e) - { - if (!IsLive()) - { - return; - } - if (e.getNewState().getType() == Material.ICE) - { - e.setCancelled(true); - } - } - - @SuppressWarnings("deprecation") - @EventHandler(ignoreCancelled=true) - public void onPlayerEmptyBucket(PlayerBucketEmptyEvent event) - { - if (!IsLive()) - { - return; - } - - Player player = event.getPlayer(); - if (player.getItemInHand().getType() == Material.WATER_BUCKET) - { - player.getItemInHand().setType(Material.BUCKET); - Block block = event.getBlockClicked().getRelative(event.getBlockFace()); - if (block.getType().toString().contains("LAVA") || (block.getType().toString().contains("WATER") && block.getType() != Material.WATER_LILY)) - { - event.setCancelled(true); - player.sendBlockChange(block.getLocation(), block.getType(), block.getData()); - return; - } - for (BlockFace bf : BlockFace.values()) - { - Block relative = block.getRelative(bf); - if (relative.getType().toString().contains("LAVA") || (relative.getType().toString().contains("WATER") && relative.getType() != Material.WATER_LILY)) - { - event.setCancelled(true); - player.sendBlockChange(block.getLocation(), block.getType(), block.getData()); - } - } - } - else if (player.getItemInHand().getType() == Material.LAVA_BUCKET) - { - event.setCancelled(true); - Block block = event.getBlockClicked().getRelative(event.getBlockFace()); - player.sendBlockChange(block.getLocation(), block.getType(), block.getData()); - } - } - - @SuppressWarnings("deprecation") - @EventHandler(ignoreCancelled=true) - public void onPlayerEmptyBucket(PlayerBucketFillEvent event) - { - if (!IsLive()) - { - return; - } - - Player player = event.getPlayer(); - if (player.getItemInHand().getType() == Material.LAVA_BUCKET) - { - event.setCancelled(true); - Block block = event.getBlockClicked().getRelative(event.getBlockFace()); - player.sendBlockChange(block.getLocation(), block.getType(), block.getData()); - } - } - - @EventHandler(ignoreCancelled=true) - public void onBlockDispense(BlockDispenseEvent event) - { - if (!IsLive()) - { - return; - } - - if (event.getItem().getType() == Material.WATER_BUCKET) - { - Block dispenser = event.getBlock(); - - MaterialData mat = dispenser.getState().getData(); - Dispenser disp_mat = (Dispenser)mat; - BlockFace face = disp_mat.getFacing(); - Block block = dispenser.getRelative(face); - if (block.getType().toString().contains("LAVA") || (block.getType().toString().contains("WATER") && block.getType() != Material.WATER_LILY)) - { - event.setCancelled(true); - return; - } - for (BlockFace bf : BlockFace.values()) - { - if (block.getRelative(bf).getType().toString().contains("LAVA") || (block.getRelative(bf).getType().toString().contains("WATER") && block.getRelative(bf).getType() != Material.WATER_LILY)) - { - event.setCancelled(true); - } - } - } - } - - @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) - public void onCombatDeath(CombatDeathEvent event) - { - if (!IsLive()) - { - return; - } - - if (event.GetLog().GetKiller() == null) - { - return; - } - - if (!event.GetLog().GetKiller().IsPlayer()) - { - return; - } - - Player player = UtilPlayer.searchExact(event.GetLog().GetKiller().GetName()); - if (player == null) - { - return; - } - - AddStat(player, GetKit(player).GetName() + "KitKills", 1, false, false); - - if (UtilPlayer.isSpectator(player)) - { - return; - } - - player.setLevel(player.getLevel() + 1); - player.getInventory().addItem(new ItemBuilder(Material.GOLDEN_APPLE).setTitle(C.cPurple + "Golden Applegate").build()); - KillStreakData data = _streakData.computeIfAbsent(player, (key) -> new KillStreakData()); - boolean hardLine = GetKit(player).GetName().equals("Hardline"); - if (data.addKill(hardLine)) - { - AddStat(player, "KillStreak", 1, false, false); - ((KitPlayer)GetKit(player)).awardKillStreak(player, hardLine ? (data.getKills() + 1) : data.getKills()); - } - if (UtilMath.isEven(data.getKills())) - { - Bukkit.broadcastMessage(F.main("Game", C.cGreen + C.Bold + player.getName() + ChatColor.RESET + " is on a " + F.elem(C.cDPurple + data.getKills() + " player Kill Streak") + "!")); - } - } - - @EventHandler - public void TNTExplosion(ExplosionPrimeEvent event) - { - if (!event.getEntity().hasMetadata("THROWER")) - { - return; - } - float radius = event.getRadius(); - event.setRadius(0f); - - Player player = UtilPlayer.searchExact(((MetadataValue)UtilEnt.GetMetadata(event.getEntity(), "THROWER")).asString()); - if (player == null) - { - return; - } - if (GetTeam(player) == null) - { - return; - } - if (GetKit(player).GetName().equals("Demolitionist")) - { - radius += 3; - } - - Map nearby = UtilPlayer.getInRadius(event.getEntity().getLocation(), radius); - for (Player near : nearby.keySet()) - { - if (UtilPlayer.isSpectator(near)) - { - continue; - } - if (near.getEntityId() != player.getEntityId() && GetTeam(near).GetColor() == GetTeam(player).GetColor()) - { - continue; - } - if (near.getEntityId() == player.getEntityId() && event.getEntity().hasMetadata("OBJECTIVE_TNT")) - { - continue; - } - - double mult = nearby.get(near); - - int highestBlastProt = 0; - int blastProtEPF = 0; - for (ItemStack item : near.getInventory().getArmorContents()) - { - if (item != null && item.getEnchantments().containsKey(Enchantment.PROTECTION_EXPLOSIONS)) - { - blastProtEPF += (2 * item.getEnchantmentLevel(Enchantment.PROTECTION_EXPLOSIONS)); - if (item.getEnchantmentLevel(Enchantment.PROTECTION_EXPLOSIONS) > highestBlastProt) - { - highestBlastProt = item.getEnchantmentLevel(Enchantment.PROTECTION_EXPLOSIONS); - } - } - } - blastProtEPF = Math.min(blastProtEPF, 20); - - double damage = 8 * mult; - damage = damage * (1 - (blastProtEPF / 25)); - - double knockbackReduction = 1 - (highestBlastProt * 0.15); - - near.damage(damage, event.getEntity()); - UtilAction.velocity(near, UtilAlg.getTrajectory(event.getEntity().getLocation(), near.getLocation()), 1 * mult * knockbackReduction, false, 0, mult * knockbackReduction, 10, true); - } - - if (event.getEntity().hasMetadata("OBJECTIVE_TNT")) - { - List crystals = new ArrayList<>(); - - for (List c : _crystals.values()) - { - crystals.addAll(c); - } - for (TeamCrystal crystal : crystals) - { - if (crystal.isActive() && !crystal.getOwner().HasPlayer(player) && UtilMath.offset(event.getEntity().getLocation(), crystal.getLocation()) <= radius) - { - crystal.destroy(); - AddGems(player, 40, "Crystal Destruction", false, true); - long remaining = crystals.stream().filter(b -> b.getOwner().GetColor() == crystal.getOwner().GetColor()).filter(TeamCrystal::isActive).count(); - if (remaining > 0) - { - Bukkit.broadcastMessage(F.main("Game", "One of " + F.elem(crystal.getOwner().GetFormattedName() + "'s Crystals") + " has been destroyed!")); - } - else - { - Bukkit.broadcastMessage(F.main("Game", "All of " + F.elem(crystal.getOwner().GetFormattedName() + "'s Crystals") + " has been destroyed and " + F.elem(_kings.get(crystal.getOwner()).getName(false)) + " is now vulnerable!")); - } - } - } - for (TeamKing king : _kings.values()) - { - if (king.isDead() && !king.getOwner().HasPlayer(player) && UtilMath.offset(event.getEntity().getLocation(), king.getLocation()) <= radius) - { - king.handleDamage(player.getName(), 50); - } - } - } - } - - @EventHandler - public void TNTThrow(PlayerInteractEvent event) - { - if (!IsLive()) - { - return; - } - - if (!UtilEvent.isAction(event, ActionType.L)) - { - return; - } Player player = event.getPlayer(); - if (!UtilInv.IsItem(player.getItemInHand(), Material.TNT, (byte) 0)) - { - return; - } - if (!IsAlive(player)) - { return; - } - event.setCancelled(true); + if (!GetTeam(ChatColor.RED).HasPlayer(player)) + return; - if (!Manager.GetGame().CanThrowTNT(player.getLocation())) - { - // Inform - UtilPlayer.message(event.getPlayer(), F.main(GetName(), "You cannot use " + F.item("Throwing TNT") + " here.")); + if (_tntCarry.containsKey(player)) return; - } - UtilInv.remove(player, Material.TNT, (byte) 0, 1); - UtilInv.Update(player); + event.getClickedBlock().setTypeId(0); - TNTPrimed tnt = player.getWorld().spawn(player.getEyeLocation().add(player.getLocation().getDirection()), TNTPrimed.class); + FallingBlock tnt = player.getWorld().spawnFallingBlock(player.getEyeLocation(), 46, (byte) 0); - tnt.setFuseTicks(60); - - double throwMult = 1; - - if (GetKit(player).GetName().equals("Demolitionist")) - { - throwMult = ((KitDemolitionist)GetKit(player)).getThrowMultiplier(player); - } - - UtilAction.velocity(tnt, player.getLocation().getDirection(), 0.5 * throwMult, false, 0, 0.1, 10, false); - - UtilEnt.SetMetadata(tnt, "THROWER", player.getName()); - } - - @EventHandler - public void onLaunch(ProjectileHitEvent event) - { - if (!IsLive()) - { - return; - } - - if (event.getEntity() instanceof EnderPearl && event.getEntity().getShooter() != null && event.getEntity().getShooter() instanceof Entity) - { - Entity shooter = (Entity) event.getEntity().getShooter(); - if (_tntCarry.contains(shooter)) - { - return; - } - Location teleport = event.getEntity().getLocation(); - teleport.setPitch(shooter.getLocation().getPitch()); - teleport.setYaw(shooter.getLocation().getYaw()); - shooter.teleport(teleport); - } - if (event.getEntity() instanceof Arrow) - { - Manager.runSyncLater(event.getEntity()::remove, 1L); - } - } - - @EventHandler - public void onOpenChest(PlayerInteractEvent event) - { - if (!IsLive()) - { - return; - } - - if (event.getClickedBlock() != null && event.getClickedBlock().getType() == Material.CHEST) - { - if (UtilPlayer.isSpectator(event.getPlayer())) - { - event.setCancelled(true); - } - } - } - - @EventHandler(ignoreCancelled = true) - public void onDamage(EntityDamageEvent event) - { - if (!IsLive()) - { - return; - } - if (event.getEntity() instanceof EnderCrystal) - { - event.setCancelled(true); - return; - } - if (event.getEntity() instanceof Zombie) - { - event.setCancelled(true); - if (event instanceof EntityDamageByEntityEvent) - { - GameTeam owner = event.getEntity().getCustomName().contains("Ryan") ? GetTeam(ChatColor.AQUA) : GetTeam(ChatColor.RED); - EntityDamageByEntityEvent e = (EntityDamageByEntityEvent) event; - if (e.getDamager() instanceof Player) - { - Player p = (Player) e.getDamager(); - if (UtilPlayer.isSpectator(p)) - { - return; - } - if (owner.HasPlayer(p)) - { - return; - } - if (_crystals.get(owner).stream().filter(TeamCrystal::isActive).count() > 0) - { - UtilPlayer.message(p, F.main("Game", "You cannot attack the enemy king until your team has destroyed his protective crystals!")); - return; - } - TeamKing king = _kings.get(owner); - if (king.handleDamage(p.getName(), e.getDamage())) - { - for (Player alert : owner.GetPlayers(true)) - { - if (Recharge.Instance.use(alert, "KingDamageAlert", 5000, false, false)) - { - alert.sendMessage(king.getName(true) + " is under attack!"); - } - } - } - } - } - } - } - - @EventHandler - public void onDrop(PlayerDropItemEvent event) - { - if (!IsLive()) - { - return; - } - - ItemStack drop = event.getItemDrop().getItemStack(); - if (drop.hasItemMeta() && drop.getItemMeta().hasLore() && drop.getItemMeta().getLore().stream().map(ChatColor::stripColor).anyMatch(lore -> lore.equals("Kit Item"))) - { - event.setCancelled(true); - return; - } - - event.getItemDrop().remove(); - } - - @EventHandler - public void craftItem(PrepareItemCraftEvent event) - { - if (!IsLive()) - { - return; - } - - if (event.getInventory().getResult().getType() == Material.FLINT_AND_STEEL) - { - event.getInventory().setResult(_flintAndSteel.build()); - } - } - - @EventHandler - public void onInvClick(InventoryClickEvent event) - { - if (!IsLive()) - { - return; - } - ItemStack current = event.getCurrentItem(); - if (event.getAction() == InventoryAction.HOTBAR_SWAP || event.getAction() == InventoryAction.HOTBAR_MOVE_AND_READD) - { - current = event.getWhoClicked().getInventory().getItem(event.getHotbarButton()); - } - if (current == null || !current.hasItemMeta()) - { - return; - } - if (current.getItemMeta().hasDisplayName() && current.getItemMeta().getDisplayName().equals(C.cRed + "TNT")) - { - event.setCancelled(true); - return; - } - if (event.getView().getTopInventory() != null && event.getView().getTopInventory().getType() == InventoryType.CHEST) - { - if (current.getItemMeta().hasLore()) - { - for (String lore : current.getItemMeta().getLore()) - { - if (ChatColor.stripColor(lore).equalsIgnoreCase("Kit Item")) - { - event.setCancelled(true); - break; - } - } - } + player.eject(); + player.setPassenger(tnt); - } + _tntCarry.put(player, tnt); + + UtilPlayer.message(player, F.main("Game", "You picked up " + F.skill("TNT") + ".")); + UtilPlayer.message(player, F.main("Game", F.elem("Right-Click") + " to detonate yourself.")); } - - @EventHandler - public void onFirstBlood(FirstBloodEvent event) - { - if (!IsLive()) - { - return; - } - - AddStat(event.getPlayer(), "FirstBlood", 1, true, false); - } - - @EventHandler - public void onPearl(PlayerInteractEvent event) - { - if (!IsLive()) - { - return; - } - - if (!UtilEvent.isAction(event, ActionType.R)) - { - return; - } - - if (event.getItem() != null && event.getItem().getType() == Material.ENDER_PEARL) - { - Player player = (Player) event.getPlayer(); - if (!Recharge.Instance.use(player, "Enderpearl", 4000, true, true)) - { - event.setCancelled(true); - player.updateInventory(); - } - } - } - - @EventHandler - public void onItemDespawn(ItemDespawnEvent event) - { - if (!IsLive()) - { - return; - } - - if (_tntSpawner.isSpawned()) - { - if (_tntSpawner.getItem().getEntityId() == event.getEntity().getEntityId()) - { - event.setCancelled(true); - } - } - } - - @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) - public void onPickup(PlayerPickupItemEvent event) - { - if (!IsLive()) - { - return; - } - - if (_tntSpawner.isSpawned() && event.getItem().getEntityId() == _tntSpawner.getItem().getEntityId()) - { - event.setCancelled(true); - if (!_tntCarry.contains(event.getPlayer())) - { - _tntSpawner.pickup(); - _tntCarry.add(event.getPlayer()); - event.getPlayer().setMetadata("OLD_HELM", new FixedMetadataValue(UtilServer.getPlugin(), event.getPlayer().getInventory().getHelmet())); - event.getPlayer().setMetadata("TNT_START", new FixedMetadataValue(UtilServer.getPlugin(), System.currentTimeMillis())); - event.getPlayer().getInventory().setHelmet(_wearableTnt.build()); - UtilPlayer.message(event.getPlayer(), F.main("Game", "You picked up " + F.skill("TNT") + ".")); - UtilPlayer.message(event.getPlayer(), F.main("Game", F.elem("Right-Click") + " to detonate yourself.")); - UtilPlayer.message(event.getPlayer(), F.main("Game", "Run to the enemy Crystal and Detonate to destroy it.")); - } - } - } - - @EventHandler(ignoreCancelled = true) + + @EventHandler(priority = EventPriority.NORMAL) public void TNTUse(PlayerInteractEvent event) { + if (event.isCancelled()) + return; + + if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.RIGHT_CLICK_AIR) + return; + Player player = event.getPlayer(); - - if (!_tntCarry.contains(player)) - { + + if (!_tntCarry.containsKey(player)) return; - } - - if (!UtilEvent.isAction(event, ActionType.R)) - { - return; - } - + event.setCancelled(true); - - player.getInventory().setHelmet((ItemStack) player.getMetadata("OLD_HELM").get(0).value()); - player.removeMetadata("OLD_HELM", UtilServer.getPlugin()); - player.removeMetadata("TNT_START", UtilServer.getPlugin()); - _tntCarry.remove(player); + + for (Location loc : _tntSpawns) + { + if (UtilMath.offset(player.getLocation(), loc) < 16) + { + UtilPlayer.message(player, F.main("Game", "You cannot " + F.skill("Detonate") + " so far from the Castle.")); + return; + } + } + + _tntCarry.remove(player).remove(); TNTPrimed tnt = player.getWorld().spawn(player.getEyeLocation(), TNTPrimed.class); - UtilEnt.SetMetadata(tnt, "THROWER", player.getName()); - UtilEnt.SetMetadata(tnt, "OBJECTIVE_TNT", true); tnt.setFuseTicks(0); UtilPlayer.message(player, F.main("Game", "You used " + F.skill("Detonate") + ".")); } - + + @EventHandler(priority = EventPriority.LOWEST) + public void TNTDeath(PlayerDeathEvent event) + { + Player player = event.getEntity(); + + if (!_tntCarry.containsKey(player)) + return; + + //Remove the TNT + _tntCarry.get(player).remove(); + + //Flag for Removal + _tntCarryEnd.add(player); + + + TNTPrimed tnt = player.getWorld().spawn(player.getEyeLocation(), TNTPrimed.class); + tnt.setFuseTicks(0); + UtilPlayer.message(player, F.main("Game", "You used " + F.skill("Detonate") + ".")); + } + + @EventHandler(priority = EventPriority.LOWEST) + public void TNTDamageDivert(ProjectileHitEvent event) + { + Iterator playerIterator = _tntCarry.keySet().iterator(); + + while (playerIterator.hasNext()) + { + Player player = playerIterator.next(); + + if (player.getPassenger() == null) + continue; + + double dist = UtilMath.offset(player.getPassenger().getLocation(), event.getEntity().getLocation().add(event.getEntity().getVelocity())); + + if (dist < 2) + { + int damage = (int) (5 * (event.getEntity().getVelocity().length() / 3d)); + + //Damage Event + Manager.GetDamage().NewDamageEvent(player, (LivingEntity)event.getEntity().getShooter(), event.getEntity(), + DamageCause.CUSTOM, damage, true, false, false, + null, GetName()); + + event.getEntity().remove(); + } + + if (_tntCarryEnd.contains(player)) + { + playerIterator.remove(); + } + } + + _tntCarryEnd.clear(); + } + + @EventHandler public void TNTExpire(UpdateEvent event) { - if (!IsLive()) - { - return; - } - if (event.getType() != UpdateType.FASTER) - { return; - } - Iterator tntIterator = _tntCarry.iterator(); + Iterator tntIterator = _tntCarry.keySet().iterator(); while (tntIterator.hasNext()) { Player player = tntIterator.next(); - - if (player.isDead() || UtilTime.elapsed(player.getMetadata("TNT_START").get(0).asLong(), 60000)) + FallingBlock block = _tntCarry.get(player); + + if (player.isDead() || !block.isValid() || block.getTicksLived() > 1500) { + player.eject(); + block.remove(); + TNTPrimed tnt = player.getWorld().spawn(player.getEyeLocation(), TNTPrimed.class); - UtilEnt.SetMetadata(tnt, "THROWER", player.getName()); - UtilEnt.SetMetadata(tnt, "OBJECTIVE_TNT", true); tnt.setFuseTicks(0); - - if (!player.isDead()) - { - player.getInventory().setHelmet((ItemStack) player.getMetadata("OLD_HELM").get(0).value()); - } - player.removeMetadata("OLD_HELM", UtilServer.getPlugin()); - player.removeMetadata("TNT_START", UtilServer.getPlugin()); - + tntIterator.remove(); continue; } - - List crystals = new ArrayList<>(); - - for (List c : _crystals.values()) - { - crystals.addAll(c); - } - for (TeamCrystal crystal : crystals) - { - if (crystal.isActive() && !crystal.getOwner().HasPlayer(player) && UtilMath.offset(player.getLocation(), crystal.getLocation()) <= 3) - { - TNTPrimed tnt = player.getWorld().spawn(player.getEyeLocation(), TNTPrimed.class); - UtilEnt.SetMetadata(tnt, "THROWER", player.getName()); - UtilEnt.SetMetadata(tnt, "OBJECTIVE_TNT", true); - tnt.setFuseTicks(0); - - if (!player.isDead()) - { - player.getInventory().setHelmet((ItemStack) player.getMetadata("OLD_HELM").get(0).value()); - } - player.removeMetadata("OLD_HELM", UtilServer.getPlugin()); - player.removeMetadata("TNT_START", UtilServer.getPlugin()); - - tntIterator.remove(); - } - } - - UtilTextBottom.display(GetTeam(player).GetColor() + player.getName() + " has the TNT!", UtilServer.getPlayers()); + + //Firework UtilFirework.playFirework(player.getEyeLocation(), Type.BURST, Color.RED, false, false); } } - + @EventHandler - public void onDeath(PlayerDeathEvent event) + public void TNTWeakness(ExplosionPrimeEvent event) { - Player player = event.getEntity(); - - _streakData.getOrDefault(player, new KillStreakData()).reset(); - - if (!_tntCarry.contains(player)) + Location weakness = null; + for (Location loc : _tntWeakness) { - return; + if (UtilMath.offset(loc, event.getEntity().getLocation()) < 4) + { + weakness = loc; + break; + } } - - player.removeMetadata("OLD_HELM", UtilServer.getPlugin()); - player.removeMetadata("TNT_START", UtilServer.getPlugin()); - _tntCarry.remove(player); - TNTPrimed tnt = player.getWorld().spawn(player.getEyeLocation(), TNTPrimed.class); - UtilEnt.SetMetadata(tnt, "THROWER", player.getName()); - UtilEnt.SetMetadata(tnt, "OBJECTIVE_TNT", true); - tnt.setFuseTicks(0); - UtilPlayer.message(player, F.main("Game", "You used " + F.skill("Detonate") + ".")); + + if (weakness == null) + return; + + _tntWeakness.remove(weakness); + + final Location extra = weakness; + + for (int i = 0; i < 10; i++) + { + Manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable() + { + public void run() + { + TNTPrimed tnt = extra.getWorld().spawn(extra.clone().add(3 - UtilMath.r(6), 5 + UtilMath.r(2), 3 - UtilMath.r(6)), TNTPrimed.class); + tnt.setFuseTicks(0); + tnt.setIsIncendiary(true); + } + }, i * 3); + } + + weakness.getWorld().playSound(weakness, Sound.EXPLODE, 16f, 0.8f); } - - @EventHandler - public void onBlockPlace(BlockPlaceEvent event) + + @EventHandler(priority = EventPriority.HIGH) + public void AttackerBlockBreak(org.bukkit.event.block.BlockBreakEvent event) { - if (_tntSpawner.canPlaceFireAt(event.getBlock())) + GameTeam team = GetTeam(event.getPlayer()); + if (team == null) + return; + + if (team.GetColor() != ChatColor.RED) + return; + + if (event.getBlock().getTypeId() == 85) + event.setCancelled(false); + } + + @EventHandler + public void DefenderBlockPlace(org.bukkit.event.block.BlockPlaceEvent event) + { + GameTeam team = GetTeam(event.getPlayer()); + if (team == null) + return; + + if (team.GetColor() != ChatColor.AQUA) + return; + + if (event.getBlock().getTypeId() != 85) + return; + + for (Block block : UtilBlock.getSurrounding(event.getBlock(), false)) + { + if (block.isLiquid()) + { + event.setCancelled(true); + UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot place " + F.elem("Barricade") + " in water.")); + } + } + + if (event.getBlockAgainst().getTypeId() == 85) { event.setCancelled(true); + UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot place " + F.elem("Barricade") + " on each other.")); + } + + if (_king != null && UtilMath.offset(_king.getLocation(), event.getBlock().getLocation().add(0.5, 0.5, 0.5)) < 4) + { + event.setCancelled(true); + UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot place " + F.elem("Barricade") + " near " + F.elem(C.cAqua + _kingName) + ".")); } } -} \ No newline at end of file + + @EventHandler + public void DefenderBlockInteract(PlayerInteractEvent event) + { + if (!UtilEvent.isAction(event, ActionType.R_BLOCK)) + return; + + GameTeam team = GetTeam(event.getPlayer()); + if (team == null) + return; + + if (team.GetColor() != ChatColor.AQUA) + return; + + if (event.getClickedBlock() == null || event.getClickedBlock().getTypeId() != 85) + return; + + UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, event.getClickedBlock().getLocation().add(0.5, 0.5, 0.5), 0, 0, 0, 0, 1, + ViewDist.LONG, UtilServer.getPlayers()); + event.getClickedBlock().getWorld().playSound(event.getClickedBlock().getLocation(), Sound.NOTE_STICKS, 2f, 1f); + Manager.GetBlockRestore().add(event.getClickedBlock(), 0, (byte) 0, 1000); + } + + @EventHandler + public void DayTimer(UpdateEvent event) + { + if (GetState() != GameState.Live) + return; + + if (event.getType() != UpdateType.TICK) + return; + + WorldTimeSet = (WorldTimeSet + 1); + } + + @EventHandler + public void SnowDamage(UpdateEvent event) + { + if (GetState() != GameState.Live) + return; + + if (event.getType() != UpdateType.FAST) + return; + + for (Player player : GetPlayers(true)) + if (player.getLocation().getBlock().getTypeId() == 78) + { + //Damage Event + Manager.GetDamage().NewDamageEvent(player, null, null, + DamageCause.DROWNING, 2, false, true, false, + "Snow", "Snow Damage"); + + player.getWorld().playEffect(player.getLocation(), Effect.STEP_SOUND, 80); + } + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiegeClassic.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiegeClassic.java deleted file mode 100644 index 76e0d0f7c..000000000 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/CastleSiegeClassic.java +++ /dev/null @@ -1,973 +0,0 @@ -package nautilus.game.arcade.game.games.castlesiege; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; - -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Color; -import org.bukkit.Effect; -import org.bukkit.EntityEffect; -import org.bukkit.FireworkEffect.Type; -import org.bukkit.Location; -import org.bukkit.Material; -import org.bukkit.Sound; -import org.bukkit.block.Block; -import org.bukkit.entity.Creature; -import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.FallingBlock; -import org.bukkit.entity.Horse; -import org.bukkit.entity.Horse.Style; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.entity.TNTPrimed; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.HandlerList; -import org.bukkit.event.block.Action; -import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import org.bukkit.event.entity.EntityTargetEvent; -import org.bukkit.event.entity.ExplosionPrimeEvent; -import org.bukkit.event.entity.PlayerDeathEvent; -import org.bukkit.event.entity.ProjectileHitEvent; -import org.bukkit.event.player.PlayerEvent; -import org.bukkit.event.player.PlayerInteractEntityEvent; -import org.bukkit.event.player.PlayerInteractEvent; -import org.bukkit.inventory.ItemStack; - -import mineplex.core.common.util.C; -import mineplex.core.common.util.F; -import mineplex.core.common.util.UtilBlock; -import mineplex.core.common.util.UtilEnt; -import mineplex.core.common.util.UtilEvent; -import mineplex.core.common.util.UtilEvent.ActionType; -import mineplex.core.common.util.UtilFirework; -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.UtilPlayer; -import mineplex.core.common.util.UtilServer; -import mineplex.core.common.util.UtilTime; -import mineplex.core.recharge.Recharge; -import mineplex.core.updater.UpdateType; -import mineplex.core.updater.event.UpdateEvent; -import mineplex.minecraft.game.core.damage.CustomDamageEvent; - -import nautilus.game.arcade.ArcadeManager; -import nautilus.game.arcade.GameType; -import nautilus.game.arcade.events.GameStateChangeEvent; -import nautilus.game.arcade.events.PlayerGameRespawnEvent; -import nautilus.game.arcade.game.GameTeam; -import nautilus.game.arcade.game.TeamGame; -import nautilus.game.arcade.game.games.castlesiege.classickits.KitHumanKnight; -import nautilus.game.arcade.game.games.castlesiege.classickits.KitHumanMarksman; -import nautilus.game.arcade.game.games.castlesiege.classickits.KitHumanPeasant; -import nautilus.game.arcade.game.games.castlesiege.classickits.KitUndeadArcher; -import nautilus.game.arcade.game.games.castlesiege.classickits.KitUndeadGhoul; -import nautilus.game.arcade.game.games.castlesiege.classickits.KitUndeadZombie; -import nautilus.game.arcade.game.modules.compass.CompassModule; -import nautilus.game.arcade.kit.Kit; -import nautilus.game.arcade.kit.NullKit; -import nautilus.game.arcade.stats.BloodThirstyStatTracker; -import nautilus.game.arcade.stats.KingDamageStatTracker; -import nautilus.game.arcade.stats.KingSlayerStatTracker; -import nautilus.game.arcade.stats.TeamDeathsStatTracker; -import nautilus.game.arcade.stats.TeamKillsStatTracker; -import nautilus.game.arcade.stats.WinAsTeamStatTracker; - -public class CastleSiegeClassic extends TeamGame -{ - public static class KingDamageEvent extends PlayerEvent - { - private static final HandlerList handlers = new HandlerList(); - - public static HandlerList getHandlerList() - { - return handlers; - } - - @Override - public HandlerList getHandlers() - { - return getHandlerList(); - } - - private final double _damage; - - public KingDamageEvent(Player who, double damage) - { - super(who); - - _damage = damage; - } - - public double getDamage() - { - return _damage; - } - } - - public static class KingSlaughterEvent extends PlayerEvent - { - private static final HandlerList handlers = new HandlerList(); - - public static HandlerList getHandlerList() - { - return handlers; - } - - @Override - public HandlerList getHandlers() - { - return getHandlerList(); - } - - public KingSlaughterEvent(Player who) - { - super(who); - } - } - - private ArrayList _lastScoreboard = new ArrayList(); - - private long _tntSpawn = 0; - private ArrayList _tntSpawns = new ArrayList(); - private ArrayList _tntWeakness = new ArrayList(); - - private HashMap _tntCarry = new HashMap(); - private HashSet _tntCarryEnd = new HashSet(); - - private ArrayList _kingLocs; - private Creature _king; - private Location _kingLoc; - private String _kingName; - private Player _kingDamager = null; - private int _kingHealth = 40; - - private ArrayList _peasantSpawns; - private ArrayList _horseSpawns; - - public CastleSiegeClassic(ArcadeManager manager) - { - super(manager, GameType.CastleSiege, - - new Kit[] - { - new KitHumanMarksman(manager), - new KitHumanKnight(manager), - //new KitHumanBrawler(manager), - //new KitHumanAssassin(manager), - new NullKit(manager), - new KitHumanPeasant(manager), - new NullKit(manager), - new KitUndeadGhoul(manager), - new KitUndeadArcher(manager), - new KitUndeadZombie(manager), - }, - - new String[] - { - F.elem(C.cAqua + "Defenders") + C.cWhite + " must defend the King.", - F.elem(C.cAqua + "Defenders") + C.cWhite + " win when the sun rises.", - F.elem(C.cAqua + "Defenders") + C.cWhite + " respawn as wolves.", - "", - F.elem(C.cRed + "Undead") + C.cWhite + " must kill the King.", - F.elem(C.cRed + "Undead") + C.cWhite + " lose when the sun rises.", - - }); - - _help = new String[] - { - "Marksmen are extremely important to defence!", - "It's recommended 50%+ of defence are Marksmen.", - "Use Barricades to block the Undeads path.", - "Use TNT to destroy weak points in walls.", - "Weak points are marked by cracked stone brick.", - "Undead can break fences with their axes.", - "Undead Archers must pick up arrows from the ground.", - - }; - - this.StrictAntiHack = true; - - this.HungerSet = 20; - this.DeathOut = false; - this.WorldTimeSet = 14000; //14000 - this.BlockPlaceAllow.add(85); - - _kingName = C.cYellow + C.Bold + "King Sparklez"; - - GameTeam notRedTeam = null; - for (GameTeam team : GetTeamList()) - { - if (team.GetColor() != ChatColor.RED) - { - notRedTeam = team; - break; - } - } - - registerStatTrackers( - new KingSlayerStatTracker(this), - new BloodThirstyStatTracker(this), - new KingDamageStatTracker(this), - - new TeamDeathsStatTracker(this), - new TeamKillsStatTracker(this) - ); - - registerChatStats( - Kills, - Deaths, - KDRatio, - BlankLine, - Assists, - DamageDealt, - DamageTaken - ); - - registerChatStats(); - - new CompassModule() - .setGiveCompass(true) - .setGiveCompassToSpecs(true) - .setGiveCompassToAlive(false) - .register(this); - } - - @Override - public void ParseData() - { - _tntSpawns = WorldData.GetDataLocs("RED"); - _tntWeakness = WorldData.GetDataLocs("BLACK"); - - _kingLocs = WorldData.GetDataLocs("YELLOW"); - - _peasantSpawns = WorldData.GetDataLocs("GREEN"); - _horseSpawns = WorldData.GetDataLocs("BROWN"); - } - - @Override - public void RestrictKits() - { - for (Kit kit : GetKits()) - { - for (GameTeam team : GetTeamList()) - { - if (team.GetColor() == ChatColor.RED) - { - if (kit.GetName().contains("Castle")) - team.GetRestrictedKits().add(kit); - - team.SetName("Undead"); - } - else - { - if (kit.GetName().contains("Undead")) - team.GetRestrictedKits().add(kit); - - team.SetRespawnTime(8); - - team.SetName("Defenders"); - } - } - } - } - - @EventHandler(priority = EventPriority.HIGH) - public void registerTeamTracker(GameStateChangeEvent event) - { - if (event.GetState() == GameState.Recruit) - { - GameTeam notRed = null; - - for (GameTeam team : GetTeamList()) - { - if (team.GetColor() == ChatColor.RED) - continue; - - notRed = team; - break; - } - - if (notRed != null) - { - registerStatTrackers(new WinAsTeamStatTracker(this, notRed, "ForTheKing")); - System.out.println("Successfully registered For the King StatTrak"); - } - } - } - - @EventHandler - public void MoveKits(GameStateChangeEvent event) - { - if (event.GetState() != GameState.Prepare) - return; - - for (int i = 0; i < WorldData.GetDataLocs("PINK").size() && i < 3; i++) - { - if (GetKits().length <= 5 + i) - continue; - - this.CreatureAllowOverride = true; - Entity ent = GetKits()[5 + i].SpawnEntity(WorldData.GetDataLocs("PINK").get(i)); - this.CreatureAllowOverride = false; - - Manager.GetLobby().addKitLocation(ent, GetKits()[5 + i], WorldData.GetDataLocs("PINK").get(i)); - } - } - - @EventHandler - public void HorseSpawn(GameStateChangeEvent event) - { - if (event.GetState() != GameState.Prepare) - return; - - for (Location loc : _horseSpawns) - { - this.CreatureAllowOverride = true; - Horse horse = loc.getWorld().spawn(loc, Horse.class); - this.CreatureAllowOverride = false; - - horse.setAdult(); - horse.setAgeLock(true); - horse.setColor(org.bukkit.entity.Horse.Color.BLACK); - horse.setStyle(Style.BLACK_DOTS); - horse.setMaxDomestication(1); - horse.getInventory().setSaddle(new ItemStack(Material.SADDLE)); - horse.getInventory().setArmor(new ItemStack(Material.IRON_BARDING)); - - horse.setMaxHealth(60); - horse.setHealth(horse.getMaxHealth()); - - horse.setCustomName("War Horse"); - } - } - - @EventHandler - public void HorseInteract(PlayerInteractEntityEvent event) - { - if (!(event.getRightClicked() instanceof Horse)) - return; - - Player player = event.getPlayer(); - GameTeam team = GetTeam(player); - - if (team == null || team.GetColor() == ChatColor.RED || !IsAlive(player)) - { - event.setCancelled(true); - } - } - - @EventHandler - public void HorseDamageCancel(CustomDamageEvent event) - { - if (!(event.GetDamageeEntity() instanceof Horse)) - return; - - Player player = event.GetDamagerPlayer(true); - if (player == null) - return; - - if (!IsAlive(player)) - return; - - if (GetTeam(player) == null) - return; - - if (GetTeam(player).GetColor() == ChatColor.RED) - return; - - event.SetCancelled("Horse Team Damage"); - } - - @EventHandler(priority = EventPriority.HIGH) - public void GameStateChange(GameStateChangeEvent event) - { - if (event.GetState() != GameState.Prepare) - return; - - //Spawn King - this.CreatureAllowOverride = true; - - _kingLoc = _kingLocs.get(UtilMath.r(_kingLocs.size())); - - _king = (Creature) _kingLoc.getWorld().spawnEntity(_kingLoc, EntityType.ZOMBIE); - - _king.getEquipment().setHelmet(new ItemStack(Material.DIAMOND_HELMET)); - _king.getEquipment().setChestplate(new ItemStack(Material.DIAMOND_CHESTPLATE)); - _king.getEquipment().setLeggings(new ItemStack(Material.DIAMOND_LEGGINGS)); - _king.getEquipment().setBoots(new ItemStack(Material.DIAMOND_BOOTS)); - _king.getEquipment().setItemInHand(new ItemStack(Material.DIAMOND_SWORD)); - - _king.setCustomName(_kingName); - _king.setCustomNameVisible(true); - - _king.setRemoveWhenFarAway(false); - - this.CreatureAllowOverride = false; - } - - @EventHandler(priority = EventPriority.HIGH) - public void SetDefenderRespawn(GameStateChangeEvent event) - { - if (event.GetState() != GameState.Live) - return; - - //Change to Peasant Spawns - this.GetTeam(ChatColor.AQUA).SetSpawns(_peasantSpawns); - } - - - @EventHandler - public void KingTarget(EntityTargetEvent event) - { - event.setCancelled(true); - } - - @EventHandler - public void KingDamage(CustomDamageEvent event) - { - if (_king == null || !_king.isValid()) - return; - - if (!event.GetDamageeEntity().equals(_king)) - return; - - event.SetCancelled("King Damage"); - - Player damager = event.GetDamagerPlayer(true); - if (damager == null) return; - - GameTeam team = GetTeam(damager); - - if (team != null && team.GetColor() == ChatColor.RED) - { - if (!Recharge.Instance.use(damager, "Damage King", 400, false, false)) - return; - - if (!IsAlive(damager)) - { - return; - } - - _king.playEffect(EntityEffect.HURT); - - _kingDamager = damager; - _kingHealth--; - - Bukkit.getPluginManager().callEvent(new KingDamageEvent(damager, 1)); - - if (_kingHealth < 0) - _kingHealth = 0; - - WriteScoreboard(); - - if (_kingHealth <= 0) - _king.damage(500); - - EndCheck(); - } - } - - @EventHandler - public void KingUpdate(UpdateEvent event) - { - if (GetState() != GameState.Live) - return; - - if (event.getType() != UpdateType.SEC) - return; - - if (_king == null) - return; - - if (UtilMath.offset(_king.getLocation(), _kingLoc) > 6) - { - _king.teleport(_kingLoc); - } - else - { - UtilEnt.CreatureMove(_king, _kingLoc, 1f); - } - } - - @EventHandler - public void PlayerDeath(PlayerGameRespawnEvent event) - { - if (GetTeam(ChatColor.AQUA).HasPlayer(event.GetPlayer())) - SetKit(event.GetPlayer(), GetKits()[3], true); - } - - @Override - @EventHandler - public void ScoreboardUpdate(UpdateEvent event) - { - if (event.getType() != UpdateType.FAST) - return; - - WriteScoreboard(); - } - - public void WriteScoreboard() - { - //Get Values - HashMap _scoreGroup = new HashMap(); - _scoreGroup.put(C.cAqua + "Defenders", 0); - _scoreGroup.put(C.cDAqua + "Wolves", 0); - _scoreGroup.put(C.cRed + "Undead", 0); - - for (Player player : UtilServer.getPlayers()) - { - if (!IsAlive(player)) - continue; - - Kit kit = GetKit(player); - if (kit == null) continue; - - if (kit.GetName().contains("Castle")) - { - if (kit.GetName().contains("Wolf")) - { - _scoreGroup.put(C.cDAqua + "Wolves", 1 + _scoreGroup.get(C.cDAqua + "Wolves")); - } - else - { - _scoreGroup.put(C.cAqua + "Defenders", 1 + _scoreGroup.get(C.cAqua + "Defenders")); - } - } - else if (kit.GetName().contains("Undead")) - { - _scoreGroup.put(C.cRed + "Undead", 1 + _scoreGroup.get(C.cRed + "Undead")); - } - } - - //Wipe Last - Scoreboard.reset(); - - //Teams - for (String group : _scoreGroup.keySet()) - { - Scoreboard.writeNewLine(); - Scoreboard.write(group); - Scoreboard.write(ChatColor.getLastColors(group) + _scoreGroup.get(group) + " Players"); - } - - //King - if (_king != null && _king.isValid()) - { - Scoreboard.writeNewLine(); - Scoreboard.write(C.cYellow + C.Bold + "King"); - Scoreboard.write(_kingHealth + " Health"); - } - - long timeLeft = 24000 - WorldTimeSet; - timeLeft = timeLeft / 20 * 1000; - - - if (timeLeft > 0) - { - Scoreboard.writeNewLine(); - Scoreboard.write(C.cYellow + C.Bold + "Sun Rise"); - Scoreboard.write(UtilTime.MakeStr(timeLeft, 0)); - } - else - { - Scoreboard.writeNewLine(); - Scoreboard.write(C.cYellow + C.Bold + "Sun Rise"); - Scoreboard.write("Undead Burning!"); - - for (Player player : GetTeam(ChatColor.RED).GetPlayers(true)) - Manager.GetCondition().Factory().Ignite("Sun Damage", player, player, 5, false, false); - } - - Scoreboard.draw(); - } - - @Override - public void EndCheck() - { - if (!IsLive()) - return; - - if (this.WorldTimeSet > 24100 || GetTeam(ChatColor.RED).GetSize() == 0) - { - SetCustomWinLine(_kingName + ChatColor.RESET + " has survived the siege!"); - - AnnounceEnd(GetTeam(ChatColor.AQUA)); - - for (GameTeam team : GetTeamList()) - { - if (WinnerTeam != null && team.equals(WinnerTeam)) - { - for (Player player : team.GetPlayers(false)) - { - AddGems(player, 10, "Winning Team", false, false); - } - } - - for (Player player : team.GetPlayers(false)) - if (player.isOnline()) - AddGems(player, 10, "Participation", false, false); - } - - SetState(GameState.End); - } - - if (!_king.isValid() || GetTeam(ChatColor.AQUA).GetSize() == 0) - { - if (_kingDamager != null) - { - SetCustomWinLine(C.cRed + _kingDamager.getName() + C.cWhite + " slaughtered " + _kingName + ChatColor.RESET + "!"); - AddGems(_kingDamager, 20, "King Slayer", false, false); - - Bukkit.getPluginManager().callEvent(new KingSlaughterEvent(_kingDamager)); - } - else - SetCustomWinLine(_kingName + ChatColor.RESET + " has died!"); - - AnnounceEnd(GetTeam(ChatColor.RED)); - - for (GameTeam team : GetTeamList()) - { - if (WinnerTeam != null && team.equals(WinnerTeam)) - { - for (Player player : team.GetPlayers(false)) - { - AddGems(player, 10, "Winning Team", false, false); - } - } - - for (Player player : team.GetPlayers(false)) - if (player.isOnline()) - AddGems(player, 10, "Participation", false, false); - } - - SetState(GameState.End); - } - } - - @EventHandler - public void TNTSpawn(UpdateEvent event) - { - if (GetState() != GameState.Live) - return; - - if (event.getType() != UpdateType.SEC) - return; - - if (!UtilTime.elapsed(this.GetStateTime(), 20000)) - return; - - if (!UtilTime.elapsed(_tntSpawn, 25000)) - return; - - if (_tntSpawns.isEmpty()) - return; - - Location loc = _tntSpawns.get(UtilMath.r(_tntSpawns.size())); - - if (loc.getBlock().getTypeId() == 46) - return; - - loc.getBlock().setTypeId(46); - _tntSpawn = System.currentTimeMillis(); - } - - @EventHandler(priority = EventPriority.LOW) - public void TNTPickup(PlayerInteractEvent event) - { - if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.LEFT_CLICK_BLOCK) - return; - - if (event.getClickedBlock().getTypeId() != 46) - return; - - event.setCancelled(true); - - Player player = event.getPlayer(); - - if (!IsAlive(player)) - return; - - if (!GetTeam(ChatColor.RED).HasPlayer(player)) - return; - - if (_tntCarry.containsKey(player)) - return; - - event.getClickedBlock().setTypeId(0); - - FallingBlock tnt = player.getWorld().spawnFallingBlock(player.getEyeLocation(), 46, (byte) 0); - - player.eject(); - player.setPassenger(tnt); - - _tntCarry.put(player, tnt); - - UtilPlayer.message(player, F.main("Game", "You picked up " + F.skill("TNT") + ".")); - UtilPlayer.message(player, F.main("Game", F.elem("Right-Click") + " to detonate yourself.")); - } - - @EventHandler(priority = EventPriority.NORMAL) - public void TNTUse(PlayerInteractEvent event) - { - if (event.isCancelled()) - return; - - if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.RIGHT_CLICK_AIR) - return; - - Player player = event.getPlayer(); - - if (!_tntCarry.containsKey(player)) - return; - - event.setCancelled(true); - - for (Location loc : _tntSpawns) - { - if (UtilMath.offset(player.getLocation(), loc) < 16) - { - UtilPlayer.message(player, F.main("Game", "You cannot " + F.skill("Detonate") + " so far from the Castle.")); - return; - } - } - - _tntCarry.remove(player).remove(); - - TNTPrimed tnt = player.getWorld().spawn(player.getEyeLocation(), TNTPrimed.class); - tnt.setFuseTicks(0); - UtilPlayer.message(player, F.main("Game", "You used " + F.skill("Detonate") + ".")); - } - - @EventHandler(priority = EventPriority.LOWEST) - public void TNTDeath(PlayerDeathEvent event) - { - Player player = event.getEntity(); - - if (!_tntCarry.containsKey(player)) - return; - - //Remove the TNT - _tntCarry.get(player).remove(); - - //Flag for Removal - _tntCarryEnd.add(player); - - - TNTPrimed tnt = player.getWorld().spawn(player.getEyeLocation(), TNTPrimed.class); - tnt.setFuseTicks(0); - UtilPlayer.message(player, F.main("Game", "You used " + F.skill("Detonate") + ".")); - } - - @EventHandler(priority = EventPriority.LOWEST) - public void TNTDamageDivert(ProjectileHitEvent event) - { - Iterator playerIterator = _tntCarry.keySet().iterator(); - - while (playerIterator.hasNext()) - { - Player player = playerIterator.next(); - - if (player.getPassenger() == null) - continue; - - double dist = UtilMath.offset(player.getPassenger().getLocation(), event.getEntity().getLocation().add(event.getEntity().getVelocity())); - - if (dist < 2) - { - int damage = (int) (5 * (event.getEntity().getVelocity().length() / 3d)); - - //Damage Event - Manager.GetDamage().NewDamageEvent(player, (LivingEntity)event.getEntity().getShooter(), event.getEntity(), - DamageCause.CUSTOM, damage, true, false, false, - null, GetName()); - - event.getEntity().remove(); - } - - if (_tntCarryEnd.contains(player)) - { - playerIterator.remove(); - } - } - - _tntCarryEnd.clear(); - } - - - @EventHandler - public void TNTExpire(UpdateEvent event) - { - if (event.getType() != UpdateType.FASTER) - return; - - Iterator tntIterator = _tntCarry.keySet().iterator(); - - while (tntIterator.hasNext()) - { - Player player = tntIterator.next(); - FallingBlock block = _tntCarry.get(player); - - if (player.isDead() || !block.isValid() || block.getTicksLived() > 1500) - { - player.eject(); - block.remove(); - - TNTPrimed tnt = player.getWorld().spawn(player.getEyeLocation(), TNTPrimed.class); - tnt.setFuseTicks(0); - - tntIterator.remove(); - continue; - } - - //Firework - UtilFirework.playFirework(player.getEyeLocation(), Type.BURST, Color.RED, false, false); - } - } - - @EventHandler - public void TNTWeakness(ExplosionPrimeEvent event) - { - Location weakness = null; - for (Location loc : _tntWeakness) - { - if (UtilMath.offset(loc, event.getEntity().getLocation()) < 4) - { - weakness = loc; - break; - } - } - - if (weakness == null) - return; - - _tntWeakness.remove(weakness); - - final Location extra = weakness; - - for (int i = 0; i < 10; i++) - { - Manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable() - { - public void run() - { - TNTPrimed tnt = extra.getWorld().spawn(extra.clone().add(3 - UtilMath.r(6), 5 + UtilMath.r(2), 3 - UtilMath.r(6)), TNTPrimed.class); - tnt.setFuseTicks(0); - tnt.setIsIncendiary(true); - } - }, i * 3); - } - - weakness.getWorld().playSound(weakness, Sound.EXPLODE, 16f, 0.8f); - } - - @EventHandler(priority = EventPriority.HIGH) - public void AttackerBlockBreak(org.bukkit.event.block.BlockBreakEvent event) - { - GameTeam team = GetTeam(event.getPlayer()); - if (team == null) - return; - - if (team.GetColor() != ChatColor.RED) - return; - - if (event.getBlock().getTypeId() == 85) - event.setCancelled(false); - } - - @EventHandler - public void DefenderBlockPlace(org.bukkit.event.block.BlockPlaceEvent event) - { - GameTeam team = GetTeam(event.getPlayer()); - if (team == null) - return; - - if (team.GetColor() != ChatColor.AQUA) - return; - - if (event.getBlock().getTypeId() != 85) - return; - - for (Block block : UtilBlock.getSurrounding(event.getBlock(), false)) - { - if (block.isLiquid()) - { - event.setCancelled(true); - UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot place " + F.elem("Barricade") + " in water.")); - } - } - - if (event.getBlockAgainst().getTypeId() == 85) - { - event.setCancelled(true); - UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot place " + F.elem("Barricade") + " on each other.")); - } - - if (_king != null && UtilMath.offset(_king.getLocation(), event.getBlock().getLocation().add(0.5, 0.5, 0.5)) < 4) - { - event.setCancelled(true); - UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot place " + F.elem("Barricade") + " near " + F.elem(C.cAqua + _kingName) + ".")); - } - } - - @EventHandler - public void DefenderBlockInteract(PlayerInteractEvent event) - { - if (!UtilEvent.isAction(event, ActionType.R_BLOCK)) - return; - - GameTeam team = GetTeam(event.getPlayer()); - if (team == null) - return; - - if (team.GetColor() != ChatColor.AQUA) - return; - - if (event.getClickedBlock() == null || event.getClickedBlock().getTypeId() != 85) - return; - - UtilParticle.PlayParticle(ParticleType.FIREWORKS_SPARK, event.getClickedBlock().getLocation().add(0.5, 0.5, 0.5), 0, 0, 0, 0, 1, - ViewDist.LONG, UtilServer.getPlayers()); - event.getClickedBlock().getWorld().playSound(event.getClickedBlock().getLocation(), Sound.NOTE_STICKS, 2f, 1f); - Manager.GetBlockRestore().add(event.getClickedBlock(), 0, (byte) 0, 1000); - } - - @EventHandler - public void DayTimer(UpdateEvent event) - { - if (GetState() != GameState.Live) - return; - - if (event.getType() != UpdateType.TICK) - return; - - WorldTimeSet = (WorldTimeSet + 1); - } - - @EventHandler - public void SnowDamage(UpdateEvent event) - { - if (GetState() != GameState.Live) - return; - - if (event.getType() != UpdateType.FAST) - return; - - for (Player player : GetPlayers(true)) - if (player.getLocation().getBlock().getTypeId() == 78) - { - //Damage Event - Manager.GetDamage().NewDamageEvent(player, null, null, - DamageCause.DROWNING, 2, false, true, false, - "Snow", "Snow Damage"); - - player.getWorld().playEffect(player.getLocation(), Effect.STEP_SOUND, 80); - } - } -} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/classickits/KitHuman.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitHuman.java similarity index 90% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/classickits/KitHuman.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitHuman.java index 0adab2c1b..6c4da8994 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/classickits/KitHuman.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitHuman.java @@ -1,4 +1,4 @@ -package nautilus.game.arcade.game.games.castlesiege.classickits; +package nautilus.game.arcade.game.games.castlesiege.kits; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.kit.KitAvailability; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/classickits/KitHumanKnight.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitHumanKnight.java similarity index 97% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/classickits/KitHumanKnight.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitHumanKnight.java index e1387e91f..ec8a3ddbc 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/classickits/KitHumanKnight.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitHumanKnight.java @@ -1,4 +1,4 @@ -package nautilus.game.arcade.game.games.castlesiege.classickits; +package nautilus.game.arcade.game.games.castlesiege.kits; import mineplex.core.common.util.C; import mineplex.core.common.util.F; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/classickits/KitHumanMarksman.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitHumanMarksman.java similarity index 97% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/classickits/KitHumanMarksman.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitHumanMarksman.java index d2687a1ea..fcd021465 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/classickits/KitHumanMarksman.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitHumanMarksman.java @@ -1,4 +1,4 @@ -package nautilus.game.arcade.game.games.castlesiege.classickits; +package nautilus.game.arcade.game.games.castlesiege.kits; import org.bukkit.Material; import org.bukkit.entity.EntityType; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/classickits/KitHumanPeasant.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitHumanPeasant.java similarity index 96% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/classickits/KitHumanPeasant.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitHumanPeasant.java index a59843e3e..c1ec3e24f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/classickits/KitHumanPeasant.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitHumanPeasant.java @@ -1,4 +1,4 @@ -package nautilus.game.arcade.game.games.castlesiege.classickits; +package nautilus.game.arcade.game.games.castlesiege.kits; import mineplex.core.disguise.disguises.DisguiseWolf; import mineplex.core.itemstack.ItemStackFactory; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/classickits/KitUndead.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitUndead.java similarity index 93% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/classickits/KitUndead.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitUndead.java index 035385d90..31db5ed38 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/classickits/KitUndead.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitUndead.java @@ -1,4 +1,4 @@ -package nautilus.game.arcade.game.games.castlesiege.classickits; +package nautilus.game.arcade.game.games.castlesiege.kits; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.kit.KitAvailability; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/classickits/KitUndeadArcher.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitUndeadArcher.java similarity index 97% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/classickits/KitUndeadArcher.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitUndeadArcher.java index 481b7249e..ebdefc25a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/classickits/KitUndeadArcher.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitUndeadArcher.java @@ -1,4 +1,4 @@ -package nautilus.game.arcade.game.games.castlesiege.classickits; +package nautilus.game.arcade.game.games.castlesiege.kits; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilInv; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/classickits/KitUndeadGhoul.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitUndeadGhoul.java similarity index 96% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/classickits/KitUndeadGhoul.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitUndeadGhoul.java index ec56ec3f4..1c893a7a6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/classickits/KitUndeadGhoul.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitUndeadGhoul.java @@ -1,4 +1,4 @@ -package nautilus.game.arcade.game.games.castlesiege.classickits; +package nautilus.game.arcade.game.games.castlesiege.kits; import mineplex.core.common.util.C; import mineplex.core.disguise.disguises.DisguisePigZombie; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/classickits/KitUndeadZombie.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitUndeadZombie.java similarity index 96% rename from Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/classickits/KitUndeadZombie.java rename to Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitUndeadZombie.java index f45fc539f..9d9eb4b75 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/classickits/KitUndeadZombie.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castlesiege/kits/KitUndeadZombie.java @@ -1,4 +1,4 @@ -package nautilus.game.arcade.game.games.castlesiege.classickits; +package nautilus.game.arcade.game.games.castlesiege.kits; import mineplex.core.common.util.C; import mineplex.core.disguise.disguises.DisguiseZombie; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/BloodThirstyStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/BloodThirstyStatTracker.java index 82ea187e8..c6df42427 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/BloodThirstyStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/BloodThirstyStatTracker.java @@ -11,7 +11,7 @@ import org.bukkit.event.EventPriority; import mineplex.core.common.util.UtilPlayer; import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; import nautilus.game.arcade.game.Game; -import nautilus.game.arcade.game.games.castlesiege.classickits.KitUndead; +import nautilus.game.arcade.game.games.castlesiege.kits.KitUndead; import nautilus.game.arcade.game.games.hideseek.kits.KitSeeker; public class BloodThirstyStatTracker extends StatTracker diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/KingDamageStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/KingDamageStatTracker.java index bf5053000..5b84ac9af 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/KingDamageStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/KingDamageStatTracker.java @@ -10,20 +10,20 @@ import org.bukkit.event.EventPriority; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.game.Game; -import nautilus.game.arcade.game.games.castlesiege.CastleSiegeClassic; +import nautilus.game.arcade.game.games.castlesiege.CastleSiege; -public class KingDamageStatTracker extends StatTracker +public class KingDamageStatTracker extends StatTracker { private final Map _kingDamage = new HashMap<>(); private double _totalKingDamage = 0; - public KingDamageStatTracker(CastleSiegeClassic game) + public KingDamageStatTracker(CastleSiege game) { super(game); } @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) - public void onKingDamage(CastleSiegeClassic.KingDamageEvent event) + public void onKingDamage(CastleSiege.KingDamageEvent event) { if (getGame().GetState() != Game.GameState.Live) return; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/KingSlayerStatTracker.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/KingSlayerStatTracker.java index 8f3e7f287..c229272e5 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/KingSlayerStatTracker.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/stats/KingSlayerStatTracker.java @@ -3,7 +3,7 @@ package nautilus.game.arcade.stats; import org.bukkit.event.EventHandler; import nautilus.game.arcade.game.Game; -import nautilus.game.arcade.game.games.castlesiege.CastleSiegeClassic; +import nautilus.game.arcade.game.games.castlesiege.CastleSiege; public class KingSlayerStatTracker extends StatTracker { @@ -13,7 +13,7 @@ public class KingSlayerStatTracker extends StatTracker } @EventHandler - public void onKingSlaughtered(CastleSiegeClassic.KingSlaughterEvent event) + public void onKingSlaughtered(CastleSiege.KingSlaughterEvent event) { if (getGame().GetState() != Game.GameState.Live) return; From 79560fd415912a3c4e5968dea1576dee07f7ca73 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Mon, 8 May 2017 17:24:12 -0400 Subject: [PATCH 63/99] Implement Castle Assault into the selection compass and re-add old Castle Siege --- .../mineplex/hub/server/ServerManager.java | 5 ++++ .../hub/server/ui/ServerGameMenu.java | 27 ++++++++++++++----- .../hub/server/ui/button/SelectCAButton.java | 23 ++++++++++++++++ 3 files changed, 48 insertions(+), 7 deletions(-) create mode 100644 Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectCAButton.java diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java index a305c124b..f72c95a65 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ServerManager.java @@ -787,6 +787,11 @@ public class ServerManager extends MiniPlugin implements BrawlShopProvider { return _statusManager; } + + public ShopBase getCastleAssaultShop() + { + return _serverNpcShopMap.get("Castle Assault"); + } public ShopBase getCastleSiegeShop() { diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java index 79d186558..00498e1d3 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java @@ -21,6 +21,7 @@ import mineplex.hub.server.ui.button.SelectBHButton; import mineplex.hub.server.ui.button.SelectBLDButton; import mineplex.hub.server.ui.button.SelectBRButton; import mineplex.hub.server.ui.button.SelectBawkButton; +import mineplex.hub.server.ui.button.SelectCAButton; import mineplex.hub.server.ui.button.SelectCLANSButton; import mineplex.hub.server.ui.button.SelectCSButton; import mineplex.hub.server.ui.button.SelectCTFButton; @@ -63,14 +64,22 @@ public class ServerGameMenu extends ShopPageBase { add(1, Material.EGG, C.cYellowB + "Bawk Bawk Battles " + C.cGray + "Challenges", new String[] { - (_extraValue ? C.cAquaB : C.cWhiteB) + "NEW GAME", C.Reset + "", C.Reset + "Follow Bawk Bawk's instructions", C.Reset + "Complete different tasks", C.Reset + "If you lose, chickens will devour you!" }, "BBB", "Bawk_Bawk_Battles", new SelectBawkButton(this)); + + add(3, Material.DIAMOND_CHESTPLATE, C.cYellowB + "Castle Assault " + C.cGray + "Fast Paced PvP", new String[] + { + (_extraValue ? C.cAquaB : C.cWhiteB) + "NEW GAME", + C.Reset + "", + C.Reset + "Combatants must battle to", + C.Reset + "win the day for their king", + C.Reset + "at all costs!", + }, "CA", "Castle_Assault", new SelectCAButton(this)); - add(4, Material.QUARTZ_BLOCK, C.cYellowB + "Speed Builders " + C.cGray + "Competitive Building", new String[] + add(5, Material.QUARTZ_BLOCK, C.cYellowB + "Speed Builders " + C.cGray + "Competitive Building", new String[] { C.Reset + "", C.Reset + "Memorize Gwen the Guardian's builds", @@ -154,13 +163,12 @@ public class ServerGameMenu extends ShopPageBase C.Reset + "last man standing.", }, "TDM", "Team_Deathmatch", new SelectTDMButton(this)); - add(24, Material.DIAMOND_CHESTPLATE, C.cYellowB + "Castle Siege " + C.cGray + "Fast-Paced PvP", new String[] + add(24, Material.DIAMOND_CHESTPLATE, C.cYellowB + "Castle Siege " + C.cGray + "Team Game", new String[] { - (_extraValue ? C.cAquaB : C.cWhiteB) + "MAJOR UPDATE/REWRITE", C.Reset + "", - C.Reset + "Combatants must battle to", - C.Reset + "win the day for their king", - C.Reset + "at all costs!", + C.Reset + "Defenders must protect King Sparklez", + C.Reset + "from the endless waves of Undead", + C.Reset + "until the sun rises!", }, "CS", "Castle_Siege", new SelectCSButton(this)); add(26, Material.GRASS, C.cYellowB + "Block Hunt " + C.cGray + "Cat and Mouse", new String[] @@ -632,6 +640,11 @@ public class ServerGameMenu extends ShopPageBase { getPlugin().getCtfShop().attemptShopOpen(player); } + + public void openCA(Player player) + { + getPlugin().getCastleAssaultShop().attemptShopOpen(player); + } public void openCS(Player player) { diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectCAButton.java b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectCAButton.java new file mode 100644 index 000000000..6ab3a36c8 --- /dev/null +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/button/SelectCAButton.java @@ -0,0 +1,23 @@ +package mineplex.hub.server.ui.button; + +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; + +import mineplex.core.shop.item.IButton; +import mineplex.hub.server.ui.ServerGameMenu; + +public class SelectCAButton implements IButton +{ + private ServerGameMenu _menu; + + public SelectCAButton(ServerGameMenu menu) + { + _menu = menu; + } + + @Override + public void onClick(Player player, ClickType clickType) + { + _menu.openCA(player); + } +} From 834c537bc8f76cdeebea820ee9e93c30dbc9f22a Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Mon, 8 May 2017 23:22:48 -0400 Subject: [PATCH 64/99] Block spectators obtaining TNT --- .../game/arcade/game/games/castleassault/CastleAssault.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java index d327f19d4..0399abe55 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java @@ -1298,6 +1298,10 @@ public class CastleAssault extends TeamGame { return; } + if (UtilPlayer.isSpectator(event.getPlayer())) + { + return; + } if (_tntSpawner.isSpawned() && event.getItem().getEntityId() == _tntSpawner.getItem().getEntityId()) { From f2ff546d476e5826fdc330e7a98d25736c3288f2 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Tue, 9 May 2017 20:35:48 -0400 Subject: [PATCH 65/99] Clean up game classes a bit --- .../games/castleassault/CastleAssault.java | 97 +++-- .../games/castleassault/CastleAssaultTDM.java | 358 +++++++----------- 2 files changed, 183 insertions(+), 272 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java index 0399abe55..c4cb2618a 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java @@ -75,7 +75,6 @@ import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTextBottom; import mineplex.core.common.util.UtilTime; -import mineplex.core.itemstack.EnchantedBookBuilder; import mineplex.core.itemstack.ItemBuilder; import mineplex.core.leaderboard.Leaderboard; import mineplex.core.leaderboard.LeaderboardManager; @@ -125,16 +124,10 @@ public class CastleAssault extends TeamGame private List _chests = new ArrayList<>(); - private ChestLoot _diamondGearCommon = new ChestLoot(true); - private ChestLoot _diamondGearRare = new ChestLoot(true); - private ChestLoot _weaponGearCommon = new ChestLoot(true); - private ChestLoot _weaponGearRare = new ChestLoot(true); private ChestLoot _rangedGear = new ChestLoot(true); private ChestLoot _rodsAndGaps = new ChestLoot(true); private ChestLoot _potionGearCommon = new ChestLoot(true); private ChestLoot _potionGearRare = new ChestLoot(true); - private ChestLoot _enchantGearCommon = new ChestLoot(true); - private ChestLoot _enchantGearRare = new ChestLoot(true); private ChestLoot _miscGear = new ChestLoot(); private ObjectiveTNTSpawner _tntSpawner; @@ -236,37 +229,6 @@ public class CastleAssault extends TeamGame private void generateLoot() { - { - _diamondGearCommon.addLoot(new ItemStack(Material.DIAMOND_HELMET), 2); - _diamondGearCommon.addLoot(new ItemStack(Material.DIAMOND_CHESTPLATE), 2); - _diamondGearCommon.addLoot(new ItemStack(Material.DIAMOND_LEGGINGS), 2); - _diamondGearCommon.addLoot(new ItemStack(Material.DIAMOND_BOOTS), 2); - _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_HELMET).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1).build(), 1); - _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_CHESTPLATE).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1).build(), 1); - _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_LEGGINGS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1).build(), 1); - _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_BOOTS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1).build(), 1); - _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_HELMET).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).build(), 1); - _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_CHESTPLATE).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).build(), 1); - _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_LEGGINGS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).build(), 1); - _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_BOOTS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).build(), 1); - _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_HELMET).addEnchantment(Enchantment.PROTECTION_PROJECTILE, 3).build(), 1); - _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_CHESTPLATE).addEnchantment(Enchantment.PROTECTION_PROJECTILE, 3).build(), 1); - _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_LEGGINGS).addEnchantment(Enchantment.PROTECTION_PROJECTILE, 3).build(), 1); - _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_BOOTS).addEnchantment(Enchantment.PROTECTION_PROJECTILE, 3).build(), 1); - } - { - _diamondGearRare.addLoot(new ItemBuilder(Material.DIAMOND_HELMET).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4).build(), 1); - _diamondGearRare.addLoot(new ItemBuilder(Material.DIAMOND_CHESTPLATE).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4).build(), 1); - _diamondGearRare.addLoot(new ItemBuilder(Material.DIAMOND_LEGGINGS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4).build(), 1); - _diamondGearRare.addLoot(new ItemBuilder(Material.DIAMOND_BOOTS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4).build(), 1); - } - { - _weaponGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_SWORD).build(), 2); - _weaponGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_SWORD).addEnchantment(Enchantment.DAMAGE_ALL, 1).build(), 2); - } - { - _weaponGearRare.addLoot(new ItemBuilder(Material.DIAMOND_SWORD).addEnchantment(Enchantment.DAMAGE_ALL, 2).build(), 1); - } { _rangedGear.addLoot(new ItemStack(Material.BOW), 3); _rangedGear.addLoot(Material.ARROW, 3, 8, 16); @@ -283,15 +245,6 @@ public class CastleAssault extends TeamGame _potionGearRare.addLoot(new ItemBuilder(Material.POTION).setData((short)8193).build(), 2); _potionGearRare.addLoot(new ItemBuilder(Material.POTION).setData((short)8195).build(), 2); } - { - _enchantGearCommon.addLoot(new EnchantedBookBuilder(1).setLevel(Enchantment.PROTECTION_ENVIRONMENTAL, 1).build(), 2); - _enchantGearCommon.addLoot(new EnchantedBookBuilder(1).setLevel(Enchantment.DAMAGE_ALL, 1).build(), 2); - _enchantGearCommon.addLoot(new EnchantedBookBuilder(1).setLevel(Enchantment.ARROW_DAMAGE, 1).build(), 2); - _enchantGearCommon.addLoot(new ItemStack(Material.EXP_BOTTLE, 64), 1); - } - { - _enchantGearRare.addLoot(new EnchantedBookBuilder(1).setLevel(Enchantment.FIRE_ASPECT, 1).build(), 1); - } { _miscGear.addLoot(new ItemStack(Material.ENDER_PEARL), 2); _miscGear.addLoot(new ItemStack(Material.WATER_BUCKET), 2); @@ -602,10 +555,29 @@ public class CastleAssault extends TeamGame AddGems(player, 10, "Participation", false, false); } - int streak = _streakData.getOrDefault(player, new KillStreakData()).getBestStreak(); - if (streak > 0) { - AddGems(player, streak, streak + " Player Kill Streak", false, false); + int crowns = 0; + for (GemData data : GetGems(player).values()) + { + crowns += data.Gems; + } + int streak = _streakData.getOrDefault(player, new KillStreakData()).getBestStreak(); + if (streak >= 2 && streak < 4) + { + AddGems(player, 0.5 * crowns, streak + " Player Kill Streak", false, false); + } + else if (streak >= 4 && streak < 6) + { + AddGems(player, crowns, streak + " Player Kill Streak", false, false); + } + else if (streak >= 6 && streak < 8) + { + AddGems(player, 1.5 * crowns, streak + " Player Kill Streak", false, false); + } + else if (streak >= 8) + { + AddGems(player, 2 * crowns, streak + " Player Kill Streak", false, false); + } } KitPlayer kit = (KitPlayer) GetKit(player); @@ -651,10 +623,29 @@ public class CastleAssault extends TeamGame AddGems(player, 10, "Participation", false, false); } - int streak = _streakData.getOrDefault(player, new KillStreakData()).getBestStreak(); - if (streak > 0) { - AddGems(player, streak, streak + " Player Kill Streak", false, false); + int crowns = 0; + for (GemData data : GetGems(player).values()) + { + crowns += data.Gems; + } + int streak = _streakData.getOrDefault(player, new KillStreakData()).getBestStreak(); + if (streak >= 2 && streak < 4) + { + AddGems(player, 0.5 * crowns, streak + " Player Kill Streak", false, false); + } + else if (streak >= 4 && streak < 6) + { + AddGems(player, crowns, streak + " Player Kill Streak", false, false); + } + else if (streak >= 6 && streak < 8) + { + AddGems(player, 1.5 * crowns, streak + " Player Kill Streak", false, false); + } + else if (streak >= 8) + { + AddGems(player, 2 * crowns, streak + " Player Kill Streak", false, false); + } } KitPlayer kit = (KitPlayer) GetKit(player); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssaultTDM.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssaultTDM.java index a64fff374..2fc876a00 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssaultTDM.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssaultTDM.java @@ -4,7 +4,6 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Map.Entry; import java.util.WeakHashMap; import org.bukkit.Bukkit; @@ -15,6 +14,7 @@ import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.block.Chest; import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.Arrow; import org.bukkit.entity.EnderPearl; import org.bukkit.entity.Entity; import org.bukkit.entity.ItemFrame; @@ -26,6 +26,7 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.block.BlockBurnEvent; import org.bukkit.event.block.BlockDispenseEvent; import org.bukkit.event.block.BlockFadeEvent; +import org.bukkit.event.block.BlockFormEvent; import org.bukkit.event.block.BlockFromToEvent; import org.bukkit.event.block.LeavesDecayEvent; import org.bukkit.event.entity.ExplosionPrimeEvent; @@ -45,6 +46,8 @@ import org.bukkit.material.Dispenser; import org.bukkit.material.MaterialData; import org.bukkit.metadata.MetadataValue; +import mineplex.core.Managers; +import mineplex.core.common.Pair; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; @@ -56,8 +59,10 @@ import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTime; -import mineplex.core.itemstack.EnchantedBookBuilder; import mineplex.core.itemstack.ItemBuilder; +import mineplex.core.leaderboard.Leaderboard; +import mineplex.core.leaderboard.LeaderboardManager; +import mineplex.core.leaderboard.LeaderboardRepository.LeaderboardSQLType; import mineplex.core.loot.ChestLoot; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; @@ -73,9 +78,6 @@ import nautilus.game.arcade.game.GameTeam; import nautilus.game.arcade.game.GemData; import nautilus.game.arcade.game.TeamGame; import nautilus.game.arcade.game.games.castleassault.data.KillStreakData; -import nautilus.game.arcade.game.games.castleassault.data.medals.MedalData; -import nautilus.game.arcade.game.games.castleassault.data.medals.MedalData.MedalLevel; -import nautilus.game.arcade.game.games.castleassault.data.medals.MedalType; import nautilus.game.arcade.game.games.castleassault.kits.KitArcher; import nautilus.game.arcade.game.games.castleassault.kits.KitDemolitionist; import nautilus.game.arcade.game.games.castleassault.kits.KitFighter; @@ -83,6 +85,7 @@ import nautilus.game.arcade.game.games.castleassault.kits.KitPlayer; import nautilus.game.arcade.game.games.castleassault.kits.KitTank; import nautilus.game.arcade.game.modules.compass.CompassModule; import nautilus.game.arcade.kit.Kit; +import nautilus.game.arcade.managers.lobby.current.NewGameLobbyManager; public class CastleAssaultTDM extends TeamGame { @@ -95,22 +98,14 @@ public class CastleAssaultTDM extends TeamGame private ItemBuilder _flintAndSteel; private Map _streakData = new WeakHashMap<>(); - private Map _medalData = new WeakHashMap<>(); private Map _teamKills = new HashMap<>(); private List _chests = new ArrayList<>(); - private ChestLoot _diamondGearCommon = new ChestLoot(true); - private ChestLoot _diamondGearRare = new ChestLoot(true); - private ChestLoot _weaponGearCommon = new ChestLoot(true); - private ChestLoot _weaponGearRare = new ChestLoot(true); private ChestLoot _rangedGear = new ChestLoot(true); private ChestLoot _rodsAndGaps = new ChestLoot(true); private ChestLoot _potionGearCommon = new ChestLoot(true); private ChestLoot _potionGearRare = new ChestLoot(true); - //private ChestLoot _blockGear = new ChestLoot(); - private ChestLoot _enchantGearCommon = new ChestLoot(true); - private ChestLoot _enchantGearRare = new ChestLoot(true); private ChestLoot _miscGear = new ChestLoot(); private boolean _writeScoreboard = true; @@ -149,7 +144,9 @@ public class CastleAssaultTDM extends TeamGame this.AllowFlintAndSteel = true; this.BlockPlaceAllow.add(Material.FIRE.getId()); this.CrownsEnabled = true; + this.Leaderboards = true; this.FirstKillReward = 20; + this.GemKillDeathRespawn = 1; new CompassModule() .setGiveCompass(true) @@ -159,95 +156,38 @@ public class CastleAssaultTDM extends TeamGame _flintAndSteel = new ItemBuilder(Material.FLINT_AND_STEEL).setData((short) (Material.FLINT_AND_STEEL.getMaxDurability() - MAX_FLINT_AND_STEEL_USES)); generateLoot(); - } - - private Player[] getMedalOwners(MedalType type) - { - Player gold = null; - Double goldScore = 0D; - Player silver = null; - Double silverScore = 0D; - Player bronze = null; - Double bronzeScore = 0D; - //GOLD - for (Entry scores : _medalData.entrySet()) + if (manager.IsRewardStats()) { - if (scores.getValue().getScore(type) > goldScore) + if (manager.GetLobby() instanceof NewGameLobbyManager) { - gold = scores.getKey(); - goldScore = scores.getValue().getScore(type); + Map> lobbyCustomLocs = ((NewGameLobbyManager)manager.GetLobby()).getCustomLocs(); + if (lobbyCustomLocs.containsKey("TOP_DAILY_WINS")) + { + Location loc = lobbyCustomLocs.get("TOP_DAILY_WINS").get(0); + Managers.get(LeaderboardManager.class).registerLeaderboard("TOP_CASTLEASSAULT_DAILY_WINS", new Leaderboard("Top Daily Wins", Pair.create("Win", "Wins"), new String[] {"Castle Assault TDM.Wins"}, LeaderboardSQLType.DAILY, loc, 10)); + } + if (lobbyCustomLocs.containsKey("TOP_DAILY_KILLS")) + { + Location loc = lobbyCustomLocs.get("TOP_DAILY_KILLS").get(0); + Managers.get(LeaderboardManager.class).registerLeaderboard("TOP_CASTLEASSAULT_DAILY_KILLS", new Leaderboard("Top Daily Kills", Pair.create("Kill", "Kills"), new String[] {"Castle Assault TDM.Kills"}, LeaderboardSQLType.DAILY, loc, 10)); + } + if (lobbyCustomLocs.containsKey("TOP_WINS")) + { + Location loc = lobbyCustomLocs.get("TOP_WINS").get(0); + Managers.get(LeaderboardManager.class).registerLeaderboard("TOP_CASTLEASSAULT_WINS", new Leaderboard("Top Wins", Pair.create("Win", "Wins"), new String[] {"Castle Assault TDM.Wins"}, LeaderboardSQLType.ALL, loc, 10)); + } + if (lobbyCustomLocs.containsKey("TOP_KILLS")) + { + Location loc = lobbyCustomLocs.get("TOP_KILLS").get(0); + Managers.get(LeaderboardManager.class).registerLeaderboard("TOP_CASTLEASSAULT_KILLS", new Leaderboard("Top Kills", Pair.create("Kill", "Kills"), new String[] {"Castle Assault TDM.Kills"}, LeaderboardSQLType.ALL, loc, 10)); + } } } - - //SILVER - for (Entry scores : _medalData.entrySet()) - { - if (gold != null && gold.getName().equals(scores.getKey().getName())) - { - continue; - } - if (scores.getValue().getScore(type) > silverScore) - { - silver = scores.getKey(); - silverScore = scores.getValue().getScore(type); - } - } - - //BRONZE - for (Entry scores : _medalData.entrySet()) - { - if (gold != null && gold.getName().equals(scores.getKey().getName())) - { - continue; - } - if (silver != null && silver.getName().equals(scores.getKey().getName())) - { - continue; - } - if (scores.getValue().getScore(type) > bronzeScore) - { - bronze = scores.getKey(); - bronzeScore = scores.getValue().getScore(type); - } - } - - return new Player[] {gold, silver, bronze}; } private void generateLoot() { - { - _diamondGearCommon.addLoot(new ItemStack(Material.DIAMOND_HELMET), 2); - _diamondGearCommon.addLoot(new ItemStack(Material.DIAMOND_CHESTPLATE), 2); - _diamondGearCommon.addLoot(new ItemStack(Material.DIAMOND_LEGGINGS), 2); - _diamondGearCommon.addLoot(new ItemStack(Material.DIAMOND_BOOTS), 2); - _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_HELMET).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1).build(), 1); - _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_CHESTPLATE).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1).build(), 1); - _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_LEGGINGS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1).build(), 1); - _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_BOOTS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 1).build(), 1); - _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_HELMET).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).build(), 1); - _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_CHESTPLATE).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).build(), 1); - _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_LEGGINGS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).build(), 1); - _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_BOOTS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 2).build(), 1); - _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_HELMET).addEnchantment(Enchantment.PROTECTION_PROJECTILE, 3).build(), 1); - _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_CHESTPLATE).addEnchantment(Enchantment.PROTECTION_PROJECTILE, 3).build(), 1); - _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_LEGGINGS).addEnchantment(Enchantment.PROTECTION_PROJECTILE, 3).build(), 1); - _diamondGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_BOOTS).addEnchantment(Enchantment.PROTECTION_PROJECTILE, 3).build(), 1); - } - { - _diamondGearRare.addLoot(new ItemBuilder(Material.DIAMOND_HELMET).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4).build(), 1); - _diamondGearRare.addLoot(new ItemBuilder(Material.DIAMOND_CHESTPLATE).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4).build(), 1); - _diamondGearRare.addLoot(new ItemBuilder(Material.DIAMOND_LEGGINGS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4).build(), 1); - _diamondGearRare.addLoot(new ItemBuilder(Material.DIAMOND_BOOTS).addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 4).build(), 1); - } - { - _weaponGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_SWORD).build(), 2); - _weaponGearCommon.addLoot(new ItemBuilder(Material.DIAMOND_SWORD).addEnchantment(Enchantment.DAMAGE_ALL, 1).build(), 2); - } - { - _weaponGearRare.addLoot(new ItemBuilder(Material.DIAMOND_SWORD).addEnchantment(Enchantment.DAMAGE_ALL, 2).build(), 1); - } { _rangedGear.addLoot(new ItemStack(Material.BOW), 3); _rangedGear.addLoot(Material.ARROW, 3, 8, 16); @@ -264,19 +204,6 @@ public class CastleAssaultTDM extends TeamGame _potionGearRare.addLoot(new ItemBuilder(Material.POTION).setData((short)8193).build(), 2); _potionGearRare.addLoot(new ItemBuilder(Material.POTION).setData((short)8195).build(), 2); } - /*{ - _blockGear.addLoot(new ItemStack(Material.STONE, 64), 2); - _blockGear.addLoot(new ItemStack(Material.WOOD, 64), 2); - }*/ - { - _enchantGearCommon.addLoot(new EnchantedBookBuilder(1).setLevel(Enchantment.PROTECTION_ENVIRONMENTAL, 1).build(), 2); - _enchantGearCommon.addLoot(new EnchantedBookBuilder(1).setLevel(Enchantment.DAMAGE_ALL, 1).build(), 2); - _enchantGearCommon.addLoot(new EnchantedBookBuilder(1).setLevel(Enchantment.ARROW_DAMAGE, 1).build(), 2); - _enchantGearCommon.addLoot(new ItemStack(Material.EXP_BOTTLE, 64), 1); - } - { - _enchantGearRare.addLoot(new EnchantedBookBuilder(1).setLevel(Enchantment.FIRE_ASPECT, 1).build(), 1); - } { _miscGear.addLoot(new ItemStack(Material.ENDER_PEARL), 2); _miscGear.addLoot(new ItemBuilder(Material.TNT, 4).setTitle(F.item("Throwing TNT")).build(), 2); @@ -318,23 +245,7 @@ public class CastleAssaultTDM extends TeamGame if (chance <= 0.3) { loot = _rangedGear; - }/* - if (chance <= 0.4) - { - loot = _weaponGearCommon; - if (subChance <= 0.4) - { - loot = _weaponGearRare; - } } - if (chance <= 0.3) - { - loot = _diamondGearCommon; - if (subChance <= 0.3) - { - loot = _diamondGearRare; - } - }*/ chest.getBlockInventory().setItem(slot, loot.getLoot()); } } @@ -380,8 +291,8 @@ public class CastleAssaultTDM extends TeamGame _writeScoreboard = false; Scoreboard.reset(); Scoreboard.writeNewLine(); - Scoreboard.write(winner + C.cBlue + " has won"); - Scoreboard.write(C.cBlue + "with " + C.cGreen + kills + C.cBlue + " kills!"); + Scoreboard.write(winner + C.cWhite + " has won"); + Scoreboard.write(C.cWhite + "with " + C.cGreen + kills + C.cWhite + " kills!"); Scoreboard.writeNewLine(); Scoreboard.draw(); @@ -401,6 +312,19 @@ public class CastleAssaultTDM extends TeamGame _teamKills.put(red, 0); GameTeam blue = GetTeam(ChatColor.AQUA); _teamKills.put(blue, 0); + this.CreatureAllowOverride = true; + int kitIndex = 0; + for (int i = 0; i < WorldData.GetDataLocs("WHITE").size(); i++) + { + if (kitIndex >= GetKits().length) + { + kitIndex = 0; + } + Entity ent = GetKits()[kitIndex].SpawnEntity(WorldData.GetDataLocs("WHITE").get(i)); + Manager.GetLobby().addKitLocation(ent, GetKits()[kitIndex], WorldData.GetDataLocs("WHITE").get(i)); + kitIndex++; + } + this.CreatureAllowOverride = false; } @Override @@ -429,34 +353,6 @@ public class CastleAssaultTDM extends TeamGame GameTeam winner = teamsAlive.get(0); AnnounceEnd(winner); writeFinalScoreboard(winner.GetColor() + winner.GetName(), _teamKills.get(winner)); - boolean announcedMedalStart = false; - for (MedalType type : MedalType.values()) - { - Player[] rewarding = getMedalOwners(type); - if (rewarding[0] != null) - { - if (!announcedMedalStart) - { - announcedMedalStart = true; - Bukkit.broadcastMessage(C.cGoldB + "-==Match Medal Recipients==-"); - } - AddGems(rewarding[0], 50, MedalLevel.GOLD.getName() + " " + type.getName(), false, false); - AddStat(rewarding[0], "Medalist", 1, false, false); - Bukkit.broadcastMessage(MedalLevel.GOLD.getName() + " " + type.getName() + C.cGray + ": " + MedalLevel.GOLD.getColor() + rewarding[0].getName()); - } - if (rewarding[1] != null) - { - AddGems(rewarding[1], 30, MedalLevel.SILVER.getName() + " " + type.getName(), false, false); - AddStat(rewarding[1], "Medalist", 1, false, false); - Bukkit.broadcastMessage(MedalLevel.SILVER.getName() + " " + type.getName() + C.cGray + ": " + MedalLevel.SILVER.getColor() + rewarding[1].getName()); - } - if (rewarding[2] != null) - { - AddGems(rewarding[2], 20, MedalLevel.BRONZE.getName() + " " + type.getName(), false, false); - AddStat(rewarding[2], "Medalist", 1, false, false); - Bukkit.broadcastMessage(MedalLevel.BRONZE.getName() + " " + type.getName() + C.cGray + ": " + MedalLevel.BRONZE.getColor() + rewarding[2].getName()); - } - } for (GameTeam team : GetTeamList()) { for (Player player : team.GetPlayers(true)) @@ -474,10 +370,29 @@ public class CastleAssaultTDM extends TeamGame AddGems(player, 10, "Participation", false, false); } - int streak = _streakData.getOrDefault(player, new KillStreakData()).getBestStreak(); - if (streak > 0) { - AddGems(player, streak, streak + " Player Kill Streak", false, false); + int crowns = 0; + for (GemData data : GetGems(player).values()) + { + crowns += data.Gems; + } + int streak = _streakData.getOrDefault(player, new KillStreakData()).getBestStreak(); + if (streak >= 2 && streak < 4) + { + AddGems(player, 0.5 * crowns, streak + " Player Kill Streak", false, false); + } + else if (streak >= 4 && streak < 6) + { + AddGems(player, crowns, streak + " Player Kill Streak", false, false); + } + else if (streak >= 6 && streak < 8) + { + AddGems(player, 1.5 * crowns, streak + " Player Kill Streak", false, false); + } + else if (streak >= 8) + { + AddGems(player, 2 * crowns, streak + " Player Kill Streak", false, false); + } } if (GetKit(player) != null) @@ -529,34 +444,6 @@ public class CastleAssaultTDM extends TeamGame { AnnounceEnd(blue); writeFinalScoreboard(blue.GetColor() + blue.GetName(), _teamKills.get(blue)); - boolean announcedMedalStart = false; - for (MedalType type : MedalType.values()) - { - Player[] rewarding = getMedalOwners(type); - if (rewarding[0] != null) - { - if (!announcedMedalStart) - { - announcedMedalStart = true; - Bukkit.broadcastMessage(C.cGoldB + "-==Match Medal Recipients==-"); - } - AddGems(rewarding[0], 50, MedalLevel.GOLD.getName() + " " + type.getName(), false, false); - AddStat(rewarding[0], "Medalist", 1, false, false); - Bukkit.broadcastMessage(MedalLevel.GOLD.getName() + " " + type.getName() + C.cGray + ": " + MedalLevel.GOLD.getColor() + rewarding[0].getName()); - } - if (rewarding[1] != null) - { - AddGems(rewarding[1], 30, MedalLevel.SILVER.getName() + " " + type.getName(), false, false); - AddStat(rewarding[1], "Medalist", 1, false, false); - Bukkit.broadcastMessage(MedalLevel.SILVER.getName() + " " + type.getName() + C.cGray + ": " + MedalLevel.SILVER.getColor() + rewarding[1].getName()); - } - if (rewarding[2] != null) - { - AddGems(rewarding[2], 20, MedalLevel.BRONZE.getName() + " " + type.getName(), false, false); - AddStat(rewarding[2], "Medalist", 1, false, false); - Bukkit.broadcastMessage(MedalLevel.BRONZE.getName() + " " + type.getName() + C.cGray + ": " + MedalLevel.BRONZE.getColor() + rewarding[2].getName()); - } - } for (GameTeam team : GetTeamList()) { for (Player player : team.GetPlayers(true)) @@ -574,10 +461,29 @@ public class CastleAssaultTDM extends TeamGame AddGems(player, 10, "Participation", false, false); } - int streak = _streakData.getOrDefault(player, new KillStreakData()).getBestStreak(); - if (streak > 0) { - AddGems(player, streak, streak + " Player Kill Streak", false, false); + int crowns = 0; + for (GemData data : GetGems(player).values()) + { + crowns += data.Gems; + } + int streak = _streakData.getOrDefault(player, new KillStreakData()).getBestStreak(); + if (streak >= 2 && streak < 4) + { + AddGems(player, 0.5 * crowns, streak + " Player Kill Streak", false, false); + } + else if (streak >= 4 && streak < 6) + { + AddGems(player, crowns, streak + " Player Kill Streak", false, false); + } + else if (streak >= 6 && streak < 8) + { + AddGems(player, 1.5 * crowns, streak + " Player Kill Streak", false, false); + } + else if (streak >= 8) + { + AddGems(player, 2 * crowns, streak + " Player Kill Streak", false, false); + } } KitPlayer kit = (KitPlayer) GetKit(player); @@ -601,34 +507,6 @@ public class CastleAssaultTDM extends TeamGame { AnnounceEnd(red); writeFinalScoreboard(red.GetColor() + red.GetName(), _teamKills.get(red)); - boolean announcedMedalStart = false; - for (MedalType type : MedalType.values()) - { - Player[] rewarding = getMedalOwners(type); - if (rewarding[0] != null) - { - if (!announcedMedalStart) - { - announcedMedalStart = true; - Bukkit.broadcastMessage(C.cGoldB + "-==Match Medal Recipients==-"); - } - AddGems(rewarding[0], 50, MedalLevel.GOLD.getName() + " " + type.getName(), false, false); - AddStat(rewarding[0], "Medalist", 1, false, false); - Bukkit.broadcastMessage(MedalLevel.GOLD.getName() + " " + type.getName() + C.cGray + ": " + MedalLevel.GOLD.getColor() + rewarding[0].getName()); - } - if (rewarding[1] != null) - { - AddGems(rewarding[1], 30, MedalLevel.SILVER.getName() + " " + type.getName(), false, false); - AddStat(rewarding[1], "Medalist", 1, false, false); - Bukkit.broadcastMessage(MedalLevel.SILVER.getName() + " " + type.getName() + C.cGray + ": " + MedalLevel.SILVER.getColor() + rewarding[1].getName()); - } - if (rewarding[2] != null) - { - AddGems(rewarding[2], 20, MedalLevel.BRONZE.getName() + " " + type.getName(), false, false); - AddStat(rewarding[2], "Medalist", 1, false, false); - Bukkit.broadcastMessage(MedalLevel.BRONZE.getName() + " " + type.getName() + C.cGray + ": " + MedalLevel.BRONZE.getColor() + rewarding[2].getName()); - } - } for (GameTeam team : GetTeamList()) { for (Player player : team.GetPlayers(true)) @@ -646,10 +524,29 @@ public class CastleAssaultTDM extends TeamGame AddGems(player, 10, "Participation", false, false); } - int streak = _streakData.getOrDefault(player, new KillStreakData()).getBestStreak(); - if (streak > 0) { - AddGems(player, streak, streak + " Player Kill Streak", false, false); + int crowns = 0; + for (GemData data : GetGems(player).values()) + { + crowns += data.Gems; + } + int streak = _streakData.getOrDefault(player, new KillStreakData()).getBestStreak(); + if (streak >= 2 && streak < 4) + { + AddGems(player, 0.5 * crowns, streak + " Player Kill Streak", false, false); + } + else if (streak >= 4 && streak < 6) + { + AddGems(player, crowns, streak + " Player Kill Streak", false, false); + } + else if (streak >= 6 && streak < 8) + { + AddGems(player, 1.5 * crowns, streak + " Player Kill Streak", false, false); + } + else if (streak >= 8) + { + AddGems(player, 2 * crowns, streak + " Player Kill Streak", false, false); + } } KitPlayer kit = (KitPlayer) GetKit(player); @@ -697,6 +594,10 @@ public class CastleAssaultTDM extends TeamGame Manager.GetDamage().SetEnabled(true); Manager.GetExplosion().setEnabled(true); Manager.GetCreature().SetDisableCustomDrops(false); + Managers.get(LeaderboardManager.class).unregisterLeaderboard("TOP_CASTLEASSAULT_DAILY_WINS"); + Managers.get(LeaderboardManager.class).unregisterLeaderboard("TOP_CASTLEASSAULT_DAILY_KILLS"); + Managers.get(LeaderboardManager.class).unregisterLeaderboard("TOP_CASTLEASSAULT_WINS"); + Managers.get(LeaderboardManager.class).unregisterLeaderboard("TOP_CASTLEASSAULT_KILLS"); } } @@ -757,6 +658,23 @@ public class CastleAssaultTDM extends TeamGame { event.setCancelled(true); } + if (event.getToBlock().getType() == Material.ICE) + { + event.setCancelled(true); + } + } + + @EventHandler + public void onBlockChange(BlockFormEvent e) + { + if (!IsLive()) + { + return; + } + if (e.getNewState().getType() == Material.ICE) + { + e.setCancelled(true); + } } @SuppressWarnings("deprecation") @@ -871,7 +789,6 @@ public class CastleAssaultTDM extends TeamGame } AddStat(player, GetKit(player).GetName() + "KitKills", 1, false, false); - _medalData.computeIfAbsent(player, key -> new MedalData()).addScore(MedalType.ELIM, 1D); _teamKills.merge(GetTeam(player), 1, Integer::sum); if (UtilPlayer.isSpectator(player)) @@ -886,7 +803,6 @@ public class CastleAssaultTDM extends TeamGame if (data.addKill(hardLine)) { AddStat(player, "KillStreak", 1, false, false); - player.sendMessage(C.cRedB + "You have received a Kill Streak Reward!"); ((KitPlayer)GetKit(player)).awardKillStreak(player, hardLine ? (data.getKills() + 1) : data.getKills()); } if (UtilMath.isEven(data.getKills())) @@ -1029,6 +945,10 @@ public class CastleAssaultTDM extends TeamGame teleport.setYaw(shooter.getLocation().getYaw()); shooter.teleport(teleport); } + if (event.getEntity() instanceof Arrow) + { + Manager.runSyncLater(event.getEntity()::remove, 1L); + } } @EventHandler From bcd60d325b1999fcd604ad5449c9c126436fcdb0 Mon Sep 17 00:00:00 2001 From: LCastr0 Date: Tue, 9 May 2017 23:06:49 -0300 Subject: [PATCH 66/99] Fixed win rooms --- .../rankwineffects/WinEffectRankEternal.java | 8 ++-- .../rankwineffects/WinEffectRankHero.java | 15 +++--- .../rankwineffects/WinEffectRankLegend.java | 8 ++-- .../rankwineffects/WinEffectRankTitan.java | 36 +++++++++++--- .../rankwineffects/WinEffectRankUltra.java | 48 ++++++++++++++----- 5 files changed, 83 insertions(+), 32 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankEternal.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankEternal.java index 2b80a5573..06343fd6d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankEternal.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankEternal.java @@ -76,7 +76,9 @@ public class WinEffectRankEternal extends WinEffectRankBased Location npcLocation = _npc.getEntity().getBukkitEntity().getLocation(); - if (_guardian == null) + _step++; + + if (_guardian == null && _step >= 5) { Manager.getPetManager().getCreatureModule().SetForce(true); _guardian = npcLocation.getWorld().spawn(npcLocation.add(0, 20, 0), Guardian.class); @@ -88,13 +90,11 @@ public class WinEffectRankEternal extends WinEffectRankBased double angle = _step * increment; Vector vector = new Vector(Math.cos(angle) * RADIUS, 0, Math.sin(angle) * RADIUS); _guardian.setVelocity(new Vector(0,0,0)); - _guardian.teleport(_player.getLocation().clone().add(vector)); + _guardian.teleport(_player.getLocation().clone().subtract(vector)); Vector direction = npcLocation.toVector().subtract(_guardian.getEyeLocation().toVector()); Location enderLocation = _guardian.getLocation().setDirection(direction); _guardian.teleport(enderLocation); - _step++; - if (_step % 2 == 0) zap(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankHero.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankHero.java index 678f1cc61..1a30a2996 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankHero.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankHero.java @@ -51,7 +51,7 @@ public class WinEffectRankHero extends WinEffectRankBased loc.setDirection(_player.getLocation().subtract(loc).toVector().multiply(-1)); - _npc = getNPC(getPlayer(), loc, true); + _npc = getNPC(getPlayer(), loc); } @Override @@ -71,10 +71,10 @@ public class WinEffectRankHero extends WinEffectRankBased if (!isRunning()) return; - if (_step > 70) + if (_step > 60) return; - if (_step == 70) + if (_step == 30) { breakBlocks(); } @@ -84,11 +84,14 @@ public class WinEffectRankHero extends WinEffectRankBased Location npcLocation = _npc.getEntity().getBukkitEntity().getLocation(); - if (_enderDragon == null) + _step++; + + if (_enderDragon == null && _step >= 5) { Manager.getPetManager().getCreatureModule().SetForce(true); _enderDragon = npcLocation.getWorld().spawn(npcLocation.add(0, 20, 0), EnderDragon.class); Manager.getPetManager().getCreatureModule().SetForce(false); + _step = 0; } double increment = (2 * Math.PI) / POINTS; @@ -96,13 +99,11 @@ public class WinEffectRankHero extends WinEffectRankBased double angle = _step * increment; Vector vector = new Vector(Math.cos(angle) * RADIUS, 0, Math.sin(angle) * RADIUS); _enderDragon.setVelocity(new Vector(0,0,0)); - _enderDragon.teleport(_player.getLocation().clone().add(vector)); + _enderDragon.teleport(_player.getLocation().clone().subtract(vector)); Vector direction = npcLocation.toVector().subtract(_enderDragon.getEyeLocation().toVector()).multiply(-1); Location enderLocation = _enderDragon.getLocation().setDirection(direction); _enderDragon.teleport(enderLocation); - _step++; - if (_step >= 50) setTarget(); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankLegend.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankLegend.java index d8266b2c8..382751252 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankLegend.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankLegend.java @@ -76,7 +76,9 @@ public class WinEffectRankLegend extends WinEffectRankBased Location npcLocation = _npc.getEntity().getBukkitEntity().getLocation(); - if (_wither == null) + _step++; + + if (_wither == null && _step >= 5) { Manager.getPetManager().getCreatureModule().SetForce(true); _wither = npcLocation.getWorld().spawn(npcLocation.add(0, 20, 0), Wither.class); @@ -88,13 +90,11 @@ public class WinEffectRankLegend extends WinEffectRankBased double angle = _step * increment; Vector vector = new Vector(Math.cos(angle) * RADIUS, 0, Math.sin(angle) * RADIUS); _wither.setVelocity(new Vector(0,0,0)); - _wither.teleport(_player.getLocation().clone().add(vector)); + _wither.teleport(_player.getLocation().clone().subtract(vector)); Vector direction = npcLocation.toVector().subtract(_wither.getEyeLocation().toVector()); Location enderLocation = _wither.getLocation().setDirection(direction); _wither.teleport(enderLocation); - _step++; - if (_step % 5 == 0) spawnSkull(); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankTitan.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankTitan.java index b6b611bfc..93c508ae5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankTitan.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankTitan.java @@ -22,12 +22,15 @@ import mineplex.core.common.util.UtilText; import mineplex.core.disguise.disguises.DisguisePlayer; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.gadgets.wineffect.rankrooms.WinEffectRankBased; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; public class WinEffectRankTitan extends WinEffectRankBased { private DisguisePlayer _npc; private Giant _giant = null; + private int _step = 0; private static final int RADIUS = 5; @@ -46,12 +49,6 @@ public class WinEffectRankTitan extends WinEffectRankBased loc.setDirection(_player.getLocation().subtract(loc).toVector().multiply(-1)); _npc = getNPC(getPlayer(), loc); - - Manager.getPetManager().getCreatureModule().SetForce(true); - - _giant = loc.getWorld().spawn(loc.add(0, 20, 0), Giant.class); - - Manager.getPetManager().getCreatureModule().SetForce(false); } @Override @@ -60,6 +57,33 @@ public class WinEffectRankTitan extends WinEffectRankBased if (_giant != null) { _giant.remove(); + _giant = null; + } + _step = 0; + } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (!isRunning()) + return; + + if (event.getType() != UpdateType.FASTEST) + return; + + if (_giant == null && _step >= 5) + { + Location loc = getBaseLocation(); + + Manager.getPetManager().getCreatureModule().SetForce(true); + + _giant = loc.getWorld().spawn(loc.add(0, 20, 0), Giant.class); + + Manager.getPetManager().getCreatureModule().SetForce(false); + } + else + { + _step++; } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankUltra.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankUltra.java index 2e8f43dc3..afb57433c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankUltra.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankUltra.java @@ -23,6 +23,8 @@ import mineplex.core.common.util.UtilText; import mineplex.core.disguise.disguises.DisguisePlayer; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.gadgets.wineffect.rankrooms.WinEffectRankBased; +import mineplex.core.updater.UpdateType; +import mineplex.core.updater.event.UpdateEvent; public class WinEffectRankUltra extends WinEffectRankBased { @@ -31,6 +33,7 @@ public class WinEffectRankUltra extends WinEffectRankBased private DisguisePlayer _npc; private Creeper _creeper; + private int _step = 0; public WinEffectRankUltra(GadgetManager manager) { @@ -47,23 +50,46 @@ public class WinEffectRankUltra extends WinEffectRankBased loc.setPitch(0); loc.setYaw(0); _npc = getNPC(getPlayer(), loc, true); - - Manager.getPetManager().getCreatureModule().SetForce(true); - - _creeper = loc.getWorld().spawn(loc.add(0, 10, 0), Creeper.class); - - _creeper.teleport(loc.subtract(0, 0, 2)); - - _creeper.setTarget((LivingEntity) _npc.getEntity().getBukkitEntity()); - - Manager.getPetManager().getCreatureModule().SetForce(false); } @Override public void finish() { - if (!_creeper.isDead()) + if (_creeper != null) + { _creeper.remove(); + _creeper = null; + } + _step = 0; + } + + @EventHandler + public void onUpdate(UpdateEvent event) + { + if (!isRunning()) + return; + + if (event.getType() != UpdateType.FASTEST) + return; + + if (_creeper == null && _step >= 5) + { + Location loc = getBaseLocation(); + + Manager.getPetManager().getCreatureModule().SetForce(true); + + _creeper = loc.getWorld().spawn(loc.add(0, 10, 0), Creeper.class); + + _creeper.teleport(loc.subtract(0, 0, 2)); + + _creeper.setTarget((LivingEntity) _npc.getEntity().getBukkitEntity()); + + Manager.getPetManager().getCreatureModule().SetForce(false); + } + else + { + _step++; + } } @EventHandler From 9018a3cc5044bc67df8bd5fefea81e7a3be652d0 Mon Sep 17 00:00:00 2001 From: LCastr0 Date: Tue, 9 May 2017 23:30:24 -0300 Subject: [PATCH 67/99] Fixed kit selectors --- .../gadgets/kitselector/HaloKitSelector.java | 47 +++++++++++++-- .../ShimmeringRingKitSelector.java | 58 ++++--------------- 2 files changed, 53 insertions(+), 52 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/HaloKitSelector.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/HaloKitSelector.java index c05fe3a10..4df61190f 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/HaloKitSelector.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/HaloKitSelector.java @@ -1,17 +1,27 @@ package mineplex.core.gadget.gadgets.kitselector; +import java.awt.Color; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; +import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; +import org.bukkit.util.Vector; import mineplex.core.common.util.C; import mineplex.core.common.util.LineFormat; +import mineplex.core.common.util.RGBData; import mineplex.core.common.util.UtilColor; +import mineplex.core.common.util.UtilMath; +import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilText; +import mineplex.core.common.util.particles.ColoredParticle; +import mineplex.core.common.util.particles.DustSpellColor; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.types.KitSelectorGadget; import mineplex.core.particleeffects.ColoredCircleEffect; @@ -22,10 +32,17 @@ public class HaloKitSelector extends KitSelectorGadget private Map _circleEffects = new HashMap<>(); private Map _selectedEntity = new HashMap<>(); + private static final int PARTICLES_PER_CIRCLE = 20; + private static final double RADIUS = 0.6; + + private List _colors; + private int _steps = 0; + public HaloKitSelector(GadgetManager manager) { super(manager, "Halo", UtilText.splitLinesToArray(new String[]{C.cGray + "Fight like an Angel."}, LineFormat.LORE), 0, Material.GOLD_HELMET, (byte) 0); + _colors = new ArrayList<>(); } @Override @@ -38,7 +55,7 @@ public class HaloKitSelector extends KitSelectorGadget @Override public void playParticle(Entity entity, Player playTo) { - if (_circleEffects.containsKey(entity)) + /*if (_circleEffects.containsKey(entity)) return; if (_selectedEntity.containsValue(playTo)) @@ -53,12 +70,28 @@ public class HaloKitSelector extends KitSelectorGadget coloredCircleEffect.start(); _selectedEntity.put(playTo, entity); - _circleEffects.put(entity, coloredCircleEffect); + _circleEffects.put(entity, coloredCircleEffect);*/ + + if (_colors.isEmpty()) + { + RGBData rgbData = UtilColor.hexToRgb(0xffd700); + _colors.add(new Color(rgbData.getFullRed(), rgbData.getFullGreen(), rgbData.getFullBlue())); + rgbData = UtilColor.hexToRgb(0xdaa520); + _colors.add(new Color(rgbData.getFullRed(), rgbData.getFullGreen(), rgbData.getFullBlue())); + } + + Location location = entity.getLocation().add(0, getEntityYOffset(entity), 0); + double increment = (2 * Math.PI) / PARTICLES_PER_CIRCLE; + double angle = _steps * increment; + Vector vector = new Vector(Math.cos(angle) * RADIUS, 0, Math.sin(angle) * RADIUS); + ColoredParticle coloredParticle = new ColoredParticle(UtilParticle.ParticleType.RED_DUST, new DustSpellColor(getNextColor()), location.add(vector)); + coloredParticle.display(UtilParticle.ViewDist.NORMAL, playTo); + _steps++; } private void stopEffect(Player player) { - if (_selectedEntity.containsKey(player)) + /*if (_selectedEntity.containsKey(player)) { Entity entity = _selectedEntity.get(player); if (_circleEffects.containsKey(entity)) @@ -67,7 +100,13 @@ public class HaloKitSelector extends KitSelectorGadget _circleEffects.remove(entity); } _selectedEntity.remove(player); - } + }*/ + } + + private Color getNextColor() + { + int r = UtilMath.random.nextInt(_colors.size()); + return _colors.get(r); } /** diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/ShimmeringRingKitSelector.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/ShimmeringRingKitSelector.java index a6535bfe9..c94da1413 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/ShimmeringRingKitSelector.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/ShimmeringRingKitSelector.java @@ -1,8 +1,5 @@ package mineplex.core.gadget.gadgets.kitselector; -import java.util.HashMap; -import java.util.Map; - import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.entity.Entity; @@ -21,9 +18,8 @@ public class ShimmeringRingKitSelector extends KitSelectorGadget private static final int PARTICLES_PER_CIRCLE = 20; - private Map _selectedEntity = new HashMap<>(); - private Map _circleHeight = new HashMap<>(); - private Map _direction = new HashMap<>(); + private double _circleHeight = 0.0; + private boolean _direction = true; public ShimmeringRingKitSelector(GadgetManager manager) { @@ -31,61 +27,27 @@ public class ShimmeringRingKitSelector extends KitSelectorGadget 0, Material.WOOL, (byte) 4); } - @Override - public void disableCustom(Player player, boolean message) - { - super.disableCustom(player, message); - if (_selectedEntity.containsKey(player)) - { - Entity selected = _selectedEntity.get(player); - _circleHeight.remove(selected); - _direction.remove(selected); - _selectedEntity.remove(player); - } - } - @Override public void playParticle(Entity entity, Player playTo) { - if (_selectedEntity.containsKey(playTo)) - { - Entity selected = _selectedEntity.get(playTo); - if (!selected.equals(entity)) - { - _selectedEntity.remove(playTo); - _circleHeight.remove(selected); - _direction.remove(selected); - _selectedEntity.put(playTo, entity); - _circleHeight.put(entity, 0.0); - _direction.put(entity, true); - } - } - else - { - _selectedEntity.put(playTo, entity); - _circleHeight.put(entity, 0.0); - _direction.put(entity, true); - } // Updates height and direction of particles - double height = _circleHeight.get(entity); - if (height <= 0) + if (_circleHeight <= 0) { - _direction.put(entity, true); + _direction = true; } - else if (height >= getEntityHeight(entity)) + else if (_circleHeight >= getEntityHeight(entity)) { - _direction.put(entity, false); + _direction = false; } - if (_direction.get(entity)) - height += 0.2; + if (_direction) + _circleHeight += 0.2; else - height -= 0.2; - _circleHeight.put(entity, height); + _circleHeight -= 0.2; for (int i = 0; i < PARTICLES_PER_CIRCLE; i++) { - Location location = entity.getLocation().add(0, height, 0); + Location location = entity.getLocation().add(0, _circleHeight, 0); double increment = (2 * Math.PI) / PARTICLES_PER_CIRCLE; double angle = i * increment; Vector vector = new Vector(Math.cos(angle), 0, Math.sin(angle)); From 8bb638c969f27c3bbfa417598f800b52afe7ad3d Mon Sep 17 00:00:00 2001 From: LCastr0 Date: Tue, 9 May 2017 23:30:52 -0300 Subject: [PATCH 68/99] Removed unused code --- .../gadgets/kitselector/HaloKitSelector.java | 44 ------------------- 1 file changed, 44 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/HaloKitSelector.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/HaloKitSelector.java index 4df61190f..4d1069e00 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/HaloKitSelector.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/kitselector/HaloKitSelector.java @@ -2,9 +2,7 @@ package mineplex.core.gadget.gadgets.kitselector; import java.awt.Color; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; -import java.util.Map; import org.bukkit.Location; import org.bukkit.Material; @@ -24,14 +22,10 @@ import mineplex.core.common.util.particles.ColoredParticle; import mineplex.core.common.util.particles.DustSpellColor; import mineplex.core.gadget.GadgetManager; import mineplex.core.gadget.types.KitSelectorGadget; -import mineplex.core.particleeffects.ColoredCircleEffect; public class HaloKitSelector extends KitSelectorGadget { - private Map _circleEffects = new HashMap<>(); - private Map _selectedEntity = new HashMap<>(); - private static final int PARTICLES_PER_CIRCLE = 20; private static final double RADIUS = 0.6; @@ -45,33 +39,9 @@ public class HaloKitSelector extends KitSelectorGadget _colors = new ArrayList<>(); } - @Override - public void disableCustom(Player player, boolean message) - { - super.disableCustom(player, message); - stopEffect(player); - } - @Override public void playParticle(Entity entity, Player playTo) { - /*if (_circleEffects.containsKey(entity)) - return; - - if (_selectedEntity.containsValue(playTo)) - { - stopEffect(playTo); - } - - ColoredCircleEffect coloredCircleEffect = new ColoredCircleEffect(Manager.getPlugin(), entity, 0.6, false); - coloredCircleEffect.addColors(UtilColor.hexToRgb(0xffd700), UtilColor.hexToRgb(0xdaa520)); - coloredCircleEffect.setYOffset(getEntityYOffset(entity)); - coloredCircleEffect.setPlayers(playTo); - coloredCircleEffect.start(); - - _selectedEntity.put(playTo, entity); - _circleEffects.put(entity, coloredCircleEffect);*/ - if (_colors.isEmpty()) { RGBData rgbData = UtilColor.hexToRgb(0xffd700); @@ -89,20 +59,6 @@ public class HaloKitSelector extends KitSelectorGadget _steps++; } - private void stopEffect(Player player) - { - /*if (_selectedEntity.containsKey(player)) - { - Entity entity = _selectedEntity.get(player); - if (_circleEffects.containsKey(entity)) - { - _circleEffects.get(entity).stop(); - _circleEffects.remove(entity); - } - _selectedEntity.remove(player); - }*/ - } - private Color getNextColor() { int r = UtilMath.random.nextInt(_colors.size()); From 3b3436d1af8b6339deff6229ae908851d418bee4 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Wed, 10 May 2017 02:06:25 -0400 Subject: [PATCH 69/99] Remove TNT from TDM chest loot --- .../game/arcade/game/games/castleassault/CastleAssaultTDM.java | 1 - 1 file changed, 1 deletion(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssaultTDM.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssaultTDM.java index 2fc876a00..dcb41bdcc 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssaultTDM.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssaultTDM.java @@ -206,7 +206,6 @@ public class CastleAssaultTDM extends TeamGame } { _miscGear.addLoot(new ItemStack(Material.ENDER_PEARL), 2); - _miscGear.addLoot(new ItemBuilder(Material.TNT, 4).setTitle(F.item("Throwing TNT")).build(), 2); _miscGear.addLoot(new ItemStack(Material.WATER_BUCKET), 2); _miscGear.addLoot(_flintAndSteel.build(), 2); _miscGear.addLoot(new ItemStack(Material.SNOW_BALL, 16), 3); From adf6e35a1f9223eb353932dc54478267e8a484e1 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Wed, 10 May 2017 02:49:21 -0400 Subject: [PATCH 70/99] Update leaderboard backend based on discussion with Jon --- .../core/leaderboard/Leaderboard.java | 14 ++- .../core/leaderboard/LeaderboardManager.java | 5 + .../leaderboard/LeaderboardRepository.java | 91 +++++++++++-------- .../games/castleassault/CastleAssault.java | 8 +- .../games/castleassault/CastleAssaultTDM.java | 8 +- .../games/castleassault/kits/KitPlayer.java | 4 +- 6 files changed, 80 insertions(+), 50 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/Leaderboard.java b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/Leaderboard.java index 7b717f6ff..4273a5399 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/Leaderboard.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/Leaderboard.java @@ -18,12 +18,17 @@ public class Leaderboard private String _display; private Pair _statDisplay; private String[] _statIds; - private int _size; + private int _size, _start; private LeaderboardSQLType _type; private Location _loc; private Hologram _holo; public Leaderboard(String display, Pair statDisplayNames, String[] statIds, LeaderboardSQLType type, Location displayLoc, int size) + { + this(display, statDisplayNames, statIds, type, displayLoc, size, 0); + } + + public Leaderboard(String display, Pair statDisplayNames, String[] statIds, LeaderboardSQLType type, Location displayLoc, int size, int start) { _display = display; _statDisplay = statDisplayNames; @@ -40,6 +45,11 @@ public class Leaderboard return _size; } + public int getStart() + { + return _start; + } + public String[] getStatIds() { return _statIds; @@ -56,7 +66,7 @@ public class Leaderboard LinkedList display = new LinkedList<>(); display.add(C.cAqua + _display); display.add(C.cRed + " "); - int place = 1; + int place = _start + 1; for (Entry entry : names.entrySet()) { if (entry.getValue() == 1) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardManager.java b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardManager.java index c9e66f1a8..754daed49 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardManager.java @@ -16,6 +16,7 @@ import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilMath; import mineplex.core.hologram.HologramManager; +import mineplex.core.leaderboard.LeaderboardRepository.LeaderboardSQLType; public class LeaderboardManager extends MiniPlugin { @@ -86,6 +87,10 @@ public class LeaderboardManager extends MiniPlugin return; } _leaderboards.put(identifier, board); + if (board.getType() == LeaderboardSQLType.MONTHLY || board.getType() == LeaderboardSQLType.MONTHLY_SEASON || board.getType() == LeaderboardSQLType.YEARLY || board.getType() == LeaderboardSQLType.YEARLY_SEASON) + { + log("Warning! You have selected a LeaderboardSQLType identified to be potentially expensive and intensive on Leaderboard ID: " + identifier); + } _repo.loadLeaderboard(board, board::update); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardRepository.java index 188103c5a..6650af665 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardRepository.java @@ -1,7 +1,6 @@ package mineplex.core.leaderboard; import java.sql.Connection; -import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; @@ -21,13 +20,21 @@ import mineplex.serverdata.database.column.ColumnVarChar; public class LeaderboardRepository extends RepositoryBase { private static final int SEASON = 1; - private static final String CREATE = "CREATE TABLE Account.statLeaderboard (id INT NOT NULL AUTO_INCREMENT, accountId INT NOT NULL, statId INT NOT NULL, value INT NOT NULL, date DATE NOT NULL, season INT NOT NULL, PRIMARY KEY (id), UNIQUE INDEX accountStatIndex(accountId, statId, date), INDEX valueIndex(value), INDEX seasonIndex(season), FOREIGN KEY (accountId) REFERENCES Account.accounts(id), FOREIGN KEY (statId) REFERENCES Account.stats(id));"; - private static final String INSERT_STAT = "INSERT INTO statLeaderboard (accountId, statId, value, date, season) VALUES (?, (SELECT id FROM stats WHERE name=?), ?, CURDATE(), " + SEASON + ") ON DUPLICATE KEY UPDATE value=value+VALUES(value);"; - private static final String FETCH_STAT_ALL = "SELECT a.name, sl.value FROM statLeaderboard AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE sl.statId IN (SELECT id FROM stats WHERE name IN (%IDS%)) AND season=" + SEASON + " ORDER BY sl.value DESC LIMIT %LIMIT%;"; - private static final String FETCH_STAT_YEARLY = "SELECT a.name, sl.value FROM statLeaderboard AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE YEAR(sl.date) = YEAR(CURDATE()) AND sl.statId IN (SELECT id FROM stats WHERE name IN (%IDS%)) AND season=" + SEASON + " ORDER BY sl.value DESC LIMIT %LIMIT%;"; - private static final String FETCH_STAT_MONTHLY = "SELECT a.name, sl.value FROM statLeaderboard AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE MONTH(sl.date) = MONTH(CURDATE()) AND YEAR(`date`) = YEAR(CURDATE()) AND sl.statId IN (SELECT id FROM stats WHERE name IN (%IDS%)) AND season=" + SEASON + " ORDER BY sl.value DESC LIMIT %LIMIT%;"; - private static final String FETCH_STAT_WEEKLY = "SELECT a.name, sl.value FROM statLeaderboard AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE YEARWEEK(sl.date, 1) = YEARWEEK(CURDATE(), 1) AND sl.statId IN (SELECT id FROM stats WHERE name IN (%IDS%)) AND season=" + SEASON + " ORDER BY sl.value DESC LIMIT %LIMIT%;"; - private static final String FETCH_STAT_DAILY = "SELECT a.name, sl.value FROM statLeaderboard AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE sl.date = CURDATE() AND sl.statId IN (SELECT id FROM stats WHERE name IN (%IDS%)) AND season=" + SEASON + " ORDER BY sl.value DESC LIMIT %LIMIT%;"; + private static final String CREATE_ALL_TIME = "CREATE TABLE accountStatsAllTime (id INT NOT NULL AUTO_INCREMENT, accountId INT NOT NULL, statId INT NOT NULL, value INT NOT NULL, date DATE NOT NULL, PRIMARY KEY (id), UNIQUE INDEX accountStatIndex(accountId, statId, date), INDEX valueIndex(value), FOREIGN KEY (accountId) REFERENCES Account.accounts(id), FOREIGN KEY (statId) REFERENCES Account.stats(id));"; + private static final String CREATE_SEASONAL = "CREATE TABLE accountStatsSeasonal (id INT NOT NULL AUTO_INCREMENT, accountId INT NOT NULL, statId INT NOT NULL, value INT NOT NULL, date DATE NOT NULL, season INT NOT NULL, PRIMARY KEY (id), UNIQUE INDEX accountStatIndex(accountId, statId, date, season), INDEX valueIndex(value), INDEX seasonIndex(season), FOREIGN KEY (accountId) REFERENCES Account.accounts(id), FOREIGN KEY (statId) REFERENCES Account.stats(id));"; + private static final String INSERT_STAT = "INSERT INTO accountStatsSeasonal (accountId, statId, value, date, season) VALUES (?, (SELECT id FROM stats WHERE name=?), ?, CURDATE(), " + SEASON + ") ON DUPLICATE KEY UPDATE value=value+VALUES(value);"; + + private static final String FETCH_STAT_ALL = "SELECT a.name, sl.value FROM accountStatsAllTime AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE sl.statId=(SELECT id FROM stats WHERE name=%STAT%) ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; + private static final String FETCH_STAT_YEARLY = "SELECT a.name, sl.value FROM accountStatsAllTime AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE YEAR(sl.date) = YEAR(CURDATE()) AND sl.statId=(SELECT id FROM stats WHERE name=%STAT%) ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; + private static final String FETCH_STAT_MONTHLY = "SELECT a.name, sl.value FROM accountStatsAllTime AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE MONTH(sl.date) = MONTH(CURDATE()) AND YEAR(`date`) = YEAR(CURDATE()) AND sl.statId=(SELECT id FROM stats WHERE name=%STAT%) ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; + private static final String FETCH_STAT_WEEKLY = "SELECT a.name, sl.value FROM accountStatsAllTime AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE YEARWEEK(sl.date, 1) = YEARWEEK(CURDATE(), 1) AND sl.statId=(SELECT id FROM stats WHERE name=%STAT%) ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; + private static final String FETCH_STAT_DAILY = "SELECT a.name, sl.value FROM accountStatsAllTime AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE sl.date = CURDATE() AND sl.statId=(SELECT id FROM stats WHERE name=%STAT%) ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; + + private static final String FETCH_STAT_ALL_SEASON = "SELECT a.name, sl.value FROM accountStatsSeasonal AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE sl.statId=(SELECT id FROM stats WHERE name=%STAT%) AND season=" + SEASON + " ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; + private static final String FETCH_STAT_YEARLY_SEASON = "SELECT a.name, sl.value FROM accountStatsSeasonal AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE YEAR(sl.date) = YEAR(CURDATE()) AND sl.statId=(SELECT id FROM stats WHERE name=%STAT%) AND season=" + SEASON + " ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; + private static final String FETCH_STAT_MONTHLY_SEASON = "SELECT a.name, sl.value FROM accountStatsSeasonal AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE MONTH(sl.date) = MONTH(CURDATE()) AND YEAR(`date`) = YEAR(CURDATE()) AND sl.statId=(SELECT id FROM stats WHERE name=%STAT%) AND season=" + SEASON + " ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; + private static final String FETCH_STAT_WEEKLY_SEASON = "SELECT a.name, sl.value FROM accountStatsSeasonal AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE YEARWEEK(sl.date, 1) = YEARWEEK(CURDATE(), 1) AND sl.statId=(SELECT id FROM stats WHERE name=%STAT%) AND season=" + SEASON + " ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; + private static final String FETCH_STAT_DAILY_SEASON = "SELECT a.name, sl.value FROM accountStatsSeasonal AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE sl.date = CURDATE() AND sl.statId=(SELECT id FROM stats WHERE name=%STAT%) AND season=" + SEASON + " ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; public LeaderboardRepository(JavaPlugin plugin) { @@ -49,10 +56,20 @@ public class LeaderboardRepository extends RepositoryBase try (Connection c = getConnection()) { Map names = new LinkedHashMap<>(); - ResultSet rs = board.getType().getStatement(c, board.getStatIds(), board.getSize()).executeQuery(); - while (rs.next()) + Statement s = c.createStatement(); + s.execute(board.getType().getStatement(board.getStatIds(), board.getStart(), board.getSize())); + for (int i = 0; i < board.getStatIds().length; i++) { - names.put(rs.getString("name"), rs.getInt("value")); + ResultSet rs = s.getResultSet(); + while (rs.next()) + { + names.merge(rs.getString("name"), rs.getInt("value"), Integer::sum); + } + + if (!s.getMoreResults()) + { + break ; + } } UtilServer.runSync(() -> leaderboard.accept(names)); @@ -77,7 +94,7 @@ public class LeaderboardRepository extends RepositoryBase int i = 0; for (Leaderboard board : boards) { - queryBuilder.append(board.getType().getMultiStatement(board.getStatIds(), board.getSize())); + queryBuilder.append(board.getType().getStatement(board.getStatIds(), board.getStart(), board.getSize())); leaderboards[i] = new LinkedHashMap<>(); i++; } @@ -87,19 +104,23 @@ public class LeaderboardRepository extends RepositoryBase { Statement s = c.createStatement(); s.execute(queryBuilder.toString()); - - for (int i = 0; i < boards.size(); i++) + int index = 0; + mainBoardLoop: for (Leaderboard board : boards) { - ResultSet rs = s.getResultSet(); - while (rs.next()) + for (int i = 0; i < board.getStatIds().length; i++) { - leaderboards[i].put(rs.getString("name"), rs.getInt("value")); - } - - if (!s.getMoreResults()) - { - break; + ResultSet rs = s.getResultSet(); + while (rs.next()) + { + leaderboards[index].merge(rs.getString("name"), rs.getInt("value"), Integer::sum); + } + + if (!s.getMoreResults()) + { + break mainBoardLoop; + } } + index++; } } @@ -115,10 +136,15 @@ public class LeaderboardRepository extends RepositoryBase public static enum LeaderboardSQLType { DAILY(FETCH_STAT_DAILY), + DAILY_SEASON(FETCH_STAT_DAILY_SEASON), WEEKLY(FETCH_STAT_WEEKLY), + WEEKLY_SEASON(FETCH_STAT_WEEKLY_SEASON), MONTHLY(FETCH_STAT_MONTHLY), + MONTHLY_SEASON(FETCH_STAT_MONTHLY_SEASON), YEARLY(FETCH_STAT_YEARLY), - ALL(FETCH_STAT_ALL) + YEARLY_SEASON(FETCH_STAT_YEARLY_SEASON), + ALL(FETCH_STAT_ALL), + ALL_SEASON(FETCH_STAT_ALL_SEASON) ; private String _sql; @@ -128,25 +154,14 @@ public class LeaderboardRepository extends RepositoryBase _sql = sql; } - public PreparedStatement getStatement(Connection connection, String[] statIds, int limit) throws SQLException + public String getStatement(String[] statIds, int start, int limit) throws SQLException { - StringBuilder idBuilder = new StringBuilder(); + StringBuilder statementBuilder = new StringBuilder(); for (String id : statIds) { - idBuilder.append("'" + id + "'").append(", "); + statementBuilder.append(_sql.replace("%STAT%", id).replace("%START%", String.valueOf(start)).replace("%LIMIT%", String.valueOf(limit))); } - PreparedStatement ps = connection.prepareStatement(_sql.replace("%LIMIT%", String.valueOf(limit)).replace("%IDS%", idBuilder.substring(0, idBuilder.length() - 2))); - return ps; - } - - public String getMultiStatement(String[] statIds, int limit) - { - StringBuilder idBuilder = new StringBuilder(); - for (String id : statIds) - { - idBuilder.append("'" + id + "'").append(", "); - } - return _sql.replace("%LIMIT%", String.valueOf(limit)).replace("%IDS%", idBuilder.substring(0, idBuilder.length() - 2)); + return statementBuilder.toString(); } } } \ No newline at end of file diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java index c4cb2618a..aa48f660d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java @@ -206,22 +206,22 @@ public class CastleAssault extends TeamGame if (lobbyCustomLocs.containsKey("TOP_DAILY_WINS")) { Location loc = lobbyCustomLocs.get("TOP_DAILY_WINS").get(0); - Managers.get(LeaderboardManager.class).registerLeaderboard("TOP_CASTLEASSAULT_DAILY_WINS", new Leaderboard("Top Daily Wins", Pair.create("Win", "Wins"), new String[] {"Castle Assault.Wins"}, LeaderboardSQLType.DAILY, loc, 10)); + Managers.get(LeaderboardManager.class).registerLeaderboard("TOP_CASTLEASSAULT_DAILY_WINS", new Leaderboard("Top Daily Wins", Pair.create("Win", "Wins"), new String[] {"Castle Assault.Wins"}, LeaderboardSQLType.DAILY_SEASON, loc, 10)); } if (lobbyCustomLocs.containsKey("TOP_DAILY_KILLS")) { Location loc = lobbyCustomLocs.get("TOP_DAILY_KILLS").get(0); - Managers.get(LeaderboardManager.class).registerLeaderboard("TOP_CASTLEASSAULT_DAILY_KILLS", new Leaderboard("Top Daily Kills", Pair.create("Kill", "Kills"), new String[] {"Castle Assault.Kills"}, LeaderboardSQLType.DAILY, loc, 10)); + Managers.get(LeaderboardManager.class).registerLeaderboard("TOP_CASTLEASSAULT_DAILY_KILLS", new Leaderboard("Top Daily Kills", Pair.create("Kill", "Kills"), new String[] {"Castle Assault.Kills"}, LeaderboardSQLType.DAILY_SEASON, loc, 10)); } if (lobbyCustomLocs.containsKey("TOP_WINS")) { Location loc = lobbyCustomLocs.get("TOP_WINS").get(0); - Managers.get(LeaderboardManager.class).registerLeaderboard("TOP_CASTLEASSAULT_WINS", new Leaderboard("Top Wins", Pair.create("Win", "Wins"), new String[] {"Castle Assault.Wins"}, LeaderboardSQLType.ALL, loc, 10)); + Managers.get(LeaderboardManager.class).registerLeaderboard("TOP_CASTLEASSAULT_WINS", new Leaderboard("Top Wins", Pair.create("Win", "Wins"), new String[] {"Castle Assault.Wins"}, LeaderboardSQLType.ALL_SEASON, loc, 10)); } if (lobbyCustomLocs.containsKey("TOP_KILLS")) { Location loc = lobbyCustomLocs.get("TOP_KILLS").get(0); - Managers.get(LeaderboardManager.class).registerLeaderboard("TOP_CASTLEASSAULT_KILLS", new Leaderboard("Top Kills", Pair.create("Kill", "Kills"), new String[] {"Castle Assault.Kills"}, LeaderboardSQLType.ALL, loc, 10)); + Managers.get(LeaderboardManager.class).registerLeaderboard("TOP_CASTLEASSAULT_KILLS", new Leaderboard("Top Kills", Pair.create("Kill", "Kills"), new String[] {"Castle Assault.Kills"}, LeaderboardSQLType.ALL_SEASON, loc, 10)); } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssaultTDM.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssaultTDM.java index dcb41bdcc..294a963a6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssaultTDM.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssaultTDM.java @@ -165,22 +165,22 @@ public class CastleAssaultTDM extends TeamGame if (lobbyCustomLocs.containsKey("TOP_DAILY_WINS")) { Location loc = lobbyCustomLocs.get("TOP_DAILY_WINS").get(0); - Managers.get(LeaderboardManager.class).registerLeaderboard("TOP_CASTLEASSAULT_DAILY_WINS", new Leaderboard("Top Daily Wins", Pair.create("Win", "Wins"), new String[] {"Castle Assault TDM.Wins"}, LeaderboardSQLType.DAILY, loc, 10)); + Managers.get(LeaderboardManager.class).registerLeaderboard("TOP_CASTLEASSAULT_DAILY_WINS", new Leaderboard("Top Daily Wins", Pair.create("Win", "Wins"), new String[] {"Castle Assault TDM.Wins"}, LeaderboardSQLType.DAILY_SEASON, loc, 10)); } if (lobbyCustomLocs.containsKey("TOP_DAILY_KILLS")) { Location loc = lobbyCustomLocs.get("TOP_DAILY_KILLS").get(0); - Managers.get(LeaderboardManager.class).registerLeaderboard("TOP_CASTLEASSAULT_DAILY_KILLS", new Leaderboard("Top Daily Kills", Pair.create("Kill", "Kills"), new String[] {"Castle Assault TDM.Kills"}, LeaderboardSQLType.DAILY, loc, 10)); + Managers.get(LeaderboardManager.class).registerLeaderboard("TOP_CASTLEASSAULT_DAILY_KILLS", new Leaderboard("Top Daily Kills", Pair.create("Kill", "Kills"), new String[] {"Castle Assault TDM.Kills"}, LeaderboardSQLType.DAILY_SEASON, loc, 10)); } if (lobbyCustomLocs.containsKey("TOP_WINS")) { Location loc = lobbyCustomLocs.get("TOP_WINS").get(0); - Managers.get(LeaderboardManager.class).registerLeaderboard("TOP_CASTLEASSAULT_WINS", new Leaderboard("Top Wins", Pair.create("Win", "Wins"), new String[] {"Castle Assault TDM.Wins"}, LeaderboardSQLType.ALL, loc, 10)); + Managers.get(LeaderboardManager.class).registerLeaderboard("TOP_CASTLEASSAULT_WINS", new Leaderboard("Top Wins", Pair.create("Win", "Wins"), new String[] {"Castle Assault TDM.Wins"}, LeaderboardSQLType.ALL_SEASON, loc, 10)); } if (lobbyCustomLocs.containsKey("TOP_KILLS")) { Location loc = lobbyCustomLocs.get("TOP_KILLS").get(0); - Managers.get(LeaderboardManager.class).registerLeaderboard("TOP_CASTLEASSAULT_KILLS", new Leaderboard("Top Kills", Pair.create("Kill", "Kills"), new String[] {"Castle Assault TDM.Kills"}, LeaderboardSQLType.ALL, loc, 10)); + Managers.get(LeaderboardManager.class).registerLeaderboard("TOP_CASTLEASSAULT_KILLS", new Leaderboard("Top Kills", Pair.create("Kill", "Kills"), new String[] {"Castle Assault TDM.Kills"}, LeaderboardSQLType.ALL_SEASON, loc, 10)); } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitPlayer.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitPlayer.java index c9fdaf1c6..1b90a1793 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitPlayer.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitPlayer.java @@ -20,12 +20,12 @@ public abstract class KitPlayer extends ProgressingKit public KitPlayer(ArcadeManager manager, String name, KitAvailability availability, String[] description, Perk[] perks, Material holding) { - super(manager, name, "csii" + name.toLowerCase(), availability, description, perks, EntityType.ZOMBIE, new ItemStack(holding)); + super(manager, name, "castleassault" + name.toLowerCase(), availability, description, perks, EntityType.ZOMBIE, new ItemStack(holding)); } public KitPlayer(ArcadeManager manager, String name, KitAvailability availability, String[] description, Perk[][] perks, String[][] upgradeDetails, Material holding) { - super(manager, name, "csii" + name.toLowerCase(), availability, description, perks, upgradeDetails, EntityType.ZOMBIE, new ItemStack(holding)); + super(manager, name, "castleassault" + name.toLowerCase(), availability, description, perks, upgradeDetails, EntityType.ZOMBIE, new ItemStack(holding)); _progressionEnabled = true; } From fa1cd00c227a3990406d069b613bdef077102d55 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Wed, 10 May 2017 02:56:00 -0400 Subject: [PATCH 71/99] Tidy up leaderboard repository class a bit --- .../src/mineplex/core/leaderboard/LeaderboardRepository.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardRepository.java index 6650af665..783f561ca 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardRepository.java @@ -20,8 +20,10 @@ import mineplex.serverdata.database.column.ColumnVarChar; public class LeaderboardRepository extends RepositoryBase { private static final int SEASON = 1; + private static final String CREATE_ALL_TIME = "CREATE TABLE accountStatsAllTime (id INT NOT NULL AUTO_INCREMENT, accountId INT NOT NULL, statId INT NOT NULL, value INT NOT NULL, date DATE NOT NULL, PRIMARY KEY (id), UNIQUE INDEX accountStatIndex(accountId, statId, date), INDEX valueIndex(value), FOREIGN KEY (accountId) REFERENCES Account.accounts(id), FOREIGN KEY (statId) REFERENCES Account.stats(id));"; private static final String CREATE_SEASONAL = "CREATE TABLE accountStatsSeasonal (id INT NOT NULL AUTO_INCREMENT, accountId INT NOT NULL, statId INT NOT NULL, value INT NOT NULL, date DATE NOT NULL, season INT NOT NULL, PRIMARY KEY (id), UNIQUE INDEX accountStatIndex(accountId, statId, date, season), INDEX valueIndex(value), INDEX seasonIndex(season), FOREIGN KEY (accountId) REFERENCES Account.accounts(id), FOREIGN KEY (statId) REFERENCES Account.stats(id));"; + private static final String INSERT_STAT = "INSERT INTO accountStatsSeasonal (accountId, statId, value, date, season) VALUES (?, (SELECT id FROM stats WHERE name=?), ?, CURDATE(), " + SEASON + ") ON DUPLICATE KEY UPDATE value=value+VALUES(value);"; private static final String FETCH_STAT_ALL = "SELECT a.name, sl.value FROM accountStatsAllTime AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE sl.statId=(SELECT id FROM stats WHERE name=%STAT%) ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; From f34a2946c4998e1237128433a5745f1a482b4e27 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Wed, 10 May 2017 03:28:55 -0400 Subject: [PATCH 72/99] Final leaderboard repository changes for Jon --- .../core/leaderboard/LeaderboardRepository.java | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardRepository.java index 783f561ca..03f696760 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardRepository.java @@ -21,16 +21,12 @@ public class LeaderboardRepository extends RepositoryBase { private static final int SEASON = 1; - private static final String CREATE_ALL_TIME = "CREATE TABLE accountStatsAllTime (id INT NOT NULL AUTO_INCREMENT, accountId INT NOT NULL, statId INT NOT NULL, value INT NOT NULL, date DATE NOT NULL, PRIMARY KEY (id), UNIQUE INDEX accountStatIndex(accountId, statId, date), INDEX valueIndex(value), FOREIGN KEY (accountId) REFERENCES Account.accounts(id), FOREIGN KEY (statId) REFERENCES Account.stats(id));"; + private static final String CREATE_ALL_TIME = "CREATE TABLE accountStatsAllTime (id INT NOT NULL AUTO_INCREMENT, accountId INT NOT NULL, statId INT NOT NULL, value INT NOT NULL, PRIMARY KEY (id), UNIQUE INDEX accountStatIndex(accountId, statId), INDEX valueIndex(value), FOREIGN KEY (accountId) REFERENCES Account.accounts(id), FOREIGN KEY (statId) REFERENCES Account.stats(id));"; private static final String CREATE_SEASONAL = "CREATE TABLE accountStatsSeasonal (id INT NOT NULL AUTO_INCREMENT, accountId INT NOT NULL, statId INT NOT NULL, value INT NOT NULL, date DATE NOT NULL, season INT NOT NULL, PRIMARY KEY (id), UNIQUE INDEX accountStatIndex(accountId, statId, date, season), INDEX valueIndex(value), INDEX seasonIndex(season), FOREIGN KEY (accountId) REFERENCES Account.accounts(id), FOREIGN KEY (statId) REFERENCES Account.stats(id));"; private static final String INSERT_STAT = "INSERT INTO accountStatsSeasonal (accountId, statId, value, date, season) VALUES (?, (SELECT id FROM stats WHERE name=?), ?, CURDATE(), " + SEASON + ") ON DUPLICATE KEY UPDATE value=value+VALUES(value);"; private static final String FETCH_STAT_ALL = "SELECT a.name, sl.value FROM accountStatsAllTime AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE sl.statId=(SELECT id FROM stats WHERE name=%STAT%) ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; - private static final String FETCH_STAT_YEARLY = "SELECT a.name, sl.value FROM accountStatsAllTime AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE YEAR(sl.date) = YEAR(CURDATE()) AND sl.statId=(SELECT id FROM stats WHERE name=%STAT%) ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; - private static final String FETCH_STAT_MONTHLY = "SELECT a.name, sl.value FROM accountStatsAllTime AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE MONTH(sl.date) = MONTH(CURDATE()) AND YEAR(`date`) = YEAR(CURDATE()) AND sl.statId=(SELECT id FROM stats WHERE name=%STAT%) ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; - private static final String FETCH_STAT_WEEKLY = "SELECT a.name, sl.value FROM accountStatsAllTime AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE YEARWEEK(sl.date, 1) = YEARWEEK(CURDATE(), 1) AND sl.statId=(SELECT id FROM stats WHERE name=%STAT%) ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; - private static final String FETCH_STAT_DAILY = "SELECT a.name, sl.value FROM accountStatsAllTime AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE sl.date = CURDATE() AND sl.statId=(SELECT id FROM stats WHERE name=%STAT%) ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; private static final String FETCH_STAT_ALL_SEASON = "SELECT a.name, sl.value FROM accountStatsSeasonal AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE sl.statId=(SELECT id FROM stats WHERE name=%STAT%) AND season=" + SEASON + " ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; private static final String FETCH_STAT_YEARLY_SEASON = "SELECT a.name, sl.value FROM accountStatsSeasonal AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE YEAR(sl.date) = YEAR(CURDATE()) AND sl.statId=(SELECT id FROM stats WHERE name=%STAT%) AND season=" + SEASON + " ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; @@ -137,13 +133,9 @@ public class LeaderboardRepository extends RepositoryBase public static enum LeaderboardSQLType { - DAILY(FETCH_STAT_DAILY), DAILY_SEASON(FETCH_STAT_DAILY_SEASON), - WEEKLY(FETCH_STAT_WEEKLY), WEEKLY_SEASON(FETCH_STAT_WEEKLY_SEASON), - MONTHLY(FETCH_STAT_MONTHLY), MONTHLY_SEASON(FETCH_STAT_MONTHLY_SEASON), - YEARLY(FETCH_STAT_YEARLY), YEARLY_SEASON(FETCH_STAT_YEARLY_SEASON), ALL(FETCH_STAT_ALL), ALL_SEASON(FETCH_STAT_ALL_SEASON) From b4c27307baea1f38c95dc58afd328b5e23fa2d01 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Wed, 10 May 2017 04:40:14 -0400 Subject: [PATCH 73/99] Further leaderboard repository tweaks --- .../core/leaderboard/Leaderboard.java | 19 +++-- .../core/leaderboard/LeaderboardManager.java | 59 +++++++++++-- .../leaderboard/LeaderboardRepository.java | 84 +++++++++++-------- .../src/mineplex/core/stats/StatsManager.java | 10 +++ .../game/arcade/managers/GameStatManager.java | 2 +- 5 files changed, 122 insertions(+), 52 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/Leaderboard.java b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/Leaderboard.java index 4273a5399..c90639b66 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/Leaderboard.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/Leaderboard.java @@ -17,22 +17,24 @@ public class Leaderboard { private String _display; private Pair _statDisplay; - private String[] _statIds; + private String[] _statNames; + private int[] _statIds; private int _size, _start; private LeaderboardSQLType _type; private Location _loc; private Hologram _holo; - public Leaderboard(String display, Pair statDisplayNames, String[] statIds, LeaderboardSQLType type, Location displayLoc, int size) + public Leaderboard(String display, Pair statDisplayNames, String[] statNames, LeaderboardSQLType type, Location displayLoc, int size) { - this(display, statDisplayNames, statIds, type, displayLoc, size, 0); + this(display, statDisplayNames, statNames, type, displayLoc, size, 0); } - public Leaderboard(String display, Pair statDisplayNames, String[] statIds, LeaderboardSQLType type, Location displayLoc, int size, int start) + public Leaderboard(String display, Pair statDisplayNames, String[] statNames, LeaderboardSQLType type, Location displayLoc, int size, int start) { _display = display; _statDisplay = statDisplayNames; - _statIds = statIds; + _statNames = statNames; + _statIds = new int[_statNames.length]; _type = type; _size = size; _loc = displayLoc; @@ -50,7 +52,12 @@ public class Leaderboard return _start; } - public String[] getStatIds() + public String[] getStatNames() + { + return _statNames; + } + + public int[] getStatIds() { return _statIds; } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardManager.java b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardManager.java index 754daed49..5300b48b0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardManager.java @@ -2,8 +2,10 @@ package mineplex.core.leaderboard; import java.util.ArrayList; import java.util.HashMap; +import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.Map.Entry; import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; @@ -17,6 +19,7 @@ import mineplex.core.common.util.F; import mineplex.core.common.util.UtilMath; import mineplex.core.hologram.HologramManager; import mineplex.core.leaderboard.LeaderboardRepository.LeaderboardSQLType; +import mineplex.core.stats.StatsManager; public class LeaderboardManager extends MiniPlugin { @@ -24,6 +27,7 @@ public class LeaderboardManager extends MiniPlugin private final long REFRESH_RATE; private final LeaderboardRepository _repo; private final HologramManager _holo; + private final Map _loading = new HashMap<>(); public LeaderboardManager(JavaPlugin plugin, HologramManager hologram) { @@ -45,6 +49,28 @@ public class LeaderboardManager extends MiniPlugin REFRESH_RATE = 5 * 60 * 20 + ((UtilMath.r(5) + 1) * 60 * 20); runSyncTimer(() -> refreshBoards(), 0, REFRESH_RATE); + + runSyncTimer(() -> + { + Iterator> iterator = _loading.entrySet().iterator(); + while (iterator.hasNext()) + { + Entry entry = iterator.next(); + boolean registered = true; + for (int id : entry.getKey().getStatIds()) + { + if (id == 0) + { + registered = false; + } + } + if (registered) + { + entry.getValue().run(); + iterator.remove(); + } + } + }, 0, 20 * 2); } private void refreshBoards() @@ -70,13 +96,16 @@ public class LeaderboardManager extends MiniPlugin return _leaderboards.get(identifier); } - public void handleStatIncrease(Player player, String statId, int value) + public void handleStatIncrease(Player player, String stat, int value) { - int accountId = Managers.get(CoreClientManager.class).getAccountId(player); - if (accountId != -1) + final int accountId = Managers.get(CoreClientManager.class).getAccountId(player); + Managers.get(StatsManager.class).loadStatId(stat, id -> { - _repo.insertStat(accountId, statId, value); - } + if (accountId != -1) + { + _repo.insertStat(accountId, id, value); + } + }); } public void registerLeaderboard(String identifier, Leaderboard board) @@ -86,12 +115,24 @@ public class LeaderboardManager extends MiniPlugin board.deconstruct(); return; } - _leaderboards.put(identifier, board); - if (board.getType() == LeaderboardSQLType.MONTHLY || board.getType() == LeaderboardSQLType.MONTHLY_SEASON || board.getType() == LeaderboardSQLType.YEARLY || board.getType() == LeaderboardSQLType.YEARLY_SEASON) + final Runnable postLoad = () -> { - log("Warning! You have selected a LeaderboardSQLType identified to be potentially expensive and intensive on Leaderboard ID: " + identifier); + _leaderboards.put(identifier, board); + if (board.getType() == LeaderboardSQLType.MONTHLY_SEASON || board.getType() == LeaderboardSQLType.YEARLY_SEASON) + { + log("Warning! You have selected a LeaderboardSQLType identified to be potentially expensive and intensive on Leaderboard ID: " + identifier); + } + _repo.loadLeaderboard(board, board::update); + }; + _loading.put(board, postLoad); + for (int i = 0; i < board.getStatNames().length; i++) + { + final int index = i; + Managers.get(StatsManager.class).loadStatId(board.getStatNames()[index], id -> + { + board.getStatIds()[index] = id.intValue(); + }); } - _repo.loadLeaderboard(board, board::update); } public void unregisterLeaderboard(String boardIdentifier) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardRepository.java index 03f696760..2f6291043 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardRepository.java @@ -15,35 +15,39 @@ import mineplex.core.common.util.UtilServer; import mineplex.serverdata.database.DBPool; import mineplex.serverdata.database.RepositoryBase; import mineplex.serverdata.database.column.ColumnInt; -import mineplex.serverdata.database.column.ColumnVarChar; public class LeaderboardRepository extends RepositoryBase { private static final int SEASON = 1; - private static final String CREATE_ALL_TIME = "CREATE TABLE accountStatsAllTime (id INT NOT NULL AUTO_INCREMENT, accountId INT NOT NULL, statId INT NOT NULL, value INT NOT NULL, PRIMARY KEY (id), UNIQUE INDEX accountStatIndex(accountId, statId), INDEX valueIndex(value), FOREIGN KEY (accountId) REFERENCES Account.accounts(id), FOREIGN KEY (statId) REFERENCES Account.stats(id));"; - private static final String CREATE_SEASONAL = "CREATE TABLE accountStatsSeasonal (id INT NOT NULL AUTO_INCREMENT, accountId INT NOT NULL, statId INT NOT NULL, value INT NOT NULL, date DATE NOT NULL, season INT NOT NULL, PRIMARY KEY (id), UNIQUE INDEX accountStatIndex(accountId, statId, date, season), INDEX valueIndex(value), INDEX seasonIndex(season), FOREIGN KEY (accountId) REFERENCES Account.accounts(id), FOREIGN KEY (statId) REFERENCES Account.stats(id));"; + private static final String CREATE_ALL_TIME = "CREATE TABLE accountStatsAllTime (accountId INT NOT NULL, statId INT NOT NULL, value INT NOT NULL, PRIMARY KEY (accountId, statId), INDEX valueIndex(value), FOREIGN KEY (accountId) REFERENCES Account.accounts(id), FOREIGN KEY (statId) REFERENCES Account.stats(id));"; + private static final String CREATE_SEASONAL = "CREATE TABLE accountStatsSeasonal (accountId INT NOT NULL, statId INT NOT NULL, value INT NOT NULL, date DATE NOT NULL, season INT NOT NULL, PRIMARY KEY (accountId, statId, date, season), INDEX valueIndex(value), FOREIGN KEY (accountId) REFERENCES Account.accounts(id), FOREIGN KEY (statId) REFERENCES Account.stats(id));"; - private static final String INSERT_STAT = "INSERT INTO accountStatsSeasonal (accountId, statId, value, date, season) VALUES (?, (SELECT id FROM stats WHERE name=?), ?, CURDATE(), " + SEASON + ") ON DUPLICATE KEY UPDATE value=value+VALUES(value);"; + private static final String INSERT_STAT = "INSERT INTO accountStatsSeasonal (accountId, statId, value, date, season) VALUES (?, (SELECT id FROM stats WHERE name=?), ?, CURDATE(), " + SEASON + ");"; + private static final String UPDATE_STAT = "UPDATE accountStatsSeasonal SET value=value + ? WHERE accountId=? AND statId=? AND date=CURDATE() AND season=" + SEASON + ";"; - private static final String FETCH_STAT_ALL = "SELECT a.name, sl.value FROM accountStatsAllTime AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE sl.statId=(SELECT id FROM stats WHERE name=%STAT%) ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; + private static final String FETCH_STAT_ALL = "SELECT a.name, sl.value FROM accountStatsAllTime AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE sl.statId=%STAT% ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; - private static final String FETCH_STAT_ALL_SEASON = "SELECT a.name, sl.value FROM accountStatsSeasonal AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE sl.statId=(SELECT id FROM stats WHERE name=%STAT%) AND season=" + SEASON + " ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; - private static final String FETCH_STAT_YEARLY_SEASON = "SELECT a.name, sl.value FROM accountStatsSeasonal AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE YEAR(sl.date) = YEAR(CURDATE()) AND sl.statId=(SELECT id FROM stats WHERE name=%STAT%) AND season=" + SEASON + " ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; - private static final String FETCH_STAT_MONTHLY_SEASON = "SELECT a.name, sl.value FROM accountStatsSeasonal AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE MONTH(sl.date) = MONTH(CURDATE()) AND YEAR(`date`) = YEAR(CURDATE()) AND sl.statId=(SELECT id FROM stats WHERE name=%STAT%) AND season=" + SEASON + " ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; - private static final String FETCH_STAT_WEEKLY_SEASON = "SELECT a.name, sl.value FROM accountStatsSeasonal AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE YEARWEEK(sl.date, 1) = YEARWEEK(CURDATE(), 1) AND sl.statId=(SELECT id FROM stats WHERE name=%STAT%) AND season=" + SEASON + " ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; - private static final String FETCH_STAT_DAILY_SEASON = "SELECT a.name, sl.value FROM accountStatsSeasonal AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE sl.date = CURDATE() AND sl.statId=(SELECT id FROM stats WHERE name=%STAT%) AND season=" + SEASON + " ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; + private static final String FETCH_STAT_ALL_SEASON = "SELECT a.name, sl.value FROM accountStatsSeasonal AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE sl.statId=%STAT% AND season=" + SEASON + " ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; + private static final String FETCH_STAT_YEARLY_SEASON = "SELECT a.name, sl.value FROM accountStatsSeasonal AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE YEAR(sl.date) = YEAR(CURDATE()) AND sl.statId=%STAT% AND season=" + SEASON + " ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; + private static final String FETCH_STAT_MONTHLY_SEASON = "SELECT a.name, sl.value FROM accountStatsSeasonal AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE MONTH(sl.date) = MONTH(CURDATE()) AND YEAR(`date`) = YEAR(CURDATE()) AND sl.statId=%STAT% AND season=" + SEASON + " ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; + private static final String FETCH_STAT_WEEKLY_SEASON = "SELECT a.name, sl.value FROM accountStatsSeasonal AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE YEARWEEK(sl.date, 1) = YEARWEEK(CURDATE(), 1) AND sl.statId=%STAT% AND season=" + SEASON + " ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; + private static final String FETCH_STAT_DAILY_SEASON = "SELECT a.name, sl.value FROM accountStatsSeasonal AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE sl.date = CURDATE() AND sl.statId=%STAT% AND season=" + SEASON + " ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; public LeaderboardRepository(JavaPlugin plugin) { super(DBPool.getAccount()); } - public void insertStat(int accountId, String statId, int value) + public void insertStat(int accountId, int statId, int value) { UtilServer.runAsync(() -> { - executeInsert(INSERT_STAT, null, new ColumnInt("accountId", accountId), new ColumnVarChar("name", 100, statId), new ColumnInt("value", value)); + int rowsAffected = executeUpdate(UPDATE_STAT, (Runnable)null, new ColumnInt("value", value), new ColumnInt("accountId", accountId), new ColumnInt("statId", statId)); + if (rowsAffected == 0) + { + executeInsert(INSERT_STAT, null, new ColumnInt("accountId", accountId), new ColumnInt("statId", statId), new ColumnInt("value", value)); + } }); } @@ -51,9 +55,9 @@ public class LeaderboardRepository extends RepositoryBase { UtilServer.runAsync(() -> { + Map names = new LinkedHashMap<>(); try (Connection c = getConnection()) { - Map names = new LinkedHashMap<>(); Statement s = c.createStatement(); s.execute(board.getType().getStatement(board.getStatIds(), board.getStart(), board.getSize())); for (int i = 0; i < board.getStatIds().length; i++) @@ -66,16 +70,18 @@ public class LeaderboardRepository extends RepositoryBase if (!s.getMoreResults()) { - break ; + break; } } - - UtilServer.runSync(() -> leaderboard.accept(names)); } catch (SQLException ex) { ex.printStackTrace(); } + finally + { + UtilServer.runSync(() -> leaderboard.accept(names)); + } }); } @@ -84,21 +90,21 @@ public class LeaderboardRepository extends RepositoryBase { UtilServer.runAsync(() -> { - try (Connection c = getConnection()) + Map[] leaderboards = new Map[boards.size()]; + StringBuilder queryBuilder = new StringBuilder(); { - Map[] leaderboards = new Map[boards.size()]; - StringBuilder queryBuilder = new StringBuilder(); + int i = 0; + for (Leaderboard board : boards) { - int i = 0; - for (Leaderboard board : boards) - { - queryBuilder.append(board.getType().getStatement(board.getStatIds(), board.getStart(), board.getSize())); - leaderboards[i] = new LinkedHashMap<>(); - i++; - } + queryBuilder.append(board.getType().getStatement(board.getStatIds(), board.getStart(), board.getSize())); + leaderboards[i] = new LinkedHashMap<>(); + i++; } - - if (queryBuilder.length() > 0) + } + + if (queryBuilder.length() > 0) + { + try (Connection c = getConnection()) { Statement s = c.createStatement(); s.execute(queryBuilder.toString()); @@ -112,7 +118,7 @@ public class LeaderboardRepository extends RepositoryBase { leaderboards[index].merge(rs.getString("name"), rs.getInt("value"), Integer::sum); } - + if (!s.getMoreResults()) { break mainBoardLoop; @@ -121,12 +127,18 @@ public class LeaderboardRepository extends RepositoryBase index++; } } - - UtilServer.runSync(() -> leaderboard.accept(leaderboards)); + catch (SQLException ex) + { + ex.printStackTrace(); + } + finally + { + UtilServer.runSync(() -> leaderboard.accept(leaderboards)); + } } - catch (SQLException ex) + else { - ex.printStackTrace(); + UtilServer.runSync(() -> leaderboard.accept(leaderboards)); } }); } @@ -148,12 +160,12 @@ public class LeaderboardRepository extends RepositoryBase _sql = sql; } - public String getStatement(String[] statIds, int start, int limit) throws SQLException + public String getStatement(int[] statIds, int start, int limit) { StringBuilder statementBuilder = new StringBuilder(); - for (String id : statIds) + for (int id : statIds) { - statementBuilder.append(_sql.replace("%STAT%", id).replace("%START%", String.valueOf(start)).replace("%LIMIT%", String.valueOf(limit))); + statementBuilder.append(_sql.replace("%STAT%", String.valueOf(id)).replace("%START%", String.valueOf(start)).replace("%LIMIT%", String.valueOf(limit))); } return statementBuilder.toString(); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java b/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java index 29804bc5b..6871997c6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java @@ -88,6 +88,16 @@ public class StatsManager extends MiniDbClientPlugin return stats; }); } + + public void loadStatId(String statName, Consumer idConsumer) + { + registerNewStat(statName, () -> + { + final int statId = _stats.get(statName); + + runSync(() -> idConsumer.accept(Integer.valueOf(statId))); + }); + } /** diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameStatManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameStatManager.java index ce18f5910..8b727b704 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameStatManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameStatManager.java @@ -81,7 +81,7 @@ public class GameStatManager implements Listener if (stat.startsWith("Global.")) continue; - Managers.get(LeaderboardManager.class).handleStatIncrease(player, stat, value); + Manager.runSyncLater(() -> Managers.get(LeaderboardManager.class).handleStatIncrease(player, stat, value), 40L); } } } From 3dbed769c9aacd39ac157164c1a09012e86208ad Mon Sep 17 00:00:00 2001 From: LCastr0 Date: Wed, 10 May 2017 17:27:17 -0300 Subject: [PATCH 74/99] Fix for win rooms --- .../rankrooms/rankwineffects/WinEffectRankEternal.java | 6 +++++- .../rankrooms/rankwineffects/WinEffectRankHero.java | 8 ++++++-- .../rankrooms/rankwineffects/WinEffectRankLegend.java | 6 +++++- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankEternal.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankEternal.java index 06343fd6d..feb570f92 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankEternal.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankEternal.java @@ -84,6 +84,10 @@ public class WinEffectRankEternal extends WinEffectRankBased _guardian = npcLocation.getWorld().spawn(npcLocation.add(0, 20, 0), Guardian.class); Manager.getPetManager().getCreatureModule().SetForce(false); } + else if (_step < 5) + { + return; + } double increment = (2 * Math.PI) / POINTS; @@ -98,7 +102,7 @@ public class WinEffectRankEternal extends WinEffectRankBased if (_step % 2 == 0) zap(); - if (_step == 25) + if (_step == 45) { breakBlocks(); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankHero.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankHero.java index 1a30a2996..e65730e7b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankHero.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankHero.java @@ -74,7 +74,7 @@ public class WinEffectRankHero extends WinEffectRankBased if (_step > 60) return; - if (_step == 30) + if (_step == 55) { breakBlocks(); } @@ -93,6 +93,10 @@ public class WinEffectRankHero extends WinEffectRankBased Manager.getPetManager().getCreatureModule().SetForce(false); _step = 0; } + else if (_step < 5) + { + return; + } double increment = (2 * Math.PI) / POINTS; @@ -104,7 +108,7 @@ public class WinEffectRankHero extends WinEffectRankBased Location enderLocation = _enderDragon.getLocation().setDirection(direction); _enderDragon.teleport(enderLocation); - if (_step >= 50) + if (_step >= 55) setTarget(); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankLegend.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankLegend.java index 382751252..818e5fc49 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankLegend.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankLegend.java @@ -84,6 +84,10 @@ public class WinEffectRankLegend extends WinEffectRankBased _wither = npcLocation.getWorld().spawn(npcLocation.add(0, 20, 0), Wither.class); Manager.getPetManager().getCreatureModule().SetForce(false); } + else if (_step < 5) + { + return; + } double increment = (2 * Math.PI) / POINTS; @@ -98,7 +102,7 @@ public class WinEffectRankLegend extends WinEffectRankBased if (_step % 5 == 0) spawnSkull(); - if (_step == 40) + if (_step == 45) breakBlocks(); } From 5fe5c613e5303e9e47e536f156cc10a5d4118c53 Mon Sep 17 00:00:00 2001 From: LCastr0 Date: Wed, 10 May 2017 19:25:14 -0300 Subject: [PATCH 75/99] Fixed win rooms again --- .../rankwineffects/WinEffectRankEternal.java | 9 ++---- .../rankwineffects/WinEffectRankHero.java | 30 +++++++++---------- .../rankwineffects/WinEffectRankLegend.java | 8 ++--- 3 files changed, 18 insertions(+), 29 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankEternal.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankEternal.java index feb570f92..aa5a9a1dd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankEternal.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankEternal.java @@ -78,19 +78,14 @@ public class WinEffectRankEternal extends WinEffectRankBased _step++; - if (_guardian == null && _step >= 5) + if (_guardian == null) { Manager.getPetManager().getCreatureModule().SetForce(true); _guardian = npcLocation.getWorld().spawn(npcLocation.add(0, 20, 0), Guardian.class); Manager.getPetManager().getCreatureModule().SetForce(false); } - else if (_step < 5) - { - return; - } double increment = (2 * Math.PI) / POINTS; - double angle = _step * increment; Vector vector = new Vector(Math.cos(angle) * RADIUS, 0, Math.sin(angle) * RADIUS); _guardian.setVelocity(new Vector(0,0,0)); @@ -99,7 +94,7 @@ public class WinEffectRankEternal extends WinEffectRankBased Location enderLocation = _guardian.getLocation().setDirection(direction); _guardian.teleport(enderLocation); - if (_step % 2 == 0) + if (_step % 2 == 0 && _step < 45) zap(); if (_step == 45) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankHero.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankHero.java index e65730e7b..06ffa9890 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankHero.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankHero.java @@ -71,10 +71,10 @@ public class WinEffectRankHero extends WinEffectRankBased if (!isRunning()) return; - if (_step > 60) + if (_step > 65) return; - if (_step == 55) + if (_step == 65) { breakBlocks(); } @@ -86,29 +86,27 @@ public class WinEffectRankHero extends WinEffectRankBased _step++; - if (_enderDragon == null && _step >= 5) + if (_enderDragon == null) { Manager.getPetManager().getCreatureModule().SetForce(true); _enderDragon = npcLocation.getWorld().spawn(npcLocation.add(0, 20, 0), EnderDragon.class); Manager.getPetManager().getCreatureModule().SetForce(false); _step = 0; } - else if (_step < 5) + + if (_step < 50) { - return; + double increment = (2 * Math.PI) / POINTS; + double angle = _step * increment; + Vector vector = new Vector(Math.cos(angle) * RADIUS, 0, Math.sin(angle) * RADIUS); + _enderDragon.setVelocity(new Vector(0, 0, 0)); + _enderDragon.teleport(_player.getLocation().clone().subtract(vector)); + Vector direction = npcLocation.toVector().subtract(_enderDragon.getEyeLocation().toVector()).multiply(-1); + Location enderLocation = _enderDragon.getLocation().setDirection(direction); + _enderDragon.teleport(enderLocation); } - double increment = (2 * Math.PI) / POINTS; - - double angle = _step * increment; - Vector vector = new Vector(Math.cos(angle) * RADIUS, 0, Math.sin(angle) * RADIUS); - _enderDragon.setVelocity(new Vector(0,0,0)); - _enderDragon.teleport(_player.getLocation().clone().subtract(vector)); - Vector direction = npcLocation.toVector().subtract(_enderDragon.getEyeLocation().toVector()).multiply(-1); - Location enderLocation = _enderDragon.getLocation().setDirection(direction); - _enderDragon.teleport(enderLocation); - - if (_step >= 55) + if (_step >= 50) setTarget(); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankLegend.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankLegend.java index 818e5fc49..85b69d905 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankLegend.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankLegend.java @@ -78,16 +78,12 @@ public class WinEffectRankLegend extends WinEffectRankBased _step++; - if (_wither == null && _step >= 5) + if (_wither == null) { Manager.getPetManager().getCreatureModule().SetForce(true); _wither = npcLocation.getWorld().spawn(npcLocation.add(0, 20, 0), Wither.class); Manager.getPetManager().getCreatureModule().SetForce(false); } - else if (_step < 5) - { - return; - } double increment = (2 * Math.PI) / POINTS; @@ -99,7 +95,7 @@ public class WinEffectRankLegend extends WinEffectRankBased Location enderLocation = _wither.getLocation().setDirection(direction); _wither.teleport(enderLocation); - if (_step % 5 == 0) + if (_step % 5 == 0 && _step < 45) spawnSkull(); if (_step == 45) From ac0339fc596d678e32e47323d8d6c5ece7bf4e3e Mon Sep 17 00:00:00 2001 From: LCastr0 Date: Wed, 10 May 2017 21:20:23 -0300 Subject: [PATCH 76/99] Fixed sync with dragon and fixed guardian not showing --- .../rankwineffects/WinEffectRankEternal.java | 40 +++++++++++++++---- .../rankwineffects/WinEffectRankHero.java | 6 +-- .../rankwineffects/WinEffectRankLegend.java | 2 +- 3 files changed, 36 insertions(+), 12 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankEternal.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankEternal.java index aa5a9a1dd..03ddfa4d5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankEternal.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankEternal.java @@ -65,6 +65,32 @@ public class WinEffectRankEternal extends WinEffectRankBased _step = 0; } + @EventHandler + public void spawnGuardian(UpdateEvent event) + { + if (event.getType() != UpdateType.TICK) + return; + + if (_guardian != null) + { + return; + } + + if (!isRunning()) + return; + + _step++; + + if (_step == 5) + { + Location npcLocation = _npc.getEntity().getBukkitEntity().getLocation(); + Manager.getPetManager().getCreatureModule().SetForce(true); + _guardian = npcLocation.getWorld().spawn(npcLocation, Guardian.class); + Manager.getPetManager().getCreatureModule().SetForce(false); + _step = 0; + } + } + @EventHandler public void onUpdate(UpdateEvent event) { @@ -74,22 +100,20 @@ public class WinEffectRankEternal extends WinEffectRankBased if (event.getType() != UpdateType.FASTEST) return; + if (_guardian == null) + { + return; + } + Location npcLocation = _npc.getEntity().getBukkitEntity().getLocation(); _step++; - if (_guardian == null) - { - Manager.getPetManager().getCreatureModule().SetForce(true); - _guardian = npcLocation.getWorld().spawn(npcLocation.add(0, 20, 0), Guardian.class); - Manager.getPetManager().getCreatureModule().SetForce(false); - } - double increment = (2 * Math.PI) / POINTS; double angle = _step * increment; Vector vector = new Vector(Math.cos(angle) * RADIUS, 0, Math.sin(angle) * RADIUS); _guardian.setVelocity(new Vector(0,0,0)); - _guardian.teleport(_player.getLocation().clone().subtract(vector)); + _guardian.teleport(npcLocation.clone().subtract(vector)); Vector direction = npcLocation.toVector().subtract(_guardian.getEyeLocation().toVector()); Location enderLocation = _guardian.getLocation().setDirection(direction); _guardian.teleport(enderLocation); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankHero.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankHero.java index 06ffa9890..f71cf48b6 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankHero.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankHero.java @@ -71,10 +71,10 @@ public class WinEffectRankHero extends WinEffectRankBased if (!isRunning()) return; - if (_step > 65) + if (_step > 62) return; - if (_step == 65) + if (_step == 62) { breakBlocks(); } @@ -100,7 +100,7 @@ public class WinEffectRankHero extends WinEffectRankBased double angle = _step * increment; Vector vector = new Vector(Math.cos(angle) * RADIUS, 0, Math.sin(angle) * RADIUS); _enderDragon.setVelocity(new Vector(0, 0, 0)); - _enderDragon.teleport(_player.getLocation().clone().subtract(vector)); + _enderDragon.teleport(npcLocation.clone().subtract(vector)); Vector direction = npcLocation.toVector().subtract(_enderDragon.getEyeLocation().toVector()).multiply(-1); Location enderLocation = _enderDragon.getLocation().setDirection(direction); _enderDragon.teleport(enderLocation); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankLegend.java b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankLegend.java index 85b69d905..ab96a352c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankLegend.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/gadget/gadgets/wineffect/rankrooms/rankwineffects/WinEffectRankLegend.java @@ -90,7 +90,7 @@ public class WinEffectRankLegend extends WinEffectRankBased double angle = _step * increment; Vector vector = new Vector(Math.cos(angle) * RADIUS, 0, Math.sin(angle) * RADIUS); _wither.setVelocity(new Vector(0,0,0)); - _wither.teleport(_player.getLocation().clone().subtract(vector)); + _wither.teleport(npcLocation.clone().subtract(vector)); Vector direction = npcLocation.toVector().subtract(_wither.getEyeLocation().toVector()); Location enderLocation = _wither.getLocation().setDirection(direction); _wither.teleport(enderLocation); From 0f98637024c08685941a1deca96456badf2ce647 Mon Sep 17 00:00:00 2001 From: cnr Date: Wed, 10 May 2017 19:54:28 -0700 Subject: [PATCH 77/99] Disallow players from switching between Gem Hunters via party --- .../src/mineplex/core/party/manager/PartyJoinManager.java | 2 +- .../src/mineplex/gemhunters/persistence/PersistenceModule.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyJoinManager.java b/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyJoinManager.java index 1dcd4c746..85f33fabc 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyJoinManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/party/manager/PartyJoinManager.java @@ -236,7 +236,7 @@ public class PartyJoinManager implements Listener requestServerJoin(best.getName(), party); } - @EventHandler + @EventHandler(ignoreCancelled = true) public void onTransfer(ServerTransferEvent event) { Player player = event.getPlayer(); diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/persistence/PersistenceModule.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/persistence/PersistenceModule.java index 9337a7284..dcf2afde9 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/persistence/PersistenceModule.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/persistence/PersistenceModule.java @@ -135,7 +135,7 @@ public class PersistenceModule extends MiniPlugin } } - @EventHandler + @EventHandler(priority = EventPriority.LOWEST) public void serverTransfer(ServerTransferEvent event) { if (event.getServer().startsWith("GH-")) From 5d1199634d393e9e81c6269ab7bea550b7175195 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 11 May 2017 14:48:35 -0400 Subject: [PATCH 78/99] Rewrite leaderboard backend (again) --- .../core/hologram/HologramManager.java | 28 +-- .../core/leaderboard/LeaderboardManager.java | 28 +-- .../leaderboard/LeaderboardRepository.java | 182 +++++++++++++----- .../src/mineplex/core/stats/StatsManager.java | 21 +- .../src/nautilus/game/arcade/Arcade.java | 3 - .../src/nautilus/game/arcade/game/Game.java | 2 - .../games/castleassault/CastleAssault.java | 5 +- .../games/castleassault/CastleAssaultTDM.java | 59 +++--- .../game/arcade/managers/GameStatManager.java | 10 - 9 files changed, 209 insertions(+), 129 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/hologram/HologramManager.java b/Plugins/Mineplex.Core/src/mineplex/core/hologram/HologramManager.java index 618c30f44..a68ce5944 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/hologram/HologramManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/hologram/HologramManager.java @@ -4,6 +4,17 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import org.bukkit.Bukkit; +import org.bukkit.World; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.util.Vector; + +import mineplex.core.MiniPlugin; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTime; import mineplex.core.packethandler.IPacketHandler; @@ -14,24 +25,13 @@ import mineplex.core.updater.event.UpdateEvent; import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity; import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity.EnumEntityUseAction; -import org.bukkit.Bukkit; -import org.bukkit.World; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.inventory.ClickType; -import org.bukkit.plugin.java.JavaPlugin; -import org.bukkit.util.Vector; - -public class HologramManager implements Listener, IPacketHandler +public class HologramManager extends MiniPlugin implements IPacketHandler { private ArrayList _activeHolograms = new ArrayList(); - public HologramManager(JavaPlugin arcadeManager, PacketHandler packetHandler) + public HologramManager(JavaPlugin plugin, PacketHandler packetHandler) { - Bukkit.getPluginManager().registerEvents(this, arcadeManager); + super("Hologram Manager", plugin); packetHandler.addPacketHandler(this, true, PacketPlayInUseEntity.class); } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardManager.java b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardManager.java index 5300b48b0..88a84c29d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardManager.java @@ -12,13 +12,11 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.Managers; import mineplex.core.MiniPlugin; -import mineplex.core.account.CoreClientManager; import mineplex.core.command.CommandBase; import mineplex.core.common.Rank; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilMath; import mineplex.core.hologram.HologramManager; -import mineplex.core.leaderboard.LeaderboardRepository.LeaderboardSQLType; import mineplex.core.stats.StatsManager; public class LeaderboardManager extends MiniPlugin @@ -26,15 +24,13 @@ public class LeaderboardManager extends MiniPlugin private final Map _leaderboards = new HashMap<>(); private final long REFRESH_RATE; private final LeaderboardRepository _repo; - private final HologramManager _holo; private final Map _loading = new HashMap<>(); - public LeaderboardManager(JavaPlugin plugin, HologramManager hologram) + public LeaderboardManager(JavaPlugin plugin) { super("Leaderboard Manager", plugin); _repo = new LeaderboardRepository(plugin); - _holo = hologram; addCommand(new CommandBase(this, Rank.DEVELOPER, "cycleleaderboard") { @@ -88,7 +84,7 @@ public class LeaderboardManager extends MiniPlugin public HologramManager getHologramManager() { - return _holo; + return Managers.get(HologramManager.class); } public Leaderboard getLeaderboard(String identifier) @@ -96,16 +92,14 @@ public class LeaderboardManager extends MiniPlugin return _leaderboards.get(identifier); } - public void handleStatIncrease(Player player, String stat, int value) + public void handleStatIncrease(Map> stats) { - final int accountId = Managers.get(CoreClientManager.class).getAccountId(player); - Managers.get(StatsManager.class).loadStatId(stat, id -> - { - if (accountId != -1) - { - _repo.insertStat(accountId, id, value); - } - }); + _repo.insertStats(stats); + } + + public void handleStatIncrease(int accountId, Map stats) + { + _repo.insertStats(accountId, stats); } public void registerLeaderboard(String identifier, Leaderboard board) @@ -118,10 +112,6 @@ public class LeaderboardManager extends MiniPlugin final Runnable postLoad = () -> { _leaderboards.put(identifier, board); - if (board.getType() == LeaderboardSQLType.MONTHLY_SEASON || board.getType() == LeaderboardSQLType.YEARLY_SEASON) - { - log("Warning! You have selected a LeaderboardSQLType identified to be potentially expensive and intensive on Leaderboard ID: " + identifier); - } _repo.loadLeaderboard(board, board::update); }; _loading.put(board, postLoad); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardRepository.java index 2f6291043..978ba3c1c 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardRepository.java @@ -1,6 +1,7 @@ package mineplex.core.leaderboard; import java.sql.Connection; +import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; @@ -14,75 +15,170 @@ import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.common.util.UtilServer; import mineplex.serverdata.database.DBPool; import mineplex.serverdata.database.RepositoryBase; -import mineplex.serverdata.database.column.ColumnInt; public class LeaderboardRepository extends RepositoryBase { private static final int SEASON = 1; - private static final String CREATE_ALL_TIME = "CREATE TABLE accountStatsAllTime (accountId INT NOT NULL, statId INT NOT NULL, value INT NOT NULL, PRIMARY KEY (accountId, statId), INDEX valueIndex(value), FOREIGN KEY (accountId) REFERENCES Account.accounts(id), FOREIGN KEY (statId) REFERENCES Account.stats(id));"; - private static final String CREATE_SEASONAL = "CREATE TABLE accountStatsSeasonal (accountId INT NOT NULL, statId INT NOT NULL, value INT NOT NULL, date DATE NOT NULL, season INT NOT NULL, PRIMARY KEY (accountId, statId, date, season), INDEX valueIndex(value), FOREIGN KEY (accountId) REFERENCES Account.accounts(id), FOREIGN KEY (statId) REFERENCES Account.stats(id));"; + private static final String CREATE_TOTAL = "CREATE TABLE accountSeasonStatsTotal (accountId INT NOT NULL, statId INT NOT NULL, season SMALLINT NOT NULL, value BIGINT NOT NULL, PRIMARY KEY (accountId, statId, season), INDEX valueIndex (value DESC), FOREIGN KEY (accountId) REFERENCES accounts(id), FOREIGN KEY (statId) REFERENCES stats(id));"; + private static final String CREATE_YEARLY = "CREATE TABLE accountSeasonStatsYearly (accountId INT NOT NULL, statId INT NOT NULL, date DATE NOT NULL, value BIGINT NOT NULL, PRIMARY KEY (accountId, statId), INDEX valueIndex (value DESC), FOREIGN KEY (accountId) REFERENCES accounts(id), FOREIGN KEY (statId) REFERENCES stats(id));"; + private static final String CREATE_MONTHLY = "CREATE TABLE accountSeasonStatsMonthly (accountId INT NOT NULL, statId INT NOT NULL, date DATE NOT NULL, value BIGINT NOT NULL, PRIMARY KEY (accountId, statId), INDEX valueIndex (value DESC), FOREIGN KEY (accountId) REFERENCES accounts(id), FOREIGN KEY (statId) REFERENCES stats(id));"; + private static final String CREATE_WEEKLY = "CREATE TABLE accountSeasonStatsWeekly (accountId INT NOT NULL, statId INT NOT NULL, date DATE NOT NULL, value BIGINT NOT NULL, PRIMARY KEY (accountId, statId), INDEX valueIndex (value DESC), FOREIGN KEY (accountId) REFERENCES accounts(id), FOREIGN KEY (statId) REFERENCES stats(id));"; + private static final String CREATE_DAILY = "CREATE TABLE accountSeasonStatsDaily (accountId INT NOT NULL, statId INT NOT NULL, date DATE NOT NULL, value BIGINT NOT NULL, PRIMARY KEY (accountId, statId), INDEX valueIndex (value DESC), FOREIGN KEY (accountId) REFERENCES accounts(id), FOREIGN KEY (statId) REFERENCES stats(id));"; - private static final String INSERT_STAT = "INSERT INTO accountStatsSeasonal (accountId, statId, value, date, season) VALUES (?, (SELECT id FROM stats WHERE name=?), ?, CURDATE(), " + SEASON + ");"; - private static final String UPDATE_STAT = "UPDATE accountStatsSeasonal SET value=value + ? WHERE accountId=? AND statId=? AND date=CURDATE() AND season=" + SEASON + ";"; + private static final String INSERT_STAT = "INSERT INTO accountSeasonStatsTotal (accountId, statId, season, value) VALUES (?, ?, " + SEASON + ", ?);"; + private static final String INSERT_STAT_ALL = "INSERT INTO accountSeasonStatsTotal (accountId, statId, season, value) VALUES (?, ?, 0, ?);"; + private static final String UPDATE_STAT = "UPDATE accountSeasonStatsTotal SET value=value + ? WHERE accountId=? AND statId=? AND season=" + SEASON + ";"; + private static final String UPDATE_STAT_ALL = "UPDATE accountSeasonStatsTotal SET value=value + ? WHERE accountId=? AND statId=? AND season=0;"; - private static final String FETCH_STAT_ALL = "SELECT a.name, sl.value FROM accountStatsAllTime AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE sl.statId=%STAT% ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; + private static final String FETCH_STAT_ALL = "SELECT a.name, sl.value FROM accountSeasonStatsTotal AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE sl.statId=%STAT% AND season=0 ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; + + private static final String FETCH_STAT_YEARLY = "SELECT a.name, sl.value FROM accountStatsSeasonal AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE YEAR(sl.date) = YEAR(CURDATE()) AND sl.statId=%STAT% ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; + private static final String FETCH_STAT_MONTHLY = "SELECT a.name, sl.value FROM accountStatsSeasonal AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE MONTH(sl.date) = MONTH(CURDATE()) AND YEAR(sl.date) = YEAR(CURDATE()) AND sl.statId=%STAT% ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; + private static final String FETCH_STAT_WEEKLY = "SELECT a.name, sl.value FROM accountStatsSeasonal AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE YEARWEEK(sl.date, 1) = YEARWEEK(CURDATE(), 1) AND sl.statId=%STAT% ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; + private static final String FETCH_STAT_DAILY = "SELECT a.name, sl.value FROM accountStatsSeasonal AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE sl.date = CURDATE() AND sl.statId=%STAT% ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; private static final String FETCH_STAT_ALL_SEASON = "SELECT a.name, sl.value FROM accountStatsSeasonal AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE sl.statId=%STAT% AND season=" + SEASON + " ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; - private static final String FETCH_STAT_YEARLY_SEASON = "SELECT a.name, sl.value FROM accountStatsSeasonal AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE YEAR(sl.date) = YEAR(CURDATE()) AND sl.statId=%STAT% AND season=" + SEASON + " ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; - private static final String FETCH_STAT_MONTHLY_SEASON = "SELECT a.name, sl.value FROM accountStatsSeasonal AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE MONTH(sl.date) = MONTH(CURDATE()) AND YEAR(`date`) = YEAR(CURDATE()) AND sl.statId=%STAT% AND season=" + SEASON + " ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; - private static final String FETCH_STAT_WEEKLY_SEASON = "SELECT a.name, sl.value FROM accountStatsSeasonal AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE YEARWEEK(sl.date, 1) = YEARWEEK(CURDATE(), 1) AND sl.statId=%STAT% AND season=" + SEASON + " ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; - private static final String FETCH_STAT_DAILY_SEASON = "SELECT a.name, sl.value FROM accountStatsSeasonal AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE sl.date = CURDATE() AND sl.statId=%STAT% AND season=" + SEASON + " ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; public LeaderboardRepository(JavaPlugin plugin) { super(DBPool.getAccount()); } - public void insertStat(int accountId, int statId, int value) + public void insertStats(Map> stats) { UtilServer.runAsync(() -> { - int rowsAffected = executeUpdate(UPDATE_STAT, (Runnable)null, new ColumnInt("value", value), new ColumnInt("accountId", accountId), new ColumnInt("statId", statId)); - if (rowsAffected == 0) + try (Connection c = getConnection()) { - executeInsert(INSERT_STAT, null, new ColumnInt("accountId", accountId), new ColumnInt("statId", statId), new ColumnInt("value", value)); + final boolean auto = c.getAutoCommit(); + + c.setAutoCommit(true); + PreparedStatement s = c.prepareStatement(UPDATE_STAT); + PreparedStatement u = c.prepareStatement(UPDATE_STAT_ALL); + for (Integer accountId : stats.keySet()) + { + for (Integer statId : stats.get(accountId).keySet()) + { + s.setLong(1, stats.get(accountId).get(statId)); + s.setInt(2, accountId); + s.setInt(3, statId); + s.addBatch(); + u.setLong(1, stats.get(accountId).get(statId)); + u.setInt(2, accountId); + u.setInt(3, statId); + u.addBatch(); + } + } + int[] rowsAffected1 = s.executeBatch(); + int[] rowsAffected2 = u.executeBatch(); + c.setAutoCommit(false); + s = c.prepareStatement(INSERT_STAT); + u = c.prepareStatement(INSERT_STAT_ALL); + int i = 0; + for (Integer accountId : stats.keySet()) + { + for (Integer statId : stats.get(accountId).keySet()) + { + if (rowsAffected1[i] < 1) + { + s.setInt(1, accountId); + s.setInt(2, statId); + s.setLong(3, stats.get(accountId).get(statId)); + s.addBatch(); + } + if (rowsAffected2[i] < 1) + { + u.setInt(1, accountId); + u.setInt(2, statId); + u.setLong(3, stats.get(accountId).get(statId)); + u.addBatch(); + } + i++; + } + } + s.executeBatch(); + u.executeBatch(); + + c.setAutoCommit(auto); + } + catch (SQLException e) + { + e.printStackTrace(); } }); } + public void insertStats(int accountId, Map stats) + { + try (Connection c = getConnection()) + { + final boolean auto = c.getAutoCommit(); + + c.setAutoCommit(true); + PreparedStatement s = c.prepareStatement(UPDATE_STAT); + for (Integer statId : stats.keySet()) + { + s.setLong(1, stats.get(statId)); + s.setInt(2, accountId); + s.setInt(3, statId); + s.addBatch(); + } + int[] rowsAffected = s.executeBatch(); + c.setAutoCommit(false); + s = c.prepareStatement(INSERT_STAT); + int i = 0; + for (Integer statId : stats.keySet()) + { + if (rowsAffected[i] < 1) + { + s.setInt(1, accountId); + s.setInt(2, statId); + s.setLong(3, stats.get(statId)); + s.addBatch(); + } + i++; + } + s.executeBatch(); + + c.setAutoCommit(auto); + + } + catch (SQLException e) + { + e.printStackTrace(); + } + } + public void loadLeaderboard(Leaderboard board, Consumer> leaderboard) { - UtilServer.runAsync(() -> + Map names = new LinkedHashMap<>(); + try (Connection c = getConnection()) { - Map names = new LinkedHashMap<>(); - try (Connection c = getConnection()) + Statement s = c.createStatement(); + s.execute(board.getType().getStatement(board.getStatIds(), board.getStart(), board.getSize())); + for (int i = 0; i < board.getStatIds().length; i++) { - Statement s = c.createStatement(); - s.execute(board.getType().getStatement(board.getStatIds(), board.getStart(), board.getSize())); - for (int i = 0; i < board.getStatIds().length; i++) + ResultSet rs = s.getResultSet(); + while (rs.next()) { - ResultSet rs = s.getResultSet(); - while (rs.next()) - { - names.merge(rs.getString("name"), rs.getInt("value"), Integer::sum); - } - - if (!s.getMoreResults()) - { - break; - } + names.merge(rs.getString("name"), rs.getInt("value"), Integer::sum); + } + + if (!s.getMoreResults()) + { + break; } } - catch (SQLException ex) - { - ex.printStackTrace(); - } - finally - { - UtilServer.runSync(() -> leaderboard.accept(names)); - } - }); + } + catch (SQLException ex) + { + ex.printStackTrace(); + } + finally + { + UtilServer.runSync(() -> leaderboard.accept(names)); + } } @SuppressWarnings("unchecked") @@ -145,10 +241,10 @@ public class LeaderboardRepository extends RepositoryBase public static enum LeaderboardSQLType { - DAILY_SEASON(FETCH_STAT_DAILY_SEASON), - WEEKLY_SEASON(FETCH_STAT_WEEKLY_SEASON), - MONTHLY_SEASON(FETCH_STAT_MONTHLY_SEASON), - YEARLY_SEASON(FETCH_STAT_YEARLY_SEASON), + DAILY(FETCH_STAT_DAILY), + WEEKLY(FETCH_STAT_WEEKLY), + MONTHLY(FETCH_STAT_MONTHLY), + YEARLY(FETCH_STAT_YEARLY), ALL(FETCH_STAT_ALL), ALL_SEASON(FETCH_STAT_ALL_SEASON) ; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java b/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java index 6871997c6..c4290ff84 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/stats/StatsManager.java @@ -21,6 +21,7 @@ import mineplex.core.account.CoreClient; import mineplex.core.account.CoreClientManager; import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilTasks; +import mineplex.core.leaderboard.LeaderboardManager; import mineplex.core.stats.command.GiveStatCommand; import mineplex.core.stats.command.MasterBuilderUnban; import mineplex.core.stats.command.SetLevelCommand; @@ -39,6 +40,7 @@ public class StatsManager extends MiniDbClientPlugin private final CoreClientManager _coreClientManager; private final StatsRepository _repository; + private final LeaderboardManager _leaderboard; private final Map _stats = new HashMap<>(); private final Map> _statUploadQueue = new HashMap<>(); @@ -50,11 +52,21 @@ public class StatsManager extends MiniDbClientPlugin _repository = new StatsRepository(); _coreClientManager = clientManager; + + _leaderboard = new LeaderboardManager(plugin); UtilScheduler.runAsyncEvery(UpdateType.SEC, () -> { - save(_statUploadQueue, _repository::saveStats, "increment"); - save(_statUploadQueueOverRidable, map -> _repository.saveStats(map, true), "override"); + save(_statUploadQueue, map -> + { + _repository.saveStats(map); + _leaderboard.handleStatIncrease(map); + }, "increment"); + save(_statUploadQueueOverRidable, map -> + { + _repository.saveStats(map, true); + _leaderboard.handleStatIncrease(map); + }, "override"); }); for (Stat stat : _repository.retrieveStats()) @@ -125,6 +137,7 @@ public class StatsManager extends MiniDbClientPlugin * * @param value The value, must be greater or equal to zero */ + @Deprecated public void setStat(Player player, String statName, long value) { if (value < 0) @@ -158,6 +171,7 @@ public class StatsManager extends MiniDbClientPlugin * * @param value The value, must be greater or equal to zero */ + @Deprecated public void setStat(final int accountId, final String statName, final long value) { if (value < 0) @@ -171,7 +185,8 @@ public class StatsManager extends MiniDbClientPlugin _repository.saveStats(uploadQueue, true); }); } - + + @Deprecated private void addToOverRidableQueue(String statName, CoreClient client, long value) { if (client.getAccountId() == -1) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java index 9c0b9e40f..7eb6eee04 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/Arcade.java @@ -52,7 +52,6 @@ import mineplex.core.ignore.IgnoreManager; import mineplex.core.incognito.IncognitoManager; import mineplex.core.inventory.InventoryManager; import mineplex.core.itemstack.ItemStackFactory; -import mineplex.core.leaderboard.LeaderboardManager; import mineplex.core.memory.MemoryFix; import mineplex.core.message.MessageManager; import mineplex.core.monitor.LagMeter; @@ -196,8 +195,6 @@ public class Arcade extends JavaPlugin ProjectileManager projectileManager = new ProjectileManager(this); HologramManager hologramManager = new HologramManager(this, packetHandler); - new LeaderboardManager(this, hologramManager); - //Inventory InventoryManager inventoryManager = new InventoryManager(this, _clientManager); CastleManager castleManager = new CastleManager(this, _clientManager, hologramManager, false); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java index 75ad46dbb..90d008a25 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/Game.java @@ -346,8 +346,6 @@ public abstract class Game extends ListenerComponent implements Lifetimed //ELO public boolean EloRanking = false; public int EloStart = 1000; - - public boolean Leaderboards = false; public boolean CanAddStats = true; public boolean CanGiveLoot = true; diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java index aa48f660d..7f206d2a3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java @@ -184,7 +184,6 @@ public class CastleAssault extends TeamGame this.AllowFlintAndSteel = true; this.BlockPlaceAllow.add(Material.FIRE.getId()); this.CrownsEnabled = true; - this.Leaderboards = true; this.FirstKillReward = 20; this.GemKillDeathRespawn = 1; @@ -206,12 +205,12 @@ public class CastleAssault extends TeamGame if (lobbyCustomLocs.containsKey("TOP_DAILY_WINS")) { Location loc = lobbyCustomLocs.get("TOP_DAILY_WINS").get(0); - Managers.get(LeaderboardManager.class).registerLeaderboard("TOP_CASTLEASSAULT_DAILY_WINS", new Leaderboard("Top Daily Wins", Pair.create("Win", "Wins"), new String[] {"Castle Assault.Wins"}, LeaderboardSQLType.DAILY_SEASON, loc, 10)); + Managers.get(LeaderboardManager.class).registerLeaderboard("TOP_CASTLEASSAULT_DAILY_WINS", new Leaderboard("Top Daily Wins", Pair.create("Win", "Wins"), new String[] {"Castle Assault.Wins"}, LeaderboardSQLType.DAILY, loc, 10)); } if (lobbyCustomLocs.containsKey("TOP_DAILY_KILLS")) { Location loc = lobbyCustomLocs.get("TOP_DAILY_KILLS").get(0); - Managers.get(LeaderboardManager.class).registerLeaderboard("TOP_CASTLEASSAULT_DAILY_KILLS", new Leaderboard("Top Daily Kills", Pair.create("Kill", "Kills"), new String[] {"Castle Assault.Kills"}, LeaderboardSQLType.DAILY_SEASON, loc, 10)); + Managers.get(LeaderboardManager.class).registerLeaderboard("TOP_CASTLEASSAULT_DAILY_KILLS", new Leaderboard("Top Daily Kills", Pair.create("Kill", "Kills"), new String[] {"Castle Assault.Kills"}, LeaderboardSQLType.DAILY, loc, 10)); } if (lobbyCustomLocs.containsKey("TOP_WINS")) { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssaultTDM.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssaultTDM.java index 294a963a6..e9bfa88d6 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssaultTDM.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssaultTDM.java @@ -47,7 +47,6 @@ import org.bukkit.material.MaterialData; import org.bukkit.metadata.MetadataValue; import mineplex.core.Managers; -import mineplex.core.common.Pair; import mineplex.core.common.util.C; import mineplex.core.common.util.F; import mineplex.core.common.util.UtilAction; @@ -60,9 +59,7 @@ import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilTime; import mineplex.core.itemstack.ItemBuilder; -import mineplex.core.leaderboard.Leaderboard; import mineplex.core.leaderboard.LeaderboardManager; -import mineplex.core.leaderboard.LeaderboardRepository.LeaderboardSQLType; import mineplex.core.loot.ChestLoot; import mineplex.core.recharge.Recharge; import mineplex.core.updater.UpdateType; @@ -85,7 +82,6 @@ import nautilus.game.arcade.game.games.castleassault.kits.KitPlayer; import nautilus.game.arcade.game.games.castleassault.kits.KitTank; import nautilus.game.arcade.game.modules.compass.CompassModule; import nautilus.game.arcade.kit.Kit; -import nautilus.game.arcade.managers.lobby.current.NewGameLobbyManager; public class CastleAssaultTDM extends TeamGame { @@ -144,7 +140,6 @@ public class CastleAssaultTDM extends TeamGame this.AllowFlintAndSteel = true; this.BlockPlaceAllow.add(Material.FIRE.getId()); this.CrownsEnabled = true; - this.Leaderboards = true; this.FirstKillReward = 20; this.GemKillDeathRespawn = 1; @@ -157,33 +152,33 @@ public class CastleAssaultTDM extends TeamGame _flintAndSteel = new ItemBuilder(Material.FLINT_AND_STEEL).setData((short) (Material.FLINT_AND_STEEL.getMaxDurability() - MAX_FLINT_AND_STEEL_USES)); generateLoot(); - if (manager.IsRewardStats()) - { - if (manager.GetLobby() instanceof NewGameLobbyManager) - { - Map> lobbyCustomLocs = ((NewGameLobbyManager)manager.GetLobby()).getCustomLocs(); - if (lobbyCustomLocs.containsKey("TOP_DAILY_WINS")) - { - Location loc = lobbyCustomLocs.get("TOP_DAILY_WINS").get(0); - Managers.get(LeaderboardManager.class).registerLeaderboard("TOP_CASTLEASSAULT_DAILY_WINS", new Leaderboard("Top Daily Wins", Pair.create("Win", "Wins"), new String[] {"Castle Assault TDM.Wins"}, LeaderboardSQLType.DAILY_SEASON, loc, 10)); - } - if (lobbyCustomLocs.containsKey("TOP_DAILY_KILLS")) - { - Location loc = lobbyCustomLocs.get("TOP_DAILY_KILLS").get(0); - Managers.get(LeaderboardManager.class).registerLeaderboard("TOP_CASTLEASSAULT_DAILY_KILLS", new Leaderboard("Top Daily Kills", Pair.create("Kill", "Kills"), new String[] {"Castle Assault TDM.Kills"}, LeaderboardSQLType.DAILY_SEASON, loc, 10)); - } - if (lobbyCustomLocs.containsKey("TOP_WINS")) - { - Location loc = lobbyCustomLocs.get("TOP_WINS").get(0); - Managers.get(LeaderboardManager.class).registerLeaderboard("TOP_CASTLEASSAULT_WINS", new Leaderboard("Top Wins", Pair.create("Win", "Wins"), new String[] {"Castle Assault TDM.Wins"}, LeaderboardSQLType.ALL_SEASON, loc, 10)); - } - if (lobbyCustomLocs.containsKey("TOP_KILLS")) - { - Location loc = lobbyCustomLocs.get("TOP_KILLS").get(0); - Managers.get(LeaderboardManager.class).registerLeaderboard("TOP_CASTLEASSAULT_KILLS", new Leaderboard("Top Kills", Pair.create("Kill", "Kills"), new String[] {"Castle Assault TDM.Kills"}, LeaderboardSQLType.ALL_SEASON, loc, 10)); - } - } - } +// if (manager.IsRewardStats()) +// { +// if (manager.GetLobby() instanceof NewGameLobbyManager) +// { +// Map> lobbyCustomLocs = ((NewGameLobbyManager)manager.GetLobby()).getCustomLocs(); +// if (lobbyCustomLocs.containsKey("TOP_DAILY_WINS")) +// { +// Location loc = lobbyCustomLocs.get("TOP_DAILY_WINS").get(0); +// Managers.get(LeaderboardManager.class).registerLeaderboard("TOP_CASTLEASSAULT_DAILY_WINS", new Leaderboard("Top Daily Wins", Pair.create("Win", "Wins"), new String[] {"Castle Assault TDM.Wins"}, LeaderboardSQLType.DAILY_SEASON, loc, 10)); +// } +// if (lobbyCustomLocs.containsKey("TOP_DAILY_KILLS")) +// { +// Location loc = lobbyCustomLocs.get("TOP_DAILY_KILLS").get(0); +// Managers.get(LeaderboardManager.class).registerLeaderboard("TOP_CASTLEASSAULT_DAILY_KILLS", new Leaderboard("Top Daily Kills", Pair.create("Kill", "Kills"), new String[] {"Castle Assault TDM.Kills"}, LeaderboardSQLType.DAILY_SEASON, loc, 10)); +// } +// if (lobbyCustomLocs.containsKey("TOP_WINS")) +// { +// Location loc = lobbyCustomLocs.get("TOP_WINS").get(0); +// Managers.get(LeaderboardManager.class).registerLeaderboard("TOP_CASTLEASSAULT_WINS", new Leaderboard("Top Wins", Pair.create("Win", "Wins"), new String[] {"Castle Assault TDM.Wins"}, LeaderboardSQLType.ALL_SEASON, loc, 10)); +// } +// if (lobbyCustomLocs.containsKey("TOP_KILLS")) +// { +// Location loc = lobbyCustomLocs.get("TOP_KILLS").get(0); +// Managers.get(LeaderboardManager.class).registerLeaderboard("TOP_CASTLEASSAULT_KILLS", new Leaderboard("Top Kills", Pair.create("Kill", "Kills"), new String[] {"Castle Assault TDM.Kills"}, LeaderboardSQLType.ALL_SEASON, loc, 10)); +// } +// } +// } } private void generateLoot() diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameStatManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameStatManager.java index 8b727b704..5916af5b1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameStatManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/GameStatManager.java @@ -12,12 +12,10 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; -import mineplex.core.Managers; import mineplex.core.common.Rank; import mineplex.core.common.util.C; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilPlayer; -import mineplex.core.leaderboard.LeaderboardManager; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; @@ -74,14 +72,6 @@ public class GameStatManager implements Listener continue; Manager.GetStatsManager().incrementStat(player, stat, value); - - if (!event.GetGame().Leaderboards) - continue; - - if (stat.startsWith("Global.")) - continue; - - Manager.runSyncLater(() -> Managers.get(LeaderboardManager.class).handleStatIncrease(player, stat, value), 40L); } } } From aa898d74da671c2d95b3e3b1b9cb2d656dd14a0b Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 11 May 2017 15:25:22 -0400 Subject: [PATCH 79/99] Fix incorrectly named tables in fetch query --- .../core/leaderboard/LeaderboardRepository.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardRepository.java index 978ba3c1c..d03464be4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardRepository.java @@ -33,12 +33,12 @@ public class LeaderboardRepository extends RepositoryBase private static final String FETCH_STAT_ALL = "SELECT a.name, sl.value FROM accountSeasonStatsTotal AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE sl.statId=%STAT% AND season=0 ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; - private static final String FETCH_STAT_YEARLY = "SELECT a.name, sl.value FROM accountStatsSeasonal AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE YEAR(sl.date) = YEAR(CURDATE()) AND sl.statId=%STAT% ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; - private static final String FETCH_STAT_MONTHLY = "SELECT a.name, sl.value FROM accountStatsSeasonal AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE MONTH(sl.date) = MONTH(CURDATE()) AND YEAR(sl.date) = YEAR(CURDATE()) AND sl.statId=%STAT% ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; - private static final String FETCH_STAT_WEEKLY = "SELECT a.name, sl.value FROM accountStatsSeasonal AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE YEARWEEK(sl.date, 1) = YEARWEEK(CURDATE(), 1) AND sl.statId=%STAT% ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; - private static final String FETCH_STAT_DAILY = "SELECT a.name, sl.value FROM accountStatsSeasonal AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE sl.date = CURDATE() AND sl.statId=%STAT% ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; + private static final String FETCH_STAT_YEARLY = "SELECT a.name, sl.value FROM accountSeasonStatsYearly AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE YEAR(sl.date) = YEAR(CURDATE()) AND sl.statId=%STAT% ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; + private static final String FETCH_STAT_MONTHLY = "SELECT a.name, sl.value FROM accountSeasonStatsMonthly AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE MONTH(sl.date) = MONTH(CURDATE()) AND YEAR(sl.date) = YEAR(CURDATE()) AND sl.statId=%STAT% ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; + private static final String FETCH_STAT_WEEKLY = "SELECT a.name, sl.value FROM accountSeasonStatsWeekly AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE YEARWEEK(sl.date, 1) = YEARWEEK(CURDATE(), 1) AND sl.statId=%STAT% ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; + private static final String FETCH_STAT_DAILY = "SELECT a.name, sl.value FROM accountSeasonStatsDaily AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE sl.date = CURDATE() AND sl.statId=%STAT% ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; - private static final String FETCH_STAT_ALL_SEASON = "SELECT a.name, sl.value FROM accountStatsSeasonal AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE sl.statId=%STAT% AND season=" + SEASON + " ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; + private static final String FETCH_STAT_ALL_SEASON = "SELECT a.name, sl.value FROM accountSeasonStatsTotal AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE sl.statId=%STAT% AND season=" + SEASON + " ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; public LeaderboardRepository(JavaPlugin plugin) { From 7f240bb5a4a8cb50c06cc6c2050cb546ed440386 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 11 May 2017 15:53:58 -0400 Subject: [PATCH 80/99] Fix some leaderboards not cleaning up after themselves --- .../game/arcade/game/games/castleassault/CastleAssault.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java index 7f206d2a3..96382fc7f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java @@ -695,6 +695,10 @@ public class CastleAssault extends TeamGame Manager.GetDamage().SetEnabled(true); Manager.GetExplosion().setEnabled(true); Manager.GetCreature().SetDisableCustomDrops(false); + } + + if (event.GetState() == GameState.Dead) + { Managers.get(LeaderboardManager.class).unregisterLeaderboard("TOP_CASTLEASSAULT_DAILY_WINS"); Managers.get(LeaderboardManager.class).unregisterLeaderboard("TOP_CASTLEASSAULT_DAILY_KILLS"); Managers.get(LeaderboardManager.class).unregisterLeaderboard("TOP_CASTLEASSAULT_WINS"); From 86c66d3a440a1e028847746077dee878f666753e Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 11 May 2017 16:05:19 -0400 Subject: [PATCH 81/99] Add specific kit spawn data locs --- .../game/games/castleassault/CastleAssault.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java index 96382fc7f..5388c6fc1 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java @@ -396,16 +396,14 @@ public class CastleAssault extends TeamGame this.CreatureAllowOverride = true; _kings.put(red, new TeamKing(red, "King Jon", redKing)); _kings.put(blue, new TeamKing(blue, "King Ryan", blueKing)); - int kitIndex = 0; - for (int i = 0; i < WorldData.GetDataLocs("WHITE").size(); i++) + for (Kit kit : GetKits()) { - if (kitIndex >= GetKits().length) + List spawns = WorldData.GetDataLocs("K:" + kit.GetName()); + for (Location spawn : spawns) { - kitIndex = 0; + Entity ent = kit.SpawnEntity(spawn); + Manager.GetLobby().addKitLocation(ent, kit, spawn); } - Entity ent = GetKits()[kitIndex].SpawnEntity(WorldData.GetDataLocs("WHITE").get(i)); - Manager.GetLobby().addKitLocation(ent, GetKits()[kitIndex], WorldData.GetDataLocs("WHITE").get(i)); - kitIndex++; } this.CreatureAllowOverride = false; _tntSpawner = new ObjectiveTNTSpawner(WorldData.GetDataLocs("BLACK")); From 0091cbe2a8cf25929173d2ea96d803ab312d41f1 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 11 May 2017 18:15:33 -0400 Subject: [PATCH 82/99] Change kit data loc formatting --- .../game/arcade/game/games/castleassault/CastleAssault.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java index 5388c6fc1..8bef3e9b0 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java @@ -398,7 +398,7 @@ public class CastleAssault extends TeamGame _kings.put(blue, new TeamKing(blue, "King Ryan", blueKing)); for (Kit kit : GetKits()) { - List spawns = WorldData.GetDataLocs("K:" + kit.GetName()); + List spawns = WorldData.GetDataLocs(kit.GetName()); for (Location spawn : spawns) { Entity ent = kit.SpawnEntity(spawn); From 4a05149743862b42833f1fd89b2f104af39b9051 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 11 May 2017 18:29:42 -0400 Subject: [PATCH 83/99] Use correct data loc pool for kit locations --- .../game/arcade/game/games/castleassault/CastleAssault.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java index 8bef3e9b0..c1d2a7f0e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java @@ -398,7 +398,7 @@ public class CastleAssault extends TeamGame _kings.put(blue, new TeamKing(blue, "King Ryan", blueKing)); for (Kit kit : GetKits()) { - List spawns = WorldData.GetDataLocs(kit.GetName()); + List spawns = WorldData.GetCustomLocs(kit.GetName().toUpperCase()); for (Location spawn : spawns) { Entity ent = kit.SpawnEntity(spawn); From a76572f6d759c5b7d57c666a2e67a94bef974722 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 11 May 2017 20:49:38 -0400 Subject: [PATCH 84/99] Change table names and add date indexes based on Jon's request --- .../leaderboard/LeaderboardRepository.java | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardRepository.java index d03464be4..68f1133e0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardRepository.java @@ -20,25 +20,25 @@ public class LeaderboardRepository extends RepositoryBase { private static final int SEASON = 1; - private static final String CREATE_TOTAL = "CREATE TABLE accountSeasonStatsTotal (accountId INT NOT NULL, statId INT NOT NULL, season SMALLINT NOT NULL, value BIGINT NOT NULL, PRIMARY KEY (accountId, statId, season), INDEX valueIndex (value DESC), FOREIGN KEY (accountId) REFERENCES accounts(id), FOREIGN KEY (statId) REFERENCES stats(id));"; - private static final String CREATE_YEARLY = "CREATE TABLE accountSeasonStatsYearly (accountId INT NOT NULL, statId INT NOT NULL, date DATE NOT NULL, value BIGINT NOT NULL, PRIMARY KEY (accountId, statId), INDEX valueIndex (value DESC), FOREIGN KEY (accountId) REFERENCES accounts(id), FOREIGN KEY (statId) REFERENCES stats(id));"; - private static final String CREATE_MONTHLY = "CREATE TABLE accountSeasonStatsMonthly (accountId INT NOT NULL, statId INT NOT NULL, date DATE NOT NULL, value BIGINT NOT NULL, PRIMARY KEY (accountId, statId), INDEX valueIndex (value DESC), FOREIGN KEY (accountId) REFERENCES accounts(id), FOREIGN KEY (statId) REFERENCES stats(id));"; - private static final String CREATE_WEEKLY = "CREATE TABLE accountSeasonStatsWeekly (accountId INT NOT NULL, statId INT NOT NULL, date DATE NOT NULL, value BIGINT NOT NULL, PRIMARY KEY (accountId, statId), INDEX valueIndex (value DESC), FOREIGN KEY (accountId) REFERENCES accounts(id), FOREIGN KEY (statId) REFERENCES stats(id));"; - private static final String CREATE_DAILY = "CREATE TABLE accountSeasonStatsDaily (accountId INT NOT NULL, statId INT NOT NULL, date DATE NOT NULL, value BIGINT NOT NULL, PRIMARY KEY (accountId, statId), INDEX valueIndex (value DESC), FOREIGN KEY (accountId) REFERENCES accounts(id), FOREIGN KEY (statId) REFERENCES stats(id));"; + private static final String CREATE_TOTAL = "CREATE TABLE accountStatsSeasonalTotal (accountId INT NOT NULL, statId INT NOT NULL, season SMALLINT NOT NULL, value BIGINT NOT NULL, PRIMARY KEY (accountId, statId, season), INDEX valueIndex (value DESC), FOREIGN KEY (accountId) REFERENCES accounts(id), FOREIGN KEY (statId) REFERENCES stats(id));"; + private static final String CREATE_YEARLY = "CREATE TABLE accountStatsYearly (accountId INT NOT NULL, statId INT NOT NULL, date DATE NOT NULL, value BIGINT NOT NULL, PRIMARY KEY (accountId, statId), INDEX valueIndex (value DESC), INDEX dateIndex (date), FOREIGN KEY (accountId) REFERENCES accounts(id), FOREIGN KEY (statId) REFERENCES stats(id));"; + private static final String CREATE_MONTHLY = "CREATE TABLE accountStatsMonthly (accountId INT NOT NULL, statId INT NOT NULL, date DATE NOT NULL, value BIGINT NOT NULL, PRIMARY KEY (accountId, statId), INDEX valueIndex (value DESC), INDEX dateIndex (date), FOREIGN KEY (accountId) REFERENCES accounts(id), FOREIGN KEY (statId) REFERENCES stats(id));"; + private static final String CREATE_WEEKLY = "CREATE TABLE accountStatsWeekly (accountId INT NOT NULL, statId INT NOT NULL, date DATE NOT NULL, value BIGINT NOT NULL, PRIMARY KEY (accountId, statId), INDEX valueIndex (value DESC), INDEX dateIndex (date), FOREIGN KEY (accountId) REFERENCES accounts(id), FOREIGN KEY (statId) REFERENCES stats(id));"; + private static final String CREATE_DAILY = "CREATE TABLE accountStatsDaily (accountId INT NOT NULL, statId INT NOT NULL, date DATE NOT NULL, value BIGINT NOT NULL, PRIMARY KEY (accountId, statId), INDEX valueIndex (value DESC), INDEX dateIndex (date), FOREIGN KEY (accountId) REFERENCES accounts(id), FOREIGN KEY (statId) REFERENCES stats(id));"; - private static final String INSERT_STAT = "INSERT INTO accountSeasonStatsTotal (accountId, statId, season, value) VALUES (?, ?, " + SEASON + ", ?);"; - private static final String INSERT_STAT_ALL = "INSERT INTO accountSeasonStatsTotal (accountId, statId, season, value) VALUES (?, ?, 0, ?);"; - private static final String UPDATE_STAT = "UPDATE accountSeasonStatsTotal SET value=value + ? WHERE accountId=? AND statId=? AND season=" + SEASON + ";"; - private static final String UPDATE_STAT_ALL = "UPDATE accountSeasonStatsTotal SET value=value + ? WHERE accountId=? AND statId=? AND season=0;"; + private static final String INSERT_STAT = "INSERT INTO accountStatsSeasonalTotal (accountId, statId, season, value) VALUES (?, ?, " + SEASON + ", ?);"; + private static final String INSERT_STAT_ALL = "INSERT INTO accountStatsSeasonalTotal (accountId, statId, season, value) VALUES (?, ?, 0, ?);"; + private static final String UPDATE_STAT = "UPDATE accountStatsSeasonalTotal SET value=value + ? WHERE accountId=? AND statId=? AND season=" + SEASON + ";"; + private static final String UPDATE_STAT_ALL = "UPDATE accountStatsSeasonalTotal SET value=value + ? WHERE accountId=? AND statId=? AND season=0;"; - private static final String FETCH_STAT_ALL = "SELECT a.name, sl.value FROM accountSeasonStatsTotal AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE sl.statId=%STAT% AND season=0 ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; + private static final String FETCH_STAT_ALL = "SELECT a.name, sl.value FROM accountStatsSeasonalTotal AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE sl.statId=%STAT% AND season=0 ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; - private static final String FETCH_STAT_YEARLY = "SELECT a.name, sl.value FROM accountSeasonStatsYearly AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE YEAR(sl.date) = YEAR(CURDATE()) AND sl.statId=%STAT% ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; - private static final String FETCH_STAT_MONTHLY = "SELECT a.name, sl.value FROM accountSeasonStatsMonthly AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE MONTH(sl.date) = MONTH(CURDATE()) AND YEAR(sl.date) = YEAR(CURDATE()) AND sl.statId=%STAT% ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; - private static final String FETCH_STAT_WEEKLY = "SELECT a.name, sl.value FROM accountSeasonStatsWeekly AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE YEARWEEK(sl.date, 1) = YEARWEEK(CURDATE(), 1) AND sl.statId=%STAT% ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; - private static final String FETCH_STAT_DAILY = "SELECT a.name, sl.value FROM accountSeasonStatsDaily AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE sl.date = CURDATE() AND sl.statId=%STAT% ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; + private static final String FETCH_STAT_YEARLY = "SELECT a.name, sl.value FROM accountStatsYearly AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE YEAR(sl.date) = YEAR(CURDATE()) AND sl.statId=%STAT% ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; + private static final String FETCH_STAT_MONTHLY = "SELECT a.name, sl.value FROM accountStatsMonthly AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE MONTH(sl.date) = MONTH(CURDATE()) AND YEAR(sl.date) = YEAR(CURDATE()) AND sl.statId=%STAT% ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; + private static final String FETCH_STAT_WEEKLY = "SELECT a.name, sl.value FROM accountStatsWeekly AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE YEARWEEK(sl.date, 1) = YEARWEEK(CURDATE(), 1) AND sl.statId=%STAT% ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; + private static final String FETCH_STAT_DAILY = "SELECT a.name, sl.value FROM accountStatsDaily AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE sl.date = CURDATE() AND sl.statId=%STAT% ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; - private static final String FETCH_STAT_ALL_SEASON = "SELECT a.name, sl.value FROM accountSeasonStatsTotal AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE sl.statId=%STAT% AND season=" + SEASON + " ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; + private static final String FETCH_STAT_ALL_SEASON = "SELECT a.name, sl.value FROM accountStatsSeasonalTotal AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE sl.statId=%STAT% AND season=" + SEASON + " ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; public LeaderboardRepository(JavaPlugin plugin) { From 1e93ad0b1e5ba61a20aaf098792decb792114957 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 11 May 2017 21:18:05 -0400 Subject: [PATCH 85/99] Proper resource management for leaderboard statements --- .../leaderboard/LeaderboardRepository.java | 76 +++++++++---------- 1 file changed, 34 insertions(+), 42 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardRepository.java index 68f1133e0..d52b487d7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardRepository.java @@ -49,13 +49,8 @@ public class LeaderboardRepository extends RepositoryBase { UtilServer.runAsync(() -> { - try (Connection c = getConnection()) + try (Connection c = getConnection(); PreparedStatement s = c.prepareStatement(UPDATE_STAT); PreparedStatement u = c.prepareStatement(UPDATE_STAT_ALL); PreparedStatement v = c.prepareStatement(INSERT_STAT); PreparedStatement w = c.prepareStatement(INSERT_STAT_ALL)) { - final boolean auto = c.getAutoCommit(); - - c.setAutoCommit(true); - PreparedStatement s = c.prepareStatement(UPDATE_STAT); - PreparedStatement u = c.prepareStatement(UPDATE_STAT_ALL); for (Integer accountId : stats.keySet()) { for (Integer statId : stats.get(accountId).keySet()) @@ -72,9 +67,6 @@ public class LeaderboardRepository extends RepositoryBase } int[] rowsAffected1 = s.executeBatch(); int[] rowsAffected2 = u.executeBatch(); - c.setAutoCommit(false); - s = c.prepareStatement(INSERT_STAT); - u = c.prepareStatement(INSERT_STAT_ALL); int i = 0; for (Integer accountId : stats.keySet()) { @@ -82,25 +74,23 @@ public class LeaderboardRepository extends RepositoryBase { if (rowsAffected1[i] < 1) { - s.setInt(1, accountId); - s.setInt(2, statId); - s.setLong(3, stats.get(accountId).get(statId)); - s.addBatch(); + v.setInt(1, accountId); + v.setInt(2, statId); + v.setLong(3, stats.get(accountId).get(statId)); + v.addBatch(); } if (rowsAffected2[i] < 1) { - u.setInt(1, accountId); - u.setInt(2, statId); - u.setLong(3, stats.get(accountId).get(statId)); - u.addBatch(); + w.setInt(1, accountId); + w.setInt(2, statId); + w.setLong(3, stats.get(accountId).get(statId)); + w.addBatch(); } i++; } } - s.executeBatch(); - u.executeBatch(); - - c.setAutoCommit(auto); + v.executeBatch(); + w.executeBatch(); } catch (SQLException e) { @@ -111,38 +101,42 @@ public class LeaderboardRepository extends RepositoryBase public void insertStats(int accountId, Map stats) { - try (Connection c = getConnection()) + try (Connection c = getConnection(); PreparedStatement s = c.prepareStatement(UPDATE_STAT); PreparedStatement u = c.prepareStatement(UPDATE_STAT_ALL); PreparedStatement v = c.prepareStatement(INSERT_STAT); PreparedStatement w = c.prepareStatement(INSERT_STAT_ALL)) { - final boolean auto = c.getAutoCommit(); - - c.setAutoCommit(true); - PreparedStatement s = c.prepareStatement(UPDATE_STAT); for (Integer statId : stats.keySet()) { s.setLong(1, stats.get(statId)); s.setInt(2, accountId); s.setInt(3, statId); s.addBatch(); + u.setLong(1, stats.get(statId)); + u.setInt(2, accountId); + u.setInt(3, statId); + u.addBatch(); } - int[] rowsAffected = s.executeBatch(); - c.setAutoCommit(false); - s = c.prepareStatement(INSERT_STAT); + int[] rowsAffected1 = s.executeBatch(); + int[] rowsAffected2 = u.executeBatch(); int i = 0; for (Integer statId : stats.keySet()) { - if (rowsAffected[i] < 1) + if (rowsAffected1[i] < 1) { - s.setInt(1, accountId); - s.setInt(2, statId); - s.setLong(3, stats.get(statId)); - s.addBatch(); + v.setInt(1, accountId); + v.setInt(2, statId); + v.setLong(3, stats.get(statId)); + v.addBatch(); + } + if (rowsAffected2[i] < 1) + { + w.setInt(1, accountId); + w.setInt(2, statId); + w.setLong(3, stats.get(statId)); + w.addBatch(); } i++; } - s.executeBatch(); - - c.setAutoCommit(auto); - + v.executeBatch(); + w.executeBatch(); } catch (SQLException e) { @@ -153,9 +147,8 @@ public class LeaderboardRepository extends RepositoryBase public void loadLeaderboard(Leaderboard board, Consumer> leaderboard) { Map names = new LinkedHashMap<>(); - try (Connection c = getConnection()) + try (Connection c = getConnection(); Statement s = c.createStatement()) { - Statement s = c.createStatement(); s.execute(board.getType().getStatement(board.getStatIds(), board.getStart(), board.getSize())); for (int i = 0; i < board.getStatIds().length; i++) { @@ -200,9 +193,8 @@ public class LeaderboardRepository extends RepositoryBase if (queryBuilder.length() > 0) { - try (Connection c = getConnection()) + try (Connection c = getConnection(); Statement s = c.createStatement()) { - Statement s = c.createStatement(); s.execute(queryBuilder.toString()); int index = 0; mainBoardLoop: for (Leaderboard board : boards) From 3023c64c359c631ba29ffdd4ad9b988e655e1b1e Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 11 May 2017 21:34:41 -0400 Subject: [PATCH 86/99] Jon is actually OCD --- .../leaderboard/LeaderboardRepository.java | 106 ++++++++++-------- 1 file changed, 62 insertions(+), 44 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardRepository.java index d52b487d7..5c79561f3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardRepository.java @@ -49,24 +49,30 @@ public class LeaderboardRepository extends RepositoryBase { UtilServer.runAsync(() -> { - try (Connection c = getConnection(); PreparedStatement s = c.prepareStatement(UPDATE_STAT); PreparedStatement u = c.prepareStatement(UPDATE_STAT_ALL); PreparedStatement v = c.prepareStatement(INSERT_STAT); PreparedStatement w = c.prepareStatement(INSERT_STAT_ALL)) + try ( + Connection c = getConnection(); + PreparedStatement updateStat = c.prepareStatement(UPDATE_STAT); + PreparedStatement updateAllStats = c.prepareStatement(UPDATE_STAT_ALL); + PreparedStatement insertStat = c.prepareStatement(INSERT_STAT); + PreparedStatement insertAllStats = c.prepareStatement(INSERT_STAT_ALL); + ) { for (Integer accountId : stats.keySet()) { for (Integer statId : stats.get(accountId).keySet()) { - s.setLong(1, stats.get(accountId).get(statId)); - s.setInt(2, accountId); - s.setInt(3, statId); - s.addBatch(); - u.setLong(1, stats.get(accountId).get(statId)); - u.setInt(2, accountId); - u.setInt(3, statId); - u.addBatch(); + updateStat.setLong(1, stats.get(accountId).get(statId)); + updateStat.setInt(2, accountId); + updateStat.setInt(3, statId); + updateStat.addBatch(); + updateAllStats.setLong(1, stats.get(accountId).get(statId)); + updateAllStats.setInt(2, accountId); + updateAllStats.setInt(3, statId); + updateAllStats.addBatch(); } } - int[] rowsAffected1 = s.executeBatch(); - int[] rowsAffected2 = u.executeBatch(); + int[] rowsAffected1 = updateStat.executeBatch(); + int[] rowsAffected2 = updateAllStats.executeBatch(); int i = 0; for (Integer accountId : stats.keySet()) { @@ -74,23 +80,23 @@ public class LeaderboardRepository extends RepositoryBase { if (rowsAffected1[i] < 1) { - v.setInt(1, accountId); - v.setInt(2, statId); - v.setLong(3, stats.get(accountId).get(statId)); - v.addBatch(); + insertStat.setInt(1, accountId); + insertStat.setInt(2, statId); + insertStat.setLong(3, stats.get(accountId).get(statId)); + insertStat.addBatch(); } if (rowsAffected2[i] < 1) { - w.setInt(1, accountId); - w.setInt(2, statId); - w.setLong(3, stats.get(accountId).get(statId)); - w.addBatch(); + insertAllStats.setInt(1, accountId); + insertAllStats.setInt(2, statId); + insertAllStats.setLong(3, stats.get(accountId).get(statId)); + insertAllStats.addBatch(); } i++; } } - v.executeBatch(); - w.executeBatch(); + insertStat.executeBatch(); + insertAllStats.executeBatch(); } catch (SQLException e) { @@ -101,42 +107,48 @@ public class LeaderboardRepository extends RepositoryBase public void insertStats(int accountId, Map stats) { - try (Connection c = getConnection(); PreparedStatement s = c.prepareStatement(UPDATE_STAT); PreparedStatement u = c.prepareStatement(UPDATE_STAT_ALL); PreparedStatement v = c.prepareStatement(INSERT_STAT); PreparedStatement w = c.prepareStatement(INSERT_STAT_ALL)) + try ( + Connection c = getConnection(); + PreparedStatement updateStat = c.prepareStatement(UPDATE_STAT); + PreparedStatement updateAllStats = c.prepareStatement(UPDATE_STAT_ALL); + PreparedStatement insertStat = c.prepareStatement(INSERT_STAT); + PreparedStatement insertAllStats = c.prepareStatement(INSERT_STAT_ALL); + ) { for (Integer statId : stats.keySet()) { - s.setLong(1, stats.get(statId)); - s.setInt(2, accountId); - s.setInt(3, statId); - s.addBatch(); - u.setLong(1, stats.get(statId)); - u.setInt(2, accountId); - u.setInt(3, statId); - u.addBatch(); + updateStat.setLong(1, stats.get(statId)); + updateStat.setInt(2, accountId); + updateStat.setInt(3, statId); + updateStat.addBatch(); + updateAllStats.setLong(1, stats.get(statId)); + updateAllStats.setInt(2, accountId); + updateAllStats.setInt(3, statId); + updateAllStats.addBatch(); } - int[] rowsAffected1 = s.executeBatch(); - int[] rowsAffected2 = u.executeBatch(); + int[] rowsAffected1 = updateStat.executeBatch(); + int[] rowsAffected2 = updateAllStats.executeBatch(); int i = 0; for (Integer statId : stats.keySet()) { if (rowsAffected1[i] < 1) { - v.setInt(1, accountId); - v.setInt(2, statId); - v.setLong(3, stats.get(statId)); - v.addBatch(); + insertStat.setInt(1, accountId); + insertStat.setInt(2, statId); + insertStat.setLong(3, stats.get(statId)); + insertStat.addBatch(); } if (rowsAffected2[i] < 1) { - w.setInt(1, accountId); - w.setInt(2, statId); - w.setLong(3, stats.get(statId)); - w.addBatch(); + insertAllStats.setInt(1, accountId); + insertAllStats.setInt(2, statId); + insertAllStats.setLong(3, stats.get(statId)); + insertAllStats.addBatch(); } i++; } - v.executeBatch(); - w.executeBatch(); + insertStat.executeBatch(); + insertAllStats.executeBatch(); } catch (SQLException e) { @@ -147,7 +159,10 @@ public class LeaderboardRepository extends RepositoryBase public void loadLeaderboard(Leaderboard board, Consumer> leaderboard) { Map names = new LinkedHashMap<>(); - try (Connection c = getConnection(); Statement s = c.createStatement()) + try ( + Connection c = getConnection(); + Statement s = c.createStatement(); + ) { s.execute(board.getType().getStatement(board.getStatIds(), board.getStart(), board.getSize())); for (int i = 0; i < board.getStatIds().length; i++) @@ -193,7 +208,10 @@ public class LeaderboardRepository extends RepositoryBase if (queryBuilder.length() > 0) { - try (Connection c = getConnection(); Statement s = c.createStatement()) + try ( + Connection c = getConnection(); + Statement s = c.createStatement(); + ) { s.execute(queryBuilder.toString()); int index = 0; From 7ad86c435c35920dfb463ee3d00379400abba11d Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Thu, 11 May 2017 21:40:06 -0400 Subject: [PATCH 87/99] More nitpicks --- .../leaderboard/LeaderboardRepository.java | 44 ++++++++++--------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardRepository.java index 5c79561f3..866a1e5b7 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardRepository.java @@ -51,10 +51,10 @@ public class LeaderboardRepository extends RepositoryBase { try ( Connection c = getConnection(); - PreparedStatement updateStat = c.prepareStatement(UPDATE_STAT); - PreparedStatement updateAllStats = c.prepareStatement(UPDATE_STAT_ALL); - PreparedStatement insertStat = c.prepareStatement(INSERT_STAT); - PreparedStatement insertAllStats = c.prepareStatement(INSERT_STAT_ALL); + PreparedStatement updateStat = c.prepareStatement(UPDATE_STAT); + PreparedStatement updateAllStats = c.prepareStatement(UPDATE_STAT_ALL); + PreparedStatement insertStat = c.prepareStatement(INSERT_STAT); + PreparedStatement insertAllStats = c.prepareStatement(INSERT_STAT_ALL); ) { for (Integer accountId : stats.keySet()) @@ -167,15 +167,17 @@ public class LeaderboardRepository extends RepositoryBase s.execute(board.getType().getStatement(board.getStatIds(), board.getStart(), board.getSize())); for (int i = 0; i < board.getStatIds().length; i++) { - ResultSet rs = s.getResultSet(); - while (rs.next()) + try (ResultSet rs = s.getResultSet()) { - names.merge(rs.getString("name"), rs.getInt("value"), Integer::sum); - } - - if (!s.getMoreResults()) - { - break; + while (rs.next()) + { + names.merge(rs.getString("name"), rs.getInt("value"), Integer::sum); + } + + if (!s.getMoreResults()) + { + break; + } } } } @@ -219,15 +221,17 @@ public class LeaderboardRepository extends RepositoryBase { for (int i = 0; i < board.getStatIds().length; i++) { - ResultSet rs = s.getResultSet(); - while (rs.next()) + try (ResultSet rs = s.getResultSet()) { - leaderboards[index].merge(rs.getString("name"), rs.getInt("value"), Integer::sum); - } - - if (!s.getMoreResults()) - { - break mainBoardLoop; + while (rs.next()) + { + leaderboards[index].merge(rs.getString("name"), rs.getInt("value"), Integer::sum); + } + + if (!s.getMoreResults()) + { + break mainBoardLoop; + } } } index++; From c8a103559103603f32a764d36b29645427f0fab8 Mon Sep 17 00:00:00 2001 From: samczsun Date: Fri, 14 Apr 2017 00:52:52 -0400 Subject: [PATCH 88/99] Comped accounts --- .../src/mineplex/core/common/api/ApiHost.java | 5 ++ .../mineplex/core/common/util/UtilPlayer.java | 6 ++ .../src/mineplex/core/antihack/AntiHack.java | 6 ++ .../core/antihack/banwave/BanWaveManager.java | 2 + .../CompromisedAccountManager.java | 76 +++++++++++++++++++ .../CompromisedAccountRepository.java | 46 +++++++++++ .../antihack/compedaccount/PlayerInfo.java | 62 +++++++++++++++ 7 files changed, 203 insertions(+) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/antihack/compedaccount/CompromisedAccountManager.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/antihack/compedaccount/CompromisedAccountRepository.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/antihack/compedaccount/PlayerInfo.java diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/api/ApiHost.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/api/ApiHost.java index a6dd1cbae..b1593c552 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/api/ApiHost.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/api/ApiHost.java @@ -71,6 +71,11 @@ public class ApiHost return getAPIHost("ENDERCHEST"); } + public static ApiHost getBanner() + { + return getAPIHost("BANNER"); + } + private String _host; private int _port; diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java index bfc5e4ec8..19b7b6059 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilPlayer.java @@ -1,5 +1,6 @@ package mineplex.core.common.util; +import java.net.InetAddress; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -1145,6 +1146,11 @@ public class UtilPlayer return entityPlayer.activeContainer != entityPlayer.defaultContainer; } + public static String getIp(Player player) + { + return player.getAddress().getAddress().getHostAddress(); + } + /* * Returns whether the UUID belongs to a slim skin */ diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java index b59982c6f..ffb40fc5d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java @@ -68,6 +68,7 @@ import mineplex.core.antihack.commands.AnticheatOnCommand; import mineplex.core.antihack.commands.DetailedMessagesCommand; import mineplex.core.antihack.commands.GetVlsCommand; import mineplex.core.antihack.commands.TestBanCommand; +import mineplex.core.antihack.compedaccount.CompromisedAccountManager; import mineplex.core.antihack.gep.GwenExtremePrejudice; import mineplex.core.antihack.guardians.GuardianManager; import mineplex.core.antihack.logging.AntihackLogger; @@ -147,6 +148,8 @@ public class AntiHack extends MiniPlugin private BanWaveManager _banWaveManager; + private final CompromisedAccountManager _compromisedAccountManager; + private AntiHack() { super("AntiHack"); @@ -155,6 +158,7 @@ public class AntiHack extends MiniPlugin require(GuardianManager.class); _banWaveManager = require(BanWaveManager.class); + _compromisedAccountManager = require(CompromisedAccountManager.class); Bukkit.getServicesManager().register(MineplexLink.class, new MineplexLinkImpl(), this._plugin, ServicePriority.Normal); @@ -225,6 +229,8 @@ public class AntiHack extends MiniPlugin new GwenBanNotification(_thisServer, player.getName(), player.getUniqueId().toString(), coreClient.GetRank().name(), CheckManager.getCheckSimpleName(cause), id, gep).publish(); }); + _compromisedAccountManager.submitImmediateBan(player); + _punish.AddPunishment(coreClient.getName(), Category.Hacking, finalMessage, AntiHack.NAME, 3, true, -1, true, after); }; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/banwave/BanWaveManager.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/banwave/BanWaveManager.java index 668c60db2..a4a5476e5 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/banwave/BanWaveManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/banwave/BanWaveManager.java @@ -5,6 +5,7 @@ import mineplex.core.ReflectivelyCreateMiniPlugin; import mineplex.core.account.CoreClient; import mineplex.core.account.CoreClientManager; import mineplex.core.antihack.AntiHack; +import mineplex.core.antihack.compedaccount.CompromisedAccountManager; import mineplex.core.antihack.logging.AntihackLogger; import mineplex.core.antihack.redisnotifications.GwenBanwaveNotification; import mineplex.core.common.util.UtilServer; @@ -74,6 +75,7 @@ public class BanWaveManager extends MiniPlugin JsonObject custom = new JsonObject(); custom.addProperty("is-banwave", true); + require(CompromisedAccountManager.class).submitPendingDelayedBan(player); require(AntihackLogger.class).saveMetadata(player, id, after, custom); } }); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/compedaccount/CompromisedAccountManager.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/compedaccount/CompromisedAccountManager.java new file mode 100644 index 000000000..cebea5a50 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/compedaccount/CompromisedAccountManager.java @@ -0,0 +1,76 @@ +package mineplex.core.antihack.compedaccount; + +import java.util.logging.Level; + +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerJoinEvent; + +import com.google.gson.JsonObject; + +import mineplex.core.MiniPlugin; +import mineplex.core.ReflectivelyCreateMiniPlugin; +import mineplex.core.account.CoreClient; +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.api.ApiHost; +import mineplex.core.common.api.ApiWebCall; +import mineplex.core.common.util.UtilPlayer; + +@ReflectivelyCreateMiniPlugin +public class CompromisedAccountManager extends MiniPlugin +{ + private final CompromisedAccountRepository _repository = new CompromisedAccountRepository(); + + private final CoreClientManager _clientManager = require(CoreClientManager.class); + + private final ApiWebCall _apiCall; + + private CompromisedAccountManager() + { + super("CompedAccount"); + + String url = "http://" + ApiHost.getBanner().getHost() + ":" + ApiHost.getBanner().getPort() + "/"; + _apiCall = new ApiWebCall(url); + } + + public void submitImmediateBan(Player player) + { + _repository.insertPunishment(_clientManager.getAccountId(player), UtilPlayer.getIp(player), "immediate").whenComplete((res, err) -> + { + if (err != null) + { + getPlugin().getLogger().log(Level.SEVERE, "An unexpected error occurred while submitting immediate ban of " + player.getName(), err); + } + }); + } + + public void submitPendingDelayedBan(Player player) + { + _repository.insertPunishment(_clientManager.getAccountId(player), UtilPlayer.getIp(player), "predelayed").whenComplete((res, err) -> + { + if (err != null) + { + getPlugin().getLogger().log(Level.SEVERE, "An unexpected error occurred while submitting delayed ban of " + player.getName(), err); + } + }); + } + + @EventHandler + public void onJoin(PlayerJoinEvent event) + { + CoreClient coreClient = _clientManager.Get(event.getPlayer()); + PlayerInfo playerInfo = new PlayerInfo( + event.getPlayer().getName(), + coreClient.getName(), + event.getPlayer().getUniqueId(), + coreClient.getAccountId(), + UtilPlayer.getIp(event.getPlayer()) + ); + + JsonObject response = _apiCall.post("api/server/login/" + event.getPlayer().getName(), JsonObject.class, playerInfo); + if (response != null && response.get("error") != null) + { + getPlugin().getLogger().log(Level.SEVERE, "Response from Banner: " + response); + } + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/compedaccount/CompromisedAccountRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/compedaccount/CompromisedAccountRepository.java new file mode 100644 index 000000000..c9af4fa35 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/compedaccount/CompromisedAccountRepository.java @@ -0,0 +1,46 @@ +package mineplex.core.antihack.compedaccount; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.util.concurrent.CompletableFuture; + +import mineplex.core.common.util.UtilServer; +import mineplex.serverdata.database.DBPool; +import mineplex.serverdata.database.RepositoryBase; + +public class CompromisedAccountRepository extends RepositoryBase +{ + private static final String INSERT_BAN = "INSERT INTO gwenPunishments (accountId, ip, type) VALUES (?, ?, ?)"; + + public CompromisedAccountRepository() + { + super(DBPool.getAccount()); + } + + public CompletableFuture insertPunishment(int accountId, String ip, String type) + { + CompletableFuture future = new CompletableFuture<>(); + + CompletableFuture.runAsync(() -> { + try (Connection connection = getConnection()) + { + try (PreparedStatement preparedStatement = connection.prepareStatement(INSERT_BAN)) + { + preparedStatement.setInt(1, accountId); + preparedStatement.setString(2, ip); + preparedStatement.setString(3, type); + preparedStatement.executeUpdate(); + } + } + catch (SQLException ex) + { + future.completeExceptionally(ex); + return; + } + future.complete(null); + }); + + return future; + } +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/compedaccount/PlayerInfo.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/compedaccount/PlayerInfo.java new file mode 100644 index 000000000..d80ccf5b9 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/compedaccount/PlayerInfo.java @@ -0,0 +1,62 @@ +package mineplex.core.antihack.compedaccount; + +import java.util.Objects; +import java.util.UUID; + +public class PlayerInfo +{ + private final String _name; + private final String _realName; + private final UUID _uuid; + private final int _accountId; + private final String _ip; + + public PlayerInfo(String name, String realName, UUID uuid, int accountId, String ip) + { + _name = name; + _realName = realName; + _uuid = uuid; + _accountId = accountId; + _ip = ip; + } + + public String getName() + { + return _name; + } + + public String getRealName() + { + return _realName; + } + + public UUID getUuid() + { + return _uuid; + } + + public int getAccountId() + { + return _accountId; + } + + public String getIp() + { + return _ip; + } + + @Override + public boolean equals(Object o) + { + if (this == o) return true; + if (!(o instanceof PlayerInfo)) return false; + PlayerInfo that = (PlayerInfo) o; + return _accountId == that._accountId; + } + + @Override + public int hashCode() + { + return Objects.hash(_accountId); + } +} From ecef2fe9db5bf6a560461c7099f50d95deb69527 Mon Sep 17 00:00:00 2001 From: samczsun Date: Wed, 26 Apr 2017 20:05:33 -0400 Subject: [PATCH 89/99] New messages/durations --- .../src/mineplex/core/antihack/AntiHack.java | 64 +++++++++++++++++-- .../core/antihack/banwave/BanWaveManager.java | 2 +- 2 files changed, 61 insertions(+), 5 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java index ffb40fc5d..515ab35da 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java @@ -81,6 +81,8 @@ import mineplex.core.preferences.Preference; import mineplex.core.preferences.PreferencesManager; import mineplex.core.punish.Category; import mineplex.core.punish.Punish; +import mineplex.core.punish.PunishClient; +import mineplex.core.punish.Punishment; import mineplex.core.punish.PunishmentResponse; import mineplex.serverdata.commands.ServerCommandManager; @@ -212,7 +214,7 @@ public class AntiHack extends MiniPlugin CoreClient coreClient = _clientManager.Get(player); String id = generateId(); - String finalMessage = "[GWEN] " + id; + String finalMessage = "[GWEN] Cheat Detection\nToken: " + id; JsonObject custom = new JsonObject(); custom.addProperty("ban-reason", CheckManager.getCheckSimpleName(cause)); if (gep) @@ -231,7 +233,7 @@ public class AntiHack extends MiniPlugin _compromisedAccountManager.submitImmediateBan(player); - _punish.AddPunishment(coreClient.getName(), Category.Hacking, finalMessage, AntiHack.NAME, 3, true, -1, true, after); + _punish.AddPunishment(coreClient.getName(), Category.Hacking, finalMessage, AntiHack.NAME, 3, true, getDaysBanned(player, cause), true, after); }; if (coreClient.GetRank().has(Rank.TWITCH)) @@ -270,7 +272,7 @@ public class AntiHack extends MiniPlugin Consumer> doPunish = after -> { - _punish.AddPunishment(coreClient.getName(), Category.Hacking, info.getMessage(), AntiHack.NAME, 3, true, -1, true, after); + _punish.AddPunishment(coreClient.getName(), Category.Hacking, info.getMessage(), AntiHack.NAME, 3, true, getDaysBanned(player, CheckManager.getCheckBySimpleName(info.getHackType())), true, after); }; if (coreClient.GetRank().has(Rank.TWITCH)) @@ -346,6 +348,60 @@ public class AntiHack extends MiniPlugin event.setCancelled(true); } + public int getPunishments(Player player) + { + PunishClient punishClient = require(Punish.class).GetClient(player.getName()); + + int totalPunishments = 0; + + if (punishClient.GetPunishments().containsKey(Category.Hacking)) + { + for (Punishment punishment : punishClient.GetPunishments().get(Category.Hacking)) + { + if (punishment.GetAdmin().equalsIgnoreCase(NAME) && punishment.GetReason().contains("[GWEN]")) + { + totalPunishments++; + } + } + } + + return totalPunishments; + } + + public int getDaysBanned(Player player, Class check) + { + if (check == null) // old banwaves + { + switch (getPunishments(player)) + { + case 0: + return 5; + case 1: + return 14; + case 2: + return 30; + default: + return -1; + } + } + + switch (check.getSimpleName()) + { + default: + switch (getPunishments(player)) + { + case 0: + return 5; + case 1: + return 14; + case 2: + return 30; + default: + return -1; + } + } + } + public void announceBan(Player player) { Bukkit.getServer().broadcastMessage(String.format(USER_HAS_BEEN_BANNED, player.getName())); @@ -433,7 +489,7 @@ public class AntiHack extends MiniPlugin .append("A").color(ChatColor.AQUA).obfuscated(true) .append(" GWEN > ", ComponentBuilder.FormatRetention.NONE).color(ChatColor.RED).bold(true) .append(violation.getPlayerName(), ComponentBuilder.FormatRetention.NONE).color(ChatColor.GOLD) - .append(" failed " + violation.getHackType() + " VL" + violation.getViolations() + " in server", ComponentBuilder.FormatRetention.NONE).color(ChatColor.YELLOW) + .append(" failed " + violation.getHackType() + " VL" + violation.getViolations() + " in server ", ComponentBuilder.FormatRetention.NONE).color(ChatColor.YELLOW) .append(violation.getOriginatingServer(), ComponentBuilder.FormatRetention.NONE).color(ChatColor.YELLOW) .event(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/server " + violation.getOriginatingServer())) .event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/banwave/BanWaveManager.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/banwave/BanWaveManager.java index a4a5476e5..3c3d2a179 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/banwave/BanWaveManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/banwave/BanWaveManager.java @@ -61,7 +61,7 @@ public class BanWaveManager extends MiniPlugin runAsync(() -> { String id = AntiHack.generateId(); - String newMessage = "[GWEN] [BanWave] " + id; + String newMessage = "[GWEN] Cheat Detection (Banwave)\nToken: " + id; CoreClient client = _clientManager.Get(player); From 1390ea1579205ce754ffe1ea9f036b9a9e6441c3 Mon Sep 17 00:00:00 2001 From: samczsun Date: Thu, 27 Apr 2017 12:28:07 -0400 Subject: [PATCH 90/99] Implement triggers --- .../CompromisedAccountManager.java | 44 +++++++++++++------ .../antihack/compedaccount/PriorityCause.java | 7 +++ .../compedaccount/TriggerPriorityInfo.java | 23 ++++++++++ .../nautilus/game/arcade/ArcadeManager.java | 10 +++++ .../arcade/managers/chat/GameChatManager.java | 3 ++ 5 files changed, 74 insertions(+), 13 deletions(-) create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/antihack/compedaccount/PriorityCause.java create mode 100644 Plugins/Mineplex.Core/src/mineplex/core/antihack/compedaccount/TriggerPriorityInfo.java diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/compedaccount/CompromisedAccountManager.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/compedaccount/CompromisedAccountManager.java index cebea5a50..48f092b2e 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/compedaccount/CompromisedAccountManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/compedaccount/CompromisedAccountManager.java @@ -58,19 +58,37 @@ public class CompromisedAccountManager extends MiniPlugin @EventHandler public void onJoin(PlayerJoinEvent event) { - CoreClient coreClient = _clientManager.Get(event.getPlayer()); - PlayerInfo playerInfo = new PlayerInfo( - event.getPlayer().getName(), - coreClient.getName(), - event.getPlayer().getUniqueId(), - coreClient.getAccountId(), - UtilPlayer.getIp(event.getPlayer()) - ); - - JsonObject response = _apiCall.post("api/server/login/" + event.getPlayer().getName(), JsonObject.class, playerInfo); - if (response != null && response.get("error") != null) + runAsync(() -> { - getPlugin().getLogger().log(Level.SEVERE, "Response from Banner: " + response); - } + JsonObject response = _apiCall.post("api/server/login/" + event.getPlayer().getName(), JsonObject.class, getPlayerInfo(event.getPlayer())); + if (response != null && response.get("error") != null) + { + getPlugin().getLogger().log(Level.SEVERE, "Response from Banner: " + response); + } + }); + } + + public void triggerPriorityBan(Player player, PriorityCause cause) + { + runAsync(() -> + { + JsonObject response = _apiCall.post("api/banner/trigger/" + player.getName(), JsonObject.class, new TriggerPriorityInfo(getPlayerInfo(player), cause)); + if (response != null && response.get("error") != null) + { + getPlugin().getLogger().log(Level.SEVERE, "Response from Banner: " + response); + } + }); + } + + private PlayerInfo getPlayerInfo(Player player) + { + CoreClient coreClient = _clientManager.Get(player); + return new PlayerInfo( + player.getName(), + coreClient.getName(), + player.getUniqueId(), + coreClient.getAccountId(), + UtilPlayer.getIp(player) + ); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/compedaccount/PriorityCause.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/compedaccount/PriorityCause.java new file mode 100644 index 000000000..697432b38 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/compedaccount/PriorityCause.java @@ -0,0 +1,7 @@ +package mineplex.core.antihack.compedaccount; + +public enum PriorityCause +{ + JOIN_GAME, + CHAT +} diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/compedaccount/TriggerPriorityInfo.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/compedaccount/TriggerPriorityInfo.java new file mode 100644 index 000000000..aea9654e2 --- /dev/null +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/compedaccount/TriggerPriorityInfo.java @@ -0,0 +1,23 @@ +package mineplex.core.antihack.compedaccount; + +public class TriggerPriorityInfo +{ + private final PlayerInfo _target; + private final PriorityCause _cause; + + public TriggerPriorityInfo(PlayerInfo target, PriorityCause cause) + { + _target = target; + _cause = cause; + } + + public PlayerInfo getTarget() + { + return _target; + } + + public PriorityCause getCause() + { + return _cause; + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java index 20c226a03..6fe776ff3 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/ArcadeManager.java @@ -39,6 +39,8 @@ import mineplex.core.MiniPlugin; import mineplex.core.account.CoreClient; import mineplex.core.account.CoreClientManager; import mineplex.core.achievement.AchievementManager; +import mineplex.core.antihack.compedaccount.CompromisedAccountManager; +import mineplex.core.antihack.compedaccount.PriorityCause; import mineplex.core.blockrestore.BlockRestore; import mineplex.core.blood.Blood; import mineplex.core.bonuses.BonusManager; @@ -262,6 +264,7 @@ public class ArcadeManager extends MiniPlugin implements IRelation public final boolean IsHolidayEnabled; private final Titles _titles; + private final CompromisedAccountManager _compromisedAccountManager = require(CompromisedAccountManager.class); public ArcadeManager(Arcade plugin, ServerStatusManager serverStatusManager, GameServerConfig serverConfig, CoreClientManager clientManager, DonationManager donationManager, DamageManager damageManager, @@ -972,6 +975,8 @@ public class ArcadeManager extends MiniPlugin implements IRelation @EventHandler public void MessageJoin(PlayerJoinEvent event) { + _compromisedAccountManager.triggerPriorityBan(event.getPlayer(), PriorityCause.JOIN_GAME); + if (_incognitoManager.Get(event.getPlayer()).Status) { event.setJoinMessage(null); @@ -2063,4 +2068,9 @@ public class ArcadeManager extends MiniPlugin implements IRelation { return this._titles; } + + public CompromisedAccountManager getCompromisedAccountManager() + { + return _compromisedAccountManager; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/chat/GameChatManager.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/chat/GameChatManager.java index 69e9958d2..a65ffd6cf 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/chat/GameChatManager.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/managers/chat/GameChatManager.java @@ -15,6 +15,7 @@ import org.bukkit.event.player.AsyncPlayerChatEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.jooq.tools.json.JSONObject; +import mineplex.core.antihack.compedaccount.PriorityCause; import mineplex.core.common.Rank; import mineplex.core.common.jsonchat.JsonMessage; import mineplex.core.common.util.C; @@ -67,6 +68,8 @@ public class GameChatManager implements Listener if (event.getMessage().trim().length() == 0) return; + _manager.getCompromisedAccountManager().triggerPriorityBan(event.getPlayer(), PriorityCause.CHAT); + Player sender = event.getPlayer(); String senderName = sender.getName(); From 7658046d621a3eff8c75ab1349a09b86fec160f1 Mon Sep 17 00:00:00 2001 From: samczsun Date: Thu, 27 Apr 2017 12:32:11 -0400 Subject: [PATCH 91/99] Change messages --- Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java | 2 +- .../src/mineplex/core/antihack/banwave/BanWaveManager.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java index 515ab35da..525351b5a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/AntiHack.java @@ -214,7 +214,7 @@ public class AntiHack extends MiniPlugin CoreClient coreClient = _clientManager.Get(player); String id = generateId(); - String finalMessage = "[GWEN] Cheat Detection\nToken: " + id; + String finalMessage = "[GWEN Cheat Detection]\n\nToken: " + id; JsonObject custom = new JsonObject(); custom.addProperty("ban-reason", CheckManager.getCheckSimpleName(cause)); if (gep) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/antihack/banwave/BanWaveManager.java b/Plugins/Mineplex.Core/src/mineplex/core/antihack/banwave/BanWaveManager.java index 3c3d2a179..3eb4506b0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/antihack/banwave/BanWaveManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/antihack/banwave/BanWaveManager.java @@ -61,7 +61,7 @@ public class BanWaveManager extends MiniPlugin runAsync(() -> { String id = AntiHack.generateId(); - String newMessage = "[GWEN] Cheat Detection (Banwave)\nToken: " + id; + String newMessage = "[GWEN Cheat Detection]\n\nToken: " + id; CoreClient client = _clientManager.Get(player); From 5c968890d304fa8ee9a99bb1407b29477675ee28 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 11 May 2017 23:07:46 +0100 Subject: [PATCH 92/99] Just implement logging --- .../loot/rewards/LootChestReward.java | 21 +++----- .../loot/rewards/LootGadgetReward.java | 10 ++-- .../loot/rewards/LootRankReward.java | 5 +- .../loot/rewards/LootShardReward.java | 3 +- .../gemhunters/util/SlackRewardBot.java | 49 +++++++++++++++++++ 5 files changed, 67 insertions(+), 21 deletions(-) create mode 100644 Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/util/SlackRewardBot.java diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/rewards/LootChestReward.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/rewards/LootChestReward.java index 5ef354ec1..323c184f9 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/rewards/LootChestReward.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/rewards/LootChestReward.java @@ -1,5 +1,6 @@ package mineplex.gemhunters.loot.rewards; +import mineplex.gemhunters.util.SlackRewardBot; import org.bukkit.inventory.ItemStack; import mineplex.core.Managers; @@ -10,14 +11,14 @@ public class LootChestReward extends LootItemReward { private final InventoryManager _inventory; - + private final String _chestName; private final int _amount; - + public LootChestReward(long cashOutDelay, ItemStack itemStack, String chestName, int amount) { super(chestName + " Chest", cashOutDelay, itemStack); - + _inventory = Managers.require(InventoryManager.class); _chestName = chestName; _amount = amount; @@ -26,27 +27,19 @@ public class LootChestReward extends LootItemReward @Override public void onCollectItem() { - + } @Override public void onSuccessful() { - _inventory.addItemToInventory(new Callback() - { - - @Override - public void run(Boolean success) - { - //DebugModule.getInstance().d("Success= " + success); - } - }, _player, _chestName + " Chest", _amount); + _inventory.addItemToInventory(success -> SlackRewardBot.logReward(_player, this, success ? "Success" : "Failure"), _player, _chestName + " Chest", _amount); } @Override public void onDeath() { - + } } diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/rewards/LootGadgetReward.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/rewards/LootGadgetReward.java index 59f9db30f..03ba74fe6 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/rewards/LootGadgetReward.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/rewards/LootGadgetReward.java @@ -1,5 +1,9 @@ package mineplex.gemhunters.loot.rewards; +import com.sun.org.apache.xpath.internal.operations.Bool; +import mineplex.core.common.util.Callback; +import mineplex.core.server.util.TransactionResponse; +import mineplex.gemhunters.util.SlackRewardBot; import org.bukkit.inventory.ItemStack; import mineplex.core.Managers; @@ -35,13 +39,11 @@ public class LootGadgetReward extends LootItemReward if (donor.ownsUnknownSalesPackage(_gadget)) { - //DebugModule.getInstance().d("Shard duplicate"); - _donation.rewardCurrencyUntilSuccess(GlobalCurrency.TREASURE_SHARD, _player, "Earned", (int) (500 + 1000 * Math.random())); + _donation.rewardCurrencyUntilSuccess(GlobalCurrency.TREASURE_SHARD, _player, "Earned", (int) (500 + 1000 * Math.random()), success -> SlackRewardBot.logReward(_player, this, (success ? "Success" : "Failure") + " (Shard Dupe)")); } else { - //DebugModule.getInstance().d("Adding gadget"); - _donation.purchaseUnknownSalesPackage(_player, _gadget, GlobalCurrency.TREASURE_SHARD, 0, true, null); + _donation.purchaseUnknownSalesPackage(_player, _gadget, GlobalCurrency.TREASURE_SHARD, 0, true, transaction -> SlackRewardBot.logReward(_player, this, transaction == TransactionResponse.Success ? "Success" : "Failure")); } } diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/rewards/LootRankReward.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/rewards/LootRankReward.java index 58ae67fb3..e0e592fd3 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/rewards/LootRankReward.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/rewards/LootRankReward.java @@ -2,6 +2,7 @@ package mineplex.gemhunters.loot.rewards; import java.util.concurrent.TimeUnit; +import mineplex.gemhunters.util.SlackRewardBot; import org.bukkit.inventory.ItemStack; import mineplex.core.Managers; @@ -70,11 +71,11 @@ public class LootRankReward extends LootItemReward if (newRank == null) { _player.sendMessage(F.main("Loot", "Since you already have eternal ( You are lucky :) ). So instead you can have " + CONSOLATION_PRICE + " shards.")); - _donation.rewardCurrencyUntilSuccess(GlobalCurrency.TREASURE_SHARD, _player, "Earned", CONSOLATION_PRICE); + _donation.rewardCurrencyUntilSuccess(GlobalCurrency.TREASURE_SHARD, _player, "Earned", CONSOLATION_PRICE, success -> SlackRewardBot.logReward(_player, this, (success ? "Success" : "Failure") + " (Shard Dupe)")); return; } - _clientManager.SaveRank(_player.getName(), _player.getUniqueId(), newRank, true); + _clientManager.SaveRank(callback -> SlackRewardBot.logReward(_player, this, callback.Name), _player.getName(), _player.getUniqueId(), newRank, true); } @Override diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/rewards/LootShardReward.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/rewards/LootShardReward.java index af1119a73..458e577e1 100644 --- a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/rewards/LootShardReward.java +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/loot/rewards/LootShardReward.java @@ -1,5 +1,6 @@ package mineplex.gemhunters.loot.rewards; +import mineplex.gemhunters.util.SlackRewardBot; import org.bukkit.inventory.ItemStack; import mineplex.core.Managers; @@ -30,7 +31,7 @@ public class LootShardReward extends LootItemReward @Override public void onSuccessful() { - _donation.rewardCurrencyUntilSuccess(GlobalCurrency.TREASURE_SHARD, _player, "Earned", _amount); + _donation.rewardCurrencyUntilSuccess(GlobalCurrency.TREASURE_SHARD, _player, "Earned", _amount, success -> SlackRewardBot.logReward(_player, this, success ? "Success" : "Failure")); } @Override diff --git a/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/util/SlackRewardBot.java b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/util/SlackRewardBot.java new file mode 100644 index 000000000..8544e411b --- /dev/null +++ b/Plugins/mineplex-game-gemhunters/src/mineplex/gemhunters/util/SlackRewardBot.java @@ -0,0 +1,49 @@ +package mineplex.gemhunters.util; + +import mineplex.core.Managers; +import mineplex.core.common.util.UtilServer; +import mineplex.core.monitor.LagMeter; +import mineplex.core.slack.SlackAPI; +import mineplex.core.slack.SlackMessage; +import mineplex.core.slack.SlackTeam; +import mineplex.gemhunters.loot.rewards.LootItemReward; +import org.bukkit.entity.Player; + +import java.net.MalformedURLException; +import java.net.URL; +import java.text.DecimalFormat; + +public class SlackRewardBot +{ + + private static final DecimalFormat FORMAT = new DecimalFormat("0.0"); + private static final String SLACK_CHANNEL_NAME = "#gem-hunters-logging"; + private static final String SLACK_USERNAME = "Gem Hunters"; + private static final String SLACK_ICON = "http://moppletop.github.io/mineplex/chest-image.png"; + + private static LagMeter _lag; + + public static void logReward(Player player, LootItemReward reward, String status) + { + if (_lag == null) + { + _lag = Managers.get(LagMeter.class); + } + + try + { + SlackAPI.getInstance().sendMessage(SlackTeam.DEVELOPER, SLACK_CHANNEL_NAME, new SlackMessage(SLACK_USERNAME, new URL(SLACK_ICON), + "Rewarding a " + reward.getClass().getSimpleName() + + "\nName: " + reward.getItemStack().getItemMeta().getDisplayName() + + "\nPlayer: " + player.getName() + + "\nStatus: *" + status + "*" + + "\nServer: " + UtilServer.getServerName() + + "\nTPS: " + FORMAT.format(_lag.getTicksPerSecond())), + true); + } + catch (MalformedURLException e) + { + } + } + +} \ No newline at end of file From 7b7b91ed3ffac491c13865bd70315c522978a08c Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Fri, 12 May 2017 00:47:11 -0400 Subject: [PATCH 93/99] Fix small gameplay issues and update kit selection data points for TDM --- .../games/castleassault/CastleAssault.java | 24 +++++++++++-- .../games/castleassault/CastleAssaultTDM.java | 35 +++++++++++++------ 2 files changed, 45 insertions(+), 14 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java index c1d2a7f0e..4df26278e 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java @@ -820,7 +820,7 @@ public class CastleAssault extends TeamGame @SuppressWarnings("deprecation") @EventHandler(ignoreCancelled=true) - public void onPlayerEmptyBucket(PlayerBucketFillEvent event) + public void onPlayerFillBucket(PlayerBucketFillEvent event) { if (!IsLive()) { @@ -828,10 +828,10 @@ public class CastleAssault extends TeamGame } Player player = event.getPlayer(); - if (player.getItemInHand().getType() == Material.LAVA_BUCKET) + Block block = event.getBlockClicked().getRelative(event.getBlockFace()); + if (block.getType() == Material.LAVA || block.getType() == Material.STATIONARY_LAVA) { event.setCancelled(true); - Block block = event.getBlockClicked().getRelative(event.getBlockFace()); player.sendBlockChange(block.getLocation(), block.getType(), block.getData()); } } @@ -1117,6 +1117,11 @@ public class CastleAssault extends TeamGame { return; } + if (Manager.GetLobby().getKits().containsKey(event.getEntity())) + { + event.setCancelled(true); + return; + } if (event.getEntity() instanceof EnderCrystal) { event.setCancelled(true); @@ -1127,6 +1132,10 @@ public class CastleAssault extends TeamGame event.setCancelled(true); if (event instanceof EntityDamageByEntityEvent) { + if (!event.getEntity().getCustomName().contains("Ryan") && !event.getEntity().getCustomName().contains("Jon")) + { + return; + } GameTeam owner = event.getEntity().getCustomName().contains("Ryan") ? GetTeam(ChatColor.AQUA) : GetTeam(ChatColor.RED); EntityDamageByEntityEvent e = (EntityDamageByEntityEvent) event; if (e.getDamager() instanceof Player) @@ -1353,6 +1362,11 @@ public class CastleAssault extends TeamGame { return; } + + Bukkit.getOnlinePlayers().forEach(player -> + { + player.getInventory().remove(_wearableTnt.build()); + }); Iterator tntIterator = _tntCarry.iterator(); @@ -1406,6 +1420,10 @@ public class CastleAssault extends TeamGame UtilTextBottom.display(GetTeam(player).GetColor() + player.getName() + " has the TNT!", UtilServer.getPlayers()); UtilFirework.playFirework(player.getEyeLocation(), Type.BURST, Color.RED, false, false); + if (player.getInventory().getHelmet() == null || player.getInventory().getHelmet().getType() != Material.TNT) + { + player.getInventory().setHelmet(_wearableTnt.build()); + } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssaultTDM.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssaultTDM.java index e9bfa88d6..e83f12804 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssaultTDM.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssaultTDM.java @@ -29,6 +29,7 @@ import org.bukkit.event.block.BlockFadeEvent; import org.bukkit.event.block.BlockFormEvent; import org.bukkit.event.block.BlockFromToEvent; import org.bukkit.event.block.LeavesDecayEvent; +import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.ExplosionPrimeEvent; import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.entity.ProjectileHitEvent; @@ -307,16 +308,14 @@ public class CastleAssaultTDM extends TeamGame GameTeam blue = GetTeam(ChatColor.AQUA); _teamKills.put(blue, 0); this.CreatureAllowOverride = true; - int kitIndex = 0; - for (int i = 0; i < WorldData.GetDataLocs("WHITE").size(); i++) + for (Kit kit : GetKits()) { - if (kitIndex >= GetKits().length) + List spawns = WorldData.GetCustomLocs(kit.GetName().toUpperCase()); + for (Location spawn : spawns) { - kitIndex = 0; + Entity ent = kit.SpawnEntity(spawn); + Manager.GetLobby().addKitLocation(ent, kit, spawn); } - Entity ent = GetKits()[kitIndex].SpawnEntity(WorldData.GetDataLocs("WHITE").get(i)); - Manager.GetLobby().addKitLocation(ent, GetKits()[kitIndex], WorldData.GetDataLocs("WHITE").get(i)); - kitIndex++; } this.CreatureAllowOverride = false; } @@ -711,18 +710,18 @@ public class CastleAssaultTDM extends TeamGame @SuppressWarnings("deprecation") @EventHandler(ignoreCancelled=true) - public void onPlayerEmptyBucket(PlayerBucketFillEvent event) + public void onPlayerFillBucket(PlayerBucketFillEvent event) { if (!IsLive()) { return; } - + Player player = event.getPlayer(); - if (player.getItemInHand().getType() == Material.LAVA_BUCKET) + Block block = event.getBlockClicked().getRelative(event.getBlockFace()); + if (block.getType() == Material.LAVA || block.getType() == Material.STATIONARY_LAVA) { event.setCancelled(true); - Block block = event.getBlockClicked().getRelative(event.getBlockFace()); player.sendBlockChange(block.getLocation(), block.getType(), block.getData()); } } @@ -1068,4 +1067,18 @@ public class CastleAssaultTDM extends TeamGame _streakData.getOrDefault(player, new KillStreakData()).reset(); } + + @EventHandler(ignoreCancelled = true) + public void onDamage(EntityDamageEvent event) + { + if (!IsLive()) + { + return; + } + if (Manager.GetLobby().getKits().containsKey(event.getEntity())) + { + event.setCancelled(true); + return; + } + } } \ No newline at end of file From 35ed1099f9246f96d25314e7e66c69e54262a175 Mon Sep 17 00:00:00 2001 From: Dan Mulloy Date: Fri, 12 May 2017 13:50:14 -0500 Subject: [PATCH 94/99] Avoid instantiating HologramManager twice --- Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java index 3421cb3d8..a4b0a0b88 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/Hub.java @@ -184,7 +184,7 @@ public class Hub extends JavaPlugin implements IRelation String boosterGroup = serverConfiguration.getServerGroup().getBoosterGroup(); ThankManager thankManager = new ThankManager(this, clientManager, donationManager); BoosterManager boosterManager = new BoosterManager(this, boosterGroup, clientManager, donationManager, inventoryManager, thankManager); - HubManager hubManager = new HubManager(this, blockRestore, clientManager, incognito, donationManager, inventoryManager, conditionManager, disguiseManager, new TaskManager(this, clientManager), portal, partyManager, preferenceManager, petManager, pollManager, statsManager, achievementManager, new HologramManager(this, packetHandler), npcManager, personalServerManager, packetHandler, punish, serverStatusManager, customDataManager, thankManager, boosterManager, castleManager); + HubManager hubManager = new HubManager(this, blockRestore, clientManager, incognito, donationManager, inventoryManager, conditionManager, disguiseManager, new TaskManager(this, clientManager), portal, partyManager, preferenceManager, petManager, pollManager, statsManager, achievementManager, hologramManager, npcManager, personalServerManager, packetHandler, punish, serverStatusManager, customDataManager, thankManager, boosterManager, castleManager); QueueManager queueManager = new QueueManager(this, clientManager, donationManager, eloManager, partyManager); ServerManager serverManager = new ServerManager(this, clientManager, donationManager, portal, partyManager, serverStatusManager, hubManager, queueManager, boosterManager); From 130d1dc05e63f791b2b3f4e39e6ec39aea633df3 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Fri, 12 May 2017 15:07:48 -0400 Subject: [PATCH 95/99] Fix TNT being stuck on head --- .../game/arcade/game/games/castleassault/CastleAssault.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java index 4df26278e..f746e3301 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java @@ -1420,7 +1420,7 @@ public class CastleAssault extends TeamGame UtilTextBottom.display(GetTeam(player).GetColor() + player.getName() + " has the TNT!", UtilServer.getPlayers()); UtilFirework.playFirework(player.getEyeLocation(), Type.BURST, Color.RED, false, false); - if (player.getInventory().getHelmet() == null || player.getInventory().getHelmet().getType() != Material.TNT) + if (player.getInventory().getHelmet() == null || player.getInventory().getHelmet().getType() == Material.AIR) { player.getInventory().setHelmet(_wearableTnt.build()); } From ea4f9aee62e07d0d3881cf40a902c966f8784ed8 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Fri, 12 May 2017 16:07:43 -0400 Subject: [PATCH 96/99] Tweak crown kill streak multipliers --- .../games/castleassault/CastleAssault.java | 39 ++++++------------- 1 file changed, 12 insertions(+), 27 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java index f746e3301..54ba4fa72 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java @@ -455,27 +455,22 @@ public class CastleAssault extends TeamGame } { - int crowns = 0; - for (GemData data : GetGems(player).values()) - { - crowns += data.Gems; - } int streak = _streakData.getOrDefault(player, new KillStreakData()).getBestStreak(); if (streak >= 2 && streak < 4) { - AddGems(player, 0.5 * crowns, streak + " Player Kill Streak", false, false); + AddGems(player, 10, streak + " Player Kill Streak", false, false); } else if (streak >= 4 && streak < 6) { - AddGems(player, crowns, streak + " Player Kill Streak", false, false); + AddGems(player, 15, streak + " Player Kill Streak", false, false); } else if (streak >= 6 && streak < 8) { - AddGems(player, 1.5 * crowns, streak + " Player Kill Streak", false, false); + AddGems(player, 20, streak + " Player Kill Streak", false, false); } else if (streak >= 8) { - AddGems(player, 2 * crowns, streak + " Player Kill Streak", false, false); + AddGems(player, 25, streak + " Player Kill Streak", false, false); } } @@ -553,27 +548,22 @@ public class CastleAssault extends TeamGame } { - int crowns = 0; - for (GemData data : GetGems(player).values()) - { - crowns += data.Gems; - } int streak = _streakData.getOrDefault(player, new KillStreakData()).getBestStreak(); if (streak >= 2 && streak < 4) { - AddGems(player, 0.5 * crowns, streak + " Player Kill Streak", false, false); + AddGems(player, 10, streak + " Player Kill Streak", false, false); } else if (streak >= 4 && streak < 6) { - AddGems(player, crowns, streak + " Player Kill Streak", false, false); + AddGems(player, 15, streak + " Player Kill Streak", false, false); } else if (streak >= 6 && streak < 8) { - AddGems(player, 1.5 * crowns, streak + " Player Kill Streak", false, false); + AddGems(player, 20, streak + " Player Kill Streak", false, false); } else if (streak >= 8) { - AddGems(player, 2 * crowns, streak + " Player Kill Streak", false, false); + AddGems(player, 25, streak + " Player Kill Streak", false, false); } } @@ -621,27 +611,22 @@ public class CastleAssault extends TeamGame } { - int crowns = 0; - for (GemData data : GetGems(player).values()) - { - crowns += data.Gems; - } int streak = _streakData.getOrDefault(player, new KillStreakData()).getBestStreak(); if (streak >= 2 && streak < 4) { - AddGems(player, 0.5 * crowns, streak + " Player Kill Streak", false, false); + AddGems(player, 10, streak + " Player Kill Streak", false, false); } else if (streak >= 4 && streak < 6) { - AddGems(player, crowns, streak + " Player Kill Streak", false, false); + AddGems(player, 15, streak + " Player Kill Streak", false, false); } else if (streak >= 6 && streak < 8) { - AddGems(player, 1.5 * crowns, streak + " Player Kill Streak", false, false); + AddGems(player, 20, streak + " Player Kill Streak", false, false); } else if (streak >= 8) { - AddGems(player, 2 * crowns, streak + " Player Kill Streak", false, false); + AddGems(player, 25, streak + " Player Kill Streak", false, false); } } From a42e6ed9e46ade1dcd9424ab006effad284334d9 Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Fri, 12 May 2017 18:44:05 -0400 Subject: [PATCH 97/99] Change crown calculations again --- .../games/castleassault/CastleAssault.java | 47 ++++++++++--------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java index 54ba4fa72..54e71d589 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java @@ -454,23 +454,29 @@ public class CastleAssault extends TeamGame AddGems(player, 10, "Participation", false, false); } + int crowns = 0; + for (GemData data : GetGems(player).values()) + { + crowns += data.Gems; + } + { int streak = _streakData.getOrDefault(player, new KillStreakData()).getBestStreak(); if (streak >= 2 && streak < 4) { - AddGems(player, 10, streak + " Player Kill Streak", false, false); + AddGems(player, 0.5 * crowns, streak + " Player Kill Streak", false, false); } else if (streak >= 4 && streak < 6) { - AddGems(player, 15, streak + " Player Kill Streak", false, false); + AddGems(player, 1 * crowns, streak + " Player Kill Streak", false, false); } else if (streak >= 6 && streak < 8) { - AddGems(player, 20, streak + " Player Kill Streak", false, false); + AddGems(player, 1.5 * crowns, streak + " Player Kill Streak", false, false); } else if (streak >= 8) { - AddGems(player, 25, streak + " Player Kill Streak", false, false); + AddGems(player, 2 * crowns, streak + " Player Kill Streak", false, false); } } @@ -480,12 +486,6 @@ public class CastleAssault extends TeamGame int kitLevel = kit.getUpgradeLevel(player.getUniqueId()); if (kitLevel > 0) { - int crowns = 0; - for (GemData data : GetGems(player).values()) - { - crowns += data.Gems; - } - AddGems(player, (0.5 * kitLevel) * crowns, kit.GetName() + " Kit Level Bonus", false, false); } } @@ -547,37 +547,40 @@ public class CastleAssault extends TeamGame AddGems(player, 10, "Participation", false, false); } + int crowns = 0; + for (GemData data : GetGems(player).values()) + { + crowns += data.Gems; + } + { int streak = _streakData.getOrDefault(player, new KillStreakData()).getBestStreak(); if (streak >= 2 && streak < 4) { - AddGems(player, 10, streak + " Player Kill Streak", false, false); + AddGems(player, 0.5 * crowns, streak + " Player Kill Streak", false, false); } else if (streak >= 4 && streak < 6) { - AddGems(player, 15, streak + " Player Kill Streak", false, false); + AddGems(player, 1 * crowns, streak + " Player Kill Streak", false, false); } else if (streak >= 6 && streak < 8) { - AddGems(player, 20, streak + " Player Kill Streak", false, false); + AddGems(player, 1.5 * crowns, streak + " Player Kill Streak", false, false); } else if (streak >= 8) { - AddGems(player, 25, streak + " Player Kill Streak", false, false); + AddGems(player, 2 * crowns, streak + " Player Kill Streak", false, false); } } - KitPlayer kit = (KitPlayer) GetKit(player); - int kitLevel = kit.getUpgradeLevel(player.getUniqueId()); - if (kitLevel > 0) + if (GetKit(player) != null) { - int crowns = 0; - for (GemData data : GetGems(player).values()) + KitPlayer kit = (KitPlayer) GetKit(player); + int kitLevel = kit.getUpgradeLevel(player.getUniqueId()); + if (kitLevel > 0) { - crowns += data.Gems; + AddGems(player, (0.5 * kitLevel) * crowns, kit.GetName() + " Kit Level Bonus", false, false); } - - AddGems(player, (0.5 * kitLevel) * crowns, kit.GetName() + " Kit Level Bonus", false, false); } } } From 37d3b47995791ef57917df468e0acb35bf1abe8a Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sat, 13 May 2017 01:00:10 -0400 Subject: [PATCH 98/99] Rebalance tank kit and set final values for kill streak crown rewards --- .../games/castleassault/CastleAssault.java | 68 +++++++------------ .../games/castleassault/kits/KitTank.java | 17 ++--- 2 files changed, 32 insertions(+), 53 deletions(-) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java index 54e71d589..f4ed36446 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/CastleAssault.java @@ -6,11 +6,11 @@ import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.Map.Entry; import java.util.WeakHashMap; import org.bukkit.Bukkit; import org.bukkit.ChatColor; -import org.bukkit.Color; import org.bukkit.FireworkEffect.Type; import org.bukkit.Location; import org.bukkit.Material; @@ -455,9 +455,12 @@ public class CastleAssault extends TeamGame } int crowns = 0; - for (GemData data : GetGems(player).values()) + for (Entry data : GetGems(player).entrySet()) { - crowns += data.Gems; + if (data.getKey().equals("Kills")) + { + crowns += data.getValue().Gems; + } } { @@ -479,16 +482,6 @@ public class CastleAssault extends TeamGame AddGems(player, 2 * crowns, streak + " Player Kill Streak", false, false); } } - - if (GetKit(player) != null) - { - KitPlayer kit = (KitPlayer) GetKit(player); - int kitLevel = kit.getUpgradeLevel(player.getUniqueId()); - if (kitLevel > 0) - { - AddGems(player, (0.5 * kitLevel) * crowns, kit.GetName() + " Kit Level Bonus", false, false); - } - } } } SetState(GameState.End); @@ -548,9 +541,12 @@ public class CastleAssault extends TeamGame } int crowns = 0; - for (GemData data : GetGems(player).values()) + for (Entry data : GetGems(player).entrySet()) { - crowns += data.Gems; + if (data.getKey().equals("Kills")) + { + crowns += data.getValue().Gems; + } } { @@ -572,16 +568,6 @@ public class CastleAssault extends TeamGame AddGems(player, 2 * crowns, streak + " Player Kill Streak", false, false); } } - - if (GetKit(player) != null) - { - KitPlayer kit = (KitPlayer) GetKit(player); - int kitLevel = kit.getUpgradeLevel(player.getUniqueId()); - if (kitLevel > 0) - { - AddGems(player, (0.5 * kitLevel) * crowns, kit.GetName() + " Kit Level Bonus", false, false); - } - } } } SetState(GameState.End); @@ -613,38 +599,34 @@ public class CastleAssault extends TeamGame AddGems(player, 10, "Participation", false, false); } + int crowns = 0; + for (Entry data : GetGems(player).entrySet()) + { + if (data.getKey().equals("Kills")) + { + crowns += data.getValue().Gems; + } + } + { int streak = _streakData.getOrDefault(player, new KillStreakData()).getBestStreak(); if (streak >= 2 && streak < 4) { - AddGems(player, 10, streak + " Player Kill Streak", false, false); + AddGems(player, 0.5 * crowns, streak + " Player Kill Streak", false, false); } else if (streak >= 4 && streak < 6) { - AddGems(player, 15, streak + " Player Kill Streak", false, false); + AddGems(player, 1 * crowns, streak + " Player Kill Streak", false, false); } else if (streak >= 6 && streak < 8) { - AddGems(player, 20, streak + " Player Kill Streak", false, false); + AddGems(player, 1.5 * crowns, streak + " Player Kill Streak", false, false); } else if (streak >= 8) { - AddGems(player, 25, streak + " Player Kill Streak", false, false); + AddGems(player, 2 * crowns, streak + " Player Kill Streak", false, false); } } - - KitPlayer kit = (KitPlayer) GetKit(player); - int kitLevel = kit.getUpgradeLevel(player.getUniqueId()); - if (kitLevel > 0) - { - int crowns = 0; - for (GemData data : GetGems(player).values()) - { - crowns += data.Gems; - } - - AddGems(player, (0.5 * kitLevel) * crowns, kit.GetName() + " Kit Level Bonus", false, false); - } } } SetState(GameState.End); @@ -1407,7 +1389,7 @@ public class CastleAssault extends TeamGame } UtilTextBottom.display(GetTeam(player).GetColor() + player.getName() + " has the TNT!", UtilServer.getPlayers()); - UtilFirework.playFirework(player.getEyeLocation(), Type.BURST, Color.RED, false, false); + UtilFirework.playFirework(player.getEyeLocation(), Type.BURST, GetTeam(player).GetColorBase(), false, false); if (player.getInventory().getHelmet() == null || player.getInventory().getHelmet().getType() == Material.AIR) { player.getInventory().setHelmet(_wearableTnt.build()); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitTank.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitTank.java index 710781ebc..c6b01406f 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitTank.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/castleassault/kits/KitTank.java @@ -14,7 +14,6 @@ import mineplex.core.itemstack.ItemBuilder; import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.kit.KitAvailability; import nautilus.game.arcade.kit.Perk; -import nautilus.game.arcade.kit.perks.PerkIronSkin; public class KitTank extends KitPlayer { @@ -26,18 +25,16 @@ public class KitTank extends KitPlayer C.cGrayB + "Starting Kit:", C.cGray + "Diamond Sword", C.cGray + "Diamond Helmet, Iron Chestplate, Iron Leggings, Diamond Boots", - C.cGray + "Protection I on Iron Armor", - C.cGreenB + "Passive Ability:", - C.cGreen + "Iron Skin: Take half a heart less damage from all Attacks" + C.cGray + "Protection I on Iron Armor" }, new Perk[][] { - new Perk[] {new PerkIronSkin(1, false)}, - new Perk[] {new PerkIronSkin(1, false)}, - new Perk[] {new PerkIronSkin(1, false)}, - new Perk[] {new PerkIronSkin(1, false)}, - new Perk[] {new PerkIronSkin(1, false)}, - new Perk[] {new PerkIronSkin(1, false)} + new Perk[] {}, + new Perk[] {}, + new Perk[] {}, + new Perk[] {}, + new Perk[] {}, + new Perk[] {} }, new String[][] { From 9cf5fda540ff1b553e34cd42e9a41cdcc2169dfb Mon Sep 17 00:00:00 2001 From: AlexTheCoder Date: Sat, 13 May 2017 01:02:06 -0400 Subject: [PATCH 99/99] Update leaderboards system to use more malleable seasons system --- .../leaderboard/LeaderboardRepository.java | 54 ++++--------------- 1 file changed, 11 insertions(+), 43 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardRepository.java index 866a1e5b7..f9b286039 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/leaderboard/LeaderboardRepository.java @@ -18,27 +18,25 @@ import mineplex.serverdata.database.RepositoryBase; public class LeaderboardRepository extends RepositoryBase { - private static final int SEASON = 1; - - private static final String CREATE_TOTAL = "CREATE TABLE accountStatsSeasonalTotal (accountId INT NOT NULL, statId INT NOT NULL, season SMALLINT NOT NULL, value BIGINT NOT NULL, PRIMARY KEY (accountId, statId, season), INDEX valueIndex (value DESC), FOREIGN KEY (accountId) REFERENCES accounts(id), FOREIGN KEY (statId) REFERENCES stats(id));"; + private static final String CREATE_TOTAL = "CREATE TABLE accountStatsAllTime (accountId INT NOT NULL, statId INT NOT NULL, value BIGINT NOT NULL, PRIMARY KEY (accountId, statId), INDEX valueIndex (value DESC), FOREIGN KEY (accountId) REFERENCES accounts(id), FOREIGN KEY (statId) REFERENCES stats(id));"; + private static final String CREATE_SEASONAL = "CREATE TABLE accountStatsSeasonal (accountId INT NOT NULL, statId INT NOT NULL, seasonId SMALLINT NOT NULL, value BIGINT NOT NULL, PRIMARY KEY (accountId, statId), INDEX valueIndex (value DESC), INDEX seasonIndex (seasonId), FOREIGN KEY (accountId) REFERENCES accounts(id), FOREIGN KEY (statId) REFERENCES stats(id), FOREIGN KEY (seasonId) REFERENCES statSeasons(id));"; private static final String CREATE_YEARLY = "CREATE TABLE accountStatsYearly (accountId INT NOT NULL, statId INT NOT NULL, date DATE NOT NULL, value BIGINT NOT NULL, PRIMARY KEY (accountId, statId), INDEX valueIndex (value DESC), INDEX dateIndex (date), FOREIGN KEY (accountId) REFERENCES accounts(id), FOREIGN KEY (statId) REFERENCES stats(id));"; private static final String CREATE_MONTHLY = "CREATE TABLE accountStatsMonthly (accountId INT NOT NULL, statId INT NOT NULL, date DATE NOT NULL, value BIGINT NOT NULL, PRIMARY KEY (accountId, statId), INDEX valueIndex (value DESC), INDEX dateIndex (date), FOREIGN KEY (accountId) REFERENCES accounts(id), FOREIGN KEY (statId) REFERENCES stats(id));"; private static final String CREATE_WEEKLY = "CREATE TABLE accountStatsWeekly (accountId INT NOT NULL, statId INT NOT NULL, date DATE NOT NULL, value BIGINT NOT NULL, PRIMARY KEY (accountId, statId), INDEX valueIndex (value DESC), INDEX dateIndex (date), FOREIGN KEY (accountId) REFERENCES accounts(id), FOREIGN KEY (statId) REFERENCES stats(id));"; private static final String CREATE_DAILY = "CREATE TABLE accountStatsDaily (accountId INT NOT NULL, statId INT NOT NULL, date DATE NOT NULL, value BIGINT NOT NULL, PRIMARY KEY (accountId, statId), INDEX valueIndex (value DESC), INDEX dateIndex (date), FOREIGN KEY (accountId) REFERENCES accounts(id), FOREIGN KEY (statId) REFERENCES stats(id));"; + private static final String CREATE_SEASON = "CREATE TABLE statSeasons (id SMALLINT NOT NULL, seasonName VARCHAR(50) NOT NULL, startDate TIMESTAMP NOT NULL DEFAULT '1969-12-31 18:00:01', endDate TIMESTAMP NOT NULL DEFAULT '1969-12-31 18:00:01', PRIMARY KEY (id), UNIQUE INDEX seasonIndex (seasonName), INDEX startIndex (startDate), INDEX endIndex (endDate));"; - private static final String INSERT_STAT = "INSERT INTO accountStatsSeasonalTotal (accountId, statId, season, value) VALUES (?, ?, " + SEASON + ", ?);"; - private static final String INSERT_STAT_ALL = "INSERT INTO accountStatsSeasonalTotal (accountId, statId, season, value) VALUES (?, ?, 0, ?);"; - private static final String UPDATE_STAT = "UPDATE accountStatsSeasonalTotal SET value=value + ? WHERE accountId=? AND statId=? AND season=" + SEASON + ";"; - private static final String UPDATE_STAT_ALL = "UPDATE accountStatsSeasonalTotal SET value=value + ? WHERE accountId=? AND statId=? AND season=0;"; + private static final String INSERT_STAT = "INSERT INTO accountStatsAllTime (accountId, statId, value) VALUES (?, ?, ?);"; + private static final String UPDATE_STAT = "UPDATE accountStatsAllTime SET value=value + ? WHERE accountId=? AND statId=?;"; - private static final String FETCH_STAT_ALL = "SELECT a.name, sl.value FROM accountStatsSeasonalTotal AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE sl.statId=%STAT% AND season=0 ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; + private static final String FETCH_STAT_ALL = "SELECT a.name, sl.value FROM accountStatsAllTime AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE sl.statId=%STAT% ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; private static final String FETCH_STAT_YEARLY = "SELECT a.name, sl.value FROM accountStatsYearly AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE YEAR(sl.date) = YEAR(CURDATE()) AND sl.statId=%STAT% ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; private static final String FETCH_STAT_MONTHLY = "SELECT a.name, sl.value FROM accountStatsMonthly AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE MONTH(sl.date) = MONTH(CURDATE()) AND YEAR(sl.date) = YEAR(CURDATE()) AND sl.statId=%STAT% ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; private static final String FETCH_STAT_WEEKLY = "SELECT a.name, sl.value FROM accountStatsWeekly AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE YEARWEEK(sl.date, 1) = YEARWEEK(CURDATE(), 1) AND sl.statId=%STAT% ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; private static final String FETCH_STAT_DAILY = "SELECT a.name, sl.value FROM accountStatsDaily AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE sl.date = CURDATE() AND sl.statId=%STAT% ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; - private static final String FETCH_STAT_ALL_SEASON = "SELECT a.name, sl.value FROM accountStatsSeasonalTotal AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE sl.statId=%STAT% AND season=" + SEASON + " ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; + private static final String FETCH_STAT_ALL_SEASON = "SELECT a.name, sl.value FROM accountStatsSeasonal AS sl INNER JOIN accounts AS a ON a.id=sl.accountId WHERE sl.statId=%STAT% AND seasonId=(SELECT id FROM statSeasons WHERE now() BETWEEN startDate AND endDate LIMIT 1) ORDER BY sl.value DESC LIMIT %START%,%LIMIT%;"; public LeaderboardRepository(JavaPlugin plugin) { @@ -52,9 +50,7 @@ public class LeaderboardRepository extends RepositoryBase try ( Connection c = getConnection(); PreparedStatement updateStat = c.prepareStatement(UPDATE_STAT); - PreparedStatement updateAllStats = c.prepareStatement(UPDATE_STAT_ALL); PreparedStatement insertStat = c.prepareStatement(INSERT_STAT); - PreparedStatement insertAllStats = c.prepareStatement(INSERT_STAT_ALL); ) { for (Integer accountId : stats.keySet()) @@ -65,38 +61,25 @@ public class LeaderboardRepository extends RepositoryBase updateStat.setInt(2, accountId); updateStat.setInt(3, statId); updateStat.addBatch(); - updateAllStats.setLong(1, stats.get(accountId).get(statId)); - updateAllStats.setInt(2, accountId); - updateAllStats.setInt(3, statId); - updateAllStats.addBatch(); } } - int[] rowsAffected1 = updateStat.executeBatch(); - int[] rowsAffected2 = updateAllStats.executeBatch(); + int[] rowsAffected = updateStat.executeBatch(); int i = 0; for (Integer accountId : stats.keySet()) { for (Integer statId : stats.get(accountId).keySet()) { - if (rowsAffected1[i] < 1) + if (rowsAffected[i] < 1) { insertStat.setInt(1, accountId); insertStat.setInt(2, statId); insertStat.setLong(3, stats.get(accountId).get(statId)); insertStat.addBatch(); } - if (rowsAffected2[i] < 1) - { - insertAllStats.setInt(1, accountId); - insertAllStats.setInt(2, statId); - insertAllStats.setLong(3, stats.get(accountId).get(statId)); - insertAllStats.addBatch(); - } i++; } } insertStat.executeBatch(); - insertAllStats.executeBatch(); } catch (SQLException e) { @@ -110,9 +93,7 @@ public class LeaderboardRepository extends RepositoryBase try ( Connection c = getConnection(); PreparedStatement updateStat = c.prepareStatement(UPDATE_STAT); - PreparedStatement updateAllStats = c.prepareStatement(UPDATE_STAT_ALL); PreparedStatement insertStat = c.prepareStatement(INSERT_STAT); - PreparedStatement insertAllStats = c.prepareStatement(INSERT_STAT_ALL); ) { for (Integer statId : stats.keySet()) @@ -121,34 +102,21 @@ public class LeaderboardRepository extends RepositoryBase updateStat.setInt(2, accountId); updateStat.setInt(3, statId); updateStat.addBatch(); - updateAllStats.setLong(1, stats.get(statId)); - updateAllStats.setInt(2, accountId); - updateAllStats.setInt(3, statId); - updateAllStats.addBatch(); } - int[] rowsAffected1 = updateStat.executeBatch(); - int[] rowsAffected2 = updateAllStats.executeBatch(); + int[] rowsAffected = updateStat.executeBatch(); int i = 0; for (Integer statId : stats.keySet()) { - if (rowsAffected1[i] < 1) + if (rowsAffected[i] < 1) { insertStat.setInt(1, accountId); insertStat.setInt(2, statId); insertStat.setLong(3, stats.get(statId)); insertStat.addBatch(); } - if (rowsAffected2[i] < 1) - { - insertAllStats.setInt(1, accountId); - insertAllStats.setInt(2, statId); - insertAllStats.setLong(3, stats.get(statId)); - insertAllStats.addBatch(); - } i++; } insertStat.executeBatch(); - insertAllStats.executeBatch(); } catch (SQLException e) {