Skip to content

Commit

Permalink
New FakePlayer (#337)
Browse files Browse the repository at this point in the history
---------

Co-authored-by: Lumine1909 <[email protected]>
  • Loading branch information
s-yh-china and Lumine1909 authored Sep 16, 2024
1 parent 3436062 commit c33b547
Show file tree
Hide file tree
Showing 20 changed files with 3,002 additions and 1,778 deletions.
771 changes: 592 additions & 179 deletions patches/api/0003-Add-fakeplayer-api.patch

Large diffs are not rendered by default.

47 changes: 35 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,10 +85,10 @@ index d97771ecaf06b92d92b5ca0224ae0866e36703a6..439305bb4f5ce232aa6237276c121d53
.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..59c98fa51afd4fd305852d14509b06f8bef859a1
index 0000000000000000000000000000000000000000..10cf4d4aed544e0e0dd6698119734eb9e9cc92e2
--- /dev/null
+++ b/src/main/java/org/leavesmc/leaves/LeavesConfig.java
@@ -0,0 +1,883 @@
@@ -0,0 +1,889 @@
+package org.leavesmc.leaves;
+
+import com.destroystokyo.paper.util.SneakyThrow;
Expand Down Expand Up @@ -228,13 +228,13 @@ index 0000000000000000000000000000000000000000..59c98fa51afd4fd305852d14509b06f8
+ public static boolean fakeplayerSpawnPhantom = false;
+
+ @GlobalConfig(name = "regen-amount", category = {"modify", "fakeplayer"}, verify = RegenAmountVerify.class)
+ public static double fakeplayerRegenAmount = 0.010;
+ public static double fakeplayerRegenAmount = 0.0;
+
+ private static class RegenAmountVerify extends ConfigVerifyImpl.DoubleConfigVerify {
+ @Override
+ public void check(Double old, Double value) throws IllegalArgumentException {
+ if (value <= 0.0) {
+ throw new IllegalArgumentException("regen-amount need > 0.0f");
+ if (value < 0.0) {
+ throw new IllegalArgumentException("regen-amount need >= 0.0");
+ }
+ }
+ }
Expand All @@ -245,6 +245,12 @@ index 0000000000000000000000000000000000000000..59c98fa51afd4fd305852d14509b06f8
+ @GlobalConfig(name = "modify-config", category = {"modify", "fakeplayer"})
+ public static boolean fakeplayerModifyConfig = false;
+
+ @GlobalConfig(name = "manual-save-and-load", category = {"modify", "fakeplayer"})
+ public static boolean fakeplayerManualSaveAndLoad = false;
+
+ @GlobalConfig(name = "cache-skin", category = {"modify", "fakeplayer"}, lock = true)
+ public static boolean fakeplayerCacheSkin = false;
+
+ // Leaves end - modify - fakeplayer
+
+ // Leaves start - modify - minecraft-old
Expand Down Expand Up @@ -974,10 +980,10 @@ index 0000000000000000000000000000000000000000..59c98fa51afd4fd305852d14509b06f8
+}
diff --git a/src/main/java/org/leavesmc/leaves/command/CommandArgument.java b/src/main/java/org/leavesmc/leaves/command/CommandArgument.java
new file mode 100644
index 0000000000000000000000000000000000000000..2f0e6671dd8bfe4f320eab92c5f5bbc10abc3b05
index 0000000000000000000000000000000000000000..0bccbf7816ef621316f0da4911ec112f4753f88e
--- /dev/null
+++ b/src/main/java/org/leavesmc/leaves/command/CommandArgument.java
@@ -0,0 +1,49 @@
@@ -0,0 +1,55 @@
+package org.leavesmc.leaves.command;
+
+import org.jetbrains.annotations.NotNull;
Expand All @@ -988,17 +994,23 @@ index 0000000000000000000000000000000000000000..2f0e6671dd8bfe4f320eab92c5f5bbc1
+
+public class CommandArgument {
+
+ public static final CommandArgument EMPTY = new CommandArgument();
+
+ private final List<CommandArgumentType<?>> argumentTypes;
+ private final List<List<String>> tabComplete;
+
+ public CommandArgument(CommandArgumentType<?>... argumentTypes) {
+ private CommandArgument(CommandArgumentType<?>... argumentTypes) {
+ this.argumentTypes = List.of(argumentTypes);
+ this.tabComplete = new ArrayList<>();
+ for (int i = 0; i < argumentTypes.length; i++) {
+ tabComplete.add(new ArrayList<>());
+ }
+ }
+
+ public static CommandArgument of(CommandArgumentType<?>... argumentTypes) {
+ return new CommandArgument(argumentTypes);
+ }
+
+ public List<String> tabComplete(int n) {
+ if (tabComplete.size() > n) {
+ return tabComplete.get(n);
Expand Down Expand Up @@ -1029,10 +1041,10 @@ index 0000000000000000000000000000000000000000..2f0e6671dd8bfe4f320eab92c5f5bbc1
+}
diff --git a/src/main/java/org/leavesmc/leaves/command/CommandArgumentResult.java b/src/main/java/org/leavesmc/leaves/command/CommandArgumentResult.java
new file mode 100644
index 0000000000000000000000000000000000000000..3f0707940f22736f703c24f4da25c18fa6e5b309
index 0000000000000000000000000000000000000000..46aa6eaa75b65aad6bdbe4a5f517b42e87bcca77
--- /dev/null
+++ b/src/main/java/org/leavesmc/leaves/command/CommandArgumentResult.java
@@ -0,0 +1,65 @@
@@ -0,0 +1,69 @@
+package org.leavesmc.leaves.command;
+
+import net.minecraft.core.BlockPos;
Expand Down Expand Up @@ -1065,6 +1077,10 @@ index 0000000000000000000000000000000000000000..3f0707940f22736f703c24f4da25c18f
+ return Objects.requireNonNullElse(read(String.class), def);
+ }
+
+ public boolean readBoolean(boolean def) {
+ return Objects.requireNonNullElse(read(Boolean.class), def);
+ }
+
+ public BlockPos readPos() {
+ Integer[] pos = {read(Integer.class), read(Integer.class), read(Integer.class)};
+ for (Integer po : pos) {
Expand Down Expand Up @@ -1100,10 +1116,10 @@ index 0000000000000000000000000000000000000000..3f0707940f22736f703c24f4da25c18f
+}
diff --git a/src/main/java/org/leavesmc/leaves/command/CommandArgumentType.java b/src/main/java/org/leavesmc/leaves/command/CommandArgumentType.java
new file mode 100644
index 0000000000000000000000000000000000000000..0d6d33e66461dda39c8f0e8395bf3f047ef88cbd
index 0000000000000000000000000000000000000000..4ca3508475bbd9771768704e300fe12b717489d6
--- /dev/null
+++ b/src/main/java/org/leavesmc/leaves/command/CommandArgumentType.java
@@ -0,0 +1,48 @@
@@ -0,0 +1,55 @@
+package org.leavesmc.leaves.command;
+
+import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -1150,6 +1166,13 @@ index 0000000000000000000000000000000000000000..0d6d33e66461dda39c8f0e8395bf3f04
+ }
+ };
+
+ public static final CommandArgumentType<Boolean> BOOLEAN = new CommandArgumentType<>() {
+ @Override
+ public Boolean pasre(@NotNull String arg) {
+ return Boolean.parseBoolean(arg);
+ }
+ };
+
+ public abstract E pasre(@NotNull String arg);
+}
diff --git a/src/main/java/org/leavesmc/leaves/command/LeavesCommand.java b/src/main/java/org/leavesmc/leaves/command/LeavesCommand.java
Expand Down
Loading

0 comments on commit c33b547

Please sign in to comment.