Skip to content

Commit 1158d4a

Browse files
authored
Support Minecraft 26.1 (#33)
* Support Minecraft 26.1 and Fabric * Fix * Remove * Check status code
1 parent a308e02 commit 1158d4a

12 files changed

Lines changed: 64 additions & 61 deletions

File tree

.github/workflows/build.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ jobs:
1919
runs-on: ubuntu-latest
2020
steps:
2121
- name: Checkout
22-
uses: actions/checkout@v5
23-
- name: Set up JDK 21
22+
uses: actions/checkout@v6
23+
- name: Set up JDK 25
2424
uses: actions/setup-java@v5
2525
with:
26-
java-version: '21'
26+
java-version: '25'
2727
distribution: 'temurin'
2828
- name: Validate Gradle wrapper
2929
uses: gradle/actions/wrapper-validation@v5
@@ -32,7 +32,7 @@ jobs:
3232
- name: Build with Gradle
3333
run: ./gradlew build
3434
- name: Publish Fabric
35-
uses: actions/upload-artifact@v5
35+
uses: actions/upload-artifact@v6
3636
with:
3737
name: Fabric
3838
path: build/libs/

.github/workflows/publish.yml

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ jobs:
1919
runs-on: ubuntu-latest
2020
steps:
2121
- name: Checkout
22-
uses: actions/checkout@v5
23-
- name: Set up JDK 21
22+
uses: actions/checkout@v6
23+
- name: Set up JDK 25
2424
uses: actions/setup-java@v5
2525
with:
26-
java-version: '21'
26+
java-version: '25'
2727
distribution: 'temurin'
2828
- name: Validate Gradle wrapper
2929
uses: gradle/actions/wrapper-validation@v5
@@ -51,27 +51,12 @@ jobs:
5151

5252
loaders: |
5353
fabric
54-
quilt
5554
modrinth-game-versions: |
56-
>=1.14
55+
>=26.1
5756
curseforge-game-versions: |
58-
>=1.14
57+
>=26.1
5958
java: |
60-
22
61-
21
62-
20
63-
19
64-
18
65-
17
66-
16
67-
15
68-
14
69-
13
70-
12
71-
11
72-
10
73-
9
74-
8
59+
>=25
7560
7661
retry-attempts: 2
7762
retry-delay: 10000

build.gradle

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
plugins {
2-
id 'fabric-loom' version '1.12-SNAPSHOT'
2+
id 'net.fabricmc.fabric-loom' version "${loom_version}"
33
}
44

55
version = project.mod_version
@@ -26,11 +26,10 @@ loom {
2626
dependencies {
2727
// To change the versions see the gradle.properties file
2828
minecraft "com.mojang:minecraft:${project.minecraft_version}"
29-
mappings loom.officialMojangMappings()
30-
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
29+
implementation "net.fabricmc:fabric-loader:${project.loader_version}"
3130

32-
implementation group: 'io.netty', name: 'netty-codec-haproxy', version: '4.2.7.Final'
33-
include group: 'io.netty', name: 'netty-codec-haproxy', version: '4.2.7.Final'
31+
implementation group: 'io.netty', name: 'netty-codec-haproxy', version: '4.2.10.Final'
32+
include group: 'io.netty', name: 'netty-codec-haproxy', version: '4.2.10.Final'
3433
}
3534

3635
processResources {
@@ -42,7 +41,7 @@ processResources {
4241
}
4342

4443
tasks.withType(JavaCompile).configureEach {
45-
it.options.release = 8
44+
it.options.release = 25
4645
it.options.encoding = "UTF-8"
4746
}
4847

@@ -52,8 +51,8 @@ java {
5251
// If you remove this line, sources will not be generated.
5352
withSourcesJar()
5453

55-
sourceCompatibility = JavaVersion.VERSION_1_8
56-
targetCompatibility = JavaVersion.VERSION_1_8
54+
sourceCompatibility = JavaVersion.VERSION_25
55+
targetCompatibility = JavaVersion.VERSION_25
5756
}
5857

5958
jar {

gradle.properties

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,16 @@
22
org.gradle.jvmargs=-Xmx8G
33
org.gradle.parallel=true
44

5+
# IntelliJ IDEA is not yet fully compatible with configuration cache, see: https://github.com/FabricMC/fabric-loom/issues/1349
6+
org.gradle.configuration-cache=false
7+
58
# Fabric Properties
69
# check these on https://fabricmc.net/develop
7-
minecraft_version=1.21.10
8-
loader_version=0.17.3
10+
minecraft_version=26.1
11+
loader_version=0.18.4
12+
loom_version=1.15-SNAPSHOT
913

1014
# Mod Properties
11-
mod_version=1.1.0-fabric
15+
mod_version=1.2.0-fabric
1216
maven_group=pl.panszelescik
1317
archives_base_name=proxy_protocol_support
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.0-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.0-bin.zip
44
networkTimeout=10000
55
zipStoreBase=GRADLE_USER_HOME
66
zipStorePath=wrapper/dists

settings.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ pluginManagement {
44
name = 'Fabric'
55
url = 'https://maven.fabricmc.net/'
66
}
7+
mavenCentral()
78
gradlePluginPortal()
89
}
9-
}
10+
}

src/main/java/pl/panszelescik/proxy_protocol_support/shared/ProxyProtocolHandler.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ public class ProxyProtocolHandler extends ChannelInboundHandlerAdapter {
1919

2020
@Override
2121
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
22-
if (msg instanceof HAProxyMessage) {
23-
final HAProxyMessage message = ((HAProxyMessage) msg);
22+
if (msg instanceof HAProxyMessage message) {
2423
try {
2524
// We only care about PROXY commands. Other commands are ignored.
2625
if (message.command() == HAProxyCommand.PROXY) {

src/main/java/pl/panszelescik/proxy_protocol_support/shared/ProxyProtocolSupport.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import pl.panszelescik.proxy_protocol_support.shared.config.Config;
55
import pl.panszelescik.proxy_protocol_support.shared.config.TCPShieldIntegration;
66
import java.io.IOException;
7-
import java.util.ArrayList;
87
import java.util.Collection;
98
import java.util.HashSet;
109
import java.util.function.Consumer;
@@ -56,7 +55,7 @@ public static void initialize(Config config) throws IOException {
5655
final HashSet<CIDRMatcher> tcpShieldIPs = TCPShieldIntegration.getWhitelistedIPs();
5756
proxyServerIPs.addAll(tcpShieldIPs);
5857
infoLogger.accept("Successfully added " + tcpShieldIPs.size() + " TCPShield IPs to the trusted proxy list.");
59-
} catch (IOException e) {
58+
} catch (IOException | InterruptedException e) {
6059
errorLogger.accept("Failed to fetch TCPShield IPs: " + e.getMessage());
6160
}
6261
}

src/main/java/pl/panszelescik/proxy_protocol_support/shared/config/Configuration.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22

33
import com.google.gson.Gson;
44
import com.google.gson.GsonBuilder;
5-
import org.apache.commons.io.FileUtils;
65
import pl.panszelescik.proxy_protocol_support.shared.ProxyProtocolSupport;
76

87
import java.io.File;
98
import java.io.IOException;
10-
import java.nio.charset.StandardCharsets;
9+
import java.nio.file.Files;
1110

1211
/**
1312
* Loads and saves Config
@@ -30,7 +29,7 @@ public static Config loadConfig(File configDir) throws IOException {
3029
}
3130

3231
private static Config loadConfigFile(File configFile) throws IOException {
33-
final String string = FileUtils.readFileToString(configFile, StandardCharsets.UTF_8);
32+
final String string = Files.readString(configFile.toPath());
3433

3534
return GSON.fromJson(string, Config.class);
3635
}
@@ -42,7 +41,7 @@ private static Config saveDefaultConfig(File configFile) throws IOException {
4241
private static Config saveConfig(File configFile, Config config) throws IOException {
4342
final String string = GSON.toJson(config);
4443

45-
FileUtils.writeStringToFile(configFile, string, StandardCharsets.UTF_8);
44+
Files.writeString(configFile.toPath(), string);
4645

4746
return config;
4847
}
Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
package pl.panszelescik.proxy_protocol_support.shared.config;
22

3-
import java.io.BufferedReader;
43
import java.io.IOException;
5-
import java.io.InputStreamReader;
64
import java.net.URI;
5+
import java.net.http.HttpClient;
6+
import java.net.http.HttpRequest;
7+
import java.net.http.HttpResponse;
78
import java.util.HashSet;
89

910
/**
@@ -16,23 +17,35 @@ public class TCPShieldIntegration {
1617
private static final URI IPV4 = URI.create("https://tcpshield.com/v4/");
1718
private static final URI IPV4_CF = URI.create("https://tcpshield.com/v4-cf/");
1819

19-
public static HashSet<CIDRMatcher> getWhitelistedIPs() throws IOException {
20+
public static HashSet<CIDRMatcher> getWhitelistedIPs() throws IOException, InterruptedException {
2021
final HashSet<CIDRMatcher> matchers = new HashSet<>();
2122

22-
readFromUrl(matchers, IPV4);
23-
readFromUrl(matchers, IPV4_CF);
23+
try (HttpClient client = HttpClient.newHttpClient()) {
24+
readFromUrl(matchers, client, IPV4);
25+
readFromUrl(matchers, client, IPV4_CF);
26+
}
2427

2528
return matchers;
2629
}
2730

28-
private static void readFromUrl(HashSet<CIDRMatcher> matchers, URI uri) throws IOException {
29-
try (final BufferedReader reader = new BufferedReader(new InputStreamReader(uri.toURL().openStream()))) {
30-
while (reader.ready()) {
31-
final String line = reader.readLine().trim();
32-
if (!line.isEmpty() && !line.startsWith("#") && !line.startsWith("127.0.0.1")) {
33-
matchers.add(new CIDRMatcher(line));
34-
}
35-
}
31+
private static void readFromUrl(HashSet<CIDRMatcher> matchers, HttpClient client, URI uri) throws IOException, InterruptedException {
32+
final HttpRequest request = HttpRequest
33+
.newBuilder(uri)
34+
.version(HttpClient.Version.HTTP_2)
35+
.GET()
36+
.build();
37+
38+
final HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
39+
final int statusCode = response.statusCode();
40+
if (statusCode < 200 || statusCode >= 300) {
41+
throw new IOException("Failed to fetch " + uri + ": HTTP " + statusCode);
3642
}
43+
44+
response.body()
45+
.lines()
46+
.map(String::trim)
47+
.filter(l -> !l.isEmpty() && !l.startsWith("#") && !l.startsWith("127.0.0.1"))
48+
.map(CIDRMatcher::new)
49+
.forEach(matchers::add);
3750
}
3851
}

0 commit comments

Comments
 (0)