added booleans

This commit is contained in:
FeuSalamander 2022-12-12 12:45:00 +01:00
parent 5993af255b
commit 1153a65d48
3 changed files with 62 additions and 11 deletions

View File

@ -25,7 +25,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.2.0</version>
<version>3.2.1</version>
<executions>
<execution>
<id>attach-sources</id>

View File

@ -1,7 +1,9 @@
package me.feusalamander.vmessage;
import com.google.inject.Inject;
import com.moandjiezana.toml.Toml;
import com.velocitypowered.api.event.player.PlayerChatEvent;
import com.velocitypowered.api.event.connection.DisconnectEvent;
import com.velocitypowered.api.event.connection.LoginEvent;
import com.velocitypowered.api.event.player.*;
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
import com.velocitypowered.api.event.Subscribe;
import com.velocitypowered.api.plugin.Plugin;
@ -12,6 +14,7 @@ import com.velocitypowered.api.proxy.server.RegisteredServer;
import net.kyori.adventure.text.Component;
import net.luckperms.api.LuckPerms;
import net.luckperms.api.LuckPermsProvider;
import net.luckperms.api.event.player.PlayerLoginProcessEvent;
import net.luckperms.api.model.user.User;
import org.slf4j.Logger;
import java.io.File;
@ -23,7 +26,7 @@ import java.util.Objects;
@Plugin(
id = "vmessage",
name = "Vmessage",
version = "1.1",
version = "1.2",
description = "A velocity plugin that creates a multi server chat for the network",
authors = {"FeuSalamander"}
)
@ -43,17 +46,40 @@ public class vmessage {
this.metricsFactory = metricsFactory;
this.dataDirectory = dataDirectory;
}
public String message = "";
private String message = "";
private boolean messageb = false;
private boolean joinb = false;
private boolean leaveb = false;
private boolean changeb = false;
@Subscribe
public void onProxyInitialization(ProxyInitializeEvent event) {
private void onProxyInitialization(ProxyInitializeEvent event) {
logger.info("Vmessage by FeuSalamander is working !");
Metrics metrics = metricsFactory.make(this, 16527);
File directory = dataDirectory.toFile();
File f = new File(directory, "config.toml");
Toml config = new Toml().read(f);
createconfig();
message = getmessage("Message-format.format");
if(config.getBoolean("Message.enabled"))messageb = true;
if(config.getBoolean("Join.enabled"))joinb = true;
if(config.getBoolean("Leave.enabled"))leaveb = true;
if(config.getBoolean("Server-change.enabled"))changeb = true;
message = getmessage("Message.format");
}
@Subscribe
public void onMessage(PlayerChatEvent e){
private void onMessage(PlayerChatEvent e){
proxy.getAllServers().stream().forEach(registeredServer -> sendMessage(registeredServer, e.getPlayer(), e.getMessage()));
}
@Subscribe
private void onJoin(LoginEvent e){
}
@Subscribe
private void onLeave(DisconnectEvent e){
}
@Subscribe
private void onChange(ServerConnectedEvent e){
}
private void sendMessage(RegisteredServer s, Player p, String m){
message = message.replaceAll("#player#", p.getUsername());
@ -66,10 +92,10 @@ public class vmessage {
User user = api.getPlayerAdapter(Player.class).getUser(p);
message = message.replaceAll("#prefix#", user.getCachedData().getMetaData().getPrefix().replaceAll("&", "§"));
s.sendMessage(Component.text(message));
message = getmessage("Message-format.format");
message = getmessage("Message.format");
}else{
s.sendMessage(Component.text(message));
message = getmessage("Message-format.format");
message = getmessage("Message.format");
}
}
}

View File

@ -1,7 +1,32 @@
[Message-format]
[Message]
#place holders:
#- "#player#" : return the player name
#- "#prefix#" : return the player's luckperms prefix (don't place it if you don't have luckperms on your server)
#- "#message#" : return the player's message
#- "#server#" : return the player's server name
format = "§a(#server#) #prefix# #player# §8§l> §r#message#"
format = "§a(#server#) #prefix# #player# §8§l> §r#message#"
enabled = true
[Join]
#place holders:
#- "#player#" : return the player name
#- "#prefix#" : return the player's luckperms prefix (don't place it if you don't have luckperms on your server)
#- "#message#" : return the player's message
#- "#server#" : return the player's server name
format = "§a(#server#) #prefix# #player# §8§l> §r#message#"
enabled = true
[Leave]
#place holders:
#- "#player#" : return the player name
#- "#prefix#" : return the player's luckperms prefix (don't place it if you don't have luckperms on your server)
#- "#message#" : return the player's message
#- "#server#" : return the player's server name
format = "§a(#server#) #prefix# #player# §8§l> §r#message#"
enabled = true
[Server-change]
#place holders:
#- "#player#" : return the player name
#- "#prefix#" : return the player's luckperms prefix (don't place it if you don't have luckperms on your server)
#- "#message#" : return the player's message
#- "#server#" : return the player's server name
format = "§a(#server#) #prefix# #player# §8§l> §r#message#"
enabled = true