geforkt von Mirrors/HeadDB
hotfix: messages file not creating
Dieser Commit ist enthalten in:
Ursprung
c0f1cb28c0
Commit
7dfde36d0c
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>tsp.headdb</groupId>
|
<groupId>tsp.headdb</groupId>
|
||||||
<artifactId>HeadDB</artifactId>
|
<artifactId>HeadDB</artifactId>
|
||||||
<version>3.2.0</version>
|
<version>3.2.1</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>HeadDB</name>
|
<name>HeadDB</name>
|
||||||
|
@ -93,12 +93,12 @@ public class HeadDB extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void createLocalizationFile() {
|
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);
|
saveResource("messages.yml", false);
|
||||||
Log.debug("Localization loaded from jar file.");
|
Log.debug("Localization loaded from jar file.");
|
||||||
}
|
}
|
||||||
|
|
||||||
File messagesFile = new File(getDataFolder() + "/messages.yml");
|
|
||||||
this.localization = new Localization(messagesFile);
|
this.localization = new Localization(messagesFile);
|
||||||
this.localization.load();
|
this.localization.load();
|
||||||
}
|
}
|
||||||
|
@ -45,6 +45,12 @@ public class CommandHeadDB implements CommandExecutor {
|
|||||||
return true;
|
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 (sub.equalsIgnoreCase("search") || sub.equalsIgnoreCase("s")) {
|
||||||
if (!sender.hasPermission("headdb.search")) {
|
if (!sender.hasPermission("headdb.search")) {
|
||||||
Utils.sendMessage(sender, localization.getMessage("noPermission"));
|
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&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 &7- Opens the database");
|
||||||
Utils.sendMessage(sender, "&7 > &c/hdb info &9(i) &7- Plugin Information");
|
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 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 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");
|
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.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.function.UnaryOperator;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Localization class for a messages file
|
* Localization class for a messages file
|
||||||
@ -31,15 +30,7 @@ public class Localization {
|
|||||||
Validate.notNull(data, "File data is null.");
|
Validate.notNull(data, "File data is null.");
|
||||||
Validate.notNull(key, "Message key can not be null.");
|
Validate.notNull(key, "Message key can not be null.");
|
||||||
|
|
||||||
return Utils.colorize(data.getString(key));
|
return Utils.colorize(data.getString(key, "null"));
|
||||||
}
|
|
||||||
|
|
||||||
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));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void load() {
|
public void load() {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
noPermission: "&cNo permission!"
|
noPermission: "&cNo permission!"
|
||||||
onlyPlayers: "&c&cOnly players may open the database."
|
onlyPlayers: "&cOnly players may open the database."
|
||||||
databaseOpen: "&7Opening &cHead Database"
|
databaseOpen: "&7Opening &cHead Database"
|
||||||
invalidPlayer: "&cPlayer is not online!"
|
invalidPlayer: "&cPlayer is not online!"
|
||||||
localFavorites: "&cLocal heads can not be added to favorites!"
|
localFavorites: "&cLocal heads can not be added to favorites!"
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren