mirror of
https://github.com/BentoBoxWorld/Level.git
synced 2024-11-22 10:36:08 +01:00
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:
commit
61719cdf3a
@ -8,11 +8,14 @@ import java.util.Optional;
|
|||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.PlayerInventory;
|
import org.bukkit.inventory.PlayerInventory;
|
||||||
|
import org.eclipse.jdt.annotation.NonNull;
|
||||||
|
|
||||||
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
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.api.user.User;
|
||||||
import world.bentobox.bentobox.util.Util;
|
import world.bentobox.bentobox.util.Util;
|
||||||
import world.bentobox.level.Level;
|
import world.bentobox.level.Level;
|
||||||
|
import world.bentobox.level.objects.IslandLevels;
|
||||||
import world.bentobox.level.panels.ValuePanel;
|
import world.bentobox.level.panels.ValuePanel;
|
||||||
import world.bentobox.level.util.Utils;
|
import world.bentobox.level.util.Utils;
|
||||||
|
|
||||||
@ -112,6 +115,19 @@ public class IslandValueCommand extends CompositeCommand
|
|||||||
"[value]", (underWater * value) + ""),
|
"[value]", (underWater * value) + ""),
|
||||||
MATERIAL, Utils.prettifyObject(material, user));
|
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
|
else
|
||||||
{
|
{
|
||||||
|
@ -62,7 +62,7 @@ public class IslandLevels implements DataObject {
|
|||||||
private Map<Material, Integer> uwCount;
|
private Map<Material, Integer> uwCount;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MaterialData count - count of all blocks
|
* MaterialData count - count of all blocks excluding under water
|
||||||
*/
|
*/
|
||||||
@Expose
|
@Expose
|
||||||
private Map<Material, Integer> mdCount;
|
private Map<Material, Integer> mdCount;
|
||||||
@ -162,6 +162,7 @@ public class IslandLevels implements DataObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* The count of underwater blocks
|
||||||
* @return the uwCount
|
* @return the uwCount
|
||||||
*/
|
*/
|
||||||
public Map<Material, Integer> getUwCount() {
|
public Map<Material, Integer> getUwCount() {
|
||||||
@ -169,6 +170,7 @@ public class IslandLevels implements DataObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Underwater blocks
|
||||||
* @param uwCount the uwCount to set
|
* @param uwCount the uwCount to set
|
||||||
*/
|
*/
|
||||||
public void setUwCount(Map<Material, Integer> uwCount) {
|
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
|
* @return the mdCount
|
||||||
*/
|
*/
|
||||||
public Map<Material, Integer> getMdCount() {
|
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
|
* @param mdCount the mdCount to set
|
||||||
*/
|
*/
|
||||||
public void setMdCount(Map<Material, Integer> mdCount) {
|
public void setMdCount(Map<Material, Integer> mdCount) {
|
||||||
|
@ -216,3 +216,7 @@ level:
|
|||||||
value-underwater: "&7 The value of '[material]' below sea-level: &e[value]"
|
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.
|
# 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"
|
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