Mirror von
https://github.com/TheSilentPro/HeadDB.git
synchronisiert 2024-12-27 11:20:05 +01:00
Merge branch 'master' of https://github.com/Altruiis/HeadDB into localization-improvements
Dieser Commit ist enthalten in:
Commit
f655bb7f25
2
pom.xml
2
pom.xml
@ -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>
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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");
|
||||
|
@ -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() {
|
||||
|
@ -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!"
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren