mirror of https://github.com/LOOHP/Limbo.git
Refactoring
This commit is contained in:
parent
68a97ec670
commit
9beae66898
|
|
@ -1,30 +0,0 @@
|
||||||
name: Build
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- '**'
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout Repository
|
|
||||||
# See https://github.com/actions/checkout/releases
|
|
||||||
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
|
|
||||||
- name: Set up JDK 21
|
|
||||||
# See https://github.com/actions/setup-java/releases
|
|
||||||
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00
|
|
||||||
with:
|
|
||||||
java-version: 21
|
|
||||||
distribution: temurin
|
|
||||||
- name: Build with Maven
|
|
||||||
run: mvn clean package
|
|
||||||
- name: Archive Artifacts
|
|
||||||
# See https://github.com/actions/upload-artifact/releases
|
|
||||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
|
|
||||||
if: success()
|
|
||||||
with:
|
|
||||||
name: Limbo
|
|
||||||
path: target/Limbo-*.jar
|
|
||||||
if-no-files-found: error
|
|
||||||
2
pom.xml
2
pom.xml
|
|
@ -24,7 +24,7 @@
|
||||||
<groupId>com.loohp</groupId>
|
<groupId>com.loohp</groupId>
|
||||||
<artifactId>Limbo</artifactId>
|
<artifactId>Limbo</artifactId>
|
||||||
<name>Limbo</name>
|
<name>Limbo</name>
|
||||||
<version>0.7.17-ALPHA</version>
|
<version>0.7.18-ALPHA</version>
|
||||||
|
|
||||||
<description>Standalone Limbo Minecraft Server.</description>
|
<description>Standalone Limbo Minecraft Server.</description>
|
||||||
<url>https://github.com/LOOHP/Limbo</url>
|
<url>https://github.com/LOOHP/Limbo</url>
|
||||||
|
|
|
||||||
|
|
@ -21,13 +21,13 @@ package com.loohp.limbo.consolegui;
|
||||||
|
|
||||||
import com.loohp.limbo.Limbo;
|
import com.loohp.limbo.Limbo;
|
||||||
|
|
||||||
import java.lang.management.ManagementFactory;
|
|
||||||
import java.text.NumberFormat;
|
import java.text.NumberFormat;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
public class SystemInfo {
|
public class SystemInfo {
|
||||||
|
|
||||||
public static void printInfo() {
|
@SuppressWarnings("InfiniteLoopStatement")
|
||||||
|
public static void printInfo() {
|
||||||
if (!Limbo.noGui) {
|
if (!Limbo.noGui) {
|
||||||
while (true) {
|
while (true) {
|
||||||
Runtime runtime = Runtime.getRuntime();
|
Runtime runtime = Runtime.getRuntime();
|
||||||
|
|
@ -47,11 +47,11 @@ public class SystemInfo {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@SuppressWarnings("restriction")
|
@SuppressWarnings("restriction")
|
||||||
com.sun.management.OperatingSystemMXBean operatingSystemMXBean = (com.sun.management.OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean();
|
com.sun.management.OperatingSystemMXBean operatingSystemMXBean = (com.sun.management.OperatingSystemMXBean) java.lang.management.ManagementFactory.getOperatingSystemMXBean();
|
||||||
@SuppressWarnings("restriction")
|
@SuppressWarnings("restriction")
|
||||||
double processLoad = operatingSystemMXBean.getProcessCpuLoad();
|
double processLoad = operatingSystemMXBean.getProcessCpuLoad();
|
||||||
@SuppressWarnings("restriction")
|
@SuppressWarnings("restriction")
|
||||||
double systemLoad = operatingSystemMXBean.getSystemCpuLoad();
|
double systemLoad = operatingSystemMXBean.getCpuLoad();
|
||||||
int processors = runtime.availableProcessors();
|
int processors = runtime.availableProcessors();
|
||||||
|
|
||||||
sb.append("Available Processors: ").append(processors).append("\n");
|
sb.append("Available Processors: ").append(processors).append("\n");
|
||||||
|
|
|
||||||
|
|
@ -35,18 +35,21 @@ public class ServerConnection extends Thread {
|
||||||
private final String ip;
|
private final String ip;
|
||||||
private final int port;
|
private final int port;
|
||||||
private final boolean silent;
|
private final boolean silent;
|
||||||
private final ExecutorService virtualThreadExecutor = Executors.newVirtualThreadPerTaskExecutor();
|
private final ExecutorService executorService;
|
||||||
|
private final List<ClientConnection> clients;
|
||||||
|
|
||||||
private ServerSocket serverSocket;
|
private ServerSocket serverSocket;
|
||||||
private List<ClientConnection> clients;
|
|
||||||
|
|
||||||
public ServerConnection(String ip, int port, boolean silent) {
|
public ServerConnection(String ip, int port, boolean silent) {
|
||||||
this.clients = new ArrayList<>();
|
this.clients = new ArrayList<>();
|
||||||
this.ip = ip;
|
this.ip = ip;
|
||||||
this.port = port;
|
this.port = port;
|
||||||
this.silent = silent;
|
this.silent = silent;
|
||||||
|
this.executorService = Executors.newVirtualThreadPerTaskExecutor();
|
||||||
start();
|
start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("InfiniteLoopStatement")
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
|
|
@ -58,9 +61,9 @@ public class ServerConnection extends Thread {
|
||||||
Socket connection = serverSocket.accept();
|
Socket connection = serverSocket.accept();
|
||||||
ClientConnection clientTask = new ClientConnection(connection);
|
ClientConnection clientTask = new ClientConnection(connection);
|
||||||
clients.add(clientTask);
|
clients.add(clientTask);
|
||||||
virtualThreadExecutor.submit(clientTask);
|
executorService.submit(clientTask);
|
||||||
}
|
}
|
||||||
} catch(IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue