Merge pull request #17 from ydal251/main

This commit is contained in:
FeuSalamander 2023-11-24 12:12:04 +01:00 committed by GitHub
commit 6cb80c86d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 32 additions and 4 deletions

View File

@ -6,7 +6,7 @@
<groupId>Vmessage</groupId>
<artifactId>Vmessage</artifactId>
<version>1.5.6</version>
<version>1.6.1</version>
<packaging>jar</packaging>
<name>Vmessage</name>

View File

@ -26,6 +26,8 @@ public final class Configuration {
private List<String> joincmd;
private List<String> leavecmd;
private List<String> changecmd;
private String custom1;
private String custom2;
private Toml aliases;
Configuration(Toml config) {
@ -47,6 +49,9 @@ public final class Configuration {
changecmd = config.getList("Server-change.commands");
minimessage = config.getBoolean("Message-format.minimessage");
all = config.getBoolean("Message.all", false);
custom1 = config.getString("Custom-Meta.custom1", "");
custom2 = config.getString("Custom-Meta.custom2", "");
this.config = config;
}
@ -130,6 +135,13 @@ public final class Configuration {
public Toml getAliases() {
return aliases;
}
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 +163,8 @@ public final class Configuration {
this.minimessage = config.getBoolean("Message-format.minimessage");
this.all = config.getBoolean("Message.all", false);
this.custom1 = config.getString("Custom-Meta.custom1");
this.custom2 = config.getString("Custom-Meta.custom2");
}
}

View File

@ -181,13 +181,22 @@ 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) {
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);
}
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) {

View File

@ -43,3 +43,7 @@ commands = []
enabled = true
[Aliases]
servername = "Server Name"
[Custom-Meta]
#Enables definition of Custom Luckperms Meta Placeholders
custom1 = ""
custom2 = ""