From d188224c0635ed72f0914191d1198424d96fbb34 Mon Sep 17 00:00:00 2001 From: TfT_02 Date: Sat, 20 Dec 2014 23:24:58 +0100 Subject: [PATCH] Make it possible to shake heads from players --- .../config/treasure/TreasureConfig.java | 4 ++++ .../gmail/nossr50/skills/fishing/Fishing.java | 3 +++ .../nossr50/skills/fishing/FishingManager.java | 18 ++++++++++++++++++ src/main/resources/treasures.yml | 6 ++++++ 4 files changed, 31 insertions(+) diff --git a/src/main/java/com/gmail/nossr50/config/treasure/TreasureConfig.java b/src/main/java/com/gmail/nossr50/config/treasure/TreasureConfig.java index 77ea403dd..0808dc2ab 100644 --- a/src/main/java/com/gmail/nossr50/config/treasure/TreasureConfig.java +++ b/src/main/java/com/gmail/nossr50/config/treasure/TreasureConfig.java @@ -57,6 +57,7 @@ public class TreasureConfig extends ConfigLoader { public List shakeFromMushroomCow = new ArrayList(); public List shakeFromPig = new ArrayList(); public List shakeFromPigZombie = new ArrayList(); + public List shakeFromPlayer = new ArrayList(); public List shakeFromSheep = new ArrayList(); public List shakeFromSkeleton = new ArrayList(); public List shakeFromSlime = new ArrayList(); @@ -353,6 +354,9 @@ public class TreasureConfig extends ConfigLoader { else if (type.equals("Shake.PIG_ZOMBIE")) { shakeFromPigZombie.add(shakeTreasure); } + else if (type.equals("Shake.PLAYER")) { + shakeFromPlayer.add(shakeTreasure); + } else if (type.equals("Shake.SHEEP")) { shakeFromSheep.add(shakeTreasure); } diff --git a/src/main/java/com/gmail/nossr50/skills/fishing/Fishing.java b/src/main/java/com/gmail/nossr50/skills/fishing/Fishing.java index 4986678b0..b7b719b13 100644 --- a/src/main/java/com/gmail/nossr50/skills/fishing/Fishing.java +++ b/src/main/java/com/gmail/nossr50/skills/fishing/Fishing.java @@ -110,6 +110,9 @@ public final class Fishing { case PIG_ZOMBIE: return TreasureConfig.getInstance().shakeFromPigZombie; + case PLAYER: + return TreasureConfig.getInstance().shakeFromPlayer; + case SHEEP: return TreasureConfig.getInstance().shakeFromSheep; diff --git a/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java b/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java index 15e68b428..f0e7ef8bb 100644 --- a/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java @@ -28,6 +28,7 @@ import org.bukkit.entity.TNTPrimed; import org.bukkit.entity.ThrownPotion; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.material.Wool; import org.bukkit.potion.Potion; import org.bukkit.potion.PotionType; @@ -393,6 +394,23 @@ public class FishingManager extends SkillManager { // Extra processing depending on the mob and drop type switch (target.getType()) { + case PLAYER: + Player targetPlayer = (Player) target; + + switch (drop.getType()) { + case SKULL_ITEM: + drop.setDurability((short) 3); + SkullMeta skullMeta = (SkullMeta) drop.getItemMeta(); + skullMeta.setOwner(targetPlayer.getName()); + drop.setItemMeta(skullMeta); + break; + + + default: + break; + } + break; + case SHEEP: Sheep sheep = (Sheep) target; diff --git a/src/main/resources/treasures.yml b/src/main/resources/treasures.yml index 894577537..772c73937 100644 --- a/src/main/resources/treasures.yml +++ b/src/main/resources/treasures.yml @@ -793,6 +793,12 @@ Shake: XP: 0 Drop_Chance: 50.0 Drop_Level: 0 + PLAYER: + SKULL_ITEM: + Amount: 1 + XP: 0 + Drop_Chance: 0.0 + Drop_Level: 0 SHEEP: WOOL: Amount: 3