Merge pull request #322 from BentoBoxWorld/273_show_placed_and_limit_in_value_hand

Adds the number placed and limit to the value hand command #273
This commit is contained in:
tastybento 2024-07-20 10:36:00 -07:00 committed by GitHub
commit 61719cdf3a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 25 additions and 1 deletions

View File

@ -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
{

View File

@ -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) {

View File

@ -216,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"