mirror of
https://github.com/BentoBoxWorld/Level.git
synced 2025-01-24 08:21:21 +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
|
* @return value of a material
|
||||||
*/
|
*/
|
||||||
private int getValue(Material md) {
|
private int getValue(Material md) {
|
||||||
// Check world settings
|
Integer value = addon.getBlockConfig().getValue(world, md);
|
||||||
if (addon.getBlockConfig().getWorldBlockValues().containsKey(world) && addon.getBlockConfig().getWorldBlockValues().get(world).containsKey(md)) {
|
if (value == null) {
|
||||||
return addon.getBlockConfig().getWorldBlockValues().get(world).get(md);
|
// Not in config
|
||||||
|
result.ncCount.add(md);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
// Check baseline
|
return value;
|
||||||
if (addon.getBlockConfig().getBlockValues().containsKey(md)) {
|
|
||||||
return addon.getBlockConfig().getBlockValues().get(md);
|
|
||||||
}
|
|
||||||
// Not in config
|
|
||||||
result.ncCount.add(md);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -10,11 +10,11 @@ import world.bentobox.level.Level;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class IslandValueCommand extends CompositeCommand {
|
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");
|
super(parent, "value");
|
||||||
this.plugin = plugin;
|
this.addon = addon;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -30,14 +30,12 @@ public class IslandValueCommand extends CompositeCommand {
|
|||||||
PlayerInventory inventory = player.getInventory();
|
PlayerInventory inventory = player.getInventory();
|
||||||
if (!inventory.getItemInMainHand().getType().equals(Material.AIR)) {
|
if (!inventory.getItemInMainHand().getType().equals(Material.AIR)) {
|
||||||
Material material = inventory.getItemInMainHand().getType();
|
Material material = inventory.getItemInMainHand().getType();
|
||||||
if (plugin.getConfig().get("blocks." + material.toString()) != null) {
|
Integer value = addon.getBlockConfig().getValue(getWorld(), material);
|
||||||
int value = plugin.getConfig().getInt("blocks." + material.toString());
|
if (value != null) {
|
||||||
user.sendMessage("island.value.success", "[value]", value + "");
|
user.sendMessage("island.value.success", "[value]", String.valueOf(value));
|
||||||
if (plugin.getConfig().get("underwater") != null) {
|
double underWater = addon.getSettings().getUnderWaterMultiplier();
|
||||||
double underWater = plugin.getConfig().getDouble("underwater");
|
if (underWater > 1.0) {
|
||||||
if (underWater > 1.0) {
|
user.sendMessage("island.value.success-underwater", "[value]", (underWater * value) + "");
|
||||||
user.sendMessage("island.value.success-underwater", "[value]", (underWater * value) + "");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
user.sendMessage("island.value.no-value");
|
user.sendMessage("island.value.no-value");
|
||||||
@ -47,4 +45,5 @@ public class IslandValueCommand extends CompositeCommand {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -107,4 +107,24 @@ public class BlockConfig {
|
|||||||
public Map<World, Map<Material, Integer>> getWorldBlockValues() {
|
public Map<World, Map<Material, Integer>> getWorldBlockValues() {
|
||||||
return worldBlockValues;
|
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