mirror of
https://github.com/BentoBoxWorld/Level.git
synced 2024-11-28 21:55:14 +01:00
commit
fd20a9eb81
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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -30,69 +30,72 @@ public class PlaceholderManager {
|
||||
private final BentoBox plugin;
|
||||
|
||||
public PlaceholderManager(Level addon) {
|
||||
this.addon = addon;
|
||||
this.plugin = addon.getPlugin();
|
||||
this.addon = addon;
|
||||
this.plugin = addon.getPlugin();
|
||||
}
|
||||
|
||||
protected void registerPlaceholders(GameModeAddon gm) {
|
||||
if (plugin.getPlaceholdersManager() == null)
|
||||
return;
|
||||
PlaceholdersManager bpm = plugin.getPlaceholdersManager();
|
||||
// Island Level
|
||||
bpm.registerPlaceholder(addon, gm.getDescription().getName().toLowerCase() + "_island_level",
|
||||
user -> addon.getManager().getIslandLevelString(gm.getOverWorld(), user.getUniqueId()));
|
||||
// Unformatted island level
|
||||
bpm.registerPlaceholder(addon, gm.getDescription().getName().toLowerCase() + "_island_level_raw",
|
||||
user -> String.valueOf(addon.getManager().getIslandLevel(gm.getOverWorld(), user.getUniqueId())));
|
||||
// Total number of points counted before applying level formula
|
||||
bpm.registerPlaceholder(addon, gm.getDescription().getName().toLowerCase() + "_island_total_points", user -> {
|
||||
IslandLevels data = addon.getManager().getLevelsData(addon.getIslands().getIsland(gm.getOverWorld(), user));
|
||||
return data.getTotalPoints() + "";
|
||||
});
|
||||
// Points to the next level for player
|
||||
bpm.registerPlaceholder(addon, gm.getDescription().getName().toLowerCase() + "_points_to_next_level",
|
||||
user -> addon.getManager().getPointsToNextString(gm.getOverWorld(), user.getUniqueId()));
|
||||
// Maximum level this island has ever been. Current level maybe lower.
|
||||
bpm.registerPlaceholder(addon, gm.getDescription().getName().toLowerCase() + "_island_level_max",
|
||||
user -> String.valueOf(addon.getManager().getIslandMaxLevel(gm.getOverWorld(), user.getUniqueId())));
|
||||
if (plugin.getPlaceholdersManager() == null)
|
||||
return;
|
||||
PlaceholdersManager bpm = plugin.getPlaceholdersManager();
|
||||
// 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())));
|
||||
// Total number of points counted before applying level formula
|
||||
bpm.registerPlaceholder(addon, gm.getDescription().getName().toLowerCase() + "_island_total_points", user -> {
|
||||
IslandLevels data = addon.getManager().getLevelsData(addon.getIslands().getIsland(gm.getOverWorld(), user));
|
||||
return data.getTotalPoints() + "";
|
||||
});
|
||||
// Points to the next level for player
|
||||
bpm.registerPlaceholder(addon, gm.getDescription().getName().toLowerCase() + "_points_to_next_level",
|
||||
user -> addon.getManager().getPointsToNextString(gm.getOverWorld(), user.getUniqueId()));
|
||||
// Maximum level this island has ever been. Current level maybe lower.
|
||||
bpm.registerPlaceholder(addon, gm.getDescription().getName().toLowerCase() + "_island_level_max",
|
||||
user -> String.valueOf(addon.getManager().getIslandMaxLevel(gm.getOverWorld(), user.getUniqueId())));
|
||||
|
||||
// Visited Island Level
|
||||
bpm.registerPlaceholder(addon, gm.getDescription().getName().toLowerCase() + "_visited_island_level",
|
||||
user -> getVisitedIslandLevel(gm, user));
|
||||
// Visited Island Level
|
||||
bpm.registerPlaceholder(addon, gm.getDescription().getName().toLowerCase() + "_visited_island_level",
|
||||
user -> getVisitedIslandLevel(gm, user));
|
||||
|
||||
// Register Top Ten Placeholders
|
||||
for (int i = 1; i < 11; i++) {
|
||||
final int rank = i;
|
||||
// Name
|
||||
bpm.registerPlaceholder(addon, gm.getDescription().getName().toLowerCase() + "_top_name_" + i,
|
||||
u -> getRankName(gm.getOverWorld(), rank, false));
|
||||
// Island Name
|
||||
bpm.registerPlaceholder(addon, gm.getDescription().getName().toLowerCase() + "_top_island_name_" + i,
|
||||
u -> getRankIslandName(gm.getOverWorld(), rank, false));
|
||||
// Members
|
||||
bpm.registerPlaceholder(addon, gm.getDescription().getName().toLowerCase() + "_top_members_" + i,
|
||||
u -> getRankMembers(gm.getOverWorld(), rank, false));
|
||||
// Level
|
||||
bpm.registerPlaceholder(addon, gm.getDescription().getName().toLowerCase() + "_top_value_" + i,
|
||||
u -> getRankLevel(gm.getOverWorld(), rank, false));
|
||||
// Weighted Level Name (Level / number of members)
|
||||
bpm.registerPlaceholder(addon, gm.getDescription().getName().toLowerCase() + "_top_weighted_name_" + i,
|
||||
u -> getRankName(gm.getOverWorld(), rank, true));
|
||||
// Weighted Island Name
|
||||
bpm.registerPlaceholder(addon,
|
||||
gm.getDescription().getName().toLowerCase() + "_top_weighted_island_name_" + i,
|
||||
u -> getRankIslandName(gm.getOverWorld(), rank, true));
|
||||
// Weighted Members
|
||||
bpm.registerPlaceholder(addon, gm.getDescription().getName().toLowerCase() + "_top_weighted_members_" + i,
|
||||
u -> getRankMembers(gm.getOverWorld(), rank, true));
|
||||
// Weighted Level (Level / number of members)
|
||||
bpm.registerPlaceholder(addon, gm.getDescription().getName().toLowerCase() + "_top_weighted_value_" + i,
|
||||
u -> getRankLevel(gm.getOverWorld(), rank, true));
|
||||
}
|
||||
// Register Top Ten Placeholders
|
||||
for (int i = 1; i < 11; i++) {
|
||||
final int rank = i;
|
||||
// Name
|
||||
bpm.registerPlaceholder(addon, gm.getDescription().getName().toLowerCase() + "_top_name_" + i,
|
||||
u -> getRankName(gm.getOverWorld(), rank, false));
|
||||
// Island Name
|
||||
bpm.registerPlaceholder(addon, gm.getDescription().getName().toLowerCase() + "_top_island_name_" + i,
|
||||
u -> getRankIslandName(gm.getOverWorld(), rank, false));
|
||||
// Members
|
||||
bpm.registerPlaceholder(addon, gm.getDescription().getName().toLowerCase() + "_top_members_" + i,
|
||||
u -> getRankMembers(gm.getOverWorld(), rank, false));
|
||||
// Level
|
||||
bpm.registerPlaceholder(addon, gm.getDescription().getName().toLowerCase() + "_top_value_" + i,
|
||||
u -> getRankLevel(gm.getOverWorld(), rank, false));
|
||||
// Weighted Level Name (Level / number of members)
|
||||
bpm.registerPlaceholder(addon, gm.getDescription().getName().toLowerCase() + "_top_weighted_name_" + i,
|
||||
u -> getRankName(gm.getOverWorld(), rank, true));
|
||||
// Weighted Island Name
|
||||
bpm.registerPlaceholder(addon,
|
||||
gm.getDescription().getName().toLowerCase() + "_top_weighted_island_name_" + i,
|
||||
u -> getRankIslandName(gm.getOverWorld(), rank, true));
|
||||
// Weighted Members
|
||||
bpm.registerPlaceholder(addon, gm.getDescription().getName().toLowerCase() + "_top_weighted_members_" + i,
|
||||
u -> getRankMembers(gm.getOverWorld(), rank, true));
|
||||
// Weighted Level (Level / number of members)
|
||||
bpm.registerPlaceholder(addon, gm.getDescription().getName().toLowerCase() + "_top_weighted_value_" + i,
|
||||
u -> getRankLevel(gm.getOverWorld(), rank, true));
|
||||
}
|
||||
|
||||
// Personal rank
|
||||
bpm.registerPlaceholder(addon, gm.getDescription().getName().toLowerCase() + "_rank_value",
|
||||
u -> getRankValue(gm.getOverWorld(), u));
|
||||
// Personal rank
|
||||
bpm.registerPlaceholder(addon, gm.getDescription().getName().toLowerCase() + "_rank_value",
|
||||
u -> getRankValue(gm.getOverWorld(), u));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -104,17 +107,17 @@ public class PlaceholderManager {
|
||||
* @return rank name
|
||||
*/
|
||||
String getRankName(World world, int rank, boolean weighted) {
|
||||
// Ensure rank is within bounds
|
||||
rank = Math.max(1, Math.min(rank, Level.TEN));
|
||||
if (weighted) {
|
||||
return addon.getManager().getWeightedTopTen(world, Level.TEN).keySet().stream().skip(rank - 1L).limit(1L)
|
||||
.findFirst().map(Island::getOwner).map(addon.getPlayers()::getName).orElse("");
|
||||
}
|
||||
@Nullable
|
||||
UUID owner = addon.getManager().getTopTen(world, Level.TEN).keySet().stream().skip(rank - 1L).limit(1L)
|
||||
.findFirst().flatMap(addon.getIslands()::getIslandById).map(Island::getOwner).orElse(null);
|
||||
// Ensure rank is within bounds
|
||||
rank = Math.max(1, Math.min(rank, Level.TEN));
|
||||
if (weighted) {
|
||||
return addon.getManager().getWeightedTopTen(world, Level.TEN).keySet().stream().skip(rank - 1L).limit(1L)
|
||||
.findFirst().map(Island::getOwner).map(addon.getPlayers()::getName).orElse("");
|
||||
}
|
||||
@Nullable
|
||||
UUID owner = addon.getManager().getTopTen(world, Level.TEN).keySet().stream().skip(rank - 1L).limit(1L)
|
||||
.findFirst().flatMap(addon.getIslands()::getIslandById).map(Island::getOwner).orElse(null);
|
||||
|
||||
return addon.getPlayers().getName(owner);
|
||||
return addon.getPlayers().getName(owner);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -126,14 +129,14 @@ public class PlaceholderManager {
|
||||
* @return name of island or nothing if there isn't one
|
||||
*/
|
||||
String getRankIslandName(World world, int rank, boolean weighted) {
|
||||
// Ensure rank is within bounds
|
||||
rank = Math.max(1, Math.min(rank, Level.TEN));
|
||||
if (weighted) {
|
||||
return addon.getManager().getWeightedTopTen(world, Level.TEN).keySet().stream().skip(rank - 1L).limit(1L)
|
||||
.findFirst().map(Island::getName).orElse("");
|
||||
}
|
||||
return addon.getManager().getTopTen(world, Level.TEN).keySet().stream().skip(rank - 1L).limit(1L).findFirst()
|
||||
.flatMap(addon.getIslands()::getIslandById).map(Island::getName).orElse("");
|
||||
// Ensure rank is within bounds
|
||||
rank = Math.max(1, Math.min(rank, Level.TEN));
|
||||
if (weighted) {
|
||||
return addon.getManager().getWeightedTopTen(world, Level.TEN).keySet().stream().skip(rank - 1L).limit(1L)
|
||||
.findFirst().map(Island::getName).orElse("");
|
||||
}
|
||||
return addon.getManager().getTopTen(world, Level.TEN).keySet().stream().skip(rank - 1L).limit(1L).findFirst()
|
||||
.flatMap(addon.getIslands()::getIslandById).map(Island::getName).orElse("");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -145,27 +148,27 @@ public class PlaceholderManager {
|
||||
* @return comma separated string of island member names
|
||||
*/
|
||||
String getRankMembers(World world, int rank, boolean weighted) {
|
||||
// Ensure rank is within bounds
|
||||
rank = Math.max(1, Math.min(rank, Level.TEN));
|
||||
if (weighted) {
|
||||
return addon.getManager().getWeightedTopTen(world, Level.TEN).keySet().stream().skip(rank - 1L).limit(1L)
|
||||
.findFirst()
|
||||
.map(is -> is.getMembers().entrySet().stream().filter(e -> e.getValue() >= RanksManager.MEMBER_RANK)
|
||||
.sorted(Collections.reverseOrder(Map.Entry.comparingByValue())).map(Map.Entry::getKey)
|
||||
.map(addon.getPlayers()::getName).collect(Collectors.joining(",")))
|
||||
.orElse("");
|
||||
}
|
||||
// Ensure rank is within bounds
|
||||
rank = Math.max(1, Math.min(rank, Level.TEN));
|
||||
if (weighted) {
|
||||
return addon.getManager().getWeightedTopTen(world, Level.TEN).keySet().stream().skip(rank - 1L).limit(1L)
|
||||
.findFirst()
|
||||
.map(is -> is.getMembers().entrySet().stream().filter(e -> e.getValue() >= RanksManager.MEMBER_RANK)
|
||||
.sorted(Collections.reverseOrder(Map.Entry.comparingByValue())).map(Map.Entry::getKey)
|
||||
.map(addon.getPlayers()::getName).collect(Collectors.joining(",")))
|
||||
.orElse("");
|
||||
}
|
||||
|
||||
Optional<Island> island = addon.getManager().getTopTen(world, Level.TEN).keySet().stream().skip(rank - 1L)
|
||||
.limit(1L).findFirst().flatMap(addon.getIslands()::getIslandById);
|
||||
Optional<Island> island = addon.getManager().getTopTen(world, Level.TEN).keySet().stream().skip(rank - 1L)
|
||||
.limit(1L).findFirst().flatMap(addon.getIslands()::getIslandById);
|
||||
|
||||
if (island.isPresent()) {
|
||||
// Sort members by rank
|
||||
return island.get().getMembers().entrySet().stream().filter(e -> e.getValue() >= RanksManager.MEMBER_RANK)
|
||||
.sorted(Collections.reverseOrder(Map.Entry.comparingByValue())).map(Map.Entry::getKey)
|
||||
.map(addon.getPlayers()::getName).collect(Collectors.joining(","));
|
||||
}
|
||||
return "";
|
||||
if (island.isPresent()) {
|
||||
// Sort members by rank
|
||||
return island.get().getMembers().entrySet().stream().filter(e -> e.getValue() >= RanksManager.MEMBER_RANK)
|
||||
.sorted(Collections.reverseOrder(Map.Entry.comparingByValue())).map(Map.Entry::getKey)
|
||||
.map(addon.getPlayers()::getName).collect(Collectors.joining(","));
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
@ -177,14 +180,14 @@ public class PlaceholderManager {
|
||||
* @return level for the rank requested
|
||||
*/
|
||||
String getRankLevel(World world, int rank, boolean weighted) {
|
||||
// Ensure rank is within bounds
|
||||
rank = Math.max(1, Math.min(rank, Level.TEN));
|
||||
if (weighted) {
|
||||
return addon.getManager().formatLevel(addon.getManager().getWeightedTopTen(world, Level.TEN).values()
|
||||
.stream().skip(rank - 1L).limit(1L).findFirst().orElse(null));
|
||||
}
|
||||
return addon.getManager().formatLevel(addon.getManager().getTopTen(world, Level.TEN).values().stream()
|
||||
.skip(rank - 1L).limit(1L).findFirst().orElse(null));
|
||||
// Ensure rank is within bounds
|
||||
rank = Math.max(1, Math.min(rank, Level.TEN));
|
||||
if (weighted) {
|
||||
return addon.getManager().formatLevel(addon.getManager().getWeightedTopTen(world, Level.TEN).values()
|
||||
.stream().skip(rank - 1L).limit(1L).findFirst().orElse(null));
|
||||
}
|
||||
return addon.getManager().formatLevel(addon.getManager().getTopTen(world, Level.TEN).values().stream()
|
||||
.skip(rank - 1L).limit(1L).findFirst().orElse(null));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -195,21 +198,21 @@ public class PlaceholderManager {
|
||||
* @return rank where 1 is the top rank.
|
||||
*/
|
||||
private String getRankValue(World world, User user) {
|
||||
if (user == null) {
|
||||
return "";
|
||||
}
|
||||
// Get the island level for this user
|
||||
long level = addon.getManager().getIslandLevel(world, user.getUniqueId());
|
||||
return String.valueOf(addon.getManager().getTopTenLists().getOrDefault(world, new TopTenData(world)).getTopTen()
|
||||
.values().stream().filter(l -> l > level).count() + 1);
|
||||
if (user == null) {
|
||||
return "";
|
||||
}
|
||||
// Get the island level for this user
|
||||
long level = addon.getManager().getIslandLevel(world, user.getUniqueId());
|
||||
return String.valueOf(addon.getManager().getTopTenLists().getOrDefault(world, new TopTenData(world)).getTopTen()
|
||||
.values().stream().filter(l -> l > level).count() + 1);
|
||||
}
|
||||
|
||||
String getVisitedIslandLevel(GameModeAddon gm, User user) {
|
||||
if (user == null || !gm.inWorld(user.getWorld()))
|
||||
return "";
|
||||
return addon.getIslands().getIslandAt(user.getLocation())
|
||||
.map(island -> addon.getManager().getIslandLevelString(gm.getOverWorld(), island.getOwner()))
|
||||
.orElse("0");
|
||||
if (user == null || !gm.inWorld(user.getWorld()))
|
||||
return "";
|
||||
return addon.getIslands().getIslandAt(user.getLocation())
|
||||
.map(island -> addon.getManager().getIslandLevelString(gm.getOverWorld(), island.getOwner()))
|
||||
.orElse("0");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,11 +8,14 @@ import java.util.Optional;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
import org.eclipse.jdt.annotation.NonNull;
|
||||
|
||||
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||
import world.bentobox.bentobox.api.localization.TextVariables;
|
||||
import world.bentobox.bentobox.api.user.User;
|
||||
import world.bentobox.bentobox.util.Util;
|
||||
import world.bentobox.level.Level;
|
||||
import world.bentobox.level.objects.IslandLevels;
|
||||
import world.bentobox.level.panels.ValuePanel;
|
||||
import world.bentobox.level.util.Utils;
|
||||
|
||||
@ -112,6 +115,19 @@ public class IslandValueCommand extends CompositeCommand
|
||||
"[value]", (underWater * value) + ""),
|
||||
MATERIAL, Utils.prettifyObject(material, user));
|
||||
}
|
||||
|
||||
// Show how many have been placed and how many are allowed
|
||||
@NonNull
|
||||
IslandLevels lvData = this.addon.getManager()
|
||||
.getLevelsData(getIslands().getPrimaryIsland(getWorld(), user.getUniqueId()));
|
||||
int count = lvData.getMdCount().getOrDefault(material, 0) + lvData.getUwCount().getOrDefault(material, 0);
|
||||
user.sendMessage("level.conversations.you-have", TextVariables.NUMBER,
|
||||
String.valueOf(count));
|
||||
int limit = this.addon.getBlockConfig().getBlockLimits().getOrDefault(material, -1);
|
||||
if (limit > 0) {
|
||||
user.sendMessage("level.conversations.you-can-place", TextVariables.NUMBER,
|
||||
String.valueOf(limit));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -62,7 +62,7 @@ public class IslandLevels implements DataObject {
|
||||
private Map<Material, Integer> uwCount;
|
||||
|
||||
/**
|
||||
* MaterialData count - count of all blocks
|
||||
* MaterialData count - count of all blocks excluding under water
|
||||
*/
|
||||
@Expose
|
||||
private Map<Material, Integer> mdCount;
|
||||
@ -162,6 +162,7 @@ public class IslandLevels implements DataObject {
|
||||
}
|
||||
|
||||
/**
|
||||
* The count of underwater blocks
|
||||
* @return the uwCount
|
||||
*/
|
||||
public Map<Material, Integer> getUwCount() {
|
||||
@ -169,6 +170,7 @@ public class IslandLevels implements DataObject {
|
||||
}
|
||||
|
||||
/**
|
||||
* Underwater blocks
|
||||
* @param uwCount the uwCount to set
|
||||
*/
|
||||
public void setUwCount(Map<Material, Integer> uwCount) {
|
||||
@ -176,6 +178,7 @@ public class IslandLevels implements DataObject {
|
||||
}
|
||||
|
||||
/**
|
||||
* All blocks count except for underwater blocks
|
||||
* @return the mdCount
|
||||
*/
|
||||
public Map<Material, Integer> getMdCount() {
|
||||
@ -183,6 +186,7 @@ public class IslandLevels implements DataObject {
|
||||
}
|
||||
|
||||
/**
|
||||
* All blocks except for underwater blocks
|
||||
* @param mdCount the mdCount to set
|
||||
*/
|
||||
public void setMdCount(Map<Material, Integer> mdCount) {
|
||||
|
@ -59,7 +59,7 @@ public class DetailsPanel {
|
||||
}
|
||||
|
||||
// By default no-filters are active.
|
||||
this.activeTab = Tab.ALL_BLOCKS;
|
||||
this.activeTab = Tab.VALUE_BLOCKS;
|
||||
this.activeFilter = Filter.NAME;
|
||||
this.materialCountList = new ArrayList<>(Material.values().length);
|
||||
|
||||
@ -111,6 +111,28 @@ public class DetailsPanel {
|
||||
this.materialCountList.clear();
|
||||
|
||||
switch (this.activeTab) {
|
||||
case VALUE_BLOCKS -> {
|
||||
Map<Material, Integer> materialCountMap = new EnumMap<>(Material.class);
|
||||
|
||||
materialCountMap.putAll(this.levelsData.getMdCount());
|
||||
|
||||
// Add underwater blocks.
|
||||
this.levelsData.getUwCount().forEach((material, count) -> materialCountMap.put(material,
|
||||
materialCountMap.computeIfAbsent(material, key -> 0) + count));
|
||||
|
||||
// Remove zero value blocks
|
||||
materialCountMap.entrySet().removeIf(en -> {
|
||||
Integer value = this.addon.getBlockConfig().getValue(world, en.getKey());
|
||||
return value == null || value == 0;
|
||||
});
|
||||
|
||||
materialCountMap.entrySet().stream().sorted((Map.Entry.comparingByKey())).forEachOrdered(entry -> {
|
||||
if (entry.getValue() > 0) {
|
||||
this.materialCountList.add(new Pair<>(entry.getKey(), entry.getValue()));
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
case ALL_BLOCKS -> {
|
||||
Map<Material, Integer> materialCountMap = new EnumMap<>(Material.class);
|
||||
|
||||
@ -220,7 +242,7 @@ public class DetailsPanel {
|
||||
builder.description(this.user.getTranslation(this.world, template.description()));
|
||||
}
|
||||
|
||||
Tab tab = Enums.getIfPresent(Tab.class, String.valueOf(template.dataMap().get("tab"))).or(Tab.ALL_BLOCKS);
|
||||
Tab tab = Enums.getIfPresent(Tab.class, String.valueOf(template.dataMap().get("tab"))).or(Tab.VALUE_BLOCKS);
|
||||
|
||||
// Get only possible actions, by removing all inactive ones.
|
||||
List<ItemTemplateRecord.ActionRecords> activeActions = new ArrayList<>(template.actions());
|
||||
@ -605,8 +627,12 @@ public class DetailsPanel {
|
||||
*/
|
||||
ALL_BLOCKS,
|
||||
/**
|
||||
* Above Sea level Tab.
|
||||
*/
|
||||
* Blocks that have value
|
||||
*/
|
||||
VALUE_BLOCKS,
|
||||
/**
|
||||
* Above Sea level Tab.
|
||||
*/
|
||||
ABOVE_SEA_LEVEL,
|
||||
/**
|
||||
* Underwater Tab.
|
||||
|
@ -112,6 +112,11 @@ level:
|
||||
limit: "&7 Block limit: &e [number]"
|
||||
count: "&7 Number of blocks: &e [number]"
|
||||
calculated: "&7 Calculated value: &e [number]"
|
||||
value_blocks:
|
||||
name: "&f&l All Blocks With Value"
|
||||
description: |-
|
||||
&7 Display all blocks
|
||||
&7 with value on island.
|
||||
all_blocks:
|
||||
name: "&f&l All Blocks"
|
||||
description: |-
|
||||
@ -211,3 +216,7 @@ level:
|
||||
value-underwater: "&7 The value of '[material]' below sea-level: &e[value]"
|
||||
# Message that is sent to user when he does not hold any items in hand.
|
||||
empty-hand: "&c There are no blocks in your hand"
|
||||
# Message when showing how many have been placed of a block
|
||||
you-have: "&7 You have [number] at last count."
|
||||
# Message about the limit
|
||||
you-can-place: "&7 You can place up to [number] and have them count"
|
||||
|
@ -24,6 +24,28 @@ detail_panel:
|
||||
1:
|
||||
# Column number
|
||||
2:
|
||||
# Icon is a Bukkit Material.
|
||||
icon: ICE
|
||||
# Title of the button shown to the user. This is a reference and the reference will be translatable in the locale file
|
||||
title: level.gui.buttons.value_blocks.name
|
||||
# Description of the button shown to the user in the lore. This is a reference and the reference will be translatable in the locale file
|
||||
description: level.gui.buttons.value_blocks.description
|
||||
# The data section is a key-value list of data relavent for this button. It is interpreted by the code implemented the panel.
|
||||
# The convention is to specify the type and the panel tab that will open if pressed. These are Enums in the code.
|
||||
data:
|
||||
# Type button will go to the ALL_BLOCKS tab when clicked.
|
||||
type: TAB
|
||||
tab: VALUE_BLOCKS
|
||||
# Actions cover what happens if the button is clicked or the mouse is moved over it. There can be multiple actions possible for different
|
||||
# click-types.
|
||||
actions:
|
||||
# Each action has an arbitrary descriptive name to define it.
|
||||
view:
|
||||
# The click-type is the same as the bukkit {@link org.bukkit.event.inventory.ClickType}. UNKNOWN is the default.
|
||||
click-type: unknown
|
||||
# tooltip is a locale reference that will be translated for the user and shown when they hover over the button.
|
||||
tooltip: level.gui.tips.click-to-view
|
||||
3:
|
||||
# Icon is a Bukkit Material.
|
||||
icon: STONE
|
||||
# Title of the button shown to the user. This is a reference and the reference will be translatable in the locale file
|
||||
@ -45,7 +67,7 @@ detail_panel:
|
||||
click-type: unknown
|
||||
# tooltip is a locale reference that will be translated for the user and shown when they hover over the button.
|
||||
tooltip: level.gui.tips.click-to-view
|
||||
3:
|
||||
4:
|
||||
icon: GRASS_BLOCK
|
||||
title: level.gui.buttons.above_sea_level.name
|
||||
description: level.gui.buttons.above_sea_level.description
|
||||
@ -56,7 +78,7 @@ detail_panel:
|
||||
view:
|
||||
click-type: unknown
|
||||
tooltip: level.gui.tips.click-to-view
|
||||
4:
|
||||
5:
|
||||
icon: WATER_BUCKET
|
||||
title: level.gui.buttons.underwater.name
|
||||
description: level.gui.buttons.underwater.description
|
||||
@ -67,7 +89,7 @@ detail_panel:
|
||||
view:
|
||||
click-type: unknown
|
||||
tooltip: level.gui.tips.click-to-view
|
||||
5:
|
||||
6:
|
||||
icon: SPAWNER
|
||||
title: level.gui.buttons.spawner.name
|
||||
description: level.gui.buttons.spawner.description
|
||||
|
Loading…
Reference in New Issue
Block a user