Merge branch 'master' of https://github.com/Altruiis/HeadDB into localization-improvements

Dieser Commit ist enthalten in:
Altruiis 2022-02-16 18:01:23 -08:00
Commit f655bb7f25
5 geänderte Dateien mit 12 neuen und 14 gelöschten Zeilen

Datei anzeigen

@ -6,7 +6,7 @@
<groupId>tsp.headdb</groupId>
<artifactId>HeadDB</artifactId>
<version>3.2.0</version>
<version>3.2.1</version>
<packaging>jar</packaging>
<name>HeadDB</name>

Datei anzeigen

@ -93,12 +93,12 @@ public class HeadDB extends JavaPlugin {
}
private void createLocalizationFile() {
if (getClass().getResource("messages.yml") != null && !new File(getDataFolder() + "/messages.yml").exists()) {
File messagesFile = new File(getDataFolder().getAbsolutePath() + "/messages.yml");
if (!messagesFile.exists()) {
saveResource("messages.yml", false);
Log.debug("Localization loaded from jar file.");
}
File messagesFile = new File(getDataFolder() + "/messages.yml");
this.localization = new Localization(messagesFile);
this.localization.load();
}

Datei anzeigen

@ -45,6 +45,12 @@ public class CommandHeadDB implements CommandExecutor {
return true;
}
if (sub.equalsIgnoreCase("reload") || sub.equalsIgnoreCase("r")) {
HeadDB.getInstance().getLocalization().load();
Utils.sendMessage(sender, "&aReloaded messages file!");
return true;
}
if (sub.equalsIgnoreCase("search") || sub.equalsIgnoreCase("s")) {
if (!sender.hasPermission("headdb.search")) {
Utils.sendMessage(sender, localization.getMessage("noPermission"));
@ -153,6 +159,7 @@ public class CommandHeadDB implements CommandExecutor {
Utils.sendMessage(sender, "&7&oParameters:&c command &9(aliases)&c arguments... &7- Description");
Utils.sendMessage(sender, "&7 > &c/hdb &7- Opens the database");
Utils.sendMessage(sender, "&7 > &c/hdb info &9(i) &7- Plugin Information");
Utils.sendMessage(sender, "&7 > &c/hdb reload &9(r) &7- Reloads the messages file");
Utils.sendMessage(sender, "&7 > &c/hdb search &9(s) &c<name> &7- Search for heads matching a name");
Utils.sendMessage(sender, "&7 > &c/hdb tagsearch &9(ts) &c<tag> &7- Search for heads matching a tag");
Utils.sendMessage(sender, "&7 > &c/hdb update &9(u) &7- Forcefully update the database");

Datei anzeigen

@ -7,7 +7,6 @@ import org.bukkit.configuration.file.YamlConfiguration;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.io.File;
import java.util.function.UnaryOperator;
/**
* Localization class for a messages file
@ -31,15 +30,7 @@ public class Localization {
Validate.notNull(data, "File data is null.");
Validate.notNull(key, "Message key can not be null.");
return Utils.colorize(data.getString(key));
}
public String getMessage(@Nonnull String key, @Nonnull UnaryOperator<String> function) {
Validate.notNull(data, "File data is null.");
Validate.notNull(key, "Message key can not be null.");
Validate.notNull(function, "Function can not be null.");
return function.apply(getMessage(key));
return Utils.colorize(data.getString(key, "null"));
}
public void load() {

Datei anzeigen

@ -1,5 +1,5 @@
noPermission: "&cNo permission!"
onlyPlayers: "&c&cOnly players may open the database."
onlyPlayers: "&cOnly players may open the database."
databaseOpen: "&7Opening &cHead Database"
invalidPlayer: "&cPlayer is not online!"
localFavorites: "&cLocal heads can not be added to favorites!"