Performs some minor fixes and improvements
This commit is contained in:
parent
de546cac36
commit
fac01fd807
@ -23,7 +23,7 @@ public final class KnarLib {
|
|||||||
*
|
*
|
||||||
* @param plugin <p>The plugin instance to use</p>
|
* @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;
|
KnarLib.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ public final class StringFormatter {
|
|||||||
* @param sender <p>The command sender to display the message to</p>
|
* @param sender <p>The command sender to display the message to</p>
|
||||||
* @param message <p>The translatable message to display</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)));
|
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 sender <p>The command sender to display the message to</p>
|
||||||
* @param message <p>The translatable message to display</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)));
|
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
|
* Gets the formatted version of any chat message
|
||||||
*
|
*
|
||||||
|
@ -3,7 +3,8 @@ package net.knarcraft.knarlib.formatting;
|
|||||||
/**
|
/**
|
||||||
* An enum containing all translatable time units
|
* 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 {
|
public enum TranslatableTimeUnit implements TranslatableMessage {
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ import java.io.File;
|
|||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -22,7 +23,7 @@ import java.util.logging.Level;
|
|||||||
*/
|
*/
|
||||||
public final class Translator {
|
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> translatedMessages;
|
||||||
private static Map<TranslatableMessage, String> backupTranslatedMessages;
|
private static Map<TranslatableMessage, String> backupTranslatedMessages;
|
||||||
|
|
||||||
|
@ -57,13 +57,13 @@ public final class UpdateChecker {
|
|||||||
String oldVersion = getVersionMethod.get();
|
String oldVersion = getVersionMethod.get();
|
||||||
//If there is a newer version, notify the user
|
//If there is a newer version, notify the user
|
||||||
if (isVersionHigher(oldVersion, newVersion)) {
|
if (isVersionHigher(oldVersion, newVersion)) {
|
||||||
plugin.getLogger().log(Level.INFO, getUpdateAvailableString(newVersion, oldVersion));
|
plugin.getLogger().log(Level.WARNING, getUpdateAvailableString(newVersion, oldVersion));
|
||||||
if (setVersionMethod != null) {
|
if (setVersionMethod != null) {
|
||||||
setVersionMethod.accept(newVersion);
|
setVersionMethod.accept(newVersion);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} 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.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user