Skip to content

Commit

Permalink
Update to Java 21
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaming32 committed May 9, 2024
1 parent ef24c9b commit 4be1c04
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,13 @@ public ProxyProtocolClient(String host, int port, long connectionId, String base
final DataInputStream dis = new DataInputStream(fSocket.getInputStream());
while (!closed) {
final ProxyMessage message = ProxyMessage.read(dis);
if (message instanceof ProxyMessage.Open open) {
WorldHost.proxyConnect(open.getConnectionId(), open.getAddress(), () -> WorldHost.proxyProtocolClient);
} else if (message instanceof ProxyMessage.Packet packet) {
WorldHost.proxyPacket(packet.getConnectionId(), packet.getBuffer());
} else if (message instanceof ProxyMessage.Close close) {
WorldHost.proxyDisconnect(close.getConnectionId());
} else {
throw new AssertionError("If..elseif for ProxyMessage should be exhaustive");
switch (message) {
case ProxyMessage.Open open ->
WorldHost.proxyConnect(open.getConnectionId(), open.getAddress(), () -> WorldHost.proxyProtocolClient);
case ProxyMessage.Packet packet ->
WorldHost.proxyPacket(packet.getConnectionId(), packet.getBuffer());
case ProxyMessage.Close close ->
WorldHost.proxyDisconnect(close.getConnectionId());
}
}
} catch (Exception e) {
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/io/github/gaming32/worldhost/toast/WHToast.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ static void add(ToastInstance toast) {
toast.calculateText();
playSound(toast.important ? IMPORTANT : REGULAR);
if (!TOASTS.isEmpty()) {
if (Y_OFFSET + 2 * toast.height + GAP <= TOASTS.get(0).y) {
if (Y_OFFSET + 2 * toast.height + GAP <= TOASTS.getFirst().y) {
toast.y = Y_OFFSET;
TOASTS.add(0, toast);
TOASTS.addFirst(toast);
return;
}
for (int i = 0; i < TOASTS.size() - 1; i++) {
Expand All @@ -73,7 +73,7 @@ static void add(ToastInstance toast) {
return;
}
}
final ToastInstance lastToast = TOASTS.get(TOASTS.size() - 1);
final ToastInstance lastToast = TOASTS.getLast();
toast.y = lastToast.y + lastToast.height + GAP;
} else {
toast.y = Y_OFFSET;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/io/github/gaming32/worldhost/upnp/Gateway.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import javax.xml.parsers.DocumentBuilderFactory;
import java.net.HttpURLConnection;
import java.net.InetAddress;
import java.net.URL;
import java.net.URI;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;
Expand Down Expand Up @@ -113,7 +113,7 @@ private Map<String, String> command(String action, Map<String, String> params) t
}
soap.append("</m:").append(action).append("></SOAP-ENV:Body></SOAP-ENV:Envelope>");
byte[] req = soap.toString().getBytes();
HttpURLConnection conn = (HttpURLConnection) new URL(controlURL).openConnection();
HttpURLConnection conn = (HttpURLConnection) new URI(controlURL).toURL().openConnection();
conn.setRequestMethod("POST");
conn.setDoOutput(true);
conn.setRequestProperty("Content-Type", "text/xml");
Expand Down
6 changes: 3 additions & 3 deletions version.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ repositories {

java {
withSourcesJar()
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}

tasks.compileJava {
options.release = 17
options.release = 21
options.compilerArgs.add("-Xlint:all")
}

Expand Down

0 comments on commit 4be1c04

Please sign in to comment.