From d6c1f97415e3889c837c66a057812b28d2307bab Mon Sep 17 00:00:00 2001 From: garbagemule Date: Fri, 1 Aug 2014 21:26:00 +0200 Subject: [PATCH] Implement boss drops. --- src/com/garbagemule/MobArena/ArenaListener.java | 15 ++++++++++----- src/com/garbagemule/MobArena/MASpawnThread.java | 1 + src/com/garbagemule/MobArena/waves/MABoss.java | 11 +++++++++++ .../garbagemule/MobArena/waves/WaveParser.java | 5 +++++ .../MobArena/waves/types/BossWave.java | 10 ++++++++++ 5 files changed, 37 insertions(+), 5 deletions(-) diff --git a/src/com/garbagemule/MobArena/ArenaListener.java b/src/com/garbagemule/MobArena/ArenaListener.java index a7c3a6b..2c80cd9 100644 --- a/src/com/garbagemule/MobArena/ArenaListener.java +++ b/src/com/garbagemule/MobArena/ArenaListener.java @@ -6,6 +6,7 @@ import com.garbagemule.MobArena.events.ArenaKillEvent; import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.block.BlockState; @@ -529,11 +530,6 @@ public class ArenaListener } callKillEvent(p, damagee); } - - MABoss boss = monsters.removeBoss(damagee); - if (boss != null) { - boss.setDead(true); - } if (!monsterExp) { event.setDroppedExp(0); @@ -541,6 +537,15 @@ public class ArenaListener event.getDrops().clear(); + MABoss boss = monsters.removeBoss(damagee); + if (boss != null) { + List drops = boss.getDrops(); + if (drops != null && !drops.isEmpty()) { + event.getDrops().addAll(drops); + } + boss.setDead(true); + } + List loot = monsters.getLoot(damagee); if (loot != null && !loot.isEmpty()) { event.getDrops().add(getRandomItem(loot)); diff --git a/src/com/garbagemule/MobArena/MASpawnThread.java b/src/com/garbagemule/MobArena/MASpawnThread.java index 42f7b67..3044890 100644 --- a/src/com/garbagemule/MobArena/MASpawnThread.java +++ b/src/com/garbagemule/MobArena/MASpawnThread.java @@ -180,6 +180,7 @@ public class MASpawnThread implements Runnable double maxHealth = bw.getMaxHealth(playerCount); MABoss boss = monsterManager.addBoss(e, maxHealth); boss.setReward(bw.getReward()); + boss.setDrops(bw.getDrops()); bw.addMABoss(boss); bw.activateAbilities(arena); if (bw.getBossName() != null) { diff --git a/src/com/garbagemule/MobArena/waves/MABoss.java b/src/com/garbagemule/MobArena/waves/MABoss.java index cd16a33..d1a5600 100644 --- a/src/com/garbagemule/MobArena/waves/MABoss.java +++ b/src/com/garbagemule/MobArena/waves/MABoss.java @@ -3,11 +3,14 @@ package com.garbagemule.MobArena.waves; import org.bukkit.entity.LivingEntity; import org.bukkit.inventory.ItemStack; +import java.util.List; + public class MABoss { private LivingEntity entity; private boolean dead; private ItemStack reward; + private List drops; /** * Create an MABoss from the given entity with the given max health. @@ -71,4 +74,12 @@ public class MABoss public ItemStack getReward() { return reward; } + + public void setDrops(List drops) { + this.drops = drops; + } + + public List getDrops() { + return drops; + } } diff --git a/src/com/garbagemule/MobArena/waves/WaveParser.java b/src/com/garbagemule/MobArena/waves/WaveParser.java index e956719..b42244a 100644 --- a/src/com/garbagemule/MobArena/waves/WaveParser.java +++ b/src/com/garbagemule/MobArena/waves/WaveParser.java @@ -291,6 +291,11 @@ public class WaveParser ItemStack item = ItemParser.parseItem(rew); if (item != null) result.setReward(item); } + + // Drops! + String drp = config.getString("drops"); + List drops = ItemParser.parseItems(drp); + result.setDrops(drops); return result; } diff --git a/src/com/garbagemule/MobArena/waves/types/BossWave.java b/src/com/garbagemule/MobArena/waves/types/BossWave.java index 599e755..f0bc283 100644 --- a/src/com/garbagemule/MobArena/waves/types/BossWave.java +++ b/src/com/garbagemule/MobArena/waves/types/BossWave.java @@ -33,6 +33,7 @@ public class BossWave extends AbstractWave private int abilityInterval; private ItemStack reward; + private List drops; public BossWave(MACreature monster) { this.monster = monster; @@ -120,6 +121,14 @@ public class BossWave extends AbstractWave public void setReward(ItemStack reward) { this.reward = reward; } + + public List getDrops() { + return drops; + } + + public void setDrops(List drops) { + this.drops = drops; + } public void activateAbilities(Arena arena) { if (activated) { @@ -149,6 +158,7 @@ public class BossWave extends AbstractWave result.healthMultiplier = this.healthMultiplier; result.flatHealth = this.flatHealth; result.reward = this.reward; + result.drops = this.drops; result.bossName = this.bossName; // From AbstractWave