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 |
|
| /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 |
|
| /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 |
|
| /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) |
|
| /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 |
|
| /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 |
|
| /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>
|
<groupId>net.knarcraft</groupId>
|
||||||
<artifactId>BooksWithoutBorders</artifactId>
|
<artifactId>BooksWithoutBorders</artifactId>
|
||||||
<version>1.3.1</version>
|
<version>1.3.3</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<licenses>
|
<licenses>
|
||||||
|
@ -2,8 +2,8 @@ package net.knarcraft.bookswithoutborders.command;
|
|||||||
|
|
||||||
import net.knarcraft.bookswithoutborders.BooksWithoutBorders;
|
import net.knarcraft.bookswithoutborders.BooksWithoutBorders;
|
||||||
import net.knarcraft.bookswithoutborders.config.BooksWithoutBordersConfig;
|
import net.knarcraft.bookswithoutborders.config.BooksWithoutBordersConfig;
|
||||||
|
import net.knarcraft.bookswithoutborders.utility.BookFormatter;
|
||||||
import net.knarcraft.bookswithoutborders.utility.InventoryHelper;
|
import net.knarcraft.bookswithoutborders.utility.InventoryHelper;
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -44,7 +44,7 @@ public class CommandSetLore implements TabExecutor {
|
|||||||
String rawLore = String.join(" ", args);
|
String rawLore = String.join(" ", args);
|
||||||
|
|
||||||
//Format lore
|
//Format lore
|
||||||
rawLore = ChatColor.translateAlternateColorCodes('&', rawLore);
|
rawLore = BookFormatter.translateAllColorCodes(rawLore);
|
||||||
String[] loreParts = rawLore.split(BooksWithoutBordersConfig.getLoreSeparator());
|
String[] loreParts = rawLore.split(BooksWithoutBordersConfig.getLoreSeparator());
|
||||||
List<String> newLore = new ArrayList<>(Arrays.asList(loreParts));
|
List<String> newLore = new ArrayList<>(Arrays.asList(loreParts));
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package net.knarcraft.bookswithoutborders.command;
|
package net.knarcraft.bookswithoutborders.command;
|
||||||
|
|
||||||
import net.knarcraft.bookswithoutborders.BooksWithoutBorders;
|
import net.knarcraft.bookswithoutborders.BooksWithoutBorders;
|
||||||
|
import net.knarcraft.bookswithoutborders.utility.BookFormatter;
|
||||||
import net.knarcraft.bookswithoutborders.utility.InventoryHelper;
|
import net.knarcraft.bookswithoutborders.utility.InventoryHelper;
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -22,7 +22,8 @@ import java.util.List;
|
|||||||
public class CommandSetTitle implements TabExecutor {
|
public class CommandSetTitle implements TabExecutor {
|
||||||
|
|
||||||
@Override
|
@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)) {
|
if (!(sender instanceof Player player)) {
|
||||||
BooksWithoutBorders.sendErrorMessage(sender, "This command can only be used by a player!");
|
BooksWithoutBorders.sendErrorMessage(sender, "This command can only be used by a player!");
|
||||||
return false;
|
return false;
|
||||||
@ -40,7 +41,7 @@ public class CommandSetTitle implements TabExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String title = String.join(" ", args);
|
String title = String.join(" ", args);
|
||||||
title = ChatColor.translateAlternateColorCodes('&', title);
|
title = BookFormatter.translateAllColorCodes(title);
|
||||||
|
|
||||||
ItemMeta itemMetadata = heldItem.getItemMeta();
|
ItemMeta itemMetadata = heldItem.getItemMeta();
|
||||||
if (itemMetadata == null) {
|
if (itemMetadata == null) {
|
||||||
@ -66,7 +67,8 @@ public class CommandSetTitle implements TabExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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<>();
|
List<String> options = new ArrayList<>();
|
||||||
options.add("<new title>");
|
options.add("<new title>");
|
||||||
return options;
|
return options;
|
||||||
|
@ -2,7 +2,7 @@ package net.knarcraft.bookswithoutborders.config;
|
|||||||
|
|
||||||
import net.knarcraft.bookswithoutborders.BooksWithoutBorders;
|
import net.knarcraft.bookswithoutborders.BooksWithoutBorders;
|
||||||
import net.knarcraft.bookswithoutborders.utility.EconomyHelper;
|
import net.knarcraft.bookswithoutborders.utility.EconomyHelper;
|
||||||
import org.bukkit.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.command.ConsoleCommandSender;
|
import org.bukkit.command.ConsoleCommandSender;
|
||||||
import org.bukkit.configuration.Configuration;
|
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.EncryptionHelper;
|
||||||
import net.knarcraft.bookswithoutborders.utility.FileHelper;
|
import net.knarcraft.bookswithoutborders.utility.FileHelper;
|
||||||
import net.knarcraft.bookswithoutborders.utility.InputCleaningHelper;
|
import net.knarcraft.bookswithoutborders.utility.InputCleaningHelper;
|
||||||
import org.bukkit.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Tag;
|
import org.bukkit.Tag;
|
||||||
import org.bukkit.block.Sign;
|
import org.bukkit.block.Sign;
|
||||||
@ -158,7 +158,7 @@ public class SignEventListener implements Listener {
|
|||||||
private ChatColor getSignLine2Color(Sign sign) {
|
private ChatColor getSignLine2Color(Sign sign) {
|
||||||
String line = sign.getLine(2);
|
String line = sign.getLine(2);
|
||||||
if (!ChatColor.stripColor(line).equals(line)) {
|
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 {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -121,7 +121,7 @@ public final class BookFormatter {
|
|||||||
* @param message <p>The string to search for color codes</p>
|
* @param message <p>The string to search for color codes</p>
|
||||||
* @return <p>The message with color codes translated</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);
|
message = ChatColor.translateAlternateColorCodes('&', message);
|
||||||
Pattern pattern = Pattern.compile("(#[a-fA-F0-9]{6})");
|
Pattern pattern = Pattern.compile("(#[a-fA-F0-9]{6})");
|
||||||
Matcher matcher = pattern.matcher(message);
|
Matcher matcher = pattern.matcher(message);
|
||||||
|
@ -3,6 +3,7 @@ package net.knarcraft.bookswithoutborders.utility;
|
|||||||
import net.knarcraft.bookswithoutborders.BooksWithoutBorders;
|
import net.knarcraft.bookswithoutborders.BooksWithoutBorders;
|
||||||
import net.knarcraft.bookswithoutborders.config.BooksWithoutBordersConfig;
|
import net.knarcraft.bookswithoutborders.config.BooksWithoutBordersConfig;
|
||||||
import net.knarcraft.bookswithoutborders.state.BookDirectory;
|
import net.knarcraft.bookswithoutborders.state.BookDirectory;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -60,7 +61,22 @@ public final class BookLoader {
|
|||||||
//Get the full path of the book to load
|
//Get the full path of the book to load
|
||||||
File file = getFullPath(sender, fileName, bookDirectory, directory);
|
File file = getFullPath(sender, fileName, bookDirectory, directory);
|
||||||
if (file == null) {
|
if (file == null) {
|
||||||
return 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
|
//Make sure the player can pay for the book
|
||||||
@ -124,9 +140,7 @@ public final class BookLoader {
|
|||||||
} else {
|
} else {
|
||||||
file = FileHelper.getBookFile(BookHelper.getBookDirectoryPathString(bookDirectory, sender) + fileName);
|
file = FileHelper.getBookFile(BookHelper.getBookDirectoryPathString(bookDirectory, sender) + fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file == null || !file.isFile()) {
|
if (file == null || !file.isFile()) {
|
||||||
BooksWithoutBorders.sendErrorMessage(sender, "Incorrect file name!");
|
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
return file;
|
return file;
|
||||||
|
@ -5,7 +5,7 @@ import net.knarcraft.bookswithoutborders.config.BooksWithoutBordersConfig;
|
|||||||
import net.knarcraft.bookswithoutborders.encryption.GenenCrypt;
|
import net.knarcraft.bookswithoutborders.encryption.GenenCrypt;
|
||||||
import net.knarcraft.bookswithoutborders.encryption.SubstitutionCipher;
|
import net.knarcraft.bookswithoutborders.encryption.SubstitutionCipher;
|
||||||
import net.knarcraft.bookswithoutborders.state.EncryptionStyle;
|
import net.knarcraft.bookswithoutborders.state.EncryptionStyle;
|
||||||
import org.bukkit.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.command.ConsoleCommandSender;
|
import org.bukkit.command.ConsoleCommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
@ -3,7 +3,7 @@ package net.knarcraft.bookswithoutborders.utility;
|
|||||||
import net.knarcraft.bookswithoutborders.BooksWithoutBorders;
|
import net.knarcraft.bookswithoutborders.BooksWithoutBorders;
|
||||||
import net.knarcraft.bookswithoutborders.config.BooksWithoutBordersConfig;
|
import net.knarcraft.bookswithoutborders.config.BooksWithoutBordersConfig;
|
||||||
import net.knarcraft.bookswithoutborders.state.BookDirectory;
|
import net.knarcraft.bookswithoutborders.state.BookDirectory;
|
||||||
import org.bukkit.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
@ -162,9 +162,8 @@ public final class FileHelper {
|
|||||||
String userName = data[1].substring(0, data[1].length() - 4);
|
String userName = data[1].substring(0, data[1].length() - 4);
|
||||||
data[1] = BookHelper.authorFromUUID(userName) + extension;
|
data[1] = BookHelper.authorFromUUID(userName) + extension;
|
||||||
fileList.add(String.join(separator, data));
|
fileList.add(String.join(separator, data));
|
||||||
} else {
|
|
||||||
fileList.add(fileName);
|
|
||||||
}
|
}
|
||||||
|
fileList.add(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
return fileList;
|
return fileList;
|
||||||
|
Reference in New Issue
Block a user