diff --git a/api/src/main/java/com/alttd/chat/config/Config.java b/api/src/main/java/com/alttd/chat/config/Config.java index 88b239e..0a1b9ca 100644 --- a/api/src/main/java/com/alttd/chat/config/Config.java +++ b/api/src/main/java/com/alttd/chat/config/Config.java @@ -204,4 +204,31 @@ public final class Config { REGEXNODE = getNode("regex-settings"); } + public static String SERVERSWTICHMESSAGEFROM = "&7* {player} comes from {from_server}..."; // TODO CONVERT THESE TO MINIMESSAGE + public static String SERVERSWTICHMESSAGETO = "&7* {player} leaves to {to_server}..."; + public static String SERVERJOINMESSAGE = "&a* {player} appears from thin air..."; + public static String SERVERLEAVEMESSAGE = "&c* {player} vanishes in the mist..."; + private static void JoinLeaveMessages() { + SERVERSWTICHMESSAGEFROM = getString("messages.switch-server-from", SERVERSWTICHMESSAGEFROM); + SERVERSWTICHMESSAGETO = getString("messages.switch-server-to", SERVERSWTICHMESSAGETO); + SERVERJOINMESSAGE = getString("messages.join-server", SERVERJOINMESSAGE); + SERVERLEAVEMESSAGE = getString("messages.leave-server", SERVERLEAVEMESSAGE); + + } + + public static String DRIVER = "databasedriver"; + public static String IP = "0.0.0.0"; + public static String PORT = "3306"; + public static String DATABASE = "database"; + public static String USERNAME = "root"; + public static String PASSWORD = "root"; + private static void database() { + DRIVER = getString("database.driver" , DRIVER); + IP = getString("database.ip", IP); + PORT = getString("database.port", PORT); + DATABASE = getString("database.name", DATABASE); + USERNAME = getString("database.username", USERNAME); + PASSWORD = getString("database.password", PASSWORD); + } + } diff --git a/api/src/main/java/com/alttd/chat/database/DatabaseConnection.java b/api/src/main/java/com/alttd/chat/database/DatabaseConnection.java index eb62ea8..9f7a2ea 100644 --- a/api/src/main/java/com/alttd/chat/database/DatabaseConnection.java +++ b/api/src/main/java/com/alttd/chat/database/DatabaseConnection.java @@ -1,6 +1,8 @@ package com.alttd.chat.database; +import com.alttd.chat.config.Config; + import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; @@ -16,14 +18,12 @@ public class DatabaseConnection { */ public DatabaseConnection() { - /*this.drivers = Config.drivers; - this.ip = Config.ip; - this.port = Config.port; - this.database = Config.database; - this.username = Config.username; - this.password = Config.password;*/ - // temp to make compile, remove when config is added - this.drivers = this.ip = this.port = this.database = this.username = this.password = ""; + this.drivers = Config.DRIVER; + this.ip = Config.IP; + this.port = Config.PORT; + this.database = Config.DATABASE; + this.username = Config.USERNAME; + this.password = Config.PASSWORD; instance = this; try { diff --git a/velocity/src/main/java/com/alttd/chat/listeners/PlayerListener.java b/velocity/src/main/java/com/alttd/chat/listeners/PlayerListener.java index 6d85767..4ace135 100644 --- a/velocity/src/main/java/com/alttd/chat/listeners/PlayerListener.java +++ b/velocity/src/main/java/com/alttd/chat/listeners/PlayerListener.java @@ -1,11 +1,20 @@ package com.alttd.chat.listeners; import com.alttd.chat.VelocityChat; +import com.alttd.chat.config.Config; import com.alttd.chat.objects.ChatPlayer; import com.velocitypowered.api.event.PostOrder; import com.velocitypowered.api.event.Subscribe; import com.velocitypowered.api.event.connection.DisconnectEvent; import com.velocitypowered.api.event.connection.LoginEvent; +import com.velocitypowered.api.event.player.ServerConnectedEvent; +import com.velocitypowered.api.proxy.Player; +import com.velocitypowered.api.proxy.server.RegisteredServer; +import net.kyori.adventure.text.minimessage.MiniMessage; +import net.kyori.adventure.text.minimessage.Template; + +import java.util.ArrayList; +import java.util.List; public class PlayerListener { @@ -18,4 +27,46 @@ public class PlayerListener { public void quitEvent(DisconnectEvent event) { VelocityChat.getPlugin().getChatHandler().removePlayer(event.getPlayer().getUniqueId()); } + + // Server Join and Leave messages + @Subscribe + public void serverConnected(ServerConnectedEvent event) { + MiniMessage miniMessage = MiniMessage.get(); + // todo optional setting to ignore this for servers? + if (event.getPreviousServer().isPresent()) { + RegisteredServer previousServer = event.getPreviousServer().get(); + + Player player = event.getPlayer(); + + + + List