Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add display for mob descriptions in bestiary entry and add util commands for managing descriptions #60

Merged
merged 1 commit into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,9 @@ public ItemStack getBestiaryItem(Player player) {
lore.add(Component.text(BestiarySoulInventory.formatWell(getId().getKey()), NamedTextColor.GRAY).decoration(TextDecoration.ITALIC, false));
lore.add(Component.text("Kills: " + BestiaryManager.getKillsForMob(player, this), NamedTextColor.DARK_RED).decoration(TextDecoration.ITALIC, false));
if (!mDescription.isEmpty()) {
lore.addAll(getDescription());
for (Component line : mDescription) {
lore.add(line.color(NamedTextColor.DARK_GRAY));
}
}
if (info.allowsAccessTo(InfoTier.STATS)) {
lore.add(Component.text("Click for more info!", NamedTextColor.LIGHT_PURPLE).decoration(TextDecoration.ITALIC, false));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.playmonumenta.libraryofsouls.bestiary;

import com.playmonumenta.libraryofsouls.LibraryOfSouls;
import com.playmonumenta.libraryofsouls.Soul;
import com.playmonumenta.libraryofsouls.SoulEntry;
import com.playmonumenta.libraryofsouls.SoulsDatabase;
import com.playmonumenta.libraryofsouls.commands.LibraryOfSoulsCommand;
Expand All @@ -10,17 +9,13 @@
import dev.jorel.commandapi.CommandPermission;
import dev.jorel.commandapi.arguments.EntitySelectorArgument;
import dev.jorel.commandapi.arguments.IntegerArgument;
import dev.jorel.commandapi.arguments.StringArgument;
import dev.jorel.commandapi.arguments.TextArgument;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.List;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.format.TextDecoration;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Item;
Expand Down Expand Up @@ -142,6 +137,26 @@ public static void register() {
}
}
})))
.withSubcommand(new CommandAPICommand("description")
.withSubcommand(new CommandAPICommand("get")
.withPermission(CommandPermission.fromString("los.bestiary.description"))
.withArguments(LibraryOfSoulsCommand.mobLabelArg)
.executesPlayer((sender, args) -> {
String name = args.getByArgument(LibraryOfSoulsCommand.mobLabelArg);
SoulEntry soul = SoulsDatabase.getInstance().getSoul(name);
if (soul == null) {
throw CommandAPI.failWithString("Mob '" + name + "' not found");
} else {
ItemStack item = new ItemStack(Material.BLAZE_POWDER);
item.lore(soul.getDescription());
Location location = sender.getLocation();
if (!sender.getInventory().addItem(item).isEmpty()) {
Item droppedItem = location.getWorld().dropItem(location, item);
droppedItem.setPickupDelay(0);
droppedItem.setCanMobPickup(false);
}
}
})))
.register();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,7 @@ public BestiarySoulInventory(Player player, SoulEntry soul, BestiaryArea parent,
effectItem = getEffectItem(effectItem);
ItemStack speedItem = getSpeedItem(entityNBT, speed, speedScalar, speedPercent);

ItemStack descriptionItem = getDescriptionItem(soul);
ItemStack loreItem = getLoreItem(soul);
ItemStack equipmentPageItem = new ItemStack(Material.LIME_STAINED_GLASS_PANE);
ItemMeta meta = equipmentPageItem.getItemMeta();
Expand All @@ -477,6 +478,9 @@ public BestiarySoulInventory(Player player, SoulEntry soul, BestiaryArea parent,
_inventory.setItem(11, healthItem);
_inventory.setItem(13, armorItem);
_inventory.setItem(15, damageItem);
if (!soul.getDescription().isEmpty()) {
_inventory.setItem(16, descriptionItem);
}
_inventory.setItem(22, equipmentPageItem);
if (!soul.getLore().isEmpty()) {
_inventory.setItem(29, speedItem);
Expand Down Expand Up @@ -758,6 +762,30 @@ public ItemStack getLoreItem(SoulEntry soul) {
return loreItem;
}

public ItemStack getDescriptionItem(SoulEntry soul) {
List<Component> description = soul.getDescription();
ItemStack descriptionItem = new ItemStack(Material.BLAZE_POWDER);
ItemMeta meta = descriptionItem.getItemMeta();
meta.displayName(Component.text("Description", NamedTextColor.WHITE, TextDecoration.BOLD).decoration(TextDecoration.ITALIC, false));

if (description == null || description.isEmpty()) {
List<Component> itemDescription = new ArrayList<>();
itemDescription.add(Component.text("This is a bug. Or at the very least, should be.", NamedTextColor.WHITE).decoration(TextDecoration.ITALIC, true));
meta.lore(itemDescription);
descriptionItem.setItemMeta(meta);
return descriptionItem;
}

List<Component> itemDescription = new ArrayList<>();
for (Component comp : description) {
itemDescription.add(comp.color(NamedTextColor.GRAY));
}

meta.lore(itemDescription);
descriptionItem.setItemMeta(meta);
return descriptionItem;
}

//Legacy function, will be edited once the new boss tags system is implemented
public static List<String> formatTags(String tag) {
List<String> ret = new ArrayList<>();
Expand Down
Loading