Implement boss drops.

This commit is contained in:
garbagemule 2014-08-01 21:26:00 +02:00
parent 7766260154
commit d6c1f97415
5 changed files with 37 additions and 5 deletions

View File

@ -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<ItemStack> drops = boss.getDrops();
if (drops != null && !drops.isEmpty()) {
event.getDrops().addAll(drops);
}
boss.setDead(true);
}
List<ItemStack> loot = monsters.getLoot(damagee);
if (loot != null && !loot.isEmpty()) {
event.getDrops().add(getRandomItem(loot));

View File

@ -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) {

View File

@ -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<ItemStack> 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<ItemStack> drops) {
this.drops = drops;
}
public List<ItemStack> getDrops() {
return drops;
}
}

View File

@ -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<ItemStack> drops = ItemParser.parseItems(drp);
result.setDrops(drops);
return result;
}

View File

@ -33,6 +33,7 @@ public class BossWave extends AbstractWave
private int abilityInterval;
private ItemStack reward;
private List<ItemStack> 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<ItemStack> getDrops() {
return drops;
}
public void setDrops(List<ItemStack> 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