mirror of
https://github.com/BentoBoxWorld/Level.git
synced 2025-01-08 16:58:23 +01:00
Implements better value command
Checks world value Fixes https://github.com/BentoBoxWorld/Level/issues/148
This commit is contained in:
parent
0a4b0af931
commit
b92d412f0a
@ -219,17 +219,13 @@ public class CalcIslandLevel {
|
||||
* @return value of a material
|
||||
*/
|
||||
private int getValue(Material md) {
|
||||
// Check world settings
|
||||
if (addon.getBlockConfig().getWorldBlockValues().containsKey(world) && addon.getBlockConfig().getWorldBlockValues().get(world).containsKey(md)) {
|
||||
return addon.getBlockConfig().getWorldBlockValues().get(world).get(md);
|
||||
Integer value = addon.getBlockConfig().getValue(world, md);
|
||||
if (value == null) {
|
||||
// Not in config
|
||||
result.ncCount.add(md);
|
||||
return 0;
|
||||
}
|
||||
// Check baseline
|
||||
if (addon.getBlockConfig().getBlockValues().containsKey(md)) {
|
||||
return addon.getBlockConfig().getBlockValues().get(md);
|
||||
}
|
||||
// Not in config
|
||||
result.ncCount.add(md);
|
||||
return 0;
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -10,11 +10,11 @@ import world.bentobox.level.Level;
|
||||
import java.util.List;
|
||||
|
||||
public class IslandValueCommand extends CompositeCommand {
|
||||
private final Level plugin;
|
||||
private final Level addon;
|
||||
|
||||
public IslandValueCommand(Level plugin, CompositeCommand parent) {
|
||||
public IslandValueCommand(Level addon, CompositeCommand parent) {
|
||||
super(parent, "value");
|
||||
this.plugin = plugin;
|
||||
this.addon = addon;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -30,14 +30,12 @@ public class IslandValueCommand extends CompositeCommand {
|
||||
PlayerInventory inventory = player.getInventory();
|
||||
if (!inventory.getItemInMainHand().getType().equals(Material.AIR)) {
|
||||
Material material = inventory.getItemInMainHand().getType();
|
||||
if (plugin.getConfig().get("blocks." + material.toString()) != null) {
|
||||
int value = plugin.getConfig().getInt("blocks." + material.toString());
|
||||
user.sendMessage("island.value.success", "[value]", value + "");
|
||||
if (plugin.getConfig().get("underwater") != null) {
|
||||
double underWater = plugin.getConfig().getDouble("underwater");
|
||||
if (underWater > 1.0) {
|
||||
user.sendMessage("island.value.success-underwater", "[value]", (underWater * value) + "");
|
||||
}
|
||||
Integer value = addon.getBlockConfig().getValue(getWorld(), material);
|
||||
if (value != null) {
|
||||
user.sendMessage("island.value.success", "[value]", String.valueOf(value));
|
||||
double underWater = addon.getSettings().getUnderWaterMultiplier();
|
||||
if (underWater > 1.0) {
|
||||
user.sendMessage("island.value.success-underwater", "[value]", (underWater * value) + "");
|
||||
}
|
||||
} else {
|
||||
user.sendMessage("island.value.no-value");
|
||||
@ -47,4 +45,5 @@ public class IslandValueCommand extends CompositeCommand {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -107,4 +107,24 @@ public class BlockConfig {
|
||||
public Map<World, Map<Material, Integer>> getWorldBlockValues() {
|
||||
return worldBlockValues;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of material in world
|
||||
* @param world - world
|
||||
* @param md - material
|
||||
* @return value or null if not configured with a value
|
||||
*/
|
||||
public Integer getValue(World world, Material md) {
|
||||
// Check world settings
|
||||
if (getWorldBlockValues().containsKey(world) && getWorldBlockValues().get(world).containsKey(md)) {
|
||||
return getWorldBlockValues().get(world).get(md);
|
||||
}
|
||||
// Check baseline
|
||||
if (getBlockValues().containsKey(md)) {
|
||||
return getBlockValues().get(md);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user