UHC head apple fixes

This commit is contained in:
Chiss 2014-10-11 23:09:56 +11:00
parent 9c8ed5360d
commit 1d3b792ed8
2 changed files with 92 additions and 20 deletions

View File

@ -33,15 +33,20 @@ import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
import org.bukkit.event.inventory.PrepareItemCraftEvent; import org.bukkit.event.inventory.PrepareItemCraftEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerItemConsumeEvent; import org.bukkit.event.player.PlayerItemConsumeEvent;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerKickEvent; import org.bukkit.event.player.PlayerKickEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.event.player.PlayerPortalEvent; import org.bukkit.event.player.PlayerPortalEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
import org.bukkit.inventory.CraftingInventory; import org.bukkit.inventory.CraftingInventory;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.ShapedRecipe; import org.bukkit.inventory.ShapedRecipe;
import org.bukkit.inventory.ShapelessRecipe; 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.PotionEffect;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import org.bukkit.scoreboard.DisplaySlot; 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.NautHashMap;
import mineplex.core.common.util.UtilBlock; import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEvent; 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.UtilMath;
import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilWorld; import mineplex.core.common.util.UtilWorld;
@ -568,6 +575,30 @@ public class UHC extends TeamGame
} }
} }
@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 @EventHandler
public void PlayerDeath(PlayerDeathEvent event) public void PlayerDeath(PlayerDeathEvent event)
{ {
@ -577,7 +608,13 @@ public class UHC extends TeamGame
if (team == null) return; if (team == null) return;
//Skull Drop //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 //Lightning
Location loc = player.getLocation(); 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 @EventHandler
public void CreatureCull(UpdateEvent event) public void CreatureCull(UpdateEvent event)
@ -756,11 +781,11 @@ public class UHC extends TeamGame
goldMelon.addIngredient(1, Material.GOLD_BLOCK); goldMelon.addIngredient(1, Material.GOLD_BLOCK);
UtilServer.getServer().addRecipe(goldMelon); UtilServer.getServer().addRecipe(goldMelon);
ShapedRecipe headApple = new ShapedRecipe(new ItemStack(Material.GOLDEN_APPLE, 1)); ShapedRecipe headApple2 = new ShapedRecipe(new ItemStack(Material.GOLDEN_APPLE, 1));
headApple.shape("GGG","GHG","GGG"); headApple2.shape("GGG","GHG","GGG");
headApple.setIngredient('G', Material.GOLD_INGOT); headApple2.setIngredient('G', Material.GOLD_INGOT);
headApple.setIngredient('H', Material.SKULL); headApple2.setIngredient('H', new MaterialData(Material.SKULL_ITEM, (byte)3));
UtilServer.getServer().addRecipe(headApple); UtilServer.getServer().addRecipe(headApple2);
} }
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
@ -805,7 +830,7 @@ public class UHC extends TeamGame
for (ItemStack item : inv.getMatrix()) for (ItemStack item : inv.getMatrix())
if (item != null && item.getType() != Material.AIR) 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) if (item.getItemMeta() == null)
continue; continue;
@ -860,6 +885,53 @@ public class UHC extends TeamGame
event.setCancelled(true); 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 @EventHandler
public void ConsumeHeadApple(PlayerItemConsumeEvent event) public void ConsumeHeadApple(PlayerItemConsumeEvent event)
{ {