From 1d3b792ed8bd2e08d63c7d5534b395506d1f28f5 Mon Sep 17 00:00:00 2001 From: Chiss Date: Sat, 11 Oct 2014 23:09:56 +1100 Subject: [PATCH] UHC head apple fixes --- .../hub/server/ui/ServerGameMenu.java | 2 +- .../game/arcade/game/games/uhc/UHC.java | 110 +++++++++++++++--- 2 files changed, 92 insertions(+), 20 deletions(-) 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 6f398d4ec..ea6465996 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/server/ui/ServerGameMenu.java @@ -41,7 +41,7 @@ public class ServerGameMenu extends ShopPageBase createMinigameCycle(); BuildPage(); - } + } @SuppressWarnings("deprecation") @Override diff --git a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java index b0008a552..501fec48b 100644 --- a/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java +++ b/Plugins/Nautilus.Game.Arcade/src/nautilus/game/arcade/game/games/uhc/UHC.java @@ -33,15 +33,20 @@ import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; import org.bukkit.event.inventory.PrepareItemCraftEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerItemConsumeEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerKickEvent; +import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.event.player.PlayerPortalEvent; +import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; import org.bukkit.inventory.CraftingInventory; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ShapedRecipe; import org.bukkit.inventory.ShapelessRecipe; +import org.bukkit.inventory.meta.SkullMeta; +import org.bukkit.material.MaterialData; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; import org.bukkit.scoreboard.DisplaySlot; @@ -52,6 +57,8 @@ import mineplex.core.common.util.F; import mineplex.core.common.util.NautHashMap; import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilEvent; +import mineplex.core.common.util.UtilGear; +import mineplex.core.common.util.UtilInv; import mineplex.core.common.util.UtilMath; import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilWorld; @@ -567,6 +574,30 @@ public class UHC extends TeamGame event.getDrops().add(ItemStackFactory.Instance.CreateStack(Material.GOLD_INGOT, 1)); } } + + @EventHandler(priority = EventPriority.LOWEST) + public void PlayerQuitDropItems(PlayerQuitEvent event) + { + Player player = event.getPlayer(); + + GameTeam team = GetTeam(player); + if (team == null) return; + + if (!IsAlive(player)) + return; + + //Drop Items + UtilInv.drop(player, true); + + //Skull Drop + ItemStack stack = ItemStackFactory.Instance.CreateStack(Material.SKULL_ITEM, (byte)3, 1, team.GetColor() + player.getName() + "'s Head"); + + SkullMeta meta = (SkullMeta)stack.getItemMeta(); + meta.setOwner(player.getName()); + stack.setItemMeta(meta); + + event.getPlayer().getWorld().dropItemNaturally(player.getEyeLocation(), stack); + } @EventHandler public void PlayerDeath(PlayerDeathEvent event) @@ -577,7 +608,13 @@ public class UHC extends TeamGame if (team == null) return; //Skull Drop - event.getDrops().add(ItemStackFactory.Instance.CreateStack(Material.SKULL, (byte)3, 1, team.GetColor() + player.getName() + "'s Head")); + ItemStack stack = ItemStackFactory.Instance.CreateStack(Material.SKULL_ITEM, (byte)3, 1, team.GetColor() + player.getName() + "'s Head"); + + SkullMeta meta = (SkullMeta)stack.getItemMeta(); + meta.setOwner(player.getName()); + stack.setItemMeta(meta); + + event.getDrops().add(stack); //Lightning Location loc = player.getLocation(); @@ -697,18 +734,6 @@ public class UHC extends TeamGame } */ - // @EventHandler(priority=EventPriority.MONITOR) - // public void DamageRecord(CustomDamageEvent event) - // { - // if (event.IsCancelled()) - // return; - // - // if (event.GetDamagerPlayer(true) != null && event.GetDamageePlayer() != null) - // { - // _combatTime.put(event.GetDamageePlayer().getName(), System.currentTimeMillis()); - // _combatTime.put(event.GetDamagerPlayer(true).getName(), System.currentTimeMillis()); - // } - // } @EventHandler public void CreatureCull(UpdateEvent event) @@ -756,11 +781,11 @@ public class UHC extends TeamGame goldMelon.addIngredient(1, Material.GOLD_BLOCK); UtilServer.getServer().addRecipe(goldMelon); - ShapedRecipe headApple = new ShapedRecipe(new ItemStack(Material.GOLDEN_APPLE, 1)); - headApple.shape("GGG","GHG","GGG"); - headApple.setIngredient('G', Material.GOLD_INGOT); - headApple.setIngredient('H', Material.SKULL); - UtilServer.getServer().addRecipe(headApple); + ShapedRecipe headApple2 = new ShapedRecipe(new ItemStack(Material.GOLDEN_APPLE, 1)); + headApple2.shape("GGG","GHG","GGG"); + headApple2.setIngredient('G', Material.GOLD_INGOT); + headApple2.setIngredient('H', new MaterialData(Material.SKULL_ITEM, (byte)3)); + UtilServer.getServer().addRecipe(headApple2); } @EventHandler(priority = EventPriority.HIGH) @@ -805,7 +830,7 @@ public class UHC extends TeamGame for (ItemStack item : inv.getMatrix()) if (item != null && item.getType() != Material.AIR) - if (item.getType() == Material.SKULL) + if (item.getType() == Material.SKULL_ITEM || item.getType() == Material.SKULL) { if (item.getItemMeta() == null) continue; @@ -859,6 +884,53 @@ public class UHC extends TeamGame if (event.getItemInHand().getType() == Material.SKULL || event.getItemInHand().getType() == Material.SKULL_ITEM) event.setCancelled(true); } + + @EventHandler + public void HeadPickup(PlayerPickupItemEvent event) + { + if (!IsLive()) + return; + + if (event.getItem().getItemStack().getType() == Material.SKULL_ITEM) + { + UtilPlayer.message(event.getPlayer(), " "); + UtilPlayer.message(event.getPlayer(), C.cGreen + C.Bold + "You picked up a Player Head!"); + UtilPlayer.message(event.getPlayer(), C.cWhite + "Craft a Golden Head Apple with it for ultimate healing."); + UtilPlayer.message(event.getPlayer(), C.cWhite + "Use the recipe for Golden Apple, but Head replaces Apple."); + UtilPlayer.message(event.getPlayer(), " "); + } + } + + /* + @EventHandler + public void HeadEat(PlayerInteractEvent event) + { + if (UtilGear.isMat(event.getPlayer().getItemInHand(), Material.SKULL_ITEM)) + { + UtilPlayer.message(event.getPlayer(), "You ate " + event.getPlayer().getItemInHand().getItemMeta().getDisplayName() + ChatColor.RESET + "."); + + (new PotionEffect(PotionEffectType.ABSORPTION, 2400, 0)).apply(event.getPlayer()); + (new PotionEffect(PotionEffectType.REGENERATION, 200, 1)).apply(event.getPlayer()); + + event.getPlayer().setItemInHand(null); + event.setCancelled(true); + } + } + + @EventHandler(priority = EventPriority.MONITOR) + public void DamageHealCancel(EntityDamageEvent event) + { + if (event.isCancelled()) + return; + + if (event.getEntity() instanceof Player) + { + Player player = (Player)event.getEntity(); + player.removePotionEffect(PotionEffectType.REGENERATION); + + UtilPlayer.message(player, "You took damage and lost " + F.elem(C.cGreen + "Regeneration") + ChatColor.RESET + "."); + } + }*/ @EventHandler public void ConsumeHeadApple(PlayerItemConsumeEvent event)