Add reward-node to boss waves.
This commit is contained in:
@@ -461,12 +461,30 @@ public class ArenaListener
|
||||
|
||||
// If the damager was a player, add to kills.
|
||||
if (damager instanceof Player) {
|
||||
ArenaPlayer ap = arena.getArenaPlayer((Player) damager);
|
||||
Player p = (Player) damager;
|
||||
ArenaPlayer ap = arena.getArenaPlayer(p);
|
||||
if (ap != null) {
|
||||
ArenaPlayerStatistics stats = ap.getStats();
|
||||
if (stats != null) {
|
||||
ap.getStats().inc("kills");
|
||||
arena.getScoreboard().addKill((Player) damager);
|
||||
arena.getScoreboard().addKill(p);
|
||||
}
|
||||
MABoss boss = monsters.removeBoss(event.getEntity());
|
||||
if (boss != null) {
|
||||
ItemStack reward = boss.getReward();
|
||||
if (reward != null) {
|
||||
String msg = p.getName() + " killed the boss and won: ";
|
||||
if (reward.getTypeId() == MobArena.ECONOMY_MONEY_ID) {
|
||||
plugin.giveMoney(p, reward.getAmount());
|
||||
msg += plugin.economyFormat(reward.getAmount());
|
||||
} else {
|
||||
arena.getRewardManager().addReward((Player) damager, reward);
|
||||
msg += MAUtils.toCamelCase(reward.getType().toString()) + ":" + reward.getAmount();
|
||||
}
|
||||
for (Player q : arena.getPlayersInArena()) {
|
||||
Messenger.tellPlayer(q, msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,6 +179,7 @@ public class MASpawnThread implements Runnable
|
||||
BossWave bw = (BossWave) w;
|
||||
int maxHealth = bw.getMaxHealth(playerCount);
|
||||
MABoss boss = monsterManager.addBoss(e, maxHealth);
|
||||
boss.setReward(bw.getReward());
|
||||
bw.addMABoss(boss);
|
||||
bw.activateAbilities(arena);
|
||||
if (bw.getBossName() != null) {
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
package com.garbagemule.MobArena.waves;
|
||||
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class MABoss
|
||||
{
|
||||
private LivingEntity entity;
|
||||
private boolean dead;
|
||||
private ItemStack reward;
|
||||
|
||||
/**
|
||||
* Create an MABoss from the given entity with the given max health.
|
||||
@@ -61,4 +63,12 @@ public class MABoss
|
||||
public void setDead(boolean dead) {
|
||||
this.dead = dead;
|
||||
}
|
||||
|
||||
public void setReward(ItemStack reward) {
|
||||
this.reward = reward;
|
||||
}
|
||||
|
||||
public ItemStack getReward() {
|
||||
return reward;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -276,6 +276,13 @@ public class WaveParser
|
||||
result.setAbilityInterval(config.getInt("ability-interval", 3) * 20);
|
||||
result.setAbilityAnnounce(config.getBoolean("ability-announce", true));
|
||||
|
||||
// Rewards!
|
||||
String rew = config.getString("reward");
|
||||
if (rew != null) {
|
||||
ItemStack item = ItemParser.parseItem(rew);
|
||||
if (item != null) result.setReward(item);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,8 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.garbagemule.MobArena.Messenger;
|
||||
import com.garbagemule.MobArena.Msg;
|
||||
import com.garbagemule.MobArena.framework.Arena;
|
||||
@@ -34,6 +36,8 @@ public class BossWave extends AbstractWave
|
||||
|
||||
private int abilityInterval;
|
||||
|
||||
private ItemStack reward;
|
||||
|
||||
public BossWave(MACreature monster) {
|
||||
this.monster = monster;
|
||||
this.bosses = new HashSet<MABoss>();
|
||||
@@ -113,6 +117,14 @@ public class BossWave extends AbstractWave
|
||||
this.abilityAnnounce = abilityAnnounce;
|
||||
}
|
||||
|
||||
public ItemStack getReward() {
|
||||
return reward;
|
||||
}
|
||||
|
||||
public void setReward(ItemStack reward) {
|
||||
this.reward = reward;
|
||||
}
|
||||
|
||||
public void activateAbilities(Arena arena) {
|
||||
if (activated) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user