Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
6ae15acc72 | |||
2c80e4117e | |||
6d539a14df | |||
184f78d935 | |||
95b0b42fd1 | |||
73eb903517 |
@ -47,7 +47,7 @@ An in-game description of available commands is available through the /bwb comma
|
||||
| /decryptbook | \<key> | Decrypts the book the player is holding. "key" is required and MUST be IDENTICAL to the key used to encrypt the held book |
|
||||
| /deletebook | \<file name or number> | Deletes the specified file in the player's directory |
|
||||
| /deletepublicbook | \<file name or number> | Same as deletebook, but deletes files in the public directory |
|
||||
| encryptbook | \<key> \[encryption style] | Encrypts the book the player is holding. "key" is required and can be any phrase or number excluding spaces. "style" is not required. Possible values are "DNA" or "" |
|
||||
| /encryptbook | \<key> \[encryption style] | Encrypts the book the player is holding. "key" is required and can be any phrase or number excluding spaces. "style" is not required. Possible values are "DNA" or "" |
|
||||
| /formatbook | None | Formats the held written book (converts color and formatting codes to the corresponding formatted text) |
|
||||
| /givebook | \<file name or number> \<playername> \[# of copies (num)] \[signed (true/false)] | Gives the selected player a book from your personal directory |
|
||||
| /givepublicbook | \<file name or number> \<playername> \[# of copies (num)] \[signed (true/false)] | Same as givebook, but uses books from the public directory |
|
||||
|
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>net.knarcraft</groupId>
|
||||
<artifactId>BooksWithoutBorders</artifactId>
|
||||
<version>1.3.1</version>
|
||||
<version>1.3.3</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<licenses>
|
||||
|
@ -2,8 +2,8 @@ package net.knarcraft.bookswithoutborders.command;
|
||||
|
||||
import net.knarcraft.bookswithoutborders.BooksWithoutBorders;
|
||||
import net.knarcraft.bookswithoutborders.config.BooksWithoutBordersConfig;
|
||||
import net.knarcraft.bookswithoutborders.utility.BookFormatter;
|
||||
import net.knarcraft.bookswithoutborders.utility.InventoryHelper;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -44,7 +44,7 @@ public class CommandSetLore implements TabExecutor {
|
||||
String rawLore = String.join(" ", args);
|
||||
|
||||
//Format lore
|
||||
rawLore = ChatColor.translateAlternateColorCodes('&', rawLore);
|
||||
rawLore = BookFormatter.translateAllColorCodes(rawLore);
|
||||
String[] loreParts = rawLore.split(BooksWithoutBordersConfig.getLoreSeparator());
|
||||
List<String> newLore = new ArrayList<>(Arrays.asList(loreParts));
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
package net.knarcraft.bookswithoutborders.command;
|
||||
|
||||
import net.knarcraft.bookswithoutborders.BooksWithoutBorders;
|
||||
import net.knarcraft.bookswithoutborders.utility.BookFormatter;
|
||||
import net.knarcraft.bookswithoutborders.utility.InventoryHelper;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -22,7 +22,8 @@ import java.util.List;
|
||||
public class CommandSetTitle implements TabExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label,
|
||||
@NotNull String[] args) {
|
||||
if (!(sender instanceof Player player)) {
|
||||
BooksWithoutBorders.sendErrorMessage(sender, "This command can only be used by a player!");
|
||||
return false;
|
||||
@ -40,7 +41,7 @@ public class CommandSetTitle implements TabExecutor {
|
||||
}
|
||||
|
||||
String title = String.join(" ", args);
|
||||
title = ChatColor.translateAlternateColorCodes('&', title);
|
||||
title = BookFormatter.translateAllColorCodes(title);
|
||||
|
||||
ItemMeta itemMetadata = heldItem.getItemMeta();
|
||||
if (itemMetadata == null) {
|
||||
@ -66,7 +67,8 @@ public class CommandSetTitle implements TabExecutor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args) {
|
||||
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias,
|
||||
@NotNull String[] args) {
|
||||
List<String> options = new ArrayList<>();
|
||||
options.add("<new title>");
|
||||
return options;
|
||||
|
@ -2,7 +2,7 @@ package net.knarcraft.bookswithoutborders.config;
|
||||
|
||||
import net.knarcraft.bookswithoutborders.BooksWithoutBorders;
|
||||
import net.knarcraft.bookswithoutborders.utility.EconomyHelper;
|
||||
import org.bukkit.ChatColor;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.configuration.Configuration;
|
||||
|
@ -7,7 +7,7 @@ import net.knarcraft.bookswithoutborders.utility.BookLoader;
|
||||
import net.knarcraft.bookswithoutborders.utility.EncryptionHelper;
|
||||
import net.knarcraft.bookswithoutborders.utility.FileHelper;
|
||||
import net.knarcraft.bookswithoutborders.utility.InputCleaningHelper;
|
||||
import org.bukkit.ChatColor;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Tag;
|
||||
import org.bukkit.block.Sign;
|
||||
@ -158,7 +158,7 @@ public class SignEventListener implements Listener {
|
||||
private ChatColor getSignLine2Color(Sign sign) {
|
||||
String line = sign.getLine(2);
|
||||
if (!ChatColor.stripColor(line).equals(line)) {
|
||||
return ChatColor.getByChar(sign.getLine(2).substring(1, 2));
|
||||
return ChatColor.getByChar(sign.getLine(2).substring(1, 2).charAt(0));
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ public final class BookFormatter {
|
||||
* @param message <p>The string to search for color codes</p>
|
||||
* @return <p>The message with color codes translated</p>
|
||||
*/
|
||||
private static String translateAllColorCodes(String message) {
|
||||
public static String translateAllColorCodes(String message) {
|
||||
message = ChatColor.translateAlternateColorCodes('&', message);
|
||||
Pattern pattern = Pattern.compile("(#[a-fA-F0-9]{6})");
|
||||
Matcher matcher = pattern.matcher(message);
|
||||
|
@ -3,6 +3,7 @@ package net.knarcraft.bookswithoutborders.utility;
|
||||
import net.knarcraft.bookswithoutborders.BooksWithoutBorders;
|
||||
import net.knarcraft.bookswithoutborders.config.BooksWithoutBordersConfig;
|
||||
import net.knarcraft.bookswithoutborders.state.BookDirectory;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -60,8 +61,23 @@ public final class BookLoader {
|
||||
//Get the full path of the book to load
|
||||
File file = getFullPath(sender, fileName, bookDirectory, directory);
|
||||
if (file == null) {
|
||||
//Try converting the username to UUID
|
||||
String titleAuthorSeparator = BooksWithoutBordersConfig.getTitleAuthorSeparator();
|
||||
String[] data = fileName.split(titleAuthorSeparator);
|
||||
String extension = data[1].substring(data[1].length() - 4);
|
||||
String userName = data[1].substring(0, data[1].length() - 4);
|
||||
Player player = Bukkit.getPlayer(userName);
|
||||
if (player != null) {
|
||||
data[1] = player.getUniqueId() + extension;
|
||||
file = getFullPath(sender, String.join(titleAuthorSeparator, data), bookDirectory, directory);
|
||||
if (file == null) {
|
||||
BooksWithoutBorders.sendErrorMessage(sender, "Incorrect file name!");
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
//Make sure the player can pay for the book
|
||||
if (BooksWithoutBordersConfig.booksHavePrice() &&
|
||||
@ -124,9 +140,7 @@ public final class BookLoader {
|
||||
} else {
|
||||
file = FileHelper.getBookFile(BookHelper.getBookDirectoryPathString(bookDirectory, sender) + fileName);
|
||||
}
|
||||
|
||||
if (file == null || !file.isFile()) {
|
||||
BooksWithoutBorders.sendErrorMessage(sender, "Incorrect file name!");
|
||||
return null;
|
||||
} else {
|
||||
return file;
|
||||
|
@ -5,7 +5,7 @@ import net.knarcraft.bookswithoutborders.config.BooksWithoutBordersConfig;
|
||||
import net.knarcraft.bookswithoutborders.encryption.GenenCrypt;
|
||||
import net.knarcraft.bookswithoutborders.encryption.SubstitutionCipher;
|
||||
import net.knarcraft.bookswithoutborders.state.EncryptionStyle;
|
||||
import org.bukkit.ChatColor;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -3,7 +3,7 @@ package net.knarcraft.bookswithoutborders.utility;
|
||||
import net.knarcraft.bookswithoutborders.BooksWithoutBorders;
|
||||
import net.knarcraft.bookswithoutborders.config.BooksWithoutBordersConfig;
|
||||
import net.knarcraft.bookswithoutborders.state.BookDirectory;
|
||||
import org.bukkit.ChatColor;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
@ -162,9 +162,8 @@ public final class FileHelper {
|
||||
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;
|
||||
|
Reference in New Issue
Block a user