Skip to content

Commit c33b547

Browse files
New FakePlayer (#337)
--------- Co-authored-by: Lumine1909 <[email protected]>
1 parent 3436062 commit c33b547

20 files changed

+3002
-1778
lines changed

patches/api/0003-Add-fakeplayer-api.patch

Lines changed: 592 additions & 179 deletions
Large diffs are not rendered by default.

patches/server/0006-Leaves-Server-Config-And-Command.patch

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,10 @@ index d97771ecaf06b92d92b5ca0224ae0866e36703a6..439305bb4f5ce232aa6237276c121d53
8585
.withRequiredArg()
8686
diff --git a/src/main/java/org/leavesmc/leaves/LeavesConfig.java b/src/main/java/org/leavesmc/leaves/LeavesConfig.java
8787
new file mode 100644
88-
index 0000000000000000000000000000000000000000..59c98fa51afd4fd305852d14509b06f8bef859a1
88+
index 0000000000000000000000000000000000000000..10cf4d4aed544e0e0dd6698119734eb9e9cc92e2
8989
--- /dev/null
9090
+++ b/src/main/java/org/leavesmc/leaves/LeavesConfig.java
91-
@@ -0,0 +1,883 @@
91+
@@ -0,0 +1,889 @@
9292
+package org.leavesmc.leaves;
9393
+
9494
+import com.destroystokyo.paper.util.SneakyThrow;
@@ -228,13 +228,13 @@ index 0000000000000000000000000000000000000000..59c98fa51afd4fd305852d14509b06f8
228228
+ public static boolean fakeplayerSpawnPhantom = false;
229229
+
230230
+ @GlobalConfig(name = "regen-amount", category = {"modify", "fakeplayer"}, verify = RegenAmountVerify.class)
231-
+ public static double fakeplayerRegenAmount = 0.010;
231+
+ public static double fakeplayerRegenAmount = 0.0;
232232
+
233233
+ private static class RegenAmountVerify extends ConfigVerifyImpl.DoubleConfigVerify {
234234
+ @Override
235235
+ public void check(Double old, Double value) throws IllegalArgumentException {
236-
+ if (value <= 0.0) {
237-
+ throw new IllegalArgumentException("regen-amount need > 0.0f");
236+
+ if (value < 0.0) {
237+
+ throw new IllegalArgumentException("regen-amount need >= 0.0");
238238
+ }
239239
+ }
240240
+ }
@@ -245,6 +245,12 @@ index 0000000000000000000000000000000000000000..59c98fa51afd4fd305852d14509b06f8
245245
+ @GlobalConfig(name = "modify-config", category = {"modify", "fakeplayer"})
246246
+ public static boolean fakeplayerModifyConfig = false;
247247
+
248+
+ @GlobalConfig(name = "manual-save-and-load", category = {"modify", "fakeplayer"})
249+
+ public static boolean fakeplayerManualSaveAndLoad = false;
250+
+
251+
+ @GlobalConfig(name = "cache-skin", category = {"modify", "fakeplayer"}, lock = true)
252+
+ public static boolean fakeplayerCacheSkin = false;
253+
+
248254
+ // Leaves end - modify - fakeplayer
249255
+
250256
+ // Leaves start - modify - minecraft-old
@@ -974,10 +980,10 @@ index 0000000000000000000000000000000000000000..59c98fa51afd4fd305852d14509b06f8
974980
+}
975981
diff --git a/src/main/java/org/leavesmc/leaves/command/CommandArgument.java b/src/main/java/org/leavesmc/leaves/command/CommandArgument.java
976982
new file mode 100644
977-
index 0000000000000000000000000000000000000000..2f0e6671dd8bfe4f320eab92c5f5bbc10abc3b05
983+
index 0000000000000000000000000000000000000000..0bccbf7816ef621316f0da4911ec112f4753f88e
978984
--- /dev/null
979985
+++ b/src/main/java/org/leavesmc/leaves/command/CommandArgument.java
980-
@@ -0,0 +1,49 @@
986+
@@ -0,0 +1,55 @@
981987
+package org.leavesmc.leaves.command;
982988
+
983989
+import org.jetbrains.annotations.NotNull;
@@ -988,17 +994,23 @@ index 0000000000000000000000000000000000000000..2f0e6671dd8bfe4f320eab92c5f5bbc1
988994
+
989995
+public class CommandArgument {
990996
+
997+
+ public static final CommandArgument EMPTY = new CommandArgument();
998+
+
991999
+ private final List<CommandArgumentType<?>> argumentTypes;
9921000
+ private final List<List<String>> tabComplete;
9931001
+
994-
+ public CommandArgument(CommandArgumentType<?>... argumentTypes) {
1002+
+ private CommandArgument(CommandArgumentType<?>... argumentTypes) {
9951003
+ this.argumentTypes = List.of(argumentTypes);
9961004
+ this.tabComplete = new ArrayList<>();
9971005
+ for (int i = 0; i < argumentTypes.length; i++) {
9981006
+ tabComplete.add(new ArrayList<>());
9991007
+ }
10001008
+ }
10011009
+
1010+
+ public static CommandArgument of(CommandArgumentType<?>... argumentTypes) {
1011+
+ return new CommandArgument(argumentTypes);
1012+
+ }
1013+
+
10021014
+ public List<String> tabComplete(int n) {
10031015
+ if (tabComplete.size() > n) {
10041016
+ return tabComplete.get(n);
@@ -1029,10 +1041,10 @@ index 0000000000000000000000000000000000000000..2f0e6671dd8bfe4f320eab92c5f5bbc1
10291041
+}
10301042
diff --git a/src/main/java/org/leavesmc/leaves/command/CommandArgumentResult.java b/src/main/java/org/leavesmc/leaves/command/CommandArgumentResult.java
10311043
new file mode 100644
1032-
index 0000000000000000000000000000000000000000..3f0707940f22736f703c24f4da25c18fa6e5b309
1044+
index 0000000000000000000000000000000000000000..46aa6eaa75b65aad6bdbe4a5f517b42e87bcca77
10331045
--- /dev/null
10341046
+++ b/src/main/java/org/leavesmc/leaves/command/CommandArgumentResult.java
1035-
@@ -0,0 +1,65 @@
1047+
@@ -0,0 +1,69 @@
10361048
+package org.leavesmc.leaves.command;
10371049
+
10381050
+import net.minecraft.core.BlockPos;
@@ -1065,6 +1077,10 @@ index 0000000000000000000000000000000000000000..3f0707940f22736f703c24f4da25c18f
10651077
+ return Objects.requireNonNullElse(read(String.class), def);
10661078
+ }
10671079
+
1080+
+ public boolean readBoolean(boolean def) {
1081+
+ return Objects.requireNonNullElse(read(Boolean.class), def);
1082+
+ }
1083+
+
10681084
+ public BlockPos readPos() {
10691085
+ Integer[] pos = {read(Integer.class), read(Integer.class), read(Integer.class)};
10701086
+ for (Integer po : pos) {
@@ -1100,10 +1116,10 @@ index 0000000000000000000000000000000000000000..3f0707940f22736f703c24f4da25c18f
11001116
+}
11011117
diff --git a/src/main/java/org/leavesmc/leaves/command/CommandArgumentType.java b/src/main/java/org/leavesmc/leaves/command/CommandArgumentType.java
11021118
new file mode 100644
1103-
index 0000000000000000000000000000000000000000..0d6d33e66461dda39c8f0e8395bf3f047ef88cbd
1119+
index 0000000000000000000000000000000000000000..4ca3508475bbd9771768704e300fe12b717489d6
11041120
--- /dev/null
11051121
+++ b/src/main/java/org/leavesmc/leaves/command/CommandArgumentType.java
1106-
@@ -0,0 +1,48 @@
1122+
@@ -0,0 +1,55 @@
11071123
+package org.leavesmc.leaves.command;
11081124
+
11091125
+import org.jetbrains.annotations.NotNull;
@@ -1150,6 +1166,13 @@ index 0000000000000000000000000000000000000000..0d6d33e66461dda39c8f0e8395bf3f04
11501166
+ }
11511167
+ };
11521168
+
1169+
+ public static final CommandArgumentType<Boolean> BOOLEAN = new CommandArgumentType<>() {
1170+
+ @Override
1171+
+ public Boolean pasre(@NotNull String arg) {
1172+
+ return Boolean.parseBoolean(arg);
1173+
+ }
1174+
+ };
1175+
+
11531176
+ public abstract E pasre(@NotNull String arg);
11541177
+}
11551178
diff --git a/src/main/java/org/leavesmc/leaves/command/LeavesCommand.java b/src/main/java/org/leavesmc/leaves/command/LeavesCommand.java

0 commit comments

Comments
 (0)