Skip to content

Commit 61719cd

Browse files
authored
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
2 parents 1d16238 + fb10703 commit 61719cd

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

src/main/java/world/bentobox/level/commands/IslandValueCommand.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,14 @@
88
import org.bukkit.Material;
99
import org.bukkit.entity.Player;
1010
import org.bukkit.inventory.PlayerInventory;
11+
import org.eclipse.jdt.annotation.NonNull;
1112

1213
import world.bentobox.bentobox.api.commands.CompositeCommand;
14+
import world.bentobox.bentobox.api.localization.TextVariables;
1315
import world.bentobox.bentobox.api.user.User;
1416
import world.bentobox.bentobox.util.Util;
1517
import world.bentobox.level.Level;
18+
import world.bentobox.level.objects.IslandLevels;
1619
import world.bentobox.level.panels.ValuePanel;
1720
import world.bentobox.level.util.Utils;
1821

@@ -112,6 +115,19 @@ private void printValue(User user, Material material)
112115
"[value]", (underWater * value) + ""),
113116
MATERIAL, Utils.prettifyObject(material, user));
114117
}
118+
119+
// Show how many have been placed and how many are allowed
120+
@NonNull
121+
IslandLevels lvData = this.addon.getManager()
122+
.getLevelsData(getIslands().getPrimaryIsland(getWorld(), user.getUniqueId()));
123+
int count = lvData.getMdCount().getOrDefault(material, 0) + lvData.getUwCount().getOrDefault(material, 0);
124+
user.sendMessage("level.conversations.you-have", TextVariables.NUMBER,
125+
String.valueOf(count));
126+
int limit = this.addon.getBlockConfig().getBlockLimits().getOrDefault(material, -1);
127+
if (limit > 0) {
128+
user.sendMessage("level.conversations.you-can-place", TextVariables.NUMBER,
129+
String.valueOf(limit));
130+
}
115131
}
116132
else
117133
{

src/main/java/world/bentobox/level/objects/IslandLevels.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public class IslandLevels implements DataObject {
6262
private Map<Material, Integer> uwCount;
6363

6464
/**
65-
* MaterialData count - count of all blocks
65+
* MaterialData count - count of all blocks excluding under water
6666
*/
6767
@Expose
6868
private Map<Material, Integer> mdCount;
@@ -162,27 +162,31 @@ public long getMaxLevel() {
162162
}
163163

164164
/**
165+
* The count of underwater blocks
165166
* @return the uwCount
166167
*/
167168
public Map<Material, Integer> getUwCount() {
168169
return uwCount;
169170
}
170171

171172
/**
173+
* Underwater blocks
172174
* @param uwCount the uwCount to set
173175
*/
174176
public void setUwCount(Map<Material, Integer> uwCount) {
175177
this.uwCount = uwCount;
176178
}
177179

178180
/**
181+
* All blocks count except for underwater blocks
179182
* @return the mdCount
180183
*/
181184
public Map<Material, Integer> getMdCount() {
182185
return mdCount;
183186
}
184187

185188
/**
189+
* All blocks except for underwater blocks
186190
* @param mdCount the mdCount to set
187191
*/
188192
public void setMdCount(Map<Material, Integer> mdCount) {

src/main/resources/locales/en-US.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,3 +216,7 @@ level:
216216
value-underwater: "&7 The value of '[material]' below sea-level: &e[value]"
217217
# Message that is sent to user when he does not hold any items in hand.
218218
empty-hand: "&c There are no blocks in your hand"
219+
# Message when showing how many have been placed of a block
220+
you-have: "&7 You have [number] at last count."
221+
# Message about the limit
222+
you-can-place: "&7 You can place up to [number] and have them count"

0 commit comments

Comments
 (0)