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 the damager was a player, add to kills.
|
||||||
if (damager instanceof Player) {
|
if (damager instanceof Player) {
|
||||||
ArenaPlayer ap = arena.getArenaPlayer((Player) damager);
|
Player p = (Player) damager;
|
||||||
|
ArenaPlayer ap = arena.getArenaPlayer(p);
|
||||||
if (ap != null) {
|
if (ap != null) {
|
||||||
ArenaPlayerStatistics stats = ap.getStats();
|
ArenaPlayerStatistics stats = ap.getStats();
|
||||||
if (stats != null) {
|
if (stats != null) {
|
||||||
ap.getStats().inc("kills");
|
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;
|
BossWave bw = (BossWave) w;
|
||||||
int maxHealth = bw.getMaxHealth(playerCount);
|
int maxHealth = bw.getMaxHealth(playerCount);
|
||||||
MABoss boss = monsterManager.addBoss(e, maxHealth);
|
MABoss boss = monsterManager.addBoss(e, maxHealth);
|
||||||
|
boss.setReward(bw.getReward());
|
||||||
bw.addMABoss(boss);
|
bw.addMABoss(boss);
|
||||||
bw.activateAbilities(arena);
|
bw.activateAbilities(arena);
|
||||||
if (bw.getBossName() != null) {
|
if (bw.getBossName() != null) {
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
package com.garbagemule.MobArena.waves;
|
package com.garbagemule.MobArena.waves;
|
||||||
|
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
public class MABoss
|
public class MABoss
|
||||||
{
|
{
|
||||||
private LivingEntity entity;
|
private LivingEntity entity;
|
||||||
private boolean dead;
|
private boolean dead;
|
||||||
|
private ItemStack reward;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an MABoss from the given entity with the given max health.
|
* Create an MABoss from the given entity with the given max health.
|
||||||
@@ -61,4 +63,12 @@ public class MABoss
|
|||||||
public void setDead(boolean dead) {
|
public void setDead(boolean dead) {
|
||||||
this.dead = 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.setAbilityInterval(config.getInt("ability-interval", 3) * 20);
|
||||||
result.setAbilityAnnounce(config.getBoolean("ability-announce", true));
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import com.garbagemule.MobArena.Messenger;
|
import com.garbagemule.MobArena.Messenger;
|
||||||
import com.garbagemule.MobArena.Msg;
|
import com.garbagemule.MobArena.Msg;
|
||||||
import com.garbagemule.MobArena.framework.Arena;
|
import com.garbagemule.MobArena.framework.Arena;
|
||||||
@@ -34,6 +36,8 @@ public class BossWave extends AbstractWave
|
|||||||
|
|
||||||
private int abilityInterval;
|
private int abilityInterval;
|
||||||
|
|
||||||
|
private ItemStack reward;
|
||||||
|
|
||||||
public BossWave(MACreature monster) {
|
public BossWave(MACreature monster) {
|
||||||
this.monster = monster;
|
this.monster = monster;
|
||||||
this.bosses = new HashSet<MABoss>();
|
this.bosses = new HashSet<MABoss>();
|
||||||
@@ -113,6 +117,14 @@ public class BossWave extends AbstractWave
|
|||||||
this.abilityAnnounce = abilityAnnounce;
|
this.abilityAnnounce = abilityAnnounce;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ItemStack getReward() {
|
||||||
|
return reward;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReward(ItemStack reward) {
|
||||||
|
this.reward = reward;
|
||||||
|
}
|
||||||
|
|
||||||
public void activateAbilities(Arena arena) {
|
public void activateAbilities(Arena arena) {
|
||||||
if (activated) {
|
if (activated) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user