2525 */
2626package com .github .games647 .fastlogin .bukkit .task ;
2727
28+ import java .io .IOException ;
29+ import java .util .Optional ;
30+
2831import org .bukkit .Bukkit ;
2932import org .bukkit .entity .Player ;
3033import org .geysermc .floodgate .api .player .FloodgatePlayer ;
3134
35+ import com .github .games647 .craftapi .model .Profile ;
36+ import com .github .games647 .craftapi .resolver .RateLimitException ;
3237import com .github .games647 .fastlogin .bukkit .BukkitLoginSession ;
3338import com .github .games647 .fastlogin .bukkit .FastLoginBukkit ;
3439import com .github .games647 .fastlogin .core .StoredProfile ;
@@ -58,7 +63,8 @@ public void run() {
5863 AuthPlugin <Player > authPlugin = plugin .getCore ().getAuthPluginHook ();
5964
6065 String autoLoginFloodgate = plugin .getCore ().getConfig ().get ("autoLoginFloodgate" ).toString ().toLowerCase ();
61- boolean autoRegisterFloodgate = plugin .getCore ().getConfig ().getBoolean ("autoRegisterFloodgate" );
66+ String autoRegisterFloodgate = plugin .getCore ().getConfig ().get ("autoRegisterFloodgate" ).toString ().toLowerCase ();
67+ String allowNameConflict = plugin .getCore ().getConfig ().get ("allowFloodgateNameConflict" ).toString ().toLowerCase ();
6268
6369 boolean isRegistered ;
6470 try {
@@ -70,7 +76,27 @@ public void run() {
7076 return ;
7177 }
7278
73- if (!isRegistered && !autoRegisterFloodgate ) {
79+ //decide if checks should be made for conflicting Java player names
80+ if (autoLoginFloodgate .equals ("no-conflict" )
81+ || !isRegistered && autoRegisterFloodgate .equals ("no-conflict" )) {
82+ // check for conflicting Premium Java name
83+ Optional <Profile > premiumUUID = Optional .empty ();
84+ try {
85+ premiumUUID = plugin .getCore ().getResolver ().findProfile (player .getName ());
86+ } catch (IOException | RateLimitException e ) {
87+ plugin .getLog ().error (
88+ "Could not check wether Floodgate Player {}'s name conflits a premium Java player's name." ,
89+ player .getName ());
90+ return ;
91+ }
92+
93+ //stop execution if player's name is conflicting
94+ if (premiumUUID .isPresent ()) {
95+ return ;
96+ }
97+ }
98+
99+ if (!isRegistered && autoRegisterFloodgate .equals ("false" )) {
74100 plugin .getLog ().info (
75101 "Auto registration is disabled for Floodgate players in config.yml" );
76102 return ;
0 commit comments