Skip to content

Commit f315d36

Browse files
authored
Merge pull request #16 from fixrtm/newer-ngtlib-fixrtm-compatibility
feat: fixRTM 2.0.24-beta2 and KaizPatchX 1.6.0-rc.2 support
2 parents d3026a2 + e920651 commit f315d36

File tree

4 files changed

+67
-12
lines changed

4 files changed

+67
-12
lines changed

build.gradle.kts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,33 +46,33 @@ val rtmId = 288988
4646
val ngtlibId = 288989
4747

4848
// minecraft modifications
49-
// KaizPatchX: 1.3.0
49+
// KaizPatchX: 1.6.0
5050
val kaizPatch by pluginPermsForNgt.mods.creatingURI(URI("https://github.com/Kai-Z-JP/KaizPatchX/releases/download/" +
51-
"v1.3.0/src1.7.10_20200822+KaizPatchX-1.3.0.jar"))
52-
// fixRTM: SNAPSHOT-2021-08-15-06-27-14.jar
53-
val fixRTM by pluginPermsForNgt.mods.creatingCurse(fixRTMId, 3425891)
51+
"v1.6.0/src1.7.10_20200822+KaizPatchX-1.6.0.jar"))
52+
// fixRTM: 2.0.24-beta2
53+
val fixRTM by pluginPermsForNgt.mods.creatingCurse(fixRTMId, 4053423)
5454

5555
// RTM: 1.7.10.41
5656
val rtm1710 by pluginPermsForNgt.mods.creatingCurse(rtmId, 3039063)
5757
// RTM: 2.4.22-40
5858
val rtm1122 by pluginPermsForNgt.mods.creatingCurse(rtmId, 3387261)
5959

60-
// NGTLib: 1.7.10.32
61-
val ngtlib1710 by pluginPermsForNgt.mods.creatingCurse(ngtlibId, 2940833)
62-
// NGTLib: 2.4.19-35
63-
val ngtlib1122 by pluginPermsForNgt.mods.creatingCurse(ngtlibId, 3387256)
60+
// NGTLib: 1.7.10.44
61+
val ngtlib1710 by pluginPermsForNgt.mods.creatingCurse(ngtlibId, 4030455)
62+
// NGTLib: 2.4.23-42
63+
val ngtlib1122 by pluginPermsForNgt.mods.creatingCurse(ngtlibId, 3873403)
6464

6565
// LuckPerms: v5.3.64
66-
val luckPermsBuildNumber = 1363
67-
val luckPermsVersion = "5.3.64"
66+
val luckPermsBuildNumber = 1460
67+
val luckPermsVersion = "5.4.52"
6868
val luckPerms1710 by pluginPermsForNgt.mods.creatingURI(URI("https://ci.lucko.me/job/LuckPerms/$luckPermsBuildNumber/artifact" +
6969
"/bukkit-legacy/loader/build/libs/LuckPerms-Bukkit-Legacy-$luckPermsVersion.jar"))
7070
val luckPerms1122 by pluginPermsForNgt.mods.creatingURI(URI("https://ci.lucko.me/job/LuckPerms/$luckPermsBuildNumber/artifact" +
7171
"/bukkit/loader/build/libs/LuckPerms-Bukkit-$luckPermsVersion.jar"))
7272

7373
// servers
74-
val mohist1710 by pluginPermsForNgt.servers.creatingMohist("1.7.10", 40)
75-
val mohist1122 by pluginPermsForNgt.servers.creatingMohist("1.12.2", 248)
74+
val mohist1710 by pluginPermsForNgt.servers.creatingMohist("1.7.10", 46)
75+
val mohist1122 by pluginPermsForNgt.servers.creatingMohist("1.12.2", 321)
7676

7777
// others
7878
val pluginPermsForNGT by pluginPermsForNgt.mods.creatingByArchiveTask(tasks.jar)

src/api/java/jp/ngt/ngtlib/util/PermissionManager.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
import net.minecraft.command.ICommandSender;
1515

1616
import java.io.IOException;
17+
import java.util.Collection;
1718
import java.util.List;
19+
import java.util.Set;
1820

1921
// The file only for signatures
2022
@Vendors({Vendor.NGT1710, Vendor.NGT1122})
@@ -45,6 +47,22 @@ public List<String> getPlayerList(String permission) {
4547
throw new IllegalStateException();
4648
}
4749

