Skip to content

Commit

Permalink
Add command to grab lore easily
Browse files Browse the repository at this point in the history
  • Loading branch information
Wembler23 authored May 17, 2024
1 parent b7ee994 commit 8193c22
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
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;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
Expand Down Expand Up @@ -120,6 +122,26 @@ public static void register() {
Player player = args.getByArgument(playerArg);
BestiaryManager.deleteAll(player);
}))
.withSubcommand(new CommandAPICommand("lore")
.withSubcommand(new CommandAPICommand("get")
.withPermission(CommandPermission.fromString("los.bestiary.lore"))
.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.BOOK);
item.lore(soul.getLore());
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

0 comments on commit 8193c22

Please sign in to comment.