addon-level/src/main/java/world/bentobox/level/events/IslandLevelCalculatedEvent.java
tastybento 750f07ba7c
Release 2.8.0 (#239)
* Version 2.7.1

* Version 2.7.2

* Use Java 9's takeWhile

* Added placeholder %Level_[gamemode]_rank_value

Fixes https://github.com/BentoBoxWorld/Level/issues/228

* No save on disable (#231)

* Release 2.6.4

* Remove saving to database on disable.

https://github.com/BentoBoxWorld/Level/issues/229

First, the top ten tables are never actually used or loaded. They are
created in memory by loading the island levels. So there is no reason to
keep saving them.
Second, the island level data is saved every time it is changed, so
there is no need to save all of the cache on exit.

* Fixes tests

* Rosestacker (#232)

* Add support for RoseStacker 1.3.0

* Made plugin a Pladdon.

* Version 2.8.0

* Added new placeholders

%Level_%gamemode%_top_island_name_%rank% - lists the island name
%Level_%gamemode%_top_island_members_%rank% - a comma separated list of
team members

https://github.com/BentoBoxWorld/Level/issues/224
https://github.com/BentoBoxWorld/Level/issues/211
https://github.com/BentoBoxWorld/Level/issues/132
https://github.com/BentoBoxWorld/Level/issues/107
https://github.com/BentoBoxWorld/Level/issues/105

* Update to BentoBox API 1.18

* Open up modules for testing access.

* Back support for BentoBox 1.16.5.
2021-10-16 16:12:52 -07:00

121 lines
2.9 KiB
Java

package world.bentobox.level.events;
import java.util.List;
import java.util.UUID;
import org.bukkit.event.HandlerList;
import org.eclipse.jdt.annotation.NonNull;
import world.bentobox.bentobox.api.events.IslandBaseEvent;
import world.bentobox.bentobox.database.objects.Island;
import world.bentobox.level.calculators.Results;
/**
* This event is fired after the island level is calculated and before the results are saved.
* If this event is cancelled, results will saved, but not communicated. i.e., the result will be silent.
*
* @author tastybento
*/
public class IslandLevelCalculatedEvent extends IslandBaseEvent {
private Results results;
private UUID targetPlayer;
private static final HandlerList handlers = new HandlerList();
@Override
public @NonNull HandlerList getHandlers() {
return getHandlerList();
}
public static HandlerList getHandlerList() {
return handlers;
}
/**
* @param targetPlayer - target player
* @param island - island
* @param results - results object to set
*/
public IslandLevelCalculatedEvent(UUID targetPlayer, Island island, Results results) {
super(island);
this.targetPlayer = targetPlayer;
this.results = results;
}
/**
* Do NOT get this result if you are not a BentoBox addon!
* @return the results
*/
public Results getResults() {
return results;
}
/**
* @return death handicap value
*/
public int getDeathHandicap() {
return results.getDeathHandicap();
}
/**
* Get the island's initial level. It may be zero if it was never calculated.
* @return initial level of island as calculated when the island was created.
*/
public long getInitialLevel() {
return results.getInitialLevel();
}
/**
* @return the level calculated
*/
public long getLevel() {
return results.getLevel();
}
/**
* Overwrite the level. This level will be used instead of the calculated level.
* @param level - the level to set
*/
public void setLevel(long level) {
results.setLevel(level);
}
/**
* @return number of points required to next level
*/
public long getPointsToNextLevel() {
return results.getPointsToNextLevel();
}
/**
* @return a human readable report explaining how the calculation was made
*/
public List<String> getReport() {
return results.getReport();
}
/**
* @return the targetPlayer
*/
public UUID getTargetPlayer() {
return targetPlayer;
}
/**
* Do not use this if you are not a BentoBox addon
* @param results the results to set
*/
public void setResults(Results results) {
this.results = results;
}
/**
* @param targetPlayer the targetPlayer to set
*/
public void setTargetPlayer(UUID targetPlayer) {
this.targetPlayer = targetPlayer;
}
}