Performs some minor fixes and improvements

This commit is contained in:
Kristian Knarvik 2022-11-07 00:15:19 +01:00
parent de546cac36
commit fac01fd807
5 changed files with 19 additions and 7 deletions

View File

@ -23,7 +23,7 @@ public final class KnarLib {
*
* @param plugin <p>The plugin instance to use</p>
*/
public static void setPlugin(final JavaPlugin plugin) {
public static void setPlugin(JavaPlugin plugin) {
KnarLib.plugin = plugin;
}

View File

@ -21,7 +21,7 @@ public final class StringFormatter {
* @param sender <p>The command sender to display the message to</p>
* @param message <p>The translatable message to display</p>
*/
public static void displaySuccessMessage(CommandSender sender, TranslatableTimeUnit message) {
public static void displaySuccessMessage(CommandSender sender, TranslatableMessage message) {
sender.sendMessage(ChatColor.GREEN + getFormattedMessage(Translator.getTranslatedMessage(message)));
}
@ -41,10 +41,20 @@ public final class StringFormatter {
* @param sender <p>The command sender to display the message to</p>
* @param message <p>The translatable message to display</p>
*/
public static void displayErrorMessage(CommandSender sender, TranslatableTimeUnit message) {
public static void displayErrorMessage(CommandSender sender, TranslatableMessage message) {
sender.sendMessage(ChatColor.DARK_RED + getFormattedMessage(Translator.getTranslatedMessage(message)));
}
/**
* Displays a message signifying an unsuccessful action
*
* @param sender <p>The command sender to display the message to</p>
* @param message <p>The translatable message to display</p>
*/
public static void displayErrorMessage(CommandSender sender, String message) {
sender.sendMessage(ChatColor.DARK_RED + getFormattedMessage(message));
}
/**
* Gets the formatted version of any chat message
*

View File

@ -3,7 +3,8 @@ package net.knarcraft.knarlib.formatting;
/**
* An enum containing all translatable time units
*
* <p>These time units must have a translatable message to use the time formatter</p>
* <p>These time units must have a translatable message if you want to use the time formatter. Register one value with
* the translator's "registerMessageCategory" method!</p>
*/
public enum TranslatableTimeUnit implements TranslatableMessage {

View File

@ -12,6 +12,7 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -22,7 +23,7 @@ import java.util.logging.Level;
*/
public final class Translator {
private static List<TranslatableMessage> messageCategories;
private static final List<TranslatableMessage> messageCategories = new ArrayList<>();
private static Map<TranslatableMessage, String> translatedMessages;
private static Map<TranslatableMessage, String> backupTranslatedMessages;

View File

@ -57,13 +57,13 @@ public final class UpdateChecker {
String oldVersion = getVersionMethod.get();
//If there is a newer version, notify the user
if (isVersionHigher(oldVersion, newVersion)) {
plugin.getLogger().log(Level.INFO, getUpdateAvailableString(newVersion, oldVersion));
plugin.getLogger().log(Level.WARNING, getUpdateAvailableString(newVersion, oldVersion));
if (setVersionMethod != null) {
setVersionMethod.accept(newVersion);
}
}
} catch (IOException e) {
plugin.getLogger().log(Level.WARNING, "Unable to get newest version.");
plugin.getLogger().log(Level.WARNING, "Unable to get the newest plugin version.");
}
}