mirror of
https://github.com/BentoBoxWorld/Level.git
synced 2024-11-22 02:25:56 +01:00
Merge pull request #320 from BentoBoxWorld/311_Request_for_Additional_Placeholders
311 request for additional placeholders
This commit is contained in:
commit
8636239e90
2
pom.xml
2
pom.xml
@ -71,7 +71,7 @@
|
||||
<!-- Do not change unless you want different name for local builds. -->
|
||||
<build.number>-LOCAL</build.number>
|
||||
<!-- This allows to change between versions. -->
|
||||
<build.version>2.14.1</build.version>
|
||||
<build.version>2.15.0</build.version>
|
||||
<sonar.projectKey>BentoBoxWorld_Level</sonar.projectKey>
|
||||
<sonar.organization>bentobox-world</sonar.organization>
|
||||
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
|
||||
|
@ -216,15 +216,32 @@ public class LevelsManager {
|
||||
*
|
||||
* @param world - world where the island is
|
||||
* @param targetPlayer - target player UUID
|
||||
* @param ownerOnly - return level only if the target player is the owner
|
||||
* @return Level of the player's island or zero if player is unknown or UUID is
|
||||
* null
|
||||
*/
|
||||
public long getIslandLevel(@NonNull World world, @Nullable UUID targetPlayer) {
|
||||
return getIslandLevel(world, targetPlayer, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get level of island from cache for a player.
|
||||
*
|
||||
* @param world - world where the island is
|
||||
* @param targetPlayer - target player UUID
|
||||
* @param ownerOnly - return level only if the target player is the owner
|
||||
* @return Level of the player's island or zero if player is unknown or UUID is
|
||||
* null
|
||||
*/
|
||||
public long getIslandLevel(@NonNull World world, @Nullable UUID targetPlayer, boolean ownerOnly) {
|
||||
if (targetPlayer == null)
|
||||
return 0L;
|
||||
// Get the island
|
||||
Island island = addon.getIslands().getIsland(world, targetPlayer);
|
||||
return island == null ? 0L : getLevelsData(island).getLevel();
|
||||
if (island == null || island.getOwner() == null || (ownerOnly && !island.getOwner().equals(targetPlayer))) {
|
||||
return 0L;
|
||||
}
|
||||
return getLevelsData(island).getLevel();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -41,6 +41,9 @@ public class PlaceholderManager {
|
||||
// Island Level
|
||||
bpm.registerPlaceholder(addon, gm.getDescription().getName().toLowerCase() + "_island_level",
|
||||
user -> addon.getManager().getIslandLevelString(gm.getOverWorld(), user.getUniqueId()));
|
||||
// Island Level owner only
|
||||
bpm.registerPlaceholder(addon, gm.getDescription().getName().toLowerCase() + "_island_level_owner",
|
||||
user -> String.valueOf(addon.getManager().getIslandLevel(gm.getOverWorld(), user.getUniqueId(), true)));
|
||||
// Unformatted island level
|
||||
bpm.registerPlaceholder(addon, gm.getDescription().getName().toLowerCase() + "_island_level_raw",
|
||||
user -> String.valueOf(addon.getManager().getIslandLevel(gm.getOverWorld(), user.getUniqueId())));
|
||||
|
Loading…
Reference in New Issue
Block a user