Add value command

This commit is contained in:
poma123 2019-02-27 22:16:11 +01:00
parent f4d7299015
commit 35557c0904
3 changed files with 64 additions and 0 deletions

View File

@ -14,6 +14,7 @@ import world.bentobox.level.commands.admin.AdminLevelCommand;
import world.bentobox.level.commands.admin.AdminTopCommand;
import world.bentobox.level.commands.island.IslandLevelCommand;
import world.bentobox.level.commands.island.IslandTopCommand;
import world.bentobox.level.commands.island.IslandValueCommand;
import world.bentobox.level.config.Settings;
import world.bentobox.level.listeners.IslandTeamListeners;
import world.bentobox.level.listeners.JoinLeaveListener;
@ -128,6 +129,7 @@ public class Level extends Addon {
gm.getPlayerCommand().ifPresent(playerCmd -> {
new IslandLevelCommand(this, playerCmd);
new IslandTopCommand(this, playerCmd);
new IslandValueCommand(this, playerCmd);
});
// Register placeholders
if (getPlugin().getPlaceholdersManager() != null) {

View File

@ -0,0 +1,50 @@
package world.bentobox.level.commands.island;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.PlayerInventory;
import world.bentobox.bentobox.api.commands.CompositeCommand;
import world.bentobox.bentobox.api.user.User;
import world.bentobox.level.Level;
import java.util.List;
public class IslandValueCommand extends CompositeCommand {
private final Level plugin;
public IslandValueCommand(Level plugin, CompositeCommand parent) {
super(parent, "value");
this.plugin = plugin;
}
@Override
public void setup() {
this.setPermission("island.value");
this.setDescription("island.value.description");
this.setOnlyPlayer(true);
}
@Override
public boolean execute(User user, String label, List<String> args) {
Player player = user.getPlayer();
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) + "");
}
}
} else {
user.sendMessage("island.value.success", "[value]", "0");
}
} else {
user.sendMessage("island.value.empty-hand");
}
return true;
}
}

View File

@ -16,6 +16,9 @@ permissions:
bskyblock.island.top:
description: Player can use top ten command
default: true
bskyblock.island.value:
description: Player can use value command
default: true
bskyblock.admin.level:
description: Player can use admin level command
default: true
@ -32,6 +35,9 @@ permissions:
acidisland.island.top:
description: Player can use top ten command
default: true
acidisland.island.value:
description: Player can use value command
default: true
acidisland.admin.level:
description: Player can use admin level command
default: true
@ -48,6 +54,9 @@ permissions:
caveblock.island.top:
description: Player can use top ten command
default: true
caveblock.island.value:
description: Player can use value command
default: true
caveblock.admin.level:
description: Player can use admin level command
default: true
@ -64,6 +73,9 @@ permissions:
skygird.island.top:
description: Player can use top ten command
default: true
skygird.island.value:
description: Player can use value command
default: true
skygird.admin.level:
description: Player can use admin level command
default: true