Improves some formatting and gets rid of BooksWithoutBordersSettings.java
This commit is contained in:
parent
d423b1e109
commit
2aa25295af
@ -21,7 +21,6 @@ import net.knarcraft.bookswithoutborders.command.CommandSetLore;
|
|||||||
import net.knarcraft.bookswithoutborders.command.CommandSetTitle;
|
import net.knarcraft.bookswithoutborders.command.CommandSetTitle;
|
||||||
import net.knarcraft.bookswithoutborders.command.CommandUnSign;
|
import net.knarcraft.bookswithoutborders.command.CommandUnSign;
|
||||||
import net.knarcraft.bookswithoutborders.config.BooksWithoutBordersConfig;
|
import net.knarcraft.bookswithoutborders.config.BooksWithoutBordersConfig;
|
||||||
import net.knarcraft.bookswithoutborders.config.BooksWithoutBordersSettings;
|
|
||||||
import net.knarcraft.bookswithoutborders.listener.BookEventListener;
|
import net.knarcraft.bookswithoutborders.listener.BookEventListener;
|
||||||
import net.knarcraft.bookswithoutborders.listener.PlayerEventListener;
|
import net.knarcraft.bookswithoutborders.listener.PlayerEventListener;
|
||||||
import net.knarcraft.bookswithoutborders.listener.SignEventListener;
|
import net.knarcraft.bookswithoutborders.listener.SignEventListener;
|
||||||
@ -41,11 +40,14 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static net.knarcraft.bookswithoutborders.config.BooksWithoutBordersSettings.getBookFolder;
|
import static net.knarcraft.bookswithoutborders.config.BooksWithoutBordersConfig.getBookFolder;
|
||||||
import static net.knarcraft.bookswithoutborders.config.BooksWithoutBordersSettings.getErrorColor;
|
import static net.knarcraft.bookswithoutborders.config.BooksWithoutBordersConfig.getErrorColor;
|
||||||
import static net.knarcraft.bookswithoutborders.config.BooksWithoutBordersSettings.getSlash;
|
import static net.knarcraft.bookswithoutborders.config.BooksWithoutBordersConfig.getSlash;
|
||||||
import static net.knarcraft.bookswithoutborders.config.BooksWithoutBordersSettings.getSuccessColor;
|
import static net.knarcraft.bookswithoutborders.config.BooksWithoutBordersConfig.getSuccessColor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The main Books Without Borders class
|
||||||
|
*/
|
||||||
public class BooksWithoutBorders extends JavaPlugin {
|
public class BooksWithoutBorders extends JavaPlugin {
|
||||||
|
|
||||||
private static ItemFactory itemFactory;
|
private static ItemFactory itemFactory;
|
||||||
@ -107,8 +109,7 @@ public class BooksWithoutBorders extends JavaPlugin {
|
|||||||
booksWithoutBorders = this;
|
booksWithoutBorders = this;
|
||||||
consoleSender = this.getServer().getConsoleSender();
|
consoleSender = this.getServer().getConsoleSender();
|
||||||
playerBooksList = new HashMap<>();
|
playerBooksList = new HashMap<>();
|
||||||
BooksWithoutBordersSettings.initialize(this);
|
BooksWithoutBordersConfig.initialize(this);
|
||||||
BooksWithoutBordersConfig.loadConfig();
|
|
||||||
publicBooksList = FileHelper.listFiles(consoleSender, true);
|
publicBooksList = FileHelper.listFiles(consoleSender, true);
|
||||||
|
|
||||||
PluginManager pluginManager = this.getServer().getPluginManager();
|
PluginManager pluginManager = this.getServer().getPluginManager();
|
||||||
|
@ -15,8 +15,8 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static net.knarcraft.bookswithoutborders.BooksWithoutBorders.sendErrorMessage;
|
import static net.knarcraft.bookswithoutborders.BooksWithoutBorders.sendErrorMessage;
|
||||||
import static net.knarcraft.bookswithoutborders.config.BooksWithoutBordersSettings.getCommandColor;
|
import static net.knarcraft.bookswithoutborders.config.BooksWithoutBordersConfig.getCommandColor;
|
||||||
import static net.knarcraft.bookswithoutborders.config.BooksWithoutBordersSettings.getSuccessColor;
|
import static net.knarcraft.bookswithoutborders.config.BooksWithoutBordersConfig.getSuccessColor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Command executor for the books without borders (bwb) command
|
* Command executor for the books without borders (bwb) command
|
||||||
@ -115,4 +115,5 @@ public class CommandBooksWithoutBorders implements TabExecutor {
|
|||||||
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) {
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -94,4 +94,5 @@ public class CommandCopy implements TabExecutor {
|
|||||||
}
|
}
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -16,8 +16,8 @@ import java.io.File;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static net.knarcraft.bookswithoutborders.config.BooksWithoutBordersSettings.getBookFolder;
|
import static net.knarcraft.bookswithoutborders.config.BooksWithoutBordersConfig.getBookFolder;
|
||||||
import static net.knarcraft.bookswithoutborders.config.BooksWithoutBordersSettings.getSlash;
|
import static net.knarcraft.bookswithoutborders.config.BooksWithoutBordersConfig.getSlash;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Command executor for the decrypt command
|
* Command executor for the decrypt command
|
||||||
@ -113,4 +113,5 @@ public class CommandDecrypt implements TabExecutor {
|
|||||||
}
|
}
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,8 +13,8 @@ import java.io.File;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static net.knarcraft.bookswithoutborders.config.BooksWithoutBordersSettings.getBookFolder;
|
import static net.knarcraft.bookswithoutborders.config.BooksWithoutBordersConfig.getBookFolder;
|
||||||
import static net.knarcraft.bookswithoutborders.config.BooksWithoutBordersSettings.getSlash;
|
import static net.knarcraft.bookswithoutborders.config.BooksWithoutBordersConfig.getSlash;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Command executor for the delete command
|
* Command executor for the delete command
|
||||||
|
@ -150,4 +150,5 @@ public class CommandGive implements TabExecutor {
|
|||||||
}
|
}
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -125,4 +125,5 @@ public class CommandLoad implements TabExecutor {
|
|||||||
}
|
}
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -30,4 +30,5 @@ public class CommandReload implements TabExecutor {
|
|||||||
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) {
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,10 +19,10 @@ import java.io.IOException;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static net.knarcraft.bookswithoutborders.config.BooksWithoutBordersSettings.getBookFolder;
|
import static net.knarcraft.bookswithoutborders.config.BooksWithoutBordersConfig.getBookFolder;
|
||||||
import static net.knarcraft.bookswithoutborders.config.BooksWithoutBordersSettings.getCommandColor;
|
import static net.knarcraft.bookswithoutborders.config.BooksWithoutBordersConfig.getCommandColor;
|
||||||
import static net.knarcraft.bookswithoutborders.config.BooksWithoutBordersSettings.getErrorColor;
|
import static net.knarcraft.bookswithoutborders.config.BooksWithoutBordersConfig.getErrorColor;
|
||||||
import static net.knarcraft.bookswithoutborders.config.BooksWithoutBordersSettings.getSlash;
|
import static net.knarcraft.bookswithoutborders.config.BooksWithoutBordersConfig.getSlash;
|
||||||
import static net.knarcraft.bookswithoutborders.utility.InputCleaningHelper.cleanString;
|
import static net.knarcraft.bookswithoutborders.utility.InputCleaningHelper.cleanString;
|
||||||
import static net.knarcraft.bookswithoutborders.utility.InputCleaningHelper.fixName;
|
import static net.knarcraft.bookswithoutborders.utility.InputCleaningHelper.fixName;
|
||||||
|
|
||||||
@ -152,4 +152,5 @@ public class CommandSave implements TabExecutor {
|
|||||||
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) {
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -57,4 +57,5 @@ public class CommandSetAuthor implements TabExecutor {
|
|||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -146,4 +146,5 @@ public class CommandSetBookPrice implements TabExecutor {
|
|||||||
}
|
}
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -67,4 +67,5 @@ public class CommandSetLore implements TabExecutor {
|
|||||||
options.add("<new lore>");
|
options.add("<new lore>");
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -71,4 +71,5 @@ public class CommandSetTitle implements TabExecutor {
|
|||||||
options.add("<new title>");
|
options.add("<new title>");
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -59,4 +59,5 @@ public class CommandUnSign implements TabExecutor {
|
|||||||
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) {
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,6 +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 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;
|
||||||
@ -13,8 +14,18 @@ import static net.knarcraft.bookswithoutborders.BooksWithoutBorders.sendErrorMes
|
|||||||
import static net.knarcraft.bookswithoutborders.BooksWithoutBorders.sendSuccessMessage;
|
import static net.knarcraft.bookswithoutborders.BooksWithoutBorders.sendSuccessMessage;
|
||||||
import static net.knarcraft.bookswithoutborders.utility.InputCleaningHelper.cleanString;
|
import static net.knarcraft.bookswithoutborders.utility.InputCleaningHelper.cleanString;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A config class that keeps track of all config values
|
||||||
|
*/
|
||||||
public class BooksWithoutBordersConfig {
|
public class BooksWithoutBordersConfig {
|
||||||
|
|
||||||
|
private static final ChatColor errorColor = ChatColor.RED;
|
||||||
|
private static final ChatColor successColor = ChatColor.GREEN;
|
||||||
|
private static final ChatColor commandColor = ChatColor.YELLOW;
|
||||||
|
private static final String SLASH = System.getProperty("file.separator");
|
||||||
|
private static boolean isInitialized;
|
||||||
|
public static String bookFolder;
|
||||||
|
|
||||||
private static int bookDuplicateLimit;
|
private static int bookDuplicateLimit;
|
||||||
private static String titleAuthorSeparator;
|
private static String titleAuthorSeparator;
|
||||||
private static String loreSeparator;
|
private static String loreSeparator;
|
||||||
@ -27,6 +38,65 @@ public class BooksWithoutBordersConfig {
|
|||||||
private static boolean adminDecrypt;
|
private static boolean adminDecrypt;
|
||||||
private static boolean formatBooks;
|
private static boolean formatBooks;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the books without borders settings class
|
||||||
|
*
|
||||||
|
* @param booksWithoutBorders <p>The books without borders object used for getting required data</p>
|
||||||
|
*/
|
||||||
|
public static void initialize(BooksWithoutBorders booksWithoutBorders) {
|
||||||
|
if (isInitialized) {
|
||||||
|
throw new IllegalArgumentException("Settings class initialized twice. This should not happen!");
|
||||||
|
}
|
||||||
|
isInitialized = true;
|
||||||
|
bookFolder = booksWithoutBorders.getDataFolder().getAbsolutePath() + getSlash() + "Books" + getSlash();
|
||||||
|
loadConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the folder used for storing books
|
||||||
|
*
|
||||||
|
* @return <p>The folder used for storing books</p>
|
||||||
|
*/
|
||||||
|
public static String getBookFolder() {
|
||||||
|
return bookFolder;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the color to use for error messages
|
||||||
|
*
|
||||||
|
* @return <p>The color to use for error messages</p>
|
||||||
|
*/
|
||||||
|
public static ChatColor getErrorColor() {
|
||||||
|
return errorColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the color to use for success messages
|
||||||
|
*
|
||||||
|
* @return <p>The color to use for success messages</p>
|
||||||
|
*/
|
||||||
|
public static ChatColor getSuccessColor() {
|
||||||
|
return successColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the color used to color commands
|
||||||
|
*
|
||||||
|
* @return <p>The color used to color commands</p>
|
||||||
|
*/
|
||||||
|
public static ChatColor getCommandColor() {
|
||||||
|
return commandColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the correct slash to use for the used OS
|
||||||
|
*
|
||||||
|
* @return <p>The slash to use for file separators</p>
|
||||||
|
*/
|
||||||
|
public static String getSlash() {
|
||||||
|
return SLASH;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets whether only the author of a book should be able to copy it
|
* Gets whether only the author of a book should be able to copy it
|
||||||
*
|
*
|
||||||
|
@ -1,78 +0,0 @@
|
|||||||
package net.knarcraft.bookswithoutborders.config;
|
|
||||||
|
|
||||||
import net.knarcraft.bookswithoutborders.BooksWithoutBorders;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class for getting various settings
|
|
||||||
*/
|
|
||||||
public class BooksWithoutBordersSettings {
|
|
||||||
|
|
||||||
//Static settings
|
|
||||||
private static final ChatColor errorColor = ChatColor.RED;
|
|
||||||
private static final ChatColor successColor = ChatColor.GREEN;
|
|
||||||
private static final ChatColor commandColor = ChatColor.YELLOW;
|
|
||||||
private static final String SLASH = System.getProperty("file.separator");
|
|
||||||
private static boolean isInitialized;
|
|
||||||
public static String bookFolder;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initializes the books without borders settings class
|
|
||||||
*
|
|
||||||
* @param booksWithoutBorders <p>The books without borders object used for getting required data</p>
|
|
||||||
*/
|
|
||||||
public static void initialize(BooksWithoutBorders booksWithoutBorders) {
|
|
||||||
if (isInitialized) {
|
|
||||||
throw new IllegalArgumentException("Settings class initialized twice. This should not happen!");
|
|
||||||
}
|
|
||||||
isInitialized = true;
|
|
||||||
bookFolder = booksWithoutBorders.getDataFolder().getAbsolutePath() + getSlash() + "Books" + getSlash();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the folder used for storing books
|
|
||||||
*
|
|
||||||
* @return <p>The folder used for storing books</p>
|
|
||||||
*/
|
|
||||||
public static String getBookFolder() {
|
|
||||||
return bookFolder;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the color to use for error messages
|
|
||||||
*
|
|
||||||
* @return <p>The color to use for error messages</p>
|
|
||||||
*/
|
|
||||||
public static ChatColor getErrorColor() {
|
|
||||||
return errorColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the color to use for success messages
|
|
||||||
*
|
|
||||||
* @return <p>The color to use for success messages</p>
|
|
||||||
*/
|
|
||||||
public static ChatColor getSuccessColor() {
|
|
||||||
return successColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the color used to color commands
|
|
||||||
*
|
|
||||||
* @return <p>The color used to color commands</p>
|
|
||||||
*/
|
|
||||||
public static ChatColor getCommandColor() {
|
|
||||||
return commandColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the correct slash to use for the used OS
|
|
||||||
*
|
|
||||||
* @return <p>The slash to use for file separators</p>
|
|
||||||
*/
|
|
||||||
public static String getSlash() {
|
|
||||||
return SLASH;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -14,8 +14,6 @@ public class GenenCrypt {
|
|||||||
|
|
||||||
private final Random ranGen;
|
private final Random ranGen;
|
||||||
private final String[] bases;
|
private final String[] bases;
|
||||||
private final ArrayList<String> originalCodonList;
|
|
||||||
private final ArrayList<String> shuffledCodonList;
|
|
||||||
private final String[] charList;
|
private final String[] charList;
|
||||||
private final HashMap<String, String[]> codonTable;
|
private final HashMap<String, String[]> codonTable;
|
||||||
private final HashMap<String, String> decryptTable;
|
private final HashMap<String, String> decryptTable;
|
||||||
@ -29,7 +27,7 @@ public class GenenCrypt {
|
|||||||
public GenenCrypt(String key) {
|
public GenenCrypt(String key) {
|
||||||
|
|
||||||
// define the initial, unshuffled codon list of 4 base codons
|
// define the initial, unshuffled codon list of 4 base codons
|
||||||
originalCodonList = new ArrayList<>();
|
ArrayList<String> originalCodonList = new ArrayList<>();
|
||||||
bases = new String[]{"A", "T", "G", "C"};
|
bases = new String[]{"A", "T", "G", "C"};
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
for (int j = 0; j < 4; j++) {
|
for (int j = 0; j < 4; j++) {
|
||||||
@ -50,7 +48,7 @@ public class GenenCrypt {
|
|||||||
ranGen = new java.util.Random(longKey);
|
ranGen = new java.util.Random(longKey);
|
||||||
|
|
||||||
// use the random number generator and the originalCodonList to make a shuffled list
|
// use the random number generator and the originalCodonList to make a shuffled list
|
||||||
shuffledCodonList = new ArrayList<>();
|
ArrayList<String> shuffledCodonList = new ArrayList<>();
|
||||||
while (originalCodonList.size() > 0) {
|
while (originalCodonList.size() > 0) {
|
||||||
int index = ranGen.nextInt(originalCodonList.size());
|
int index = ranGen.nextInt(originalCodonList.size());
|
||||||
shuffledCodonList.add(originalCodonList.get(index));
|
shuffledCodonList.add(originalCodonList.get(index));
|
||||||
@ -90,24 +88,6 @@ public class GenenCrypt {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Prints the shuffled codon list used for generating the codon table
|
|
||||||
*/
|
|
||||||
public void printShuffledList() {
|
|
||||||
for (String s : shuffledCodonList) {
|
|
||||||
System.out.println(s);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Prints the original codon list before it was shuffled
|
|
||||||
*/
|
|
||||||
public void printOriginalList() {
|
|
||||||
for (String s : originalCodonList) {
|
|
||||||
System.out.println(s);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prints the codon table used for encryption and decryption
|
* Prints the codon table used for encryption and decryption
|
||||||
*/
|
*/
|
||||||
@ -181,4 +161,5 @@ public class GenenCrypt {
|
|||||||
}
|
}
|
||||||
return output.toString();
|
return output.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,9 @@ package net.knarcraft.bookswithoutborders.encryption;
|
|||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A simple substitution cipher
|
||||||
|
*/
|
||||||
public class SubstitutionCipher {
|
public class SubstitutionCipher {
|
||||||
|
|
||||||
public SubstitutionCipher() {
|
public SubstitutionCipher() {
|
||||||
@ -83,5 +86,6 @@ public class SubstitutionCipher {
|
|||||||
}
|
}
|
||||||
return output.toString();
|
return output.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,9 +18,12 @@ import org.bukkit.inventory.meta.ItemMeta;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
import static net.knarcraft.bookswithoutborders.config.BooksWithoutBordersSettings.getBookFolder;
|
import static net.knarcraft.bookswithoutborders.config.BooksWithoutBordersConfig.getBookFolder;
|
||||||
import static net.knarcraft.bookswithoutborders.config.BooksWithoutBordersSettings.getSlash;
|
import static net.knarcraft.bookswithoutborders.config.BooksWithoutBordersConfig.getSlash;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A listener for listening to player-related events such as joining or holding a book
|
||||||
|
*/
|
||||||
public class PlayerEventListener implements Listener {
|
public class PlayerEventListener implements Listener {
|
||||||
|
|
||||||
private final String slash = getSlash();
|
private final String slash = getSlash();
|
||||||
|
@ -24,10 +24,13 @@ import org.bukkit.inventory.meta.BookMeta;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
import static net.knarcraft.bookswithoutborders.config.BooksWithoutBordersSettings.getBookFolder;
|
import static net.knarcraft.bookswithoutborders.config.BooksWithoutBordersConfig.getBookFolder;
|
||||||
import static net.knarcraft.bookswithoutborders.config.BooksWithoutBordersSettings.getSlash;
|
import static net.knarcraft.bookswithoutborders.config.BooksWithoutBordersConfig.getSlash;
|
||||||
import static net.knarcraft.bookswithoutborders.utility.FileHelper.isBookListIndex;
|
import static net.knarcraft.bookswithoutborders.utility.FileHelper.isBookListIndex;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A listener for relevant sign events such as clicking a decryption sign
|
||||||
|
*/
|
||||||
public class SignEventListener implements Listener {
|
public class SignEventListener implements Listener {
|
||||||
|
|
||||||
private final String slash = getSlash();
|
private final String slash = getSlash();
|
||||||
|
@ -4,8 +4,20 @@ package net.knarcraft.bookswithoutborders.state;
|
|||||||
* This enum represents the different directories books can be saved in
|
* This enum represents the different directories books can be saved in
|
||||||
*/
|
*/
|
||||||
public enum BookDirectory {
|
public enum BookDirectory {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The public directory
|
||||||
|
*/
|
||||||
PUBLIC,
|
PUBLIC,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A player directory
|
||||||
|
*/
|
||||||
PLAYER,
|
PLAYER,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The encrypted directory
|
||||||
|
*/
|
||||||
ENCRYPTED;
|
ENCRYPTED;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -25,4 +37,5 @@ public enum BookDirectory {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ package net.knarcraft.bookswithoutborders.state;
|
|||||||
* This enum represents the different available encryption styles
|
* This enum represents the different available encryption styles
|
||||||
*/
|
*/
|
||||||
public enum EncryptionStyle {
|
public enum EncryptionStyle {
|
||||||
|
|
||||||
DNA("dna"),
|
DNA("dna"),
|
||||||
SUBSTITUTION("substitution");
|
SUBSTITUTION("substitution");
|
||||||
|
|
||||||
@ -27,4 +28,5 @@ public enum EncryptionStyle {
|
|||||||
}
|
}
|
||||||
return SUBSTITUTION;
|
return SUBSTITUTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,6 @@ import java.util.regex.Pattern;
|
|||||||
public final class BookFormatter {
|
public final class BookFormatter {
|
||||||
|
|
||||||
private BookFormatter() {
|
private BookFormatter() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2,7 +2,6 @@ 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.config.BooksWithoutBordersSettings;
|
|
||||||
import net.knarcraft.bookswithoutborders.state.BookDirectory;
|
import net.knarcraft.bookswithoutborders.state.BookDirectory;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -14,8 +13,14 @@ import java.io.File;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A helper class for loading books from files
|
||||||
|
*/
|
||||||
public final class BookLoader {
|
public final class BookLoader {
|
||||||
|
|
||||||
|
private BookLoader() {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads the given book
|
* Loads the given book
|
||||||
*
|
*
|
||||||
@ -109,8 +114,8 @@ public final class BookLoader {
|
|||||||
*/
|
*/
|
||||||
private static File getFullPath(CommandSender sender, String fileName, BookDirectory bookDirectory, String directory) {
|
private static File getFullPath(CommandSender sender, String fileName, BookDirectory bookDirectory, String directory) {
|
||||||
File file = null;
|
File file = null;
|
||||||
String slash = BooksWithoutBordersSettings.getSlash();
|
String slash = BooksWithoutBordersConfig.getSlash();
|
||||||
String bookFolder = BooksWithoutBordersSettings.getBookFolder();
|
String bookFolder = BooksWithoutBordersConfig.getBookFolder();
|
||||||
if (bookDirectory == BookDirectory.PUBLIC) {
|
if (bookDirectory == BookDirectory.PUBLIC) {
|
||||||
file = FileHelper.getBookFile(bookFolder + fileName);
|
file = FileHelper.getBookFile(bookFolder + fileName);
|
||||||
} else if (bookDirectory == BookDirectory.PLAYER) {
|
} else if (bookDirectory == BookDirectory.PLAYER) {
|
||||||
|
@ -22,7 +22,6 @@ public final class EconomyHelper {
|
|||||||
private static Economy economy;
|
private static Economy economy;
|
||||||
|
|
||||||
private EconomyHelper() {
|
private EconomyHelper() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -17,8 +17,8 @@ import java.io.IOException;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static net.knarcraft.bookswithoutborders.config.BooksWithoutBordersSettings.getBookFolder;
|
import static net.knarcraft.bookswithoutborders.config.BooksWithoutBordersConfig.getBookFolder;
|
||||||
import static net.knarcraft.bookswithoutborders.config.BooksWithoutBordersSettings.getSlash;
|
import static net.knarcraft.bookswithoutborders.config.BooksWithoutBordersConfig.getSlash;
|
||||||
import static net.knarcraft.bookswithoutborders.utility.InputCleaningHelper.cleanString;
|
import static net.knarcraft.bookswithoutborders.utility.InputCleaningHelper.cleanString;
|
||||||
import static net.knarcraft.bookswithoutborders.utility.InputCleaningHelper.fixName;
|
import static net.knarcraft.bookswithoutborders.utility.InputCleaningHelper.fixName;
|
||||||
|
|
||||||
@ -28,7 +28,6 @@ import static net.knarcraft.bookswithoutborders.utility.InputCleaningHelper.fixN
|
|||||||
public final class EncryptionHelper {
|
public final class EncryptionHelper {
|
||||||
|
|
||||||
private EncryptionHelper() {
|
private EncryptionHelper() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -10,8 +10,8 @@ import java.util.List;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import static net.knarcraft.bookswithoutborders.config.BooksWithoutBordersSettings.getBookFolder;
|
import static net.knarcraft.bookswithoutborders.config.BooksWithoutBordersConfig.getBookFolder;
|
||||||
import static net.knarcraft.bookswithoutborders.config.BooksWithoutBordersSettings.getSlash;
|
import static net.knarcraft.bookswithoutborders.config.BooksWithoutBordersConfig.getSlash;
|
||||||
import static net.knarcraft.bookswithoutborders.utility.InputCleaningHelper.cleanString;
|
import static net.knarcraft.bookswithoutborders.utility.InputCleaningHelper.cleanString;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -20,7 +20,6 @@ import static net.knarcraft.bookswithoutborders.utility.InputCleaningHelper.clea
|
|||||||
public final class FileHelper {
|
public final class FileHelper {
|
||||||
|
|
||||||
private FileHelper() {
|
private FileHelper() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -9,7 +9,6 @@ import java.util.List;
|
|||||||
public final class InputCleaningHelper {
|
public final class InputCleaningHelper {
|
||||||
|
|
||||||
private InputCleaningHelper() {
|
private InputCleaningHelper() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -14,7 +14,6 @@ import org.bukkit.inventory.meta.BookMeta;
|
|||||||
public final class InventoryHelper {
|
public final class InventoryHelper {
|
||||||
|
|
||||||
private InventoryHelper() {
|
private InventoryHelper() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -9,7 +9,6 @@ import java.util.List;
|
|||||||
public final class TabCompletionHelper {
|
public final class TabCompletionHelper {
|
||||||
|
|
||||||
private TabCompletionHelper() {
|
private TabCompletionHelper() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user