diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/SpellButton.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/SpellButton.java index 3d3134bc8..0287e0eb4 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/SpellButton.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/SpellButton.java @@ -41,6 +41,7 @@ public class SpellButton implements IButton _spellPage.getWizards().drawUtilTextBottom(player); _spellPage.getWizards().changeWandsTitles(player); + _spellPage.getWizards().changeWandsType(player, -1, player.getInventory().getHeldItemSlot()); player.closeInventory(); } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/SpellMenuPage.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/SpellMenuPage.java index 71b0faa30..bc9e963dc 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/SpellMenuPage.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/SpellMenuPage.java @@ -63,13 +63,13 @@ public class SpellMenuPage extends ShopPageBase spell, int maxLevel, - int spellCost, int spellCooldown, int manaChangePerLevel, int cooldownChangePerLevel, int itemAmount, String... desc) + private SpellType(SpellElement type, WandElement wandElement, String spellName, ItemStack spellItem, + Class spell, int maxLevel, int spellCost, int spellCooldown, int manaChangePerLevel, + int cooldownChangePerLevel, int itemAmount, String... desc) { + _wandElement = wandElement; _maxLevel = maxLevel; _item = spellItem; _desc = desc; @@ -663,6 +716,11 @@ public enum SpellType // ❤ return _spellName; } + public WandElement getWandType() + { + return _wandElement; + } + public ItemStack makeSpell(Wizards wizards, ItemStack item) { ItemBuilder builder = new ItemBuilder(item); diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/WizardSpellMenu.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/WizardSpellMenu.java index 9ba3d42ec..8c7901c85 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/WizardSpellMenu.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/WizardSpellMenu.java @@ -20,93 +20,93 @@ import org.bukkit.plugin.java.JavaPlugin; public class WizardSpellMenu extends MiniPlugin { - private Wizards _wizards; - private WizardSpellMenuShop _wizardShop; - private ItemStack _wizardSpells = new ItemBuilder(Material.ENCHANTED_BOOK).setTitle(C.cGold + "Wizard Spells") - .addLore(C.cGray + "Right click with this to view the spells").build(); + private Wizards _wizards; + private WizardSpellMenuShop _wizardShop; + private ItemStack _wizardSpells = new ItemBuilder(Material.ENCHANTED_BOOK).setTitle(C.cGold + "Wizard Spells") + .addLore(C.cGray + "Right click with this to view the spells").build(); - public WizardSpellMenu(String moduleName, JavaPlugin plugin, Wizards wizards) - { - super("Wizard Spell Menu", plugin); - _wizardShop = new WizardSpellMenuShop(this, wizards.getArcadeManager().GetClients(), wizards.getArcadeManager() - .GetDonation(), wizards); - _wizards = wizards; - } + public WizardSpellMenu(String moduleName, JavaPlugin plugin, Wizards wizards) + { + super("Wizard Spell Menu", plugin); + _wizardShop = new WizardSpellMenuShop(this, wizards.getArcadeManager().GetClients(), wizards.getArcadeManager() + .GetDonation(), wizards); + _wizards = wizards; + } - @EventHandler - public void onJoin(PlayerJoinEvent event) - { + @EventHandler + public void onJoin(PlayerJoinEvent event) + { - if (_wizards.GetState() == GameState.Recruit || _wizards.GetState() == GameState.Live) - { - event.getPlayer().getInventory().addItem(_wizardSpells); - } - } + if (_wizards.GetState() == GameState.Recruit || _wizards.GetState() == GameState.Live) + { + event.getPlayer().getInventory().addItem(_wizardSpells); + } + } - @EventHandler - public void onDeath(final PlayerDeathEvent event) - { - Bukkit.getScheduler().scheduleSyncDelayedTask(_plugin, new Runnable() - { - public void run() - { - if (_wizards.IsLive()) - { - event.getEntity().getInventory().addItem(_wizardSpells); - } - } - }); - } + @EventHandler + public void onDeath(final PlayerDeathEvent event) + { + Bukkit.getScheduler().scheduleSyncDelayedTask(_plugin, new Runnable() + { + public void run() + { + if (_wizards.IsLive()) + { + event.getEntity().getInventory().addItem(_wizardSpells); + } + } + }); + } - @EventHandler - public void onJoin(GameStateChangeEvent event) - { + @EventHandler + public void onJoin(GameStateChangeEvent event) + { - if (event.GetState() == GameState.Recruit) - { - for (Player player : Bukkit.getOnlinePlayers()) - { - player.getInventory().addItem(_wizardSpells); - } - } - } + if (event.GetState() == GameState.Recruit) + { + for (Player player : Bukkit.getOnlinePlayers()) + { + player.getInventory().addItem(_wizardSpells); + } + } + } - @EventHandler - public void onInteract(PlayerInteractEvent event) - { - if (event.getAction() != Action.PHYSICAL && (!_wizards.IsLive() || !_wizards.IsAlive(event.getPlayer()))) - { + @EventHandler + public void onInteract(PlayerInteractEvent event) + { + if (event.getAction() != Action.PHYSICAL && (!_wizards.IsLive() || !_wizards.IsAlive(event.getPlayer()))) + { - ItemStack item = event.getItem(); + ItemStack item = event.getItem(); - if (item != null && item.isSimilar(_wizardSpells)) - { + if (item != null && item.isSimilar(_wizardSpells)) + { - _wizardShop.attemptShopOpen(event.getPlayer()); - } - } + _wizardShop.attemptShopOpen(event.getPlayer()); + } + } - if (_wizards.IsLive() && _wizards.IsAlive(event.getPlayer())) - { + if (_wizards.IsLive() && _wizards.IsAlive(event.getPlayer())) + { - ItemStack item = event.getItem(); - if (item != null && item.getType() == Material.BLAZE_ROD) - { + ItemStack item = event.getItem(); - Player p = event.getPlayer(); + if (item != null && item.getType() != Material.STAINED_GLASS_PANE) + { + Player p = event.getPlayer(); - if (event.getAction().name().contains("RIGHT")) - { - if (p.getInventory().getHeldItemSlot() < 5) - { - if (event.getClickedBlock() == null || !(event.getClickedBlock().getState() instanceof InventoryHolder)) - { - _wizardShop.attemptShopOpen(p); - } - } - } - } - } - } + if (event.getAction().name().contains("RIGHT")) + { + if (p.getInventory().getHeldItemSlot() < 5) + { + if (event.getClickedBlock() == null || !(event.getClickedBlock().getState() instanceof InventoryHolder)) + { + _wizardShop.attemptShopOpen(p); + } + } + } + } + } + } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/Wizards.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/Wizards.java index b094dfe34..bbf980127 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/Wizards.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/Wizards.java @@ -312,8 +312,7 @@ public class Wizards extends SoloGame private void addRandomItem(int amount, ItemStack item, int minAmount, int maxAmount) { item.setAmount(minAmount); - HashMap.SimpleEntry entry = new HashMap.SimpleEntry(item, maxAmount - - minAmount); + HashMap.SimpleEntry entry = new HashMap.SimpleEntry(item, maxAmount - minAmount); for (int i = 0; i < amount; i++) { @@ -447,6 +446,37 @@ public class Wizards extends SoloGame } } + public void changeWandsType(Player player, int oldSlot, int newSlot) + { + PlayerInventory inv = player.getInventory(); + + if (oldSlot >= 0 && oldSlot < 5) + { + SpellType spell = getWizard(player).getSpell(oldSlot); + + if (spell != null) + { + ItemStack item = inv.getItem(oldSlot); + item.setType(spell.getSpellItem().getType()); + inv.setItem(oldSlot, item); + } + } + + if (newSlot >= 0 && newSlot < 5) + { + SpellType spell = getWizard(player).getSpell(newSlot); + + if (spell != null) + { + ItemStack item = inv.getItem(newSlot); + + item.setType(spell.getWandType().getMaterial()); + + inv.setItem(newSlot, item); + } + } + } + public void changeWandsTitles(Player player) { PlayerInventory inv = player.getInventory(); @@ -457,7 +487,7 @@ public class Wizards extends SoloGame ItemStack item = inv.getItem(slot); SpellType type = wizard.getSpell(slot); - if (item != null && item.getType() == Material.BLAZE_ROD) + if (item != null && item.getType() != Material.STAINED_GLASS_PANE) { String display; @@ -744,7 +774,6 @@ public class Wizards extends SoloGame { HashSet spells = new HashSet(); ArrayList itemsToDrop = new ArrayList(); - ArrayList normalItemsToDrop = UtilInv.getItems(player); Wizard wizard = getWizard(player); int wandsHeld = 0; @@ -767,23 +796,24 @@ public class Wizards extends SoloGame } } - Iterator itel = normalItemsToDrop.iterator(); - - while (itel.hasNext()) + for (ItemStack item : UtilInv.getItems(player)) { - ItemStack item = itel.next(); - if (item.getType() == Material.BLAZE_ROD) + switch (item.getType()) { + case WOOD_HOE: + case STONE_HOE: + case GOLD_HOE: + case IRON_HOE: + case DIAMOND_HOE: + case BLAZE_ROD: + case STICK: wandsHeld++; - itel.remove(); - } - else if (item.getType() == Material.STAINED_GLASS_PANE) - { - itel.remove(); - } - else - { + break; + case STAINED_GLASS_PANE: + break; + default: player.getWorld().dropItemNaturally(player.getLocation(), item); + break; } } @@ -937,11 +967,10 @@ public class Wizards extends SoloGame { ItemStack item = player.getItemInHand(); - if (IsLive() && IsAlive(player) && item != null && item.getType() == Material.BLAZE_ROD - && player.getInventory().getHeldItemSlot() < 5) + if (IsLive() && IsAlive(player) && item != null && player.getInventory().getHeldItemSlot() < 5) { - Wizard wizard = getWizard(player); + SpellType spell = wizard.getSpell(player.getInventory().getHeldItemSlot()); if (spell != null) @@ -1085,18 +1114,17 @@ public class Wizards extends SoloGame if (IsAlive(p)) { dropSpells(p); + /*Iterator itel = event.getDrops().iterator(); - Iterator itel = event.getDrops().iterator(); + while (itel.hasNext()) + { + ItemStack item = itel.next(); - while (itel.hasNext()) - { - ItemStack item = itel.next(); - - if (item.getType() == Material.BLAZE_ROD || item.getType() == Material.STAINED_GLASS_PANE) - { - itel.remove(); - } - } + if (item.getType() == Material.BLAZE_ROD || item.getType() == Material.STAINED_GLASS_PANE) + { + itel.remove(); + } + }*/ } _wizards.remove(p.getName()); @@ -1161,7 +1189,7 @@ public class Wizards extends SoloGame _droppedWandsBooks.add(event.getEntity()); } - else if (item.getType() == Material.BOOK) + else if (item.getType() == Material.BOOK || item.getType() == Material.STICK) { event.getEntity().remove(); } @@ -1257,20 +1285,9 @@ public class Wizards extends SoloGame @EventHandler public void onInteract(PlayerInteractEvent event) { - ItemStack item = event.getItem(); - if (item != null) + if (event.getAction().name().contains("LEFT")) { - - Player p = event.getPlayer(); - if (event.getAction().name().contains("LEFT")) - { - - if (item.getType() == Material.BLAZE_ROD) - { - - onCastSpell(p, event.getClickedBlock()); - } - } + onCastSpell(event.getPlayer(), event.getClickedBlock()); } } @@ -1439,22 +1456,29 @@ public class Wizards extends SoloGame @EventHandler public void onSwapItem(PlayerItemHeldEvent event) { - if (IsLive()) + if (!IsLive()) { - Player p = event.getPlayer(); + return; + } + Player p = event.getPlayer(); - if (event.getNewSlot() >= 0 && event.getNewSlot() < 5) - { - drawUtilTextBottom(p); - } - else - { + if (!_wizards.containsKey(p.getName())) + { + return; + } - // Get rid of the old wand message - if (event.getPreviousSlot() >= 0 && event.getPreviousSlot() < 5) - { - UtilTextBottom.display(C.Bold, p); - } + changeWandsType(p, event.getPreviousSlot(), event.getNewSlot()); + + if (event.getNewSlot() >= 0 && event.getNewSlot() < 5) + { + drawUtilTextBottom(p); + } + else + { + // Get rid of the old wand message + if (event.getPreviousSlot() >= 0 && event.getPreviousSlot() < 5) + { + UtilTextBottom.display(C.Bold, p); } } } @@ -1475,10 +1499,21 @@ public class Wizards extends SoloGame ItemStack result = recipe != null ? recipe.getResult() : null; - if (result != null && (result.getType().name().contains("_SWORD") || result.getType().name().contains("_AXE"))) + if (result != null) { - event.getInventory().setResult(new ItemStack(Material.AIR)); - UtilPlayer.message(event.getViewers().get(0), C.cRed + "You may not craft weaponsa"); + if (result.getType().name().contains("_SWORD") || result.getType().name().contains("_AXE")) + { + event.getInventory().setResult(new ItemStack(Material.AIR)); + + UtilPlayer.message(event.getViewers().get(0), C.cRed + "You may not craft weapons"); + } + else if (result.getType() == Material.STICK || result.getType() == Material.FERMENTED_SPIDER_EYE + || result.getType().name().contains("_HOE")) + { + event.getInventory().setResult(new ItemStack(Material.AIR)); + + UtilPlayer.message(event.getViewers().get(0), C.cRed + "You may not craft this item"); + } } } diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/kit/KitMystic.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/kit/KitMystic.java index 7b5320365..32a755eab 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/kit/KitMystic.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/kit/KitMystic.java @@ -20,7 +20,7 @@ public class KitMystic extends Kit super(manager, "Mystic", KitAvailability.Free, new String[] { "Mana regeneration increased by 10%" - }, new Perk[0], EntityType.WITCH, new ItemStack(Material.BLAZE_ROD)); + }, new Perk[0], EntityType.WITCH, new ItemStack(Material.WOOD_HOE)); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/kit/KitSorcerer.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/kit/KitSorcerer.java index 0ed52b42d..b0dda7740 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/kit/KitSorcerer.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/kit/KitSorcerer.java @@ -20,7 +20,7 @@ public class KitSorcerer extends Kit super(manager, "Sorcerer", KitAvailability.Free, new String[] { "Start out with an extra wand" - }, new Perk[0], EntityType.WITCH, new ItemStack(Material.BLAZE_ROD)); + }, new Perk[0], EntityType.WITCH, new ItemStack(Material.STONE_HOE)); } @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/kit/KitWitchDoctor.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/kit/KitWitchDoctor.java index 5ae610300..74b9cc154 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/kit/KitWitchDoctor.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/wizards/kit/KitWitchDoctor.java @@ -21,7 +21,7 @@ public class KitWitchDoctor extends Kit super(manager, "Witch Doctor", KitAvailability.Free, new String[] { "Max mana increased to 150" - }, new Perk[0], EntityType.WITCH, new ItemStack(Material.BLAZE_ROD)); + }, new Perk[0], EntityType.WITCH, new ItemStack(Material.IRON_HOE)); this.setAchievementRequirements(new Achievement[] {