Skip to content

Commit

Permalink
Merge pull request #72 from Gaming32/port/1.20.6
Browse files Browse the repository at this point in the history
Port to 1.20.6 and other improvements
  • Loading branch information
Gaming32 authored May 11, 2024
2 parents f6cc193 + 941ca4f commit 6f0169c
Show file tree
Hide file tree
Showing 36 changed files with 397 additions and 368 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ jobs:
~/.gradle/caches
~/.gradle/wrapper
.gradle/loom-cache
- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v1
with:
java-version: 17
java-version: 21
- name: Build with Gradle
run: ./gradlew build --stacktrace
- name: Capture build artifacts
Expand Down
10 changes: 7 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
plugins {
id("dev.deftu.gradle.preprocess-root") version "0.4.2"
id("xyz.wagyourtail.unimined") version "1.2.0" apply false
id("io.github.gaming32.gradle.preprocess-root") version "0.4.4"
id("xyz.wagyourtail.unimined") version "1.2.4" apply false
}

repositories {
mavenCentral()
}

preprocess {
val fabric12006 = createNode("1.20.6-fabric", 1_20_06, "yarn")
val neoforge12006 = createNode("1.20.6-neoforge", 1_20_06, "yarn")
val fabric12004 = createNode("1.20.4-fabric", 1_20_04, "yarn")
val neoforge12004 = createNode("1.20.4-neoforge", 1_20_04, "yarn")
val fabric12001 = createNode("1.20.1-fabric", 1_20_01, "yarn")
Expand All @@ -21,7 +23,9 @@ preprocess {
val fabric11701 = createNode("1.17.1-fabric", 1_17_01, "yarn")
val forge11701 = createNode("1.17.1-forge", 1_17_01, "srg")

fabric12004.link(neoforge12004)
fabric12006.link(neoforge12006)
neoforge12006.link(neoforge12004)
neoforge12004.link(fabric12004)
fabric12004.link(fabric12001)
fabric12001.link(forge12001)
forge12001.link(forge11904)
Expand Down
7 changes: 3 additions & 4 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,10 @@ pluginManagement {
maven("https://maven.jab125.dev/")
maven("https://maven.wagyourtail.xyz/snapshots")
maven("https://maven.wagyourtail.xyz/releases")
maven("https://maven.jemnetworks.com/releases")
gradlePluginPortal()
mavenCentral()
}

plugins {
id("dev.deftu.gradle.multiversion-root") version("1.18.0")
}
}

rootProject.name = "world-host"
Expand All @@ -34,6 +31,8 @@ listOf(
"1.20.1-fabric",
"1.20.4-neoforge",
"1.20.4-fabric",
"1.20.6-neoforge",
"1.20.6-fabric",
).forEach { version ->
include(":$version")
project(":$version").apply {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package io.github.gaming32.worldhost;

import java.util.Map;
import it.unimi.dsi.fastutil.objects.Object2LongMap;

import java.util.UUID;

public interface FriendsListUpdate {
void friendsListUpdate(Map<UUID, Long> friends);
void friendsListUpdate(Object2LongMap<UUID> friends);

default void friendsListUpdate() {
friendsListUpdate(WorldHost.ONLINE_FRIENDS);
Expand Down
1 change: 1 addition & 0 deletions src/main/java/io/github/gaming32/worldhost/IOFunction.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.io.IOException;

// TODO: Remove when 1.18.2 is minimum
@FunctionalInterface
public interface IOFunction<T, R> {
R apply(T t) throws IOException;
Expand Down
15 changes: 9 additions & 6 deletions src/main/java/io/github/gaming32/worldhost/ProxyClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
import io.github.gaming32.worldhost.protocol.proxy.ProxyPassthrough;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.InetAddress;
import java.net.Socket;
import java.util.Arrays;
import java.util.function.Supplier;

public class ProxyClient extends Thread {
public final class ProxyClient {
private final Thread thread;
private final Socket socket;
private final InetAddress remoteAddress;
private final long connectionId;
Expand All @@ -24,7 +24,7 @@ public ProxyClient(
long connectionId,
Supplier<ProxyPassthrough> proxy
) throws IOException {
super("ProxyClient for " + connectionId);
thread = Thread.ofVirtual().name("ProxyClient for " + connectionId).unstarted(this::run);
socket = new Socket(InetAddress.getLoopbackAddress(), port);
this.remoteAddress = remoteAddress;
this.connectionId = connectionId;
Expand All @@ -34,11 +34,10 @@ public ProxyClient(
}
}

@Override
public void run() {
private void run() {
WorldHost.LOGGER.info("Starting proxy client from {}", remoteAddress);
try {
final InputStream is = socket.getInputStream();
final var is = socket.getInputStream();
final byte[] b = new byte[0xffff];
int n;
while ((n = is.read(b)) != -1) {
Expand All @@ -59,6 +58,10 @@ public void run() {
WorldHost.LOGGER.info("Proxy client connection for {} closed", remoteAddress);
}

public void start() {
thread.start();
}

public void close() {
if (closed) return;
closed = true;
Expand Down
Loading

0 comments on commit 6f0169c

Please sign in to comment.