77import com .elchologamer .userlogin .util .Utils ;
88import org .bukkit .Location ;
99import org .bukkit .configuration .ConfigurationSection ;
10+ import org .bukkit .configuration .file .FileConfiguration ;
1011import org .bukkit .entity .Player ;
1112
1213import java .net .InetSocketAddress ;
1314import java .util .HashMap ;
15+ import java .util .List ;
1416import java .util .Map ;
1517import java .util .UUID ;
1618
@@ -99,16 +101,17 @@ public void onQuit() {
99101
100102 public void onAuthenticate (AuthType type ) {
101103 Player player = getPlayer ();
104+ FileConfiguration config = plugin .getConfig ();
102105
103- ConfigurationSection teleports = plugin . getConfig () .getConfigurationSection ("teleports" );
106+ ConfigurationSection teleports = config .getConfigurationSection ("teleports" );
104107 assert teleports != null ;
105108
106109 // Call event
107110 AuthenticationEvent event ;
108111
109- boolean bungeeEnabled = plugin . getConfig () .getBoolean ("bungeeCord.enabled" );
112+ boolean bungeeEnabled = config .getBoolean ("bungeeCord.enabled" );
110113 if (bungeeEnabled ) {
111- String targetServer = plugin . getConfig () .getString ("bungeeCord.spawnServer" );
114+ String targetServer = config .getString ("bungeeCord.spawnServer" );
112115 event = new AuthenticationEvent (player , type , targetServer );
113116 } else {
114117 Location target = null ;
@@ -130,7 +133,7 @@ public void onAuthenticate(AuthType type) {
130133 cancelPreLoginTasks ();
131134
132135 // Save IP address
133- if (plugin . getConfig () .getBoolean ("ipRecords.enabled" )) {
136+ if (config .getBoolean ("ipRecords.enabled" )) {
134137 InetSocketAddress addr = player .getAddress ();
135138 if (addr != null ) ip = addr .getHostString ();
136139 }
@@ -149,6 +152,15 @@ public void onAuthenticate(AuthType type) {
149152
150153 loggedIn = true ;
151154
155+ // Run login commands
156+ List <String > loginCommands = config .getStringList ("loginCommands" );
157+ for (String command : loginCommands ) {
158+ plugin .getServer ().dispatchCommand (
159+ plugin .getServer ().getConsoleSender (),
160+ command .replace ("{player}" , player .getName ()).replaceFirst ("^/" , "" )
161+ );
162+ }
163+
152164 // Teleport to destination
153165 if (bungeeEnabled && event .getTargetServer () != null ) {
154166 Utils .sendPluginMessage (player , "BungeeCord" , "Connect" , event .getTargetServer ());
0 commit comments