From b366dee1c1fdaa0bccab117bb02a2d39ca825c8e Mon Sep 17 00:00:00 2001
From: jones6096 <63066064+jones6096@users.noreply.github.com>
Date: Wed, 22 Nov 2023 21:51:24 -0500
Subject: [PATCH 1/2] Add Extra LP Meta Placeholders
---
pom.xml | 2 +-
.../feusalamander/vmessage/Configuration.java | 18 +++++++++++++++++
.../me/feusalamander/vmessage/Listeners.java | 20 ++++++++++++++++---
src/main/resources/config.toml | 6 ++++++
4 files changed, 42 insertions(+), 4 deletions(-)
diff --git a/pom.xml b/pom.xml
index 1304943..c3864cb 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
Vmessage
Vmessage
- 1.5.6
+ 1.6.1
jar
Vmessage
diff --git a/src/main/java/me/feusalamander/vmessage/Configuration.java b/src/main/java/me/feusalamander/vmessage/Configuration.java
index 9c20f6d..5e3502f 100644
--- a/src/main/java/me/feusalamander/vmessage/Configuration.java
+++ b/src/main/java/me/feusalamander/vmessage/Configuration.java
@@ -26,6 +26,10 @@ public final class Configuration {
private List joincmd;
private List leavecmd;
private List changecmd;
+ private String custom1;
+ private String custom2;
+ private boolean custom1Enabled;
+ private boolean custom2Enabled;
private Toml aliases;
Configuration(Toml config) {
@@ -47,6 +51,11 @@ public final class Configuration {
changecmd = config.getList("Server-change.commands");
minimessage = config.getBoolean("Message-format.minimessage");
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", "");
+ custom2 = config.getString("Custom-Meta.custom2", "");
this.config = config;
}
@@ -130,6 +139,10 @@ public final class Configuration {
public Toml getAliases() {
return aliases;
}
+ public boolean isCustom1Enabled() {return this.custom1Enabled;}
+ public boolean isCustom2Enabled() {return this.custom2Enabled;}
+ public String getCustom1() {return this.custom1;}
+ public String getCustom2() {return this.custom2;}
void reload(){
config = config.read(file);
this.messageFormat = config.getString("Message.format");
@@ -151,5 +164,10 @@ public final class Configuration {
this.minimessage = config.getBoolean("Message-format.minimessage");
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.custom2 = config.getString("Custom-Meta.custom2");
}
}
diff --git a/src/main/java/me/feusalamander/vmessage/Listeners.java b/src/main/java/me/feusalamander/vmessage/Listeners.java
index ada2bd9..35c9614 100644
--- a/src/main/java/me/feusalamander/vmessage/Listeners.java
+++ b/src/main/java/me/feusalamander/vmessage/Listeners.java
@@ -181,13 +181,27 @@ public final class Listeners {
final CachedMetaData data = luckPermsAPI.getPlayerAdapter(Player.class).getMetaData(p);
final String prefix = data.getPrefix();
final String suffix = data.getSuffix();
- if (message.contains("#prefix#")&&prefix != null) {
+ String custom1 = null;
+ String custom2 = null;
+ if (configuration.isCustom1Enabled()) {
+ custom1 = data.getMetaValue(configuration.getCustom1());
+ }
+ if (configuration.isCustom2Enabled()) {
+ custom2 = data.getMetaValue(configuration.getCustom2());
+ }
+ if (message.contains("#prefix#") && prefix != null) {
message = message.replace("#prefix#", prefix);
}
- if (message.contains("#suffix#")&&suffix != null) {
+ if (message.contains("#suffix#") && suffix != null) {
message = message.replace("#suffix#", suffix);
}
- message = message.replace("#prefix#", "").replace("#suffix#", "");
+ if (message.contains("#custom1#") && custom1 != null) {
+ message = message.replace("#custom1#", custom1);
+ }
+ if (message.contains("#custom2#") && custom2 != null) {
+ message = message.replace("#custom2#", custom2);
+ }
+ message = message.replace("#prefix#", "").replace("#suffix#", "").replace("#custom1#","").replace("#custom2#","");
return message;
}
public void message(final Player p, final String m) {
diff --git a/src/main/resources/config.toml b/src/main/resources/config.toml
index eafe2a4..7025b5b 100644
--- a/src/main/resources/config.toml
+++ b/src/main/resources/config.toml
@@ -43,3 +43,9 @@ commands = []
enabled = true
[Aliases]
servername = "Server Name"
+[Custom-Meta]
+#Enables definition of Custom Luckperms Meta Placeholders
+custom1 = ""
+custom1enabled = false
+custom2 = ""
+custom2enabled = false
From 0143d3fa0d9e597d91c0b9916b4a90b1fd6314d8 Mon Sep 17 00:00:00 2001
From: jones6096 <63066064+jones6096@users.noreply.github.com>
Date: Thu, 23 Nov 2023 22:04:12 -0500
Subject: [PATCH 2/2] Remove Unnecessary Check
Meta placeholders are always enabled, errors aren't thrown when an invalid or no meta key is requested
---
.../feusalamander/vmessage/Configuration.java | 17 +++++++----------
.../me/feusalamander/vmessage/Listeners.java | 11 +++--------
src/main/resources/config.toml | 2 --
3 files changed, 10 insertions(+), 20 deletions(-)
diff --git a/src/main/java/me/feusalamander/vmessage/Configuration.java b/src/main/java/me/feusalamander/vmessage/Configuration.java
index 5e3502f..224cc79 100644
--- a/src/main/java/me/feusalamander/vmessage/Configuration.java
+++ b/src/main/java/me/feusalamander/vmessage/Configuration.java
@@ -28,8 +28,6 @@ public final class Configuration {
private List changecmd;
private String custom1;
private String custom2;
- private boolean custom1Enabled;
- private boolean custom2Enabled;
private Toml aliases;
Configuration(Toml config) {
@@ -52,8 +50,6 @@ public final class Configuration {
minimessage = config.getBoolean("Message-format.minimessage");
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", "");
custom2 = config.getString("Custom-Meta.custom2", "");
this.config = config;
@@ -139,10 +135,13 @@ public final class Configuration {
public Toml getAliases() {
return aliases;
}
- public boolean isCustom1Enabled() {return this.custom1Enabled;}
- public boolean isCustom2Enabled() {return this.custom2Enabled;}
- public String getCustom1() {return this.custom1;}
- public String getCustom2() {return this.custom2;}
+ public String getCustom1() {
+ return this.custom1;
+ }
+ public String getCustom2() {
+ return this.custom2;
+ }
+
void reload(){
config = config.read(file);
this.messageFormat = config.getString("Message.format");
@@ -165,8 +164,6 @@ public final class Configuration {
this.minimessage = config.getBoolean("Message-format.minimessage");
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.custom2 = config.getString("Custom-Meta.custom2");
}
diff --git a/src/main/java/me/feusalamander/vmessage/Listeners.java b/src/main/java/me/feusalamander/vmessage/Listeners.java
index 35c9614..c6d9109 100644
--- a/src/main/java/me/feusalamander/vmessage/Listeners.java
+++ b/src/main/java/me/feusalamander/vmessage/Listeners.java
@@ -181,14 +181,9 @@ public final class Listeners {
final CachedMetaData data = luckPermsAPI.getPlayerAdapter(Player.class).getMetaData(p);
final String prefix = data.getPrefix();
final String suffix = data.getSuffix();
- String custom1 = null;
- String custom2 = null;
- if (configuration.isCustom1Enabled()) {
- custom1 = data.getMetaValue(configuration.getCustom1());
- }
- if (configuration.isCustom2Enabled()) {
- custom2 = data.getMetaValue(configuration.getCustom2());
- }
+ final String custom1 = data.getMetaValue(configuration.getCustom1());
+ final String custom2 = data.getMetaValue(configuration.getCustom2());
+
if (message.contains("#prefix#") && prefix != null) {
message = message.replace("#prefix#", prefix);
}
diff --git a/src/main/resources/config.toml b/src/main/resources/config.toml
index 7025b5b..9e3fe83 100644
--- a/src/main/resources/config.toml
+++ b/src/main/resources/config.toml
@@ -46,6 +46,4 @@ servername = "Server Name"
[Custom-Meta]
#Enables definition of Custom Luckperms Meta Placeholders
custom1 = ""
-custom1enabled = false
custom2 = ""
-custom2enabled = false