diff --git a/src/main/java/net/riblab/tradecore/item/TCTool.java b/src/main/java/net/riblab/tradecore/item/TCTool.java index 1fe9589..eda8070 100644 --- a/src/main/java/net/riblab/tradecore/item/TCTool.java +++ b/src/main/java/net/riblab/tradecore/item/TCTool.java @@ -1,11 +1,17 @@ package net.riblab.tradecore.item; import lombok.Getter; +import net.kyori.adventure.text.Component; import net.kyori.adventure.text.TextComponent; +import net.kyori.adventure.text.format.NamedTextColor; +import net.kyori.adventure.text.format.TextDecoration; import net.riblab.tradecore.ItemCreator; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; +import java.util.ArrayList; +import java.util.List; + /** * プラグインのツールクラス */ @@ -61,7 +67,25 @@ public double getActualMiningSpeed(){ @Override protected ItemCreator createItem() { - return super.createItem().setIntNBT(durabilityTag, baseDurability); + return super.createItem().setIntNBT(durabilityTag, baseDurability) + .setLores(getLore(baseDurability)); + } + + /** + * ツールの説明を生成する + * @param durability インスタンスが持つ耐久値 + * @return ツールの説明 + */ + protected List getLore(int durability){ + List texts = new ArrayList<>(); + if(baseDurability != -1){ + texts.add(Component.text("耐久値: ").decoration(TextDecoration.ITALIC, false).color(NamedTextColor.WHITE) + .append(Component.text(durability).color(durability == baseDurability ? NamedTextColor.WHITE : NamedTextColor.YELLOW)) + .append(Component.text("/" + baseDurability).color(NamedTextColor.WHITE))); + } + texts.add(Component.text("採掘速度: ").decoration(TextDecoration.ITALIC, false).color(NamedTextColor.WHITE) + .append(Component.text((Math.floor(baseMiningSpeed * 10)) / 10))); + return texts; } /** @@ -85,7 +109,7 @@ public ItemStack reduceDurability(ItemStack instance){ int damageToSet = (int)(instance.getType().getMaxDurability() * ((float)durability / (float) baseDurability)); int damageToDeal = (instance.getType().getMaxDurability() - instance.getDurability()) - damageToSet; - return new ItemCreator(instance).damage(damageToDeal).setIntNBT(durabilityTag, durability).create(); + return new ItemCreator(instance).setLores(getLore(durability)).damage(damageToDeal).setIntNBT(durabilityTag, durability).create(); } public enum ToolType {