Use ThingPicker for boss rewards.

By using a ThingPicker instead of a Thing, boss rewards can now, just
like regular wave rewards, make use of the new `random()` and `all()`
functions as well as the `nothing` keyword.

Closes #628
This commit is contained in:
Andreas Troelsen
2020-08-24 22:53:00 +02:00
parent d30bd96a2a
commit 3b132d28dd
5 changed files with 20 additions and 12 deletions
+1
View File
@@ -20,6 +20,7 @@ These changes will (most likely) be included in the next version.
- New per-arena setting `announcer-type` determines where to display per-arena announcements such as wave spawns, auto start timers, boss abilities, and death messages. Options are `title` (default) or `chat`. - New per-arena setting `announcer-type` determines where to display per-arena announcements such as wave spawns, auto start timers, boss abilities, and death messages. Options are `title` (default) or `chat`.
- It is now possible to group rewards. For example, `all(stick, bone)` results a stick and a bone, while `random(all(stick, bone), all(dirt, stone))` results in getting _either_ a stick and a bone _or_ a dirt block and a stone block. - It is now possible to group rewards. For example, `all(stick, bone)` results a stick and a bone, while `random(all(stick, bone), all(dirt, stone))` results in getting _either_ a stick and a bone _or_ a dirt block and a stone block.
- The new `nothing` keyword can be used to _not_ grant a reward. This can be used in a crude way to create "loot table"-style reward systems where there is a _chance_ that something is reward, but it might also just be nothing. - The new `nothing` keyword can be used to _not_ grant a reward. This can be used in a crude way to create "loot table"-style reward systems where there is a _chance_ that something is reward, but it might also just be nothing.
- Boss rewards also support the `all()` and `random()` functions as well as the `nothing` keyword.
- The Root Target ability now uses potion effects (slowness, slow falling, and negative jump boost) instead of repeated teleports. This should make for a smoother root experience. - The Root Target ability now uses potion effects (slowness, slow falling, and negative jump boost) instead of repeated teleports. This should make for a smoother root experience.
- Using `spectate-on-death: true` no longer forces players out to their join location/exit warp before moving them to the spectator area. This should prevent "jumpy" behavior in multi-world setups. - Using `spectate-on-death: true` no longer forces players out to their join location/exit warp before moving them to the spectator area. This should prevent "jumpy" behavior in multi-world setups.
- Players should now properly respawn at the spectator area rather than at world spawn on servers with plugins that override respawn locations. - Players should now properly respawn at the spectator area rather than at world spawn on servers with plugins that override respawn locations.
@@ -15,6 +15,7 @@ import com.garbagemule.MobArena.repairable.RepairableDoor;
import com.garbagemule.MobArena.repairable.RepairableSign; import com.garbagemule.MobArena.repairable.RepairableSign;
import com.garbagemule.MobArena.things.ExperienceThing; import com.garbagemule.MobArena.things.ExperienceThing;
import com.garbagemule.MobArena.things.Thing; import com.garbagemule.MobArena.things.Thing;
import com.garbagemule.MobArena.things.ThingPicker;
import com.garbagemule.MobArena.util.ClassChests; import com.garbagemule.MobArena.util.ClassChests;
import com.garbagemule.MobArena.waves.MABoss; import com.garbagemule.MobArena.waves.MABoss;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@@ -610,10 +611,13 @@ public class ArenaListener
for (Player q : arena.getPlayersInArena()) { for (Player q : arena.getPlayersInArena()) {
arena.getMessenger().tell(q, Msg.WAVE_BOSS_KILLED, p.getName()); arena.getMessenger().tell(q, Msg.WAVE_BOSS_KILLED, p.getName());
} }
Thing reward = boss.getReward(); ThingPicker picker = boss.getReward();
if (reward != null) { if (picker != null) {
arena.getRewardManager().addReward(p, reward); Thing reward = picker.pick();
arena.getMessenger().tell(damager, Msg.WAVE_BOSS_REWARD_EARNED, reward.toString()); if (reward != null) {
arena.getRewardManager().addReward(p, reward);
arena.getMessenger().tell(damager, Msg.WAVE_BOSS_REWARD_EARNED, reward.toString());
}
} }
} }
} }
@@ -2,6 +2,7 @@ package com.garbagemule.MobArena.waves;
import com.garbagemule.MobArena.healthbar.HealthBar; import com.garbagemule.MobArena.healthbar.HealthBar;
import com.garbagemule.MobArena.things.Thing; import com.garbagemule.MobArena.things.Thing;
import com.garbagemule.MobArena.things.ThingPicker;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.attribute.Attribute; import org.bukkit.attribute.Attribute;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
@@ -13,7 +14,7 @@ public class MABoss
{ {
private LivingEntity entity; private LivingEntity entity;
private boolean dead; private boolean dead;
private Thing reward; private ThingPicker reward;
private List<ItemStack> drops; private List<ItemStack> drops;
private HealthBar healthbar; private HealthBar healthbar;
@@ -79,11 +80,11 @@ public class MABoss
healthbar.removeAll(); healthbar.removeAll();
} }
public void setReward(Thing reward) { public void setReward(ThingPicker reward) {
this.reward = reward; this.reward = reward;
} }
public Thing getReward() { public ThingPicker getReward() {
return reward; return reward;
} }
@@ -6,6 +6,7 @@ import com.garbagemule.MobArena.region.ArenaRegion;
import com.garbagemule.MobArena.things.InvalidThingInputString; import com.garbagemule.MobArena.things.InvalidThingInputString;
import com.garbagemule.MobArena.things.Thing; import com.garbagemule.MobArena.things.Thing;
import com.garbagemule.MobArena.things.ThingManager; import com.garbagemule.MobArena.things.ThingManager;
import com.garbagemule.MobArena.things.ThingPicker;
import com.garbagemule.MobArena.util.ItemParser; import com.garbagemule.MobArena.util.ItemParser;
import com.garbagemule.MobArena.util.PotionEffectParser; import com.garbagemule.MobArena.util.PotionEffectParser;
import com.garbagemule.MobArena.waves.ability.Ability; import com.garbagemule.MobArena.waves.ability.Ability;
@@ -307,8 +308,8 @@ public class WaveParser
String rew = config.getString("reward", null); String rew = config.getString("reward", null);
if (rew != null && !rew.isEmpty()) { if (rew != null && !rew.isEmpty()) {
try { try {
Thing thing = arena.getPlugin().getThingManager().parse(rew.trim()); ThingPicker picker = arena.getPlugin().getThingPickerManager().parse(rew.trim());
result.setReward(thing); result.setReward(picker);
} catch (InvalidThingInputString e) { } catch (InvalidThingInputString e) {
throw new ConfigError("Failed to parse boss reward in wave " + name + " of arena " + arena.configName() + ": " + e.getInput()); throw new ConfigError("Failed to parse boss reward in wave " + name + " of arena " + arena.configName() + ": " + e.getInput());
} }
@@ -3,6 +3,7 @@ package com.garbagemule.MobArena.waves.types;
import com.garbagemule.MobArena.Msg; import com.garbagemule.MobArena.Msg;
import com.garbagemule.MobArena.framework.Arena; import com.garbagemule.MobArena.framework.Arena;
import com.garbagemule.MobArena.things.Thing; import com.garbagemule.MobArena.things.Thing;
import com.garbagemule.MobArena.things.ThingPicker;
import com.garbagemule.MobArena.waves.AbstractWave; import com.garbagemule.MobArena.waves.AbstractWave;
import com.garbagemule.MobArena.waves.BossAbilityThread; import com.garbagemule.MobArena.waves.BossAbilityThread;
import com.garbagemule.MobArena.waves.MABoss; import com.garbagemule.MobArena.waves.MABoss;
@@ -37,7 +38,7 @@ public class BossWave extends AbstractWave
private int abilityInterval; private int abilityInterval;
private Thing reward; private ThingPicker reward;
private List<ItemStack> drops; private List<ItemStack> drops;
public BossWave(MACreature monster) { public BossWave(MACreature monster) {
@@ -119,11 +120,11 @@ public class BossWave extends AbstractWave
this.abilityAnnounce = abilityAnnounce; this.abilityAnnounce = abilityAnnounce;
} }
public Thing getReward() { public ThingPicker getReward() {
return reward; return reward;
} }
public void setReward(Thing reward) { public void setReward(ThingPicker reward) {
this.reward = reward; this.reward = reward;
} }