Skip to content

Commit

Permalink
Due recent level addon changes, it is required to use RequestHandler …
Browse files Browse the repository at this point in the history
…instead of direct access to island level.
  • Loading branch information
BONNe committed Aug 21, 2020
1 parent dd1b70b commit 4d0ebe4
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
<powermock.version>2.0.2</powermock.version>
<!-- More visible way how to change dependency versions -->
<spigot.version>1.16.1-R0.1-SNAPSHOT</spigot.version>
<bentobox.version>1.14.0-SNAPSHOT</bentobox.version>
<level.version>1.9.3</level.version>
<bentobox.version>1.14.0</bentobox.version>
<level.version>2.4.0</level.version>
<vault.version>1.7</vault.version>
<!-- Revision variable removes warning about dynamic version -->
<revision>${build.version}-SNAPSHOT</revision>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,11 @@ public boolean canChangeBiome()
// This is here as I am not sure if Level addon can calculate island level
// if players can build anywhere.

LevelsData data = this.addon.getLevelAddon().getLevelsData(this.targetUser.getUniqueId());
long islandLevel = Utils.getIslandLevel(this.targetUser.getUniqueId(),
this.world.getName());

if (data == null ||
!data.getLevels().containsKey(Util.getWorld(this.world).getName()) ||
this.biome.getRequiredLevel() > 0 &&
data.getLevel(Util.getWorld(this.world)) <= this.biome.getRequiredLevel())
if (this.biome.getRequiredLevel() > 0 &&
islandLevel < this.biome.getRequiredLevel())
{
// Not enough level

Expand Down
19 changes: 19 additions & 0 deletions src/main/java/world/bentobox/biomes/utils/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.util.*;

import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.api.addons.request.AddonRequestBuilder;


/**
Expand Down Expand Up @@ -337,4 +338,22 @@ public static boolean isTheEndBiome(Biome biome)
return false;
}
}


/**
* Returns the level of this player's island in the given world.
* @param playerUUID UUID of the player, not null.
* @param worldName Name of the world (Overworld) the island is in, not null.
* @return the player's island level or {@code 0L} if the input was invalid or
* if this player does not have an island in this world.
*/
public static long getIslandLevel(UUID playerUUID, String worldName)
{
return (Long) new AddonRequestBuilder().
addon("Level").
label("island-level").
addMetaData("world-name", worldName).
addMetaData("player", playerUUID).
request();
}
}

0 comments on commit 4d0ebe4

Please sign in to comment.