Skip to content

Commit e6945b2

Browse files
committed
port: Now on 26.1!
1 parent 0983146 commit e6945b2

File tree

13 files changed

+100
-87
lines changed

13 files changed

+100
-87
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
- name: Setup jdk
1313
uses: actions/setup-java@v4
1414
with:
15-
java-version: 21
15+
java-version: 25
1616
distribution: 'temurin'
1717

1818
- name: Setup Gradle

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
- name: Setup jdk
1616
uses: actions/setup-java@v4
1717
with:
18-
java-version: 21
18+
java-version: 25
1919
distribution: 'temurin'
2020

2121
- name: Setup Gradle

build.gradle

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,26 @@ plugins {
55
}
66

77
version = "$baseVersion"
8-
archivesBaseName = project.slug
8+
9+
base {
10+
archivesName = project.slug
11+
}
912

1013
repositories {
1114
maven {
12-
url "https://maven.gegy.dev/"
15+
url = "https://maven.gegy.dev/"
1316
content {
1417
includeGroupAndSubgroups("dev.gegy")
1518
}
1619
}
1720
maven {
18-
url "https://maven.nucleoid.xyz/"
21+
url = "https://maven.nucleoid.xyz/"
1922
content {
2023
includeGroupAndSubgroups("xyz.nucleoid")
2124
}
2225
}
2326
maven {
24-
url "https://maven.theepicblock.nl/"
27+
url = "https://maven.theepicblock.nl/"
2528
content {
2629
includeGroupAndSubgroups("nl.theepicblock")
2730
}
@@ -46,27 +49,24 @@ configurations {
4649

4750
dependencies {
4851
minecraft libs.mc
49-
mappings variantOf(libs.yarn) { classifier "v2" }
5052

51-
modImplementation libs.fl
52-
modImplementation libs.fapi
53-
modImplementation libs.playerrolesapi
54-
modImplementation libs.playerroles
53+
implementation libs.fl
54+
implementation libs.fapi
55+
implementation libs.playerrolesapi
56+
implementation libs.playerroles
5557

5658
shadow libs.javasseclient
5759
implementation libs.javasseclient
5860
}
5961

62+
jar {
63+
destinationDirectory = new java.io.File(project.buildFile, "devlibs")
64+
}
65+
6066
var shadowJar = tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) {
6167
configurations = [project.configurations.shadow]
62-
destinationDirectory = tasks.named("jar").flatMap {it.destinationDirectory }
6368
minimize()
64-
enableRelocation = true
65-
relocationPrefix = "net.modfest.rolesync"
66-
}
67-
68-
remapJar {
69-
inputFile = shadowJar.flatMap { it.archiveFile }
69+
relocate("nl.theepicblock.sseclient", "net.modfest.rolesync.sseclient")
7070
}
7171

7272
processResources {
@@ -91,18 +91,18 @@ processResources {
9191

9292
tasks.withType(JavaCompile).configureEach {
9393
it.options.encoding = "UTF-8"
94-
it.options.release = 21
94+
it.options.release = 25
9595
}
9696

9797
java {
9898
withSourcesJar()
99-
sourceCompatibility = JavaVersion.VERSION_21
100-
targetCompatibility = JavaVersion.VERSION_21
99+
sourceCompatibility = JavaVersion.VERSION_25
100+
targetCompatibility = JavaVersion.VERSION_25
101101
}
102102

103103
jar {
104104
from("LICENSE") {
105-
rename { "${it}_${archivesBaseName}" }
105+
rename { "${it}_${base.archivesName.get()}" }
106106
}
107107
}
108108

gradle/wrapper/gradle-wrapper.properties

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-8.12.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.0-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

libs.versions.toml

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,20 @@
11
[versions]
2-
loom = "1.10.+"
3-
shadow = "8.3.6"
2+
loom = "1.15.+"
3+
shadow = "9.4.1"
44

5-
mc = "1.21.1"
6-
fl = "0.16.10"
7-
yarn = "1.21+build.9"
8-
fapi = "0.102.0+1.21"
9-
player-roles = "1.6.13"
10-
java-sse-client = "0.3.1"
5+
mc = "26.1"
6+
fl = "0.18.5"
7+
fapi = "0.144.4+26.1"
8+
player-roles = "1.9.0-pre.1"
9+
java-sse-client = "0.4.0"
1110

1211
[plugins]
13-
loom = { id = "fabric-loom", version.ref = "loom" }
12+
loom = { id = "net.fabricmc.fabric-loom", version.ref = "loom" }
1413
shadow = { id = "com.gradleup.shadow", version.ref = "shadow"}
1514

1615
[libraries]
1716
mc = { group = "mojang", name = "minecraft", version.ref = "mc" }
1817
fl = { group = "net.fabricmc", name = "fabric-loader", version.ref = "fl" }
19-
yarn = { group = "net.fabricmc", name = "yarn", version.ref = "yarn" }
2018
fapi = { group = "net.fabricmc.fabric-api", name = "fabric-api", version.ref = "fapi" }
2119
playerroles = { group = "dev.gegy", name = "player-roles", version.ref = "player-roles" }
2220
playerrolesapi = { group = "dev.gegy", name = "player-roles-api", version.ref = "player-roles" }
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
package net.modfest.rolesync;
22

33
import dev.gegy.roles.api.Role;
4-
import net.minecraft.entity.player.PlayerEntity;
4+
import net.minecraft.world.entity.player.Player;
55
import org.jetbrains.annotations.Nullable;
66

77
import java.util.UUID;
88

99
public interface PlatformRoleLookup {
1010
PlatformRoleLookup EMPTY = new PlatformRoleLookup() {
1111
@Override
12-
public @Nullable Role getRole(PlayerEntity player) {
12+
public @Nullable Role getRole(Player player) {
1313
return null;
1414
}
1515

@@ -19,6 +19,6 @@ public interface PlatformRoleLookup {
1919
}
2020
};
2121

22-
@Nullable Role getRole(PlayerEntity player);
22+
@Nullable Role getRole(Player player);
2323
@Nullable Role getRoleUUID(UUID id);
2424
}

src/main/java/net/modfest/rolesync/TestLookup.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import dev.gegy.roles.api.PlayerRolesApi;
44
import dev.gegy.roles.api.Role;
5-
import net.minecraft.entity.player.PlayerEntity;
5+
import net.minecraft.world.entity.player.Player;
66
import org.jetbrains.annotations.Nullable;
77

88
import java.util.UUID;
@@ -13,7 +13,7 @@ public TestLookup(String name) {
1313
}
1414

1515
@Override
16-
public @Nullable Role getRole(PlayerEntity player) {
16+
public @Nullable Role getRole(Player player) {
1717
return role;
1818
}
1919

src/main/java/net/modfest/rolesync/WrappedLookup.java

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,17 @@
77
import dev.gegy.roles.api.RoleReader;
88
import dev.gegy.roles.api.override.RoleOverrideReader;
99
import dev.gegy.roles.api.override.RoleOverrideType;
10-
import net.minecraft.entity.Entity;
11-
import net.minecraft.entity.player.PlayerEntity;
12-
import net.minecraft.server.command.ServerCommandSource;
10+
import net.minecraft.commands.CommandSourceStack;
11+
import net.minecraft.world.entity.Entity;
12+
import net.minecraft.world.entity.player.Player;
1313
import org.jetbrains.annotations.NotNull;
1414
import org.jetbrains.annotations.Nullable;
1515

16-
import java.util.*;
16+
import java.util.ArrayList;
17+
import java.util.Collection;
18+
import java.util.HashSet;
19+
import java.util.Iterator;
20+
import java.util.Set;
1721
import java.util.stream.Stream;
1822

1923
/**
@@ -29,7 +33,7 @@ public WrappedLookup(RoleLookup root) {
2933
}
3034

3135
@Override
32-
public @NotNull RoleReader byPlayer(PlayerEntity player) {
36+
public @NotNull RoleReader byPlayer(Player player) {
3337
var additionalRole = this.platformLookup.getRole(player);
3438
if (additionalRole != null) {
3539
return new MergedRoleReader(additionalRole, root.byPlayer(player));
@@ -39,7 +43,7 @@ public WrappedLookup(RoleLookup root) {
3943

4044
@Override
4145
public @NotNull RoleReader byEntity(Entity entity) {
42-
if (entity instanceof PlayerEntity player) {
46+
if (entity instanceof Player player) {
4347
var additionalRole = this.platformLookup.getRole(player);
4448
if (additionalRole != null) {
4549
return new MergedRoleReader(additionalRole, root.byEntity(entity));
@@ -49,9 +53,9 @@ public WrappedLookup(RoleLookup root) {
4953
}
5054

5155
@Override
52-
public @NotNull RoleReader bySource(ServerCommandSource serverCommandSource) {
56+
public @NotNull RoleReader bySource(CommandSourceStack serverCommandSource) {
5357
var entity = serverCommandSource.getEntity();
54-
if (entity instanceof PlayerEntity player) {
58+
if (entity instanceof Player player) {
5559
var additionalRole = this.platformLookup.getRole(player);
5660
if (additionalRole != null) {
5761
return new MergedRoleReader(additionalRole, root.byEntity(entity));

src/main/java/net/modfest/rolesync/cache/CacheManager.java

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,27 @@
44
import com.google.common.hash.HashingInputStream;
55
import com.google.common.hash.HashingOutputStream;
66
import net.fabricmc.loader.api.FabricLoader;
7-
import net.minecraft.util.Pair;
7+
import net.minecraft.util.Tuple;
88
import net.modfest.rolesync.ModFestRoleSync;
99
import net.modfest.rolesync.SyncedRole;
1010
import org.jspecify.annotations.NonNull;
1111

12-
import java.io.*;
12+
import java.io.BufferedInputStream;
13+
import java.io.BufferedOutputStream;
14+
import java.io.DataInputStream;
15+
import java.io.DataOutputStream;
16+
import java.io.FileInputStream;
17+
import java.io.FileNotFoundException;
18+
import java.io.FileOutputStream;
19+
import java.io.IOException;
20+
import java.io.OutputStream;
1321
import java.nio.file.Files;
1422
import java.nio.file.Path;
15-
import java.util.*;
23+
import java.util.ArrayList;
24+
import java.util.Arrays;
25+
import java.util.Comparator;
26+
import java.util.List;
27+
import java.util.UUID;
1628
import java.util.concurrent.locks.ReentrantLock;
1729
import java.util.function.Consumer;
1830
import java.util.function.Supplier;
@@ -23,7 +35,7 @@ public class CacheManager {
2335
private static final long MAGIC = 0xBEBE220da001BEBEL;
2436
private final @NonNull Path location;
2537
private byte[] hash;
26-
private ReentrantLock writeLock = new ReentrantLock();
38+
private final ReentrantLock writeLock = new ReentrantLock();
2739

2840
public CacheManager() {
2941
this(FabricLoader.getInstance().getGameDir().resolve("platform_role_cache.bin"));
@@ -33,7 +45,7 @@ public CacheManager(@NonNull Path location) {
3345
this.location = location;
3446
}
3547

36-
public void read(Consumer<Stream<Pair<UUID,SyncedRole>>> onReadFinished) {
48+
public void read(Consumer<Stream<Tuple<UUID,SyncedRole>>> onReadFinished) {
3749
// No protection is needed against two threads reading at once. The callback already
3850
// has locking and checks the time of each read
3951
var readThread = new Thread(() -> {
@@ -47,7 +59,7 @@ public void read(Consumer<Stream<Pair<UUID,SyncedRole>>> onReadFinished) {
4759
return;
4860
}
4961
var len = s.readInt();
50-
var contents = new ArrayList<Pair<UUID,SyncedRole>>(len);
62+
var contents = new ArrayList<Tuple<UUID,SyncedRole>>(len);
5163

5264
for (int i = 0; i < len; i++) {
5365
var uuid = new UUID(s.readLong(), s.readLong());
@@ -57,7 +69,7 @@ public void read(Consumer<Stream<Pair<UUID,SyncedRole>>> onReadFinished) {
5769
case 8 -> SyncedRole.PARTICIPANT;
5870
default -> throw new IOException("Invalid role in cache");
5971
};
60-
contents.add(new Pair<>(uuid, role));
72+
contents.add(new Tuple<>(uuid, role));
6173
}
6274
// We only set the hash and call the callback if we successfully read the whole file.
6375
// It's possible for the file to be corrupt (especially since our writes aren't atomic),
@@ -77,7 +89,7 @@ public void read(Consumer<Stream<Pair<UUID,SyncedRole>>> onReadFinished) {
7789
readThread.start();
7890
}
7991

80-
public void write(Supplier<Stream<Pair<UUID,SyncedRole>>> provider) {
92+
public void write(Supplier<Stream<Tuple<UUID,SyncedRole>>> provider) {
8193
// Run on a separate thread to not bog down the server with IO
8294
// This function should only be running whenever the server shuts down (or
8395
// something in the configuration changes), so there's little performance concern
@@ -87,7 +99,7 @@ public void write(Supplier<Stream<Pair<UUID,SyncedRole>>> provider) {
8799
try {
88100
// Ensure the list is consistent by sorting it by uuid
89101
var list = provider.get().collect(Collectors.toCollection(ArrayList::new));
90-
list.sort(Comparator.comparing(Pair::getLeft));
102+
list.sort(Comparator.comparing(Tuple::getA));
91103
// We write the collection to a hashing output first, and we only save the file if
92104
// the hash changes
93105
var hash = Hashing.sha512();
@@ -117,14 +129,14 @@ public void write(Supplier<Stream<Pair<UUID,SyncedRole>>> provider) {
117129
writeThread.start();
118130
}
119131

120-
private void write(List<Pair<UUID,SyncedRole>> data, OutputStream stream) throws IOException {
132+
private void write(List<Tuple<UUID,SyncedRole>> data, OutputStream stream) throws IOException {
121133
var s = new DataOutputStream(stream);
122134
s.writeLong(MAGIC);
123135
s.writeInt(data.size());
124136
for (var p : data) {
125-
s.writeLong(p.getLeft().getMostSignificantBits());
126-
s.writeLong(p.getLeft().getLeastSignificantBits());
127-
s.writeByte(switch (p.getRight()) {
137+
s.writeLong(p.getA().getMostSignificantBits());
138+
s.writeLong(p.getA().getLeastSignificantBits());
139+
s.writeByte(switch (p.getB()) {
128140
case TEAM -> 1;
129141
case PARTICIPANT -> 8;
130142
});
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
package net.modfest.rolesync.logging;
22

3-
import net.minecraft.server.command.ServerCommandSource;
4-
import net.minecraft.text.Text;
5-
import net.minecraft.util.Formatting;
3+
import net.minecraft.ChatFormatting;
4+
import net.minecraft.commands.CommandSourceStack;
5+
import net.minecraft.network.chat.Component;
66

7-
public record CommandLogger(ServerCommandSource source) implements MiniLogger {
7+
public record CommandLogger(CommandSourceStack source) implements MiniLogger {
88
@Override
99
public void error(String error) {
10-
source.sendError(Text.literal(error));
10+
source.sendFailure(Component.literal(error));
1111
}
1212

1313
@Override
1414
public void warn(String warning) {
15-
source.sendError(Text.literal(warning).formatted(Formatting.YELLOW));
15+
source.sendFailure(Component.literal(warning).withStyle(ChatFormatting.YELLOW));
1616
}
1717

1818
@Override
1919
public void info(String info) {
20-
source.sendFeedback(() -> Text.literal(info), false);
20+
source.sendSuccess(() -> Component.literal(info), false);
2121
}
2222
}

0 commit comments

Comments
 (0)