Bring keep-exp per-arena setting back.
This setting was removed a long time ago, likely by "happy mistake" in a larger refactoring. When enabled, players are granted any collected experience during the arena session as a reward when they die or reach the final wave of the arena. Note that deliberately leaving the arena is not included here, because "leaving" an arena is a highly ambiguous and conditional concept at the time of this commit. Figuring out when and how the experience reward should be added is complicated, and unless someone puts in a request for it, I think it's enough that the "legitimate" reasons for getting the experience (honorable death and reaching the final wave) are covered. Closes #485
This commit is contained in:
@@ -22,6 +22,7 @@ These changes will (most likely) be included in the next version.
|
|||||||
- Armor stands can now be placed in arenas and lobbies.
|
- Armor stands can now be placed in arenas and lobbies.
|
||||||
- The new command `/ma ready` (`/ma rdy` for short) can be used as an alternative to the iron block for readying up.
|
- The new command `/ma ready` (`/ma rdy` for short) can be used as an alternative to the iron block for readying up.
|
||||||
- Total experience is now correctly stored, reset, and restored on arena join/leave. This fixes a potential bug where total experience could increase in the arena, but levels and progress would still get reset at arena end.
|
- Total experience is now correctly stored, reset, and restored on arena join/leave. This fixes a potential bug where total experience could increase in the arena, but levels and progress would still get reset at arena end.
|
||||||
|
- The per-arena setting `keep-exp` returns. If enabled, any experience collected during an arena session is added as a reward on death or when the final wave is reached.
|
||||||
|
|
||||||
Thanks to:
|
Thanks to:
|
||||||
- Sait for adding the /ma ready command
|
- Sait for adding the /ma ready command
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import com.garbagemule.MobArena.repairable.RepairableBlock;
|
|||||||
import com.garbagemule.MobArena.repairable.RepairableContainer;
|
import com.garbagemule.MobArena.repairable.RepairableContainer;
|
||||||
import com.garbagemule.MobArena.repairable.RepairableDoor;
|
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.Thing;
|
import com.garbagemule.MobArena.things.Thing;
|
||||||
import com.garbagemule.MobArena.util.ClassChests;
|
import com.garbagemule.MobArena.util.ClassChests;
|
||||||
import com.garbagemule.MobArena.waves.MABoss;
|
import com.garbagemule.MobArena.waves.MABoss;
|
||||||
@@ -576,6 +577,9 @@ public class ArenaListener
|
|||||||
if (arena.getSettings().getBoolean("show-death-messages", true)) {
|
if (arena.getSettings().getBoolean("show-death-messages", true)) {
|
||||||
arena.announce(event.getDeathMessage());
|
arena.announce(event.getDeathMessage());
|
||||||
}
|
}
|
||||||
|
if (arena.getSettings().getBoolean("keep-exp", false)) {
|
||||||
|
arena.getRewardManager().addReward(player, new ExperienceThing(player.getTotalExperience()));
|
||||||
|
}
|
||||||
event.setDeathMessage(null);
|
event.setDeathMessage(null);
|
||||||
arena.getScoreboard().death(player);
|
arena.getScoreboard().death(player);
|
||||||
arena.playerDeath(player);
|
arena.playerDeath(player);
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import com.garbagemule.MobArena.framework.Arena;
|
|||||||
import com.garbagemule.MobArena.healthbar.CreatesHealthBar;
|
import com.garbagemule.MobArena.healthbar.CreatesHealthBar;
|
||||||
import com.garbagemule.MobArena.healthbar.HealthBar;
|
import com.garbagemule.MobArena.healthbar.HealthBar;
|
||||||
import com.garbagemule.MobArena.region.ArenaRegion;
|
import com.garbagemule.MobArena.region.ArenaRegion;
|
||||||
|
import com.garbagemule.MobArena.things.ExperienceThing;
|
||||||
import com.garbagemule.MobArena.things.Thing;
|
import com.garbagemule.MobArena.things.Thing;
|
||||||
import com.garbagemule.MobArena.waves.MABoss;
|
import com.garbagemule.MobArena.waves.MABoss;
|
||||||
import com.garbagemule.MobArena.waves.MACreature;
|
import com.garbagemule.MobArena.waves.MACreature;
|
||||||
@@ -130,6 +131,9 @@ public class MASpawnThread implements Runnable
|
|||||||
// Then force leave everyone
|
// Then force leave everyone
|
||||||
List<Player> players = new ArrayList<>(arena.getPlayersInArena());
|
List<Player> players = new ArrayList<>(arena.getPlayersInArena());
|
||||||
for (Player p : players) {
|
for (Player p : players) {
|
||||||
|
if (arena.getSettings().getBoolean("keep-exp", false)) {
|
||||||
|
arena.getRewardManager().addReward(p, new ExperienceThing(p.getTotalExperience()));
|
||||||
|
}
|
||||||
arena.playerLeave(p);
|
arena.playerLeave(p);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -0,0 +1,47 @@
|
|||||||
|
package com.garbagemule.MobArena.things;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class ExperienceThing implements Thing {
|
||||||
|
private final int experience;
|
||||||
|
|
||||||
|
public ExperienceThing(int experience) {
|
||||||
|
this.experience = experience;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean giveTo(Player player) {
|
||||||
|
player.giveExp(experience);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean takeFrom(Player player) {
|
||||||
|
int current = player.getTotalExperience();
|
||||||
|
if (current < experience) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Unfortunately, Player#giveExp(int) behaves strangely with negative
|
||||||
|
* values; if the amount of points into the current level is less than
|
||||||
|
* the amount we try to take away, the levels won't decrease, and the
|
||||||
|
* progress will simply go into negative values. As a workaround, we
|
||||||
|
* can just reset the experience values and then return the previous
|
||||||
|
* total experience - minus the amount we're taking away.
|
||||||
|
*/
|
||||||
|
|
||||||
|
player.setTotalExperience(0);
|
||||||
|
player.setLevel(0);
|
||||||
|
player.setExp(0);
|
||||||
|
|
||||||
|
player.giveExp(current - experience);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean heldBy(Player player) {
|
||||||
|
return player.getTotalExperience() > experience;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -27,6 +27,7 @@ wave-interval: 15
|
|||||||
final-wave: 0
|
final-wave: 0
|
||||||
monster-limit: 100
|
monster-limit: 100
|
||||||
monster-exp: false
|
monster-exp: false
|
||||||
|
keep-exp: false
|
||||||
food-regen: false
|
food-regen: false
|
||||||
lock-food-level: true
|
lock-food-level: true
|
||||||
player-time-in-arena: world
|
player-time-in-arena: world
|
||||||
|
|||||||
Reference in New Issue
Block a user