Fixes books being loaded twice
All checks were successful
EpicKnarvik97/Books-Without-Borders/pipeline/head This commit looks good

This commit is contained in:
2025-07-27 18:42:43 +02:00
parent 3f3566089e
commit 4ddfafe6ec
4 changed files with 11 additions and 4 deletions

View File

@@ -113,7 +113,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.21-R0.1-SNAPSHOT</version>
<version>1.21.8-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>

View File

@@ -35,7 +35,7 @@ public class CommandLoad implements TabExecutor {
* @param loadPublic <p>Whether to list public files as loadable</p>
* @return <p>True if the book was loaded successfully</p>
*/
boolean loadBook(CommandSender sender, String[] args, String directory, boolean loadPublic) {
public boolean loadBook(CommandSender sender, String[] args, String directory, boolean loadPublic) {
if (!(sender instanceof Player player)) {
BooksWithoutBorders.sendErrorMessage(sender, "This command can only be used by a player!");
return false;

View File

@@ -3,6 +3,7 @@ package net.knarcraft.bookswithoutborders.listener;
import net.knarcraft.bookswithoutborders.config.BooksWithoutBordersConfig;
import net.knarcraft.bookswithoutborders.utility.IntegerToRomanConverter;
import net.md_5.bungee.api.ChatColor;
import org.bukkit.NamespacedKey;
import org.bukkit.block.ChiseledBookshelf;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
@@ -140,7 +141,12 @@ public class BookshelfListener implements Listener {
* @return <p>The prettified enchantment name</p>
*/
private String getEnchantmentName(Enchantment enchantment) {
return uppercaseFirst(enchantment.getKey().getKey().replace("_", " "));
NamespacedKey key = enchantment.getKeyOrNull();
if (key != null) {
return uppercaseFirst(key.getKey().replace("_", " "));
} else {
return "Unknown Enchantment";
}
}
/**

View File

@@ -158,8 +158,9 @@ public final class BookFileHelper {
String userName = data[1].substring(0, data[1].length() - 4);
data[1] = BookHelper.authorFromUUID(userName) + extension;
fileList.add(String.join(separator, data));
} else {
fileList.add(fileName);
}
fileList.add(fileName);
}
return fileList;