Remove Unnecessary Check

Meta placeholders are always enabled, errors aren't thrown when an invalid or no meta key is requested
This commit is contained in:
jones6096 2023-11-23 22:04:12 -05:00
parent b366dee1c1
commit 0143d3fa0d
3 changed files with 10 additions and 20 deletions

View File

@ -28,8 +28,6 @@ public final class Configuration {
private List<String> changecmd; private List<String> changecmd;
private String custom1; private String custom1;
private String custom2; private String custom2;
private boolean custom1Enabled;
private boolean custom2Enabled;
private Toml aliases; private Toml aliases;
Configuration(Toml config) { Configuration(Toml config) {
@ -52,8 +50,6 @@ public final class Configuration {
minimessage = config.getBoolean("Message-format.minimessage"); minimessage = config.getBoolean("Message-format.minimessage");
all = config.getBoolean("Message.all", false); all = config.getBoolean("Message.all", false);
custom1Enabled = config.getBoolean("Custom-Meta.custom1enabled", false);
custom2Enabled = config.getBoolean("Custom-Meta.custom2enabled", false);
custom1 = config.getString("Custom-Meta.custom1", ""); custom1 = config.getString("Custom-Meta.custom1", "");
custom2 = config.getString("Custom-Meta.custom2", ""); custom2 = config.getString("Custom-Meta.custom2", "");
this.config = config; this.config = config;
@ -139,10 +135,13 @@ public final class Configuration {
public Toml getAliases() { public Toml getAliases() {
return aliases; return aliases;
} }
public boolean isCustom1Enabled() {return this.custom1Enabled;} public String getCustom1() {
public boolean isCustom2Enabled() {return this.custom2Enabled;} return this.custom1;
public String getCustom1() {return this.custom1;} }
public String getCustom2() {return this.custom2;} public String getCustom2() {
return this.custom2;
}
void reload(){ void reload(){
config = config.read(file); config = config.read(file);
this.messageFormat = config.getString("Message.format"); this.messageFormat = config.getString("Message.format");
@ -165,8 +164,6 @@ public final class Configuration {
this.minimessage = config.getBoolean("Message-format.minimessage"); this.minimessage = config.getBoolean("Message-format.minimessage");
this.all = config.getBoolean("Message.all", false); this.all = config.getBoolean("Message.all", false);
this.custom1Enabled = config.getBoolean("Custom-Meta.custom1enabled");
this.custom2Enabled = config.getBoolean("Custom-Meta.custom2enabled");
this.custom1 = config.getString("Custom-Meta.custom1"); this.custom1 = config.getString("Custom-Meta.custom1");
this.custom2 = config.getString("Custom-Meta.custom2"); this.custom2 = config.getString("Custom-Meta.custom2");
} }

View File

@ -181,14 +181,9 @@ public final class Listeners {
final CachedMetaData data = luckPermsAPI.getPlayerAdapter(Player.class).getMetaData(p); final CachedMetaData data = luckPermsAPI.getPlayerAdapter(Player.class).getMetaData(p);
final String prefix = data.getPrefix(); final String prefix = data.getPrefix();
final String suffix = data.getSuffix(); final String suffix = data.getSuffix();
String custom1 = null; final String custom1 = data.getMetaValue(configuration.getCustom1());
String custom2 = null; final String custom2 = data.getMetaValue(configuration.getCustom2());
if (configuration.isCustom1Enabled()) {
custom1 = data.getMetaValue(configuration.getCustom1());
}
if (configuration.isCustom2Enabled()) {
custom2 = data.getMetaValue(configuration.getCustom2());
}
if (message.contains("#prefix#") && prefix != null) { if (message.contains("#prefix#") && prefix != null) {
message = message.replace("#prefix#", prefix); message = message.replace("#prefix#", prefix);
} }

View File

@ -46,6 +46,4 @@ servername = "Server Name"
[Custom-Meta] [Custom-Meta]
#Enables definition of Custom Luckperms Meta Placeholders #Enables definition of Custom Luckperms Meta Placeholders
custom1 = "" custom1 = ""
custom1enabled = false
custom2 = "" custom2 = ""
custom2enabled = false