added the "vmessage.minimessage" permission
This commit is contained in:
parent
db7a55f99e
commit
d820c202c9
@ -7,5 +7,6 @@
|
|||||||
- LuckPerms Prefix and Suffix Support
|
- LuckPerms Prefix and Suffix Support
|
||||||
- Velocity only
|
- Velocity only
|
||||||
- Reload command: "/vmessage reload", permission: "vmessage.reload"
|
- Reload command: "/vmessage reload", permission: "vmessage.reload"
|
||||||
|
- MiniMessage support, if a player want to have MiniMessage in his message he needs to have the permission "vmessage.minimessage"
|
||||||
- Global message command: "/sendall"
|
- Global message command: "/sendall"
|
||||||
- You can also check my Bukkit plugin https://github.com/FeuSalamander/MiniWalls
|
- You can also check my Bukkit plugin https://github.com/FeuSalamander/MiniWalls
|
||||||
|
@ -26,7 +26,7 @@ import java.util.Objects;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.SortedMap;
|
import java.util.SortedMap;
|
||||||
import java.util.concurrent.CompletionException;
|
import java.util.concurrent.CompletionException;
|
||||||
@SuppressWarnings("UnstableApiUsage")
|
@SuppressWarnings({"UnstableApiUsage", "deprecation"})
|
||||||
public final class Listeners {
|
public final class Listeners {
|
||||||
public static final LegacyComponentSerializer SERIALIZER = LegacyComponentSerializer.builder()
|
public static final LegacyComponentSerializer SERIALIZER = LegacyComponentSerializer.builder()
|
||||||
.character('&')
|
.character('&')
|
||||||
@ -138,25 +138,28 @@ public final class Listeners {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void message(final Player p, final String m) {
|
public void message(final Player p, final String m) {
|
||||||
|
final boolean permission = p.hasPermission("vmessage.minimessage");
|
||||||
String message = configuration.getMessageFormat()
|
String message = configuration.getMessageFormat()
|
||||||
.replace("#player#", p.getUsername())
|
.replace("#player#", p.getUsername())
|
||||||
.replace("#message#", m)
|
|
||||||
.replace("#server#", p.getCurrentServer().orElseThrow().getServerInfo().getName());
|
.replace("#server#", p.getCurrentServer().orElseThrow().getServerInfo().getName());
|
||||||
if (luckPermsAPI != null) {
|
if (luckPermsAPI != null) {
|
||||||
message = luckperms(message, p);
|
message = luckperms(message, p);
|
||||||
}
|
}
|
||||||
final Component finalMessage;
|
if(permission)message = message.replace("#message#", m);
|
||||||
|
Component finalMessage;
|
||||||
if (configuration.isMinimessageEnabled()) {
|
if (configuration.isMinimessageEnabled()) {
|
||||||
finalMessage = mm.deserialize(message.replace("§", ""));
|
finalMessage = mm.deserialize(message.replace("§", ""));
|
||||||
} else {
|
} else {
|
||||||
finalMessage = SERIALIZER.deserialize(message);
|
finalMessage = SERIALIZER.deserialize(message);
|
||||||
}
|
}
|
||||||
|
if(!permission)finalMessage = finalMessage.replaceText("#message#", Component.text(m));
|
||||||
if(configuration.isAllEnabled()){
|
if(configuration.isAllEnabled()){
|
||||||
proxyServer.sendMessage(finalMessage);
|
proxyServer.sendMessage(finalMessage);
|
||||||
}else {
|
}else {
|
||||||
|
final Component FMessage = finalMessage;
|
||||||
proxyServer.getAllServers().forEach(server -> {
|
proxyServer.getAllServers().forEach(server -> {
|
||||||
if (!Objects.equals(p.getCurrentServer().map(ServerConnection::getServerInfo).orElse(null), server.getServerInfo())) {
|
if (!Objects.equals(p.getCurrentServer().map(ServerConnection::getServerInfo).orElse(null), server.getServerInfo())) {
|
||||||
server.sendMessage(finalMessage);
|
server.sendMessage(FMessage);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user