50+
// the function to get list of players the permission have
51+
// in the kaizPatchX, this is named getPlayerList but due to signature conflict, renamed to
52+
// getPlayerList0 here. will be renamed in ClassTransformer for NGTPermissionManagerBukkit.
53+
// see https://github.com/Kai-Z-JP/KaizPatchX/pull/312
54+
@Vendors({Vendor.KaizPatch})
55+
public Collection<String> getPlayerList0(String permission) {
56+
throw new IllegalStateException();
57+
}
58+
59+
// the function to get list of players the permission have
60+
// see https://github.com/fixrtm/fixRTM/pull/550
61+
@Vendors({Vendor.FixRTM})
62+
public Set<String> getPlayerSet(String permission) {
63+
throw new IllegalStateException();
64+
}
65+
4866
// the function to register permission for completion
4967
@Vendors(Vendor.KaizPatch)
5068
public void registerPermission(String per1) {

src/main/java/com/anatawa12/pluginPermsForNgt/NGTPermissionManagerBukkit.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@
2020

2121
import java.lang.reflect.InvocationTargetException;
2222
import java.lang.reflect.Method;
23+
import java.util.Collection;
2324
import java.util.Collections;
2425
import java.util.List;
26+
import java.util.Set;
2527

2628
import static com.anatawa12.pluginPermsForNgt.PluginPermsForNgtMain.PERM_PREFIX;
2729

@@ -46,6 +48,20 @@ public List<String> getPlayerList(String par1) {
4648
return Collections.emptyList();
4749
}
4850

51+
@Vendors(Vendor.KaizPatch)
52+
@Override
53+
public Collection<String> getPlayerList0(String permission) {
54+
PluginPermsForNgtMain.log("calling getPlayerList of KaizPatch by " + new Throwable().getStackTrace()[1]);
55+
// In the KaizPatch's implementation, returns set so use set here.
56+
return Collections.emptySet();
57+
}
58+
59+
@Override
60+
public Set<String> getPlayerSet(String permission) {
61+
PluginPermsForNgtMain.log("calling getPlayerList of fixRTM by " + new Throwable().getStackTrace()[1]);
62+
return Collections.emptySet();
63+
}
64+
4965
// KaizPatchX
5066
@Vendors(Vendor.KaizPatch)
5167
public void registerPermission(String per1) {

src/main/java/com/anatawa12/pluginPermsForNgt/coreMod/ClassTransformer.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ public byte[] transform(String name, String transformedName, byte[] basicClass)
3333
return transformFixRTMPermissionManager(basicClass);
3434
if ("com.anatawa12.pluginPermsForNgt.PluginPermsForNgtMain".equals(name))
3535
return transformPluginPermsForNgtMain(basicClass);
36+
if (nameOfNGTPermissionManagerBukkit.equals(name))
37+
return transformNGTPermissionManagerBukkit(basicClass);
3638
return basicClass;
3739
}
3840

@@ -66,6 +68,23 @@ private byte[] transformNGTPermissionManager(byte[] basicClass) {
6668
return writer.toByteArray();
6769
}
6870

71+
private byte[] transformNGTPermissionManagerBukkit(byte[] basicClass) {
72+
ClassNode node = new ClassNode();
73+
new ClassReader(basicClass).accept(node, 0);
74+
75+
// remove final flag
76+
node.access = node.access & ~Opcodes.ACC_FINAL;
77+
for (MethodNode method : node.methods) {
78+
if ("getPlayerList0".equals(method.name) && "(Ljava/lang/String;)Ljava/util/Collection;".equals(method.desc)) {
79+
method.name = "getPlayerList";
80+
}
81+
}
82+
83+
ClassWriter writer = new ClassWriter(0);
84+
node.accept(writer);
85+
return writer.toByteArray();
86+
}
87+
6988
private byte[] transformFixRTMPermissionManager(byte[] basicClass) {
7089
ClassNode node = new ClassNode();
7190
new ClassReader(basicClass).accept(node, 0);
@@ -109,6 +128,8 @@ public String map(String typeName) {
109128

110129
private static final String internalNameOfNGTPermissionManagerBukkit
111130
= "com/anatawa12/pluginPermsForNgt/NGTPermissionManagerBukkit";
131+
private static final String nameOfNGTPermissionManagerBukkit
132+
= "com.anatawa12.pluginPermsForNgt.NGTPermissionManagerBukkit";
112133

113134
private static class FmlPackageNameFinder {
114135
private static final String fmlPackage;

0 commit comments

Comments
 (0)