Skip to content

Commit

Permalink
Fix extra yggdrasil
Browse files Browse the repository at this point in the history
  • Loading branch information
s-yh-china committed Aug 12, 2024
1 parent 1782bd4 commit c19e742
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
27 changes: 15 additions & 12 deletions patches/server/0006-Leaves-Server-Config-And-Command.patch
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ index c2c421b1caf76b40542fdc436801accbe97a38cb..29f139fb4d70a9a362ac0a30579eb0b4
.withRequiredArg()
diff --git a/src/main/java/org/leavesmc/leaves/LeavesConfig.java b/src/main/java/org/leavesmc/leaves/LeavesConfig.java
new file mode 100644
index 0000000000000000000000000000000000000000..5009708d8875f2a88e76f4a48c180d616c2547a6
index 0000000000000000000000000000000000000000..f554b8e61a31c307bb46fa007c54f2b842be4dfc
--- /dev/null
+++ b/src/main/java/org/leavesmc/leaves/LeavesConfig.java
@@ -0,0 +1,939 @@
Expand Down Expand Up @@ -201,7 +201,7 @@ index 0000000000000000000000000000000000000000..5009708d8875f2a88e76f4a48c180d61
+ }
+
+ @RemovedConfig(name = "unable-fakeplayer-names", category = "fakeplayer", transform = true)
+ @GlobalConfig(name = "unable-fakeplayer-names", category = {"modify", "fakeplayer"}, verify = ConfigVerify.ListConfigVerify.class)
+ @GlobalConfig(name = "unable-fakeplayer-names", category = {"modify", "fakeplayer"}, verify = ConfigVerify.ListConfigVerify.STRING.class)
+ public static List<String> unableFakeplayerNames = List.of("player-name");
+
+ @GlobalConfig(name = "limit", category = {"modify", "fakeplayer"}, verify = ConfigVerify.IntConfigVerify.class)
Expand Down Expand Up @@ -892,7 +892,7 @@ index 0000000000000000000000000000000000000000..5009708d8875f2a88e76f4a48c180d61
+ @GlobalConfig(name = "allow-experimental", category = {"misc", "auto-update"})
+ public static Boolean autoUpdateAllowExperimental = false;
+
+ @GlobalConfig(name = "time", category = {"misc", "auto-update"}, lock = true, verify = ConfigVerify.ListConfigVerify.class)
+ @GlobalConfig(name = "time", category = {"misc", "auto-update"}, lock = true, verify = ConfigVerify.ListConfigVerify.STRING.class)
+ public static List<String> autoUpdateTime = List.of("14:00", "2:00");
+
+ // Leaves end - misc - auto-update
Expand All @@ -916,13 +916,13 @@ index 0000000000000000000000000000000000000000..5009708d8875f2a88e76f4a48c180d61
+ @GlobalConfig(name = "login-protect", category = {"misc", "extra-yggdrasil-service"})
+ public static boolean extraYggdrasilLoginProtect = false;
+
+ @GlobalConfig(name = "urls", category = {"misc", "extra-yggdrasil-service"}, verify = ExtraYggdrasilUrlsVerify.class)
+ @GlobalConfig(name = "urls", category = {"misc", "extra-yggdrasil-service"}, lock = true, verify = ExtraYggdrasilUrlsVerify.class)
+ public static List<String> extraYggdrasilServiceList = List.of("https://url.with.authlib-injector-yggdrasil");
+
+ public static class ExtraYggdrasilUrlsVerify extends ConfigVerify.ListConfigVerify {
+ public static class ExtraYggdrasilUrlsVerify extends ConfigVerify.ListConfigVerify<String> {
+ @Override
+ public String check(List<?> old, List<?> value) {
+ org.leavesmc.leaves.profile.LeavesMinecraftSessionService.initExtraYggdrasilList();
+ public String check(List<String> old, List<String> value) {
+ org.leavesmc.leaves.profile.LeavesMinecraftSessionService.initExtraYggdrasilList(value);
+ return null;
+ }
+ }
Expand Down Expand Up @@ -1463,10 +1463,10 @@ index 0000000000000000000000000000000000000000..3ddeff82e31178c9c1bb1737c9a28a81
+}
diff --git a/src/main/java/org/leavesmc/leaves/config/ConfigVerify.java b/src/main/java/org/leavesmc/leaves/config/ConfigVerify.java
new file mode 100644
index 0000000000000000000000000000000000000000..08ffa951d8fd835f075c45021f56cec19f03e7fc
index 0000000000000000000000000000000000000000..e3cfc606222f27f029ff8e4d1fd370685e76e325
--- /dev/null
+++ b/src/main/java/org/leavesmc/leaves/config/ConfigVerify.java
@@ -0,0 +1,90 @@
@@ -0,0 +1,93 @@
+package org.leavesmc.leaves.config;
+
+import java.lang.reflect.ParameterizedType;
Expand Down Expand Up @@ -1522,9 +1522,12 @@ index 0000000000000000000000000000000000000000..08ffa951d8fd835f075c45021f56cec1
+ }
+ }
+
+ class ListConfigVerify implements ConfigVerify<List<?>> {
+ abstract class ListConfigVerify<E> implements ConfigVerify<List<E>> {
+ public static class STRING extends ListConfigVerify<String> {
+ }
+
+ @Override
+ public List<?> convert(String value) {
+ public List<E> convert(String value) {
+ throw new IllegalArgumentException("not support"); // TODO
+ }
+ }
Expand All @@ -1539,7 +1542,7 @@ index 0000000000000000000000000000000000000000..08ffa951d8fd835f075c45021f56cec1
+ Type genericSuperclass = getClass().getGenericSuperclass();
+ Type[] typeArguments = ((ParameterizedType) genericSuperclass).getActualTypeArguments();
+ this.enumClass = (Class<E>) typeArguments[0];
+ this.enumValues = new ArrayList<>(){{
+ this.enumValues = new ArrayList<>() {{
+ for (E e : enumClass.getEnumConstants()) {
+ add(e.name().toLowerCase(Locale.ROOT));
+ }
Expand Down
10 changes: 5 additions & 5 deletions patches/server/0047-Leaves-Extra-Yggdrasil-Service.patch
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ index 0000000000000000000000000000000000000000..6f14a66d78709fae9fecbefc80e3489b
+}
diff --git a/src/main/java/org/leavesmc/leaves/profile/LeavesMinecraftSessionService.java b/src/main/java/org/leavesmc/leaves/profile/LeavesMinecraftSessionService.java
new file mode 100644
index 0000000000000000000000000000000000000000..c99092acd7aecb7f4c4c5cd1327991d9d468c5c5
index 0000000000000000000000000000000000000000..b15ee80ac1aea751594cd3321928f26d3cbf243e
--- /dev/null
+++ b/src/main/java/org/leavesmc/leaves/profile/LeavesMinecraftSessionService.java
@@ -0,0 +1,102 @@
Expand Down Expand Up @@ -124,9 +124,9 @@ index 0000000000000000000000000000000000000000..c99092acd7aecb7f4c4c5cd1327991d9
+
+ private static List<URL> extraYggdrasilList = List.of();
+
+ public static void initExtraYggdrasilList() {
+ public static void initExtraYggdrasilList(List<String> extraYggdrasilServiceList) {
+ List<URL> list = new ArrayList<>();
+ for (String str : LeavesConfig.extraYggdrasilServiceList) {
+ for (String str : extraYggdrasilServiceList) {
+ list.add(HttpAuthenticationService.constantURL(str + "/sessionserver/session/minecraft/hasJoined"));
+ }
+ extraYggdrasilList = Collections.unmodifiableList(list);
Expand Down Expand Up @@ -174,8 +174,8 @@ index 0000000000000000000000000000000000000000..c99092acd7aecb7f4c4c5cd1327991d9
+ }
+
+ final Set<ProfileActionType> profileActions = response.profileActions().stream()
+ .map(ProfileAction::type)
+ .collect(Collectors.toSet());
+ .map(ProfileAction::type)
+ .collect(Collectors.toSet());
+ return new ProfileResult(result1, profileActions);
+ }
+ } catch (final MinecraftClientException e) {
Expand Down

0 comments on commit c19e742

Please sign in to comment.