From 37f1f7eabbe8f24543423f8bf9f7ea4d38e53ebd Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Fri, 1 May 2015 17:46:42 -0500 Subject: [PATCH 1/4] Master Builders changes for chiss --- .../artifacts/Mineplex_Game_Clans_jar.xml | 2 +- .../artifacts/Nautilus_Game_Arcade_jar.xml | 2 +- Plugins/.idea/misc.xml | 3 - .../core/common/util/UtilParticle.java | 113 ++++++++++++------ .../game/arcade/game/games/build/Build.java | 73 +++++++++++ .../arcade/game/games/build/BuildData.java | 7 +- .../game/games/build/gui/OptionsShop.java | 28 +++++ .../games/build/gui/page/OptionsMenu.java | 62 ++++++++++ .../games/build/gui/page/ParticlesPage.java | 86 +++++++++++++ .../game/games/build/gui/page/TimePage.java | 69 +++++++++++ .../games/build/gui/page/WeatherPage.java | 100 ++++++++++++++++ 11 files changed, 503 insertions(+), 42 deletions(-) create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/gui/OptionsShop.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/gui/page/OptionsMenu.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/gui/page/ParticlesPage.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/gui/page/TimePage.java create mode 100644 Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/gui/page/WeatherPage.java diff --git a/Plugins/.idea/artifacts/Mineplex_Game_Clans_jar.xml b/Plugins/.idea/artifacts/Mineplex_Game_Clans_jar.xml index 85ea6bec4..d88c9bbd4 100644 --- a/Plugins/.idea/artifacts/Mineplex_Game_Clans_jar.xml +++ b/Plugins/.idea/artifacts/Mineplex_Game_Clans_jar.xml @@ -5,7 +5,6 @@ - @@ -18,6 +17,7 @@ + \ No newline at end of file diff --git a/Plugins/.idea/artifacts/Nautilus_Game_Arcade_jar.xml b/Plugins/.idea/artifacts/Nautilus_Game_Arcade_jar.xml index cd4447b88..3f5cae6e4 100644 --- a/Plugins/.idea/artifacts/Nautilus_Game_Arcade_jar.xml +++ b/Plugins/.idea/artifacts/Nautilus_Game_Arcade_jar.xml @@ -17,7 +17,7 @@ - + \ No newline at end of file diff --git a/Plugins/.idea/misc.xml b/Plugins/.idea/misc.xml index d5107f5ca..76fba6e9f 100644 --- a/Plugins/.idea/misc.xml +++ b/Plugins/.idea/misc.xml @@ -10,7 +10,4 @@ - - - \ No newline at end of file diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilParticle.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilParticle.java index 1c42b669e..699b4f48c 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilParticle.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilParticle.java @@ -5,6 +5,7 @@ import java.lang.reflect.Field; import net.minecraft.server.v1_7_R4.PacketPlayOutWorldParticles; import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer; import org.bukkit.entity.Player; @@ -12,47 +13,87 @@ public class UtilParticle { public enum ParticleType { - HUGE_EXPLOSION("hugeexplosion"), - LARGE_EXPLODE("largeexplode"), - FIREWORKS_SPARK("fireworksSpark"), - BUBBLE("bubble"), - SUSPEND("suspended"), - DEPTH_SUSPEND("depthSuspend"), - TOWN_AURA("townaura"), - CRIT("crit"), - MAGIC_CRIT("magicCrit"), - MOB_SPELL("mobSpell"), - MOB_SPELL_AMBIENT("mobSpellAmbient"), - SPELL("spell"), - INSTANT_SPELL("instantSpell"), - WITCH_MAGIC("witchMagic"), - NOTE("note"), - PORTAL("portal"), - ENCHANTMENT_TABLE("enchantmenttable"), - EXPLODE("explode"), - FLAME("flame"), - LAVA("lava"), - FOOTSTEP("footstep"), - SPLASH("splash"), - LARGE_SMOKE("largesmoke"), - CLOUD("cloud"), - RED_DUST("reddust"), - SNOWBALL_POOF("snowballpoof"), - DRIP_WATER("dripWater"), - DRIP_LAVA("dripLava"), - DROPLET("droplet"), - SNOW_SHOVEL("snowshovel"), - SLIME("slime"), - HEART("heart"), - ANGRY_VILLAGER("angryVillager"), - HAPPY_VILLAGER("happyVillager"); + // TODO Update material data as well as friendly name + HUGE_EXPLOSION("hugeexplosion", "Huge Explosion", Material.SAPLING, (byte) 0, true), + LARGE_EXPLODE("largeexplode", "Large Explosion", Material.SAPLING, (byte) 0, true), + FIREWORKS_SPARK("fireworksSpark", "Spark", Material.SAPLING, (byte) 0, true), + BUBBLE("bubble", "Bubble", Material.SAPLING, (byte) 0, true), + SUSPEND("suspended", "Suspended", Material.SAPLING, (byte) 0, true), + DEPTH_SUSPEND("depthSuspend", "Depth Suspend", Material.SAPLING, (byte) 0, true), + TOWN_AURA("townaura", "Town Aura", Material.SAPLING, (byte) 0, true), + CRIT("crit", "Critical Hit", Material.SAPLING, (byte) 0, true), + MAGIC_CRIT("magicCrit", "Magic Critical Hit", Material.SAPLING, (byte) 0, true), + MOB_SPELL("mobSpell", "Mob Spell", Material.SAPLING, (byte) 0, true), + MOB_SPELL_AMBIENT("mobSpellAmbient", "Mob Spell Ambient", Material.SAPLING, (byte) 0, true), + SPELL("spell", "Spell", Material.SAPLING, (byte) 0, true), + INSTANT_SPELL("instantSpell", "Instant Spell", Material.SAPLING, (byte) 0, true), + WITCH_MAGIC("witchMagic", "Witch Magic", Material.SAPLING, (byte) 0, true), + NOTE("note", "Note", Material.SAPLING, (byte) 0, true), + PORTAL("portal", "Portal", Material.SAPLING, (byte) 0, true), + ENCHANTMENT_TABLE("enchantmenttable", "Enchantment Table", Material.SAPLING, (byte) 0, true), + EXPLODE("explode", "Explode", Material.SAPLING, (byte) 0, true), + FLAME("flame", "Flame", Material.SAPLING, (byte) 0, true), + LAVA("lava", "Lava", Material.SAPLING, (byte) 0, true), + FOOTSTEP("footstep", "Footstep", Material.SAPLING, (byte) 0, true), + SPLASH("splash", "Splash", Material.SAPLING, (byte) 0, true), + LARGE_SMOKE("largesmoke", "Large Smoke", Material.SAPLING, (byte) 0, true), + CLOUD("cloud", "Cloud", Material.SAPLING, (byte) 0, true), + RED_DUST("reddust", "Red Dust", Material.SAPLING, (byte) 0, true), + SNOWBALL_POOF("snowballpoof", "Snowball Poof", Material.SAPLING, (byte) 0, true), + DRIP_WATER("dripWater", "Drip Water", Material.SAPLING, (byte) 0, true), + DRIP_LAVA("dripLava", "Drip Lava", Material.SAPLING, (byte) 0, true), + DROPLET("droplet", "Droplet", Material.SAPLING, (byte) 0, true), + SNOW_SHOVEL("snowshovel", "Snow Shovel", Material.SAPLING, (byte) 0, true), + SLIME("slime", "Slime", Material.SAPLING, (byte) 0, true), + HEART("heart", "Heart", Material.SAPLING, (byte) 0, true), + ANGRY_VILLAGER("angryVillager", "Angry Villager", Material.SAPLING, (byte) 0, true), + HAPPY_VILLAGER("happyVillager", "Happy Villager", Material.SAPLING, (byte) 0, true); public String particleName; - - ParticleType(String particleName) + private String _friendlyName; + private Material _material; + private byte _data; + private boolean _displayGuis; + + ParticleType(String particleName, String friendlyName, Material material, byte data, boolean displayGuis) { this.particleName = particleName; + _friendlyName = friendlyName; + _material = material; + _data = data; + _displayGuis = displayGuis; } + + public String getFriendlyName() + { + return _friendlyName; + } + + public Material getMaterial() + { + return _material; + } + + public byte getData() + { + return _data; + } + + public boolean shouldDisplayGuis() + { + return _displayGuis; + } + + public static ParticleType getFromFriendlyName(String name) + { + for (ParticleType t : values()) + { + if (t.getFriendlyName().equals(name)) + return t; + } + + return null; + } } public static void PlayParticle(Player player, ParticleType type, Location location, float offsetX, float offsetY, float offsetZ, float speed, int count) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/Build.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/Build.java index ea1417dee..b2fa275c2 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/Build.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/Build.java @@ -2,6 +2,7 @@ package nautilus.game.arcade.game.games.build; import java.util.ArrayList; +import org.bukkit.ChatColor; import org.bukkit.GameMode; import org.bukkit.Location; import org.bukkit.Material; @@ -22,7 +23,9 @@ import org.bukkit.event.block.BlockPistonRetractEvent; import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.entity.EntityShootBowEvent; import org.bukkit.event.entity.ProjectileLaunchEvent; +import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.player.PlayerBucketEmptyEvent; +import org.bukkit.event.player.PlayerDropItemEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerQuitEvent; @@ -52,6 +55,7 @@ import nautilus.game.arcade.GameType; import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.events.PlayerPrepareTeleportEvent; import nautilus.game.arcade.game.SoloGame; +import nautilus.game.arcade.game.games.build.gui.OptionsShop; import nautilus.game.arcade.game.games.draw.kits.*; import nautilus.game.arcade.kit.Kit; @@ -70,6 +74,9 @@ public class Build extends SoloGame private String _word = "?"; + private OptionsShop _shop; + private ItemStack _shopItem; + public Build(ArcadeManager manager) { super(manager, GameType.Build, @@ -107,6 +114,9 @@ public class Build extends SoloGame { "Pirate Ship", "Mineshaft", "Archers Tower", "Dinner Table", "Pokemon" }; + + _shop = new OptionsShop(this, getArcadeManager(), getArcadeManager().GetClients(), getArcadeManager().GetDonation()); + _shopItem = ItemStackFactory.Instance.CreateStack(Material.DIAMOND, (byte) 0, 1, C.cGreen + "Options"); } @EventHandler @@ -168,6 +178,9 @@ public class Build extends SoloGame this.InventoryClick = false; UtilTextMiddle.display(null, C.cYellow + "Time Up!", 5, 60, 5); + + for (Player player : GetPlayers(true)) + player.getInventory().clear(8); } } //Pause @@ -356,6 +369,11 @@ public class Build extends SoloGame return BuildQuality.getQuality(score / ((double)GetPlayers(true).size()-1 * 1.5d)); } + public BuildData getBuildData(Player player) + { + return _data.get(player); + } + @EventHandler public void blockPlace(BlockPlaceEvent event) { @@ -624,4 +642,59 @@ public class Build extends SoloGame Scoreboard.Draw(); } + + @EventHandler + public void openShop(PlayerInteractEvent event) + { + if (IsAlive(event.getPlayer()) && _shopItem.equals(event.getPlayer().getItemInHand())) + _shop.attemptShopOpen(event.getPlayer()); + } + + @EventHandler + public void giveItem(UpdateEvent event) + { + if (event.getType() != UpdateType.TWOSEC) return; + + if (IsLive() && _buildGameState == 0) + for (Player player : GetPlayers(true)) + player.getInventory().setItem(8, _shopItem); + } + + @EventHandler + public void stopShopItemMove(InventoryClickEvent event) + { + if (event.getClickedInventory() != null && _shopItem.equals(event.getClickedInventory().getItem(event.getSlot()))) + event.setCancelled(true); + } + + @EventHandler + public void stopShopItemDrop(PlayerDropItemEvent event) + { + if (_shopItem.equals(event.getItemDrop().getItemStack())) + event.setCancelled(true); + } + + @EventHandler + public void placeParticles(PlayerInteractEvent event) + { + if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) return; + + ItemStack itemInHand = event.getPlayer().getItemInHand(); + if (itemInHand != null && itemInHand.getItemMeta().getDisplayName().startsWith(ChatColor.GREEN + "Place ")) + { + ParticleType particleType = ParticleType.getFromFriendlyName(itemInHand.getItemMeta().getDisplayName().substring(8)); + if (particleType != null) + { + BuildData data = _data.get(event.getPlayer()); + if (data != null) + { + data.Particles.put(event.getPlayer().getLocation(), particleType); + } + } + else + { + System.out.println("Place particles error! This shouldn't happen!"); + } + } + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/BuildData.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/BuildData.java index e007a60d6..b169ef50d 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/BuildData.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/BuildData.java @@ -35,7 +35,7 @@ public class BuildData public int Time = 6000; - public int Weather = 0; + public WeatherType Weather = WeatherType.SUNNY; public NautHashMap Score = new NautHashMap(); @@ -97,4 +97,9 @@ public class BuildData return true; } + + public enum WeatherType + { + SUNNY, RAINING, STORMING; + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/gui/OptionsShop.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/gui/OptionsShop.java new file mode 100644 index 000000000..f1d9e43e1 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/gui/OptionsShop.java @@ -0,0 +1,28 @@ +package nautilus.game.arcade.game.games.build.gui; + +import org.bukkit.entity.Player; + +import mineplex.core.account.CoreClientManager; +import mineplex.core.donation.DonationManager; +import mineplex.core.shop.ShopBase; +import mineplex.core.shop.page.ShopPageBase; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.build.Build; +import nautilus.game.arcade.game.games.build.gui.page.OptionsMenu; + +public class OptionsShop extends ShopBase +{ + private Build _game; + + public OptionsShop(Build game, ArcadeManager plugin, CoreClientManager clientManager, DonationManager donationManager) + { + super(plugin, clientManager, donationManager, "Options"); + _game = game; + } + + @Override + protected ShopPageBase> buildPagesFor(Player player) + { + return new OptionsMenu(_game, getPlugin(), this, getClientManager(), getDonationManager(), player); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/gui/page/OptionsMenu.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/gui/page/OptionsMenu.java new file mode 100644 index 000000000..4025b12ad --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/gui/page/OptionsMenu.java @@ -0,0 +1,62 @@ +package nautilus.game.arcade.game.games.build.gui.page; + +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; + +import mineplex.core.account.CoreClientManager; +import mineplex.core.donation.DonationManager; +import mineplex.core.shop.item.IButton; +import mineplex.core.shop.item.ShopItem; +import mineplex.core.shop.page.ShopPageBase; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.build.Build; +import nautilus.game.arcade.game.games.build.gui.OptionsShop; + +public class OptionsMenu extends ShopPageBase +{ + private Build _game; + + public OptionsMenu(Build game, ArcadeManager plugin, OptionsShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player) + { + super(plugin, shop, clientManager, donationManager, "Options", player, 9); + _game = game; + buildPage(); + } + + @Override + protected void buildPage() + { + + ShopItem particles = new ShopItem(Material.NETHER_STAR, "Particles", 0, false); + ShopItem weather = new ShopItem(Material.FEATHER, "Weather", 0, false); + ShopItem time = new ShopItem(Material.WATCH, "Time of Day", 0, false); + + addButton(2, particles, new IButton() + { + @Override + public void onClick(Player player, ClickType clickType) + { + getShop().openPageForPlayer(player, new ParticlesPage(_game, getPlugin(), getShop(), getClientManager(), getDonationManager(), player)); + } + }); + + addButton(4, weather, new IButton() + { + @Override + public void onClick(Player player, ClickType clickType) + { + getShop().openPageForPlayer(player, new WeatherPage(_game, getPlugin(), getShop(), getClientManager(), getDonationManager(), player)); + } + }); + + addButton(6, time, new IButton() + { + @Override + public void onClick(Player player, ClickType clickType) + { + getShop().openPageForPlayer(player, new TimePage(_game, getPlugin(), getShop(), getClientManager(), getDonationManager(), player)); + } + }); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/gui/page/ParticlesPage.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/gui/page/ParticlesPage.java new file mode 100644 index 000000000..fd3bfa24f --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/gui/page/ParticlesPage.java @@ -0,0 +1,86 @@ +package nautilus.game.arcade.game.games.build.gui.page; + +import java.util.Arrays; + +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; +import org.bukkit.inventory.ItemStack; + +import mineplex.core.account.CoreClientManager; +import mineplex.core.common.util.C; +import mineplex.core.common.util.UtilParticle; +import mineplex.core.donation.DonationManager; +import mineplex.core.itemstack.ItemStackFactory; +import mineplex.core.shop.item.IButton; +import mineplex.core.shop.item.ShopItem; +import mineplex.core.shop.page.ShopPageBase; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.build.Build; +import nautilus.game.arcade.game.games.build.BuildData; +import nautilus.game.arcade.game.games.build.gui.OptionsShop; + +public class ParticlesPage extends ShopPageBase +{ + private Build _game; + + public ParticlesPage(Build game, ArcadeManager plugin, OptionsShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player) + { + super(plugin, shop, clientManager, donationManager, "Add Particles", player); + _game = game; + buildPage(); + } + + @Override + protected void buildPage() + { + final BuildData buildData = _game.getBuildData(getPlayer()); + + if (buildData == null) + { + getPlayer().closeInventory(); + return; + } + + int index = 0; + for (final UtilParticle.ParticleType particleType : UtilParticle.ParticleType.values()) + { + if (particleType.shouldDisplayGuis()) + { + ShopItem shopItem = new ShopItem(particleType.getMaterial(), particleType.getFriendlyName(), null, 0, false); + addButton(index, shopItem, new IButton() + { + @Override + public void onClick(Player player, ClickType clickType) + { + String[] lore = { ChatColor.GRAY + "Right click to place" }; + ItemStack itemStack = ItemStackFactory.Instance.CreateStack(particleType.getMaterial(), particleType.getData(), 1, ChatColor.GREEN + "Place " + particleType.getFriendlyName(), Arrays.asList(lore)); + player.getInventory().addItem(itemStack); + } + }); + + index++; + } + } + + ShopItem clearButton = new ShopItem(Material.TNT, "Clear Particles", null, 0, false); + addButton(53, clearButton, new IButton() + { + @Override + public void onClick(Player player, ClickType clickType) + { + buildData.Particles.clear(); + } + }); + + addButton((9 * 5) + 4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() + { + @Override + public void onClick(Player player, ClickType clickType) + { + getShop().openPageForPlayer(player, new OptionsMenu(_game, getPlugin(), getShop(), getClientManager(), getDonationManager(), player)); + } + }); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/gui/page/TimePage.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/gui/page/TimePage.java new file mode 100644 index 000000000..981d50e2e --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/gui/page/TimePage.java @@ -0,0 +1,69 @@ +package nautilus.game.arcade.game.games.build.gui.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.donation.DonationManager; +import mineplex.core.shop.item.IButton; +import mineplex.core.shop.item.ShopItem; +import mineplex.core.shop.page.ShopPageBase; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.build.Build; +import nautilus.game.arcade.game.games.build.BuildData; +import nautilus.game.arcade.game.games.build.gui.OptionsShop; + +public class TimePage extends ShopPageBase +{ + private Build _game; + + public TimePage(Build game, ArcadeManager plugin, OptionsShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player) + { + super(plugin, shop, clientManager, donationManager, "Set Time", player, 18); + _game = game; + buildPage(); + } + + @Override + protected void buildPage() + { + final BuildData buildData = _game.getBuildData(getPlayer()); + + if (buildData == null) + { + getPlayer().closeInventory(); + return; + } + + for (int i = 0; i < 9; i++) + { + final int ticks = 3000 * i; + boolean am = (ticks >= 0 && ticks < 6000) || (ticks >= 18000); + int time = (6 + (ticks / 1000)) % 12; + if (time == 0) time = 12; + + byte data = (byte) (buildData.Time == ticks ? 5 : 14); + ShopItem item = new ShopItem(Material.STAINED_CLAY, data, time + (am ? " am" : " pm"), null, 0, false, false); + addButton(i, item, new IButton() + { + @Override + public void onClick(Player player, ClickType clickType) + { + buildData.Time = ticks; + buildPage(); + } + }); + } + + addButton(9 + 4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() + { + @Override + public void onClick(Player player, ClickType clickType) + { + getShop().openPageForPlayer(player, new OptionsMenu(_game, getPlugin(), getShop(), getClientManager(), getDonationManager(), player)); + } + }); + } +} diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/gui/page/WeatherPage.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/gui/page/WeatherPage.java new file mode 100644 index 000000000..484b3c896 --- /dev/null +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/gui/page/WeatherPage.java @@ -0,0 +1,100 @@ +package nautilus.game.arcade.game.games.build.gui.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.donation.DonationManager; +import mineplex.core.shop.item.IButton; +import mineplex.core.shop.item.ShopItem; +import mineplex.core.shop.page.ShopPageBase; +import nautilus.game.arcade.ArcadeManager; +import nautilus.game.arcade.game.games.build.Build; +import nautilus.game.arcade.game.games.build.BuildData; +import nautilus.game.arcade.game.games.build.gui.OptionsShop; + +public class WeatherPage extends ShopPageBase +{ + private Build _game; + + public WeatherPage(Build game, ArcadeManager plugin, OptionsShop shop, CoreClientManager clientManager, DonationManager donationManager, Player player) + { + super(plugin, shop, clientManager, donationManager, "Set Weather", player, 18); + _game = game; + buildPage(); + } + + @Override + protected void buildPage() + { + + final BuildData buildData = _game.getBuildData(getPlayer()); + + if (buildData == null) + { + getPlayer().closeInventory(); + return; + } + + int sunnySlot = 2; + int rainingSlot = 4; + int stormingSlot = 6; + + ShopItem sunny = new ShopItem(Material.DOUBLE_PLANT, "Sunny", 1, false); + ShopItem raining = new ShopItem(Material.WATER_BUCKET, "Raining", 1, false); + ShopItem storming = new ShopItem(Material.BLAZE_ROD, "Storming", 1, false); + + addButton(sunnySlot, sunny, new IButton() + { + @Override + public void onClick(Player player, ClickType clickType) + { + buildData.Weather = BuildData.WeatherType.SUNNY; + buildPage(); + } + }); + + addButton(rainingSlot, raining, new IButton() + { + @Override + public void onClick(Player player, ClickType clickType) + { + buildData.Weather = BuildData.WeatherType.RAINING; + buildPage(); + } + }); + + addButton(stormingSlot, storming, new IButton() + { + @Override + public void onClick(Player player, ClickType clickType) + { + buildData.Weather = BuildData.WeatherType.STORMING; + buildPage(); + } + }); + + switch (buildData.Weather) + { + case RAINING: + addGlow(rainingSlot); + break; + case STORMING: + addGlow(stormingSlot); + break; + default: + addGlow(sunnySlot); + } + + addButton(9 + 4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[]{}, 1, false), new IButton() + { + @Override + public void onClick(Player player, ClickType clickType) + { + getShop().openPageForPlayer(player, new OptionsMenu(_game, getPlugin(), getShop(), getClientManager(), getDonationManager(), player)); + } + }); + } +} From 244ffece8a6d43cbacd52e6c15f915fe363a8622 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Fri, 1 May 2015 18:02:06 -0500 Subject: [PATCH 2/4] Fixes for build game + fix clans compile --- .../core/common/util/UtilParticle.java | 45 ++++++++++++++++++- .../src/mineplex/game/clans/Clans.java | 4 +- .../game/arcade/game/games/build/Build.java | 2 + .../games/build/gui/page/ParticlesPage.java | 2 +- 4 files changed, 50 insertions(+), 3 deletions(-) diff --git a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilParticle.java b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilParticle.java index 0cd02d837..df8cd78a2 100644 --- a/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilParticle.java +++ b/Plugins/Mineplex.Core.Common/src/mineplex/core/common/util/UtilParticle.java @@ -12,7 +12,7 @@ public class UtilParticle { public enum ParticleType { - ANGRY_VILLAGER("angryVillager"), + ANGRY_VILLAGER("angryVillager", "Angry Villager", Material.SAPLING, (byte) 0), BLOCK_CRACK("blockcrack_1_0") { @@ -117,16 +117,59 @@ public class UtilParticle WITCH_MAGIC("witchMagic"); public String particleName; + private boolean _friendlyData; + private String _friendlyName; + private Material _material; + private byte _data; ParticleType(String particleName) { this.particleName = particleName; + _friendlyData = false; + } + + ParticleType(String particleName, String friendlyName, Material material, byte data) + { + _friendlyData = true; + _friendlyName = friendlyName; + _material = material; + _data = data; } public String getParticle(Material type, int data) { return particleName; } + + public boolean hasFriendlyData() + { + return _friendlyData; + } + + public String getFriendlyName() + { + return _friendlyName; + } + + public Material getMaterial() + { + return _material; + } + + public byte getData() + { + return _data; + } + + public static ParticleType getFromFriendlyName(String name) + { + for (ParticleType type : values()) + { + if (type.hasFriendlyData() && type.getFriendlyName().equals(name)) + return type; + } + return null; + } } private static PacketPlayOutWorldParticles getPacket(String particleName, Location location, float offsetX, float offsetY, diff --git a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java index 6c61713e8..899cbc101 100644 --- a/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java +++ b/Plugins/Mineplex.Game.Clans/src/mineplex/game/clans/Clans.java @@ -6,6 +6,7 @@ import net.minecraft.server.v1_7_R4.MinecraftServer; import mineplex.core.account.CoreClientManager; import mineplex.core.antihack.AntiHack; import mineplex.core.blockrestore.BlockRestore; +import mineplex.core.chat.Chat; import mineplex.core.command.CommandCenter; import mineplex.core.donation.DonationManager; import mineplex.core.explosion.Explosion; @@ -78,7 +79,8 @@ public class Clans extends JavaPlugin BlockRestore blockRestore = new BlockRestore(this); IgnoreManager ignoreManager = new IgnoreManager(this, _clientManager, preferenceManager, portal); - new MessageManager(this, _clientManager, preferenceManager, ignoreManager, punish, new FriendManager(this, _clientManager, preferenceManager, portal)); + Chat chat = new Chat(this, _clientManager, preferenceManager, serverStatusManager.getCurrentServerName()); + new MessageManager(this, _clientManager, preferenceManager, ignoreManager, punish, new FriendManager(this, _clientManager, preferenceManager, portal), chat); new MemoryFix(this); new Explosion(this, blockRestore); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/Build.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/Build.java index 907c717cf..1b607c9aa 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/Build.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/Build.java @@ -686,6 +686,8 @@ public class Build extends SoloGame { data.Particles.put(event.getPlayer().getLocation(), particleType); } + + event.setCancelled(true); } else { diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/gui/page/ParticlesPage.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/gui/page/ParticlesPage.java index fd3bfa24f..4afc50e15 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/gui/page/ParticlesPage.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/gui/page/ParticlesPage.java @@ -46,7 +46,7 @@ public class ParticlesPage extends ShopPageBase int index = 0; for (final UtilParticle.ParticleType particleType : UtilParticle.ParticleType.values()) { - if (particleType.shouldDisplayGuis()) + if (particleType.hasFriendlyData()) { ShopItem shopItem = new ShopItem(particleType.getMaterial(), particleType.getFriendlyName(), null, 0, false); addButton(index, shopItem, new IButton() From e04b61a91dcb7d8055e278eba6beb6d0a63b8ea7 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Fri, 1 May 2015 18:03:56 -0500 Subject: [PATCH 3/4] Give build item when game starts --- .../nautilus/game/arcade/game/games/build/Build.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/Build.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/Build.java index 1b607c9aa..826aa9289 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/Build.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/build/Build.java @@ -646,6 +646,16 @@ public class Build extends SoloGame _shop.attemptShopOpen(event.getPlayer()); } + @EventHandler + public void giveItemStart(GameStateChangeEvent event) + { + if (event.GetGame() == this && event.GetState() == GameState.Live) + { + for (Player player : GetPlayers(true)) + player.getInventory().setItem(8, _shopItem); + } + } + @EventHandler public void giveItem(UpdateEvent event) { From 2902e6075f85adde80aa5b527585c79e88590fd7 Mon Sep 17 00:00:00 2001 From: Jonathan Williams Date: Fri, 1 May 2015 22:05:03 -0500 Subject: [PATCH 4/4] Fix for n positive bug. --- .../game/arcade/game/games/wizards/spells/SpellImplode.java | 1 + 1 file changed, 1 insertion(+) diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellImplode.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellImplode.java index 592e55b16..82859b284 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellImplode.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/spells/SpellImplode.java @@ -76,6 +76,7 @@ public class SpellImplode extends Spell implements SpellClick public void run() { + if (effectedBlocks.size() > 0) { Block block = effectedBlocks.get(UtilMath.r(effectedBlocks.size())); block.getWorld().playSound(block.getLocation(),