Skip to content

Commit

Permalink
Change System.out to Bukkit.getLogger
Browse files Browse the repository at this point in the history
  • Loading branch information
Gertius committed Sep 25, 2021
1 parent dedc6d0 commit d715d01
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
7 changes: 4 additions & 3 deletions src/main/java/lilypad/bukkit/connect/ConnectPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import lilypad.bukkit.connect.util.ReflectionUtils;
import lilypad.client.connect.api.Connect;
import lilypad.client.connect.lib.ConnectImpl;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
import org.bukkit.event.player.PlayerLoginEvent;
Expand Down Expand Up @@ -77,7 +78,7 @@ public void onEnable() {
protocol = new Protocol1_17_R1();
break;
default:
System.out.println("[Connect] Unable to start plugin - unsupported version (" + version + "). Please retrieve the newest version at http://lilypadmc.org");
Bukkit.getLogger().info("[Connect] Unable to start plugin - unsupported version (" + version + "). Please retrieve the newest version at http://lilypadmc.org");
return;
}

Expand All @@ -99,7 +100,7 @@ public void onEnable() {
}
} catch(Exception exception) {
exception.printStackTrace();
System.out.println("[Connect] Unable to start plugin - unsupported version?");
Bukkit.getLogger().info("[Connect] Unable to start plugin - unsupported version?");
return;
}

Expand All @@ -119,7 +120,7 @@ public void run() {
ConnectPlugin.this.connectThread.start();
} catch(Exception exception) {
exception.printStackTrace();
System.out.println("[Connect] Unable to start plugin - unsupported version?");
Bukkit.getLogger().info("[Connect] Unable to start plugin - unsupported version?");
}
}
});
Expand Down
27 changes: 14 additions & 13 deletions src/main/java/lilypad/bukkit/connect/ConnectThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import lilypad.client.connect.api.result.impl.AsServerResult;
import lilypad.client.connect.api.result.impl.AuthenticateResult;
import lilypad.client.connect.api.result.impl.GetKeyResult;
import org.bukkit.Bukkit;

public class ConnectThread implements Runnable {

Expand Down Expand Up @@ -48,7 +49,7 @@ public void run() {
throw interruptedException;
} catch(Throwable throwable) {
connect.disconnect();
System.out.println("[Connect] Couldn't connect to remote host: \"" + throwable.getMessage() + "\", retrying");
Bukkit.getLogger().info("[Connect] Couldn't connect to remote host: \"" + throwable.getMessage() + "\", retrying");
Thread.sleep(1000L);
continue;
}
Expand All @@ -59,13 +60,13 @@ public void run() {
getKeyResult = connect.request(new GetKeyRequest()).await(2500L);
} catch(RequestException exception) {
connect.disconnect();
System.out.println("[Connect] Request exception while keying, retrying: " + exception.getMessage());
Bukkit.getLogger().info("[Connect] Request exception while keying, retrying: " + exception.getMessage());
Thread.sleep(1000L);
continue;
}
if (getKeyResult == null) {
connect.disconnect();
System.out.println("[Connect] Connection timed out while keying, retrying");
Bukkit.getLogger().info("[Connect] Connection timed out while keying, retrying");
Thread.sleep(1000L);
continue;
}
Expand All @@ -76,13 +77,13 @@ public void run() {
authenticationResult = connect.request(new AuthenticateRequest(settings.getUsername(), settings.getPassword(), getKeyResult.getKey())).await(2500L);
} catch(RequestException exception) {
connect.disconnect();
System.out.println("[Connect] Request exception while authenticating, retrying: " + exception.getMessage());
Bukkit.getLogger().info("[Connect] Request exception while authenticating, retrying: " + exception.getMessage());
Thread.sleep(1000L);
continue;
}
if (authenticationResult == null) {
connect.disconnect();
System.out.println("[Connect] Connection timed out while authenticating, retrying");
Bukkit.getLogger().info("[Connect] Connection timed out while authenticating, retrying");
Thread.sleep(1000L);
continue;
}
Expand All @@ -91,12 +92,12 @@ public void run() {
break;
case INVALID_GENERIC:
connect.disconnect();
System.out.println("[Connect] Invalid username or password, retrying");
Bukkit.getLogger().info("[Connect] Invalid username or password, retrying");
Thread.sleep(1000L);
continue;
default:
connect.disconnect();
System.out.println("[Connect] Unknown error while authenticating: \"" + authenticationResult.getStatusCode() + "\", retrying");
Bukkit.getLogger().info("[Connect] Unknown error while authenticating: \"" + authenticationResult.getStatusCode() + "\", retrying");
Thread.sleep(1000L);
continue;
}
Expand All @@ -107,13 +108,13 @@ public void run() {
asServerResult = connect.request(new AsServerRequest(this.connectPlugin.getInboundAddress().getPort())).await(2500L);
} catch(RequestException exception) {
connect.disconnect();
System.out.println("[Connect] Request exception while acquiring role, retrying: " + exception.getMessage());
Bukkit.getLogger().info("[Connect] Request exception while acquiring role, retrying: " + exception.getMessage());
Thread.sleep(1000L);
continue;
}
if (asServerResult == null) {
connect.disconnect();
System.out.println("[Connect] Connection timed out while acquiring role, retrying");
Bukkit.getLogger().info("[Connect] Connection timed out while acquiring role, retrying");
Thread.sleep(1000L);
continue;
}
Expand All @@ -122,24 +123,24 @@ public void run() {
break;
case INVALID_GENERIC:
connect.disconnect();
System.out.println("[Connect] Invalid username, already in use");
Bukkit.getLogger().info("[Connect] Invalid username, already in use");
Thread.sleep(1000L);
break;
default:
connect.disconnect();
System.out.println("[Connect] Unknown error while acquiring role: \"" + asServerResult.getStatusCode() + "\", retrying");
Bukkit.getLogger().info("[Connect] Unknown error while acquiring role: \"" + asServerResult.getStatusCode() + "\", retrying");
Thread.sleep(1000L);
continue;
}

// pause
System.out.println("[Connect] Connected to the cloud");
Bukkit.getLogger().info("[Connect] Connected to the cloud");
this.connectPlugin.setSecurityKey(asServerResult.getSecurityKey());
while(connect.isConnected()) {
Thread.sleep(1000L);
}
this.connectPlugin.setSecurityKey(null);
System.out.println("[Connect] Lost connection to the cloud, reconnecting");
Bukkit.getLogger().info("[Connect] Lost connection to the cloud, reconnecting");
}
} catch(InterruptedException exception) {
// ignore
Expand Down

0 comments on commit d715d01

Please sign in to comment.