Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds the number placed and limit to the value hand command #273 #322

Merged
merged 1 commit into from
Jul 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@
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;

Expand Down Expand Up @@ -112,6 +115,19 @@ private void printValue(User user, Material material)
"[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
{
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/world/bentobox/level/objects/IslandLevels.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -162,27 +162,31 @@ public long getMaxLevel() {
}

/**
* The count of underwater blocks
* @return the uwCount
*/
public Map<Material, Integer> getUwCount() {
return uwCount;
}

/**
* Underwater blocks
* @param uwCount the uwCount to set
*/
public void setUwCount(Map<Material, Integer> uwCount) {
this.uwCount = uwCount;
}

/**
* All blocks count except for underwater blocks
* @return the mdCount
*/
public Map<Material, Integer> getMdCount() {
return mdCount;
}

/**
* All blocks except for underwater blocks
* @param mdCount the mdCount to set
*/
public void setMdCount(Map<Material, Integer> mdCount) {
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/locales/en-US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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