mirror of
https://github.com/BentoBoxWorld/Level.git
synced 2024-12-22 17:18:44 +01:00
Adds the number placed and limit to the value hand command #273
This commit is contained in:
parent
8255073706
commit
fb107038ca
@ -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) {
|
||||
|
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user