mirror of
https://github.com/Samsuik/Sakura.git
synced 2025-12-29 03:39:07 +00:00
Start on updating 1.21.4
This commit is contained in:
85
migrate/api/0001-Customise-Version-Command.patch
Normal file
85
migrate/api/0001-Customise-Version-Command.patch
Normal file
@@ -0,0 +1,85 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Samsuik <40902469+Samsuik@users.noreply.github.com>
|
||||
Date: Wed, 2 Aug 2023 18:00:04 +0100
|
||||
Subject: [PATCH] Customise Version Command
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
|
||||
index b9b751ea0d11381e846d5f35f39f285c075c171a..d629598719298aa15666b559490a0f6db92b2483 100644
|
||||
--- a/src/main/java/org/bukkit/Bukkit.java
|
||||
+++ b/src/main/java/org/bukkit/Bukkit.java
|
||||
@@ -125,6 +125,20 @@ public final class Bukkit {
|
||||
// Paper end
|
||||
}
|
||||
|
||||
+ // Sakura start - expose git info
|
||||
+ @NotNull
|
||||
+ public static String getGitInformation() {
|
||||
+ final io.papermc.paper.ServerBuildInfo version = io.papermc.paper.ServerBuildInfo.buildInfo();
|
||||
+ final String gitBranch = version.gitBranch().orElse("Dev");
|
||||
+ final String gitCommit = version.gitCommit().orElse("");
|
||||
+ String branchMsg = " on " + gitBranch;
|
||||
+ if ("master".equals(gitBranch) || "main".equals(gitBranch)) {
|
||||
+ branchMsg = ""; // Don't show branch on main/master
|
||||
+ }
|
||||
+ return "(Git: " + gitCommit + branchMsg + ")";
|
||||
+ }
|
||||
+ // Sakura end
|
||||
+
|
||||
/**
|
||||
* Gets the name of this server implementation.
|
||||
*
|
||||
diff --git a/src/main/java/org/bukkit/command/defaults/VersionCommand.java b/src/main/java/org/bukkit/command/defaults/VersionCommand.java
|
||||
index e64bb57f74e6d6f78927be228825b3e0bdf41f48..019b8abbf69ea0f741e725ae1c965f04604fe16d 100644
|
||||
--- a/src/main/java/org/bukkit/command/defaults/VersionCommand.java
|
||||
+++ b/src/main/java/org/bukkit/command/defaults/VersionCommand.java
|
||||
@@ -33,6 +33,11 @@ import net.kyori.adventure.text.event.ClickEvent;
|
||||
import net.kyori.adventure.text.format.TextDecoration;
|
||||
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
||||
// Paper end - version command 2.0
|
||||
+// Sakura start
|
||||
+import net.kyori.adventure.text.event.HoverEvent;
|
||||
+import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
+import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||
+// Sakura end
|
||||
|
||||
public class VersionCommand extends BukkitCommand {
|
||||
private VersionFetcher versionFetcher; // Paper - version command 2.0
|
||||
@@ -44,6 +49,15 @@ public class VersionCommand extends BukkitCommand {
|
||||
return versionFetcher;
|
||||
}
|
||||
|
||||
+ // Sakura start
|
||||
+ private static final String VERSION_MESSAGE = """
|
||||
+ <dark_purple>.
|
||||
+ <dark_purple>| <white>This server is running <gradient:red:light_purple>Sakura</gradient>
|
||||
+ <dark_purple>| <white>Commit<dark_gray>: \\<<commit>> <gray>targeting </gray>(<yellow>MC</yellow>: <gray><version></gray>)
|
||||
+ <dark_purple>| <white>Github<dark_gray>: \\<<yellow><click:open_url:'https://github.com/Samsuik/Sakura'>link</click></yellow>>
|
||||
+ <dark_purple>'""";
|
||||
+ // Sakura end
|
||||
+
|
||||
public VersionCommand(@NotNull String name) {
|
||||
super(name);
|
||||
|
||||
@@ -55,12 +69,18 @@ public class VersionCommand extends BukkitCommand {
|
||||
|
||||
@Override
|
||||
public boolean execute(@NotNull CommandSender sender, @NotNull String currentAlias, @NotNull String[] args) {
|
||||
- if (!testPermission(sender)) return true;
|
||||
+ // Sakura - move down into else
|
||||
|
||||
if (args.length == 0) {
|
||||
//sender.sendMessage("This server is running " + Bukkit.getName() + " version " + Bukkit.getVersion() + " (Implementing API version " + Bukkit.getBukkitVersion() + ")"); // Paper - moved to setVersionMessage
|
||||
- sendVersion(sender);
|
||||
- } else {
|
||||
+ // Sakura start
|
||||
+ sender.sendMessage(MiniMessage.miniMessage().deserialize(VERSION_MESSAGE,
|
||||
+ Placeholder.component("commit", Component.text("hover", NamedTextColor.YELLOW)
|
||||
+ .hoverEvent(HoverEvent.showText(Component.text(Bukkit.getGitInformation())))),
|
||||
+ Placeholder.unparsed("version", Bukkit.getMinecraftVersion())
|
||||
+ ));
|
||||
+ } else if (testPermission(sender)) {
|
||||
+ // Sakura end
|
||||
StringBuilder name = new StringBuilder();
|
||||
|
||||
for (String arg : args) {
|
||||
186
migrate/api/0002-Client-Visibility-Settings-API.patch
Normal file
186
migrate/api/0002-Client-Visibility-Settings-API.patch
Normal file
@@ -0,0 +1,186 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Samsuik <kfian294ma4@gmail.com>
|
||||
Date: Tue, 21 Sep 2021 23:55:45 +0100
|
||||
Subject: [PATCH] Client Visibility Settings API
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/samsuik/sakura/player/visibility/VisibilitySettings.java b/src/main/java/me/samsuik/sakura/player/visibility/VisibilitySettings.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..50ba48ebb99fac7f42fa1db76808f84ed9e601c4
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/samsuik/sakura/player/visibility/VisibilitySettings.java
|
||||
@@ -0,0 +1,48 @@
|
||||
+package me.samsuik.sakura.player.visibility;
|
||||
+
|
||||
+import org.jspecify.annotations.NullMarked;
|
||||
+
|
||||
+@NullMarked
|
||||
+public interface VisibilitySettings {
|
||||
+ default boolean isEnabled(VisibilityType type) {
|
||||
+ return this.get(type) == VisibilityState.ON;
|
||||
+ }
|
||||
+
|
||||
+ default boolean isDisabled(VisibilityType type) {
|
||||
+ return this.get(type) == VisibilityState.OFF;
|
||||
+ }
|
||||
+
|
||||
+ default boolean isToggled(VisibilityType type) {
|
||||
+ return !type.isDefault(this.get(type));
|
||||
+ }
|
||||
+
|
||||
+ default VisibilityState toggle(VisibilityType type) {
|
||||
+ VisibilityState state = this.get(type);
|
||||
+ return this.set(type, toggleState(state));
|
||||
+ }
|
||||
+
|
||||
+ default VisibilityState cycle(VisibilityType type) {
|
||||
+ VisibilityState state = this.get(type);
|
||||
+ return this.set(type, type.cycle(state));
|
||||
+ }
|
||||
+
|
||||
+ default void toggleAll() {
|
||||
+ VisibilityState state = this.currentState();
|
||||
+ VisibilityState newState = toggleState(state);
|
||||
+ for (VisibilityType type : VisibilityTypes.types()) {
|
||||
+ this.set(type, newState);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ VisibilityState get(VisibilityType type);
|
||||
+
|
||||
+ VisibilityState set(VisibilityType type, VisibilityState state);
|
||||
+
|
||||
+ VisibilityState currentState();
|
||||
+
|
||||
+ boolean playerModified();
|
||||
+
|
||||
+ static VisibilityState toggleState(VisibilityState state) {
|
||||
+ return state != VisibilityState.OFF ? VisibilityState.OFF : VisibilityState.ON;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/me/samsuik/sakura/player/visibility/VisibilityState.java b/src/main/java/me/samsuik/sakura/player/visibility/VisibilityState.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..d9cb2ea30f1cb1117437aa2c04a9471ece4be052
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/samsuik/sakura/player/visibility/VisibilityState.java
|
||||
@@ -0,0 +1,5 @@
|
||||
+package me.samsuik.sakura.player.visibility;
|
||||
+
|
||||
+public enum VisibilityState {
|
||||
+ ON, MODIFIED, MINIMAL, OFF;
|
||||
+}
|
||||
diff --git a/src/main/java/me/samsuik/sakura/player/visibility/VisibilityType.java b/src/main/java/me/samsuik/sakura/player/visibility/VisibilityType.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..6b6b482d1c34e2318e5ca3b7a68e628818f048f8
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/samsuik/sakura/player/visibility/VisibilityType.java
|
||||
@@ -0,0 +1,35 @@
|
||||
+package me.samsuik.sakura.player.visibility;
|
||||
+
|
||||
+import com.google.common.collect.ImmutableList;
|
||||
+import org.jspecify.annotations.NullMarked;
|
||||
+
|
||||
+@NullMarked
|
||||
+public record VisibilityType(String key, ImmutableList<VisibilityState> states) {
|
||||
+ public VisibilityState getDefault() {
|
||||
+ return this.states.getFirst();
|
||||
+ }
|
||||
+
|
||||
+ public boolean isDefault(VisibilityState state) {
|
||||
+ return state == this.getDefault();
|
||||
+ }
|
||||
+
|
||||
+ public VisibilityState cycle(VisibilityState state) {
|
||||
+ int index = this.states.indexOf(state);
|
||||
+ int next = (index + 1) % this.states.size();
|
||||
+ return this.states.get(next);
|
||||
+ }
|
||||
+
|
||||
+ public static VisibilityType from(String key, boolean minimal) {
|
||||
+ return new VisibilityType(key, states(minimal));
|
||||
+ }
|
||||
+
|
||||
+ private static ImmutableList<VisibilityState> states(boolean minimal) {
|
||||
+ ImmutableList.Builder<VisibilityState> listBuilder = ImmutableList.builder();
|
||||
+ listBuilder.add(VisibilityState.ON);
|
||||
+ if (minimal) {
|
||||
+ listBuilder.add(VisibilityState.MINIMAL);
|
||||
+ }
|
||||
+ listBuilder.add(VisibilityState.OFF);
|
||||
+ return listBuilder.build();
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/me/samsuik/sakura/player/visibility/VisibilityTypes.java b/src/main/java/me/samsuik/sakura/player/visibility/VisibilityTypes.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..f323cfc2d7370ff8ea9020e79c5148a86e51e8c8
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/samsuik/sakura/player/visibility/VisibilityTypes.java
|
||||
@@ -0,0 +1,31 @@
|
||||
+package me.samsuik.sakura.player.visibility;
|
||||
+
|
||||
+import com.google.common.collect.ImmutableList;
|
||||
+import org.jspecify.annotations.NullMarked;
|
||||
+
|
||||
+import java.util.ArrayList;
|
||||
+import java.util.List;
|
||||
+
|
||||
+@NullMarked
|
||||
+public final class VisibilityTypes {
|
||||
+ private static final List<VisibilityType> TYPES = new ArrayList<>();
|
||||
+
|
||||
+ public static final VisibilityType TNT = register(create("tnt", true));
|
||||
+ public static final VisibilityType SAND = register(create("sand", true));
|
||||
+ public static final VisibilityType EXPLOSIONS = register(create("explosions", true));
|
||||
+ public static final VisibilityType SPAWNERS = register(create("spawners", false));
|
||||
+ public static final VisibilityType PISTONS = register(create("pistons", false));
|
||||
+
|
||||
+ public static ImmutableList<VisibilityType> types() {
|
||||
+ return ImmutableList.copyOf(TYPES);
|
||||
+ }
|
||||
+
|
||||
+ private static VisibilityType create(String key, boolean minimal) {
|
||||
+ return VisibilityType.from(key, minimal);
|
||||
+ }
|
||||
+
|
||||
+ private static VisibilityType register(VisibilityType type) {
|
||||
+ TYPES.add(type);
|
||||
+ return type;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java
|
||||
index 95f0b3186e313c7fbd5c8531d52b82a69e525f94..0560784e8b71a927db6d8cdf9d36a23e3b56ef74 100644
|
||||
--- a/src/main/java/org/bukkit/entity/Player.java
|
||||
+++ b/src/main/java/org/bukkit/entity/Player.java
|
||||
@@ -9,6 +9,8 @@ import java.util.Date;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
+
|
||||
+import me.samsuik.sakura.player.visibility.VisibilitySettings;
|
||||
import org.bukkit.BanEntry;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Effect;
|
||||
@@ -49,7 +51,6 @@ import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.messaging.PluginMessageRecipient;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
-import org.bukkit.profile.PlayerProfile;
|
||||
import org.bukkit.scoreboard.Scoreboard;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -60,6 +61,15 @@ import org.jetbrains.annotations.Nullable;
|
||||
*/
|
||||
public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginMessageRecipient, net.kyori.adventure.identity.Identified, net.kyori.adventure.bossbar.BossBarViewer, com.destroystokyo.paper.network.NetworkClient { // Paper
|
||||
|
||||
+ // Sakura start
|
||||
+ /**
|
||||
+ * Visibility API for FPS settings.
|
||||
+ *
|
||||
+ * @return visibility api
|
||||
+ */
|
||||
+ VisibilitySettings getVisibility();
|
||||
+ // Sakura end
|
||||
+
|
||||
// Paper start
|
||||
@Override
|
||||
default net.kyori.adventure.identity.@NotNull Identity identity() {
|
||||
100
migrate/api/0003-Merge-Cannon-Entities.patch
Normal file
100
migrate/api/0003-Merge-Cannon-Entities.patch
Normal file
@@ -0,0 +1,100 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Samsuik <40902469+Samsuik@users.noreply.github.com>
|
||||
Date: Thu, 5 Oct 2023 14:34:30 +0100
|
||||
Subject: [PATCH] Merge Cannon Entities
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/samsuik/sakura/entity/merge/MergeLevel.java b/src/main/java/me/samsuik/sakura/entity/merge/MergeLevel.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..f8010a92ac82e76611ff7a9be259f11db0a1cc90
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/samsuik/sakura/entity/merge/MergeLevel.java
|
||||
@@ -0,0 +1,42 @@
|
||||
+package me.samsuik.sakura.entity.merge;
|
||||
+
|
||||
+import org.jspecify.annotations.NullMarked;
|
||||
+
|
||||
+@NullMarked
|
||||
+public enum MergeLevel {
|
||||
+ /**
|
||||
+ * Disabled.
|
||||
+ */
|
||||
+ NONE(-1),
|
||||
+ /**
|
||||
+ * "STRICT" merges entities with the same properties, position, momentum and OOE.
|
||||
+ * This is considered safe to use, and will not break cannon mechanics.
|
||||
+ */
|
||||
+ STRICT(1),
|
||||
+ /**
|
||||
+ * "LENIENT" merges entities aggressively by tracking the entities that have
|
||||
+ * previously merged. This is a hybrid of "SPAWN" and "STRICT" merging, with the
|
||||
+ * visuals of "STRICT" merging and better merging potential of "SPAWN" merging.
|
||||
+ */
|
||||
+ LENIENT(2),
|
||||
+ /**
|
||||
+ * "SPAWN" merges entities one gametick after they have spawned. Merging is
|
||||
+ * only possible after it has been established that the entity is safe to
|
||||
+ * merge by collecting information on the entities that merge together over time.
|
||||
+ */
|
||||
+ SPAWN(3);
|
||||
+
|
||||
+ private final int level;
|
||||
+
|
||||
+ MergeLevel(int level) {
|
||||
+ this.level = level;
|
||||
+ }
|
||||
+
|
||||
+ public boolean atLeast(MergeLevel level) {
|
||||
+ return this.getLevel() >= level.getLevel();
|
||||
+ }
|
||||
+
|
||||
+ public int getLevel() {
|
||||
+ return this.level;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/me/samsuik/sakura/entity/merge/Mergeable.java b/src/main/java/me/samsuik/sakura/entity/merge/Mergeable.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..c33c461b10ff27bc5b0a294b61078c89cceae6b8
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/samsuik/sakura/entity/merge/Mergeable.java
|
||||
@@ -0,0 +1,14 @@
|
||||
+package me.samsuik.sakura.entity.merge;
|
||||
+
|
||||
+import org.jspecify.annotations.NullMarked;
|
||||
+
|
||||
+@NullMarked
|
||||
+public interface Mergeable {
|
||||
+ MergeLevel getMergeLevel();
|
||||
+
|
||||
+ void setMergeLevel(MergeLevel level);
|
||||
+
|
||||
+ int getStacked();
|
||||
+
|
||||
+ void setStacked(int stacked);
|
||||
+}
|
||||
diff --git a/src/main/java/org/bukkit/entity/FallingBlock.java b/src/main/java/org/bukkit/entity/FallingBlock.java
|
||||
index 7904c716a3b0869ebf2f9b416536c59121a539a8..2479453b96a75fda2c307261f84c91034e73000d 100644
|
||||
--- a/src/main/java/org/bukkit/entity/FallingBlock.java
|
||||
+++ b/src/main/java/org/bukkit/entity/FallingBlock.java
|
||||
@@ -7,7 +7,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
/**
|
||||
* Represents a falling block
|
||||
*/
|
||||
-public interface FallingBlock extends Entity {
|
||||
+public interface FallingBlock extends Entity, me.samsuik.sakura.entity.merge.Mergeable { // Sakura
|
||||
|
||||
/**
|
||||
* Get the Material of the falling block
|
||||
diff --git a/src/main/java/org/bukkit/entity/TNTPrimed.java b/src/main/java/org/bukkit/entity/TNTPrimed.java
|
||||
index 87e717c9ea61b0cbf536bc62fa829ddcfae5ad8c..ba84b3cbbd3358b16b21a18baa9c1812733fc144 100644
|
||||
--- a/src/main/java/org/bukkit/entity/TNTPrimed.java
|
||||
+++ b/src/main/java/org/bukkit/entity/TNTPrimed.java
|
||||
@@ -6,7 +6,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
/**
|
||||
* Represents a Primed TNT.
|
||||
*/
|
||||
-public interface TNTPrimed extends Explosive {
|
||||
+public interface TNTPrimed extends Explosive, me.samsuik.sakura.entity.merge.Mergeable { // Sakura
|
||||
|
||||
/**
|
||||
* Set the number of ticks until the TNT blows up after being primed.
|
||||
33
migrate/api/0004-isPushedByFluid-API.patch
Normal file
33
migrate/api/0004-isPushedByFluid-API.patch
Normal file
@@ -0,0 +1,33 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Samsuik <40902469+Samsuik@users.noreply.github.com>
|
||||
Date: Fri, 13 Oct 2023 20:01:48 +0100
|
||||
Subject: [PATCH] isPushedByFluid API
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/entity/Entity.java b/src/main/java/org/bukkit/entity/Entity.java
|
||||
index d0ae8a94db20281d3664d74718c65234eb2e5f83..cc4c1a60585f923dbe48c5432a425dec99ae22ff 100644
|
||||
--- a/src/main/java/org/bukkit/entity/Entity.java
|
||||
+++ b/src/main/java/org/bukkit/entity/Entity.java
|
||||
@@ -111,6 +111,22 @@ public interface Entity extends Metadatable, CommandSender, Nameable, Persistent
|
||||
*/
|
||||
public boolean isInWater();
|
||||
|
||||
+ // Sakura start
|
||||
+ /**
|
||||
+ * Gets if the entity will be pushed by fluid.
|
||||
+ *
|
||||
+ * @return if this entity can be pushed by fluid.
|
||||
+ */
|
||||
+ boolean isPushedByFluid();
|
||||
+
|
||||
+ /**
|
||||
+ * Sets if the entity will be pushed by fluid.
|
||||
+ *
|
||||
+ * @param state whether entity should be pushed by fluid
|
||||
+ */
|
||||
+ void setPushedByFluid(boolean state);
|
||||
+ // Sakura end
|
||||
+
|
||||
/**
|
||||
* Gets the current world this entity resides in
|
||||
*
|
||||
30
migrate/api/0005-Falling-Block-Parity-API.patch
Normal file
30
migrate/api/0005-Falling-Block-Parity-API.patch
Normal file
@@ -0,0 +1,30 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Samsuik <40902469+Samsuik@users.noreply.github.com>
|
||||
Date: Sun, 15 Oct 2023 22:53:38 +0100
|
||||
Subject: [PATCH] Falling Block Parity API
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/entity/FallingBlock.java b/src/main/java/org/bukkit/entity/FallingBlock.java
|
||||
index 2479453b96a75fda2c307261f84c91034e73000d..a8e3a1c34957b7f7e225dc9932edbd300755be23 100644
|
||||
--- a/src/main/java/org/bukkit/entity/FallingBlock.java
|
||||
+++ b/src/main/java/org/bukkit/entity/FallingBlock.java
|
||||
@@ -183,4 +183,19 @@ public interface FallingBlock extends Entity, me.samsuik.sakura.entity.merge.Mer
|
||||
*/
|
||||
void shouldAutoExpire(boolean autoExpires);
|
||||
// Paper end - Auto expire setting
|
||||
+ // Sakura start
|
||||
+ /**
|
||||
+ * Gets if falling block has height parity
|
||||
+ *
|
||||
+ * @return parity
|
||||
+ */
|
||||
+ boolean getHeightParity();
|
||||
+
|
||||
+ /**
|
||||
+ * Sets falling block height parity
|
||||
+ *
|
||||
+ * @param parity value
|
||||
+ */
|
||||
+ void setHeightParity(boolean parity);
|
||||
+ // Sakura end
|
||||
}
|
||||
323
migrate/api/0006-Local-Value-Storage-API.patch
Normal file
323
migrate/api/0006-Local-Value-Storage-API.patch
Normal file
@@ -0,0 +1,323 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Samsuik <40902469+Samsuik@users.noreply.github.com>
|
||||
Date: Tue, 21 Nov 2023 23:22:35 +0000
|
||||
Subject: [PATCH] Local Value Storage API
|
||||
|
||||
|
||||
diff --git a/src/main/java/me/samsuik/sakura/local/LocalRegion.java b/src/main/java/me/samsuik/sakura/local/LocalRegion.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..e9c29d22dc734854244c2e91f8b186abe0e34443
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/samsuik/sakura/local/LocalRegion.java
|
||||
@@ -0,0 +1,46 @@
|
||||
+package me.samsuik.sakura.local;
|
||||
+
|
||||
+import io.papermc.paper.math.Position;
|
||||
+import org.bukkit.util.BoundingBox;
|
||||
+import org.bukkit.util.Vector;
|
||||
+import org.jspecify.annotations.NullMarked;
|
||||
+
|
||||
+@NullMarked
|
||||
+public record LocalRegion(int minX, int minZ, int maxX, int maxZ) {
|
||||
+ public static LocalRegion from(BoundingBox boundingBox) {
|
||||
+ return of(boundingBox.getMin(), boundingBox.getMax());
|
||||
+ }
|
||||
+
|
||||
+ public static LocalRegion of(Vector min, Vector max) {
|
||||
+ return of(min.getBlockX(), min.getBlockZ(), max.getBlockX(), max.getBlockZ());
|
||||
+ }
|
||||
+
|
||||
+ public static LocalRegion of(Position min, Position max) {
|
||||
+ return of(min.blockX(), min.blockZ(), max.blockX(), max.blockZ());
|
||||
+ }
|
||||
+
|
||||
+ public static LocalRegion of(int minX, int minZ, int maxX, int maxZ) {
|
||||
+ return new LocalRegion(
|
||||
+ Math.min(minX, maxX), Math.min(minZ, maxZ),
|
||||
+ Math.max(minX, maxX), Math.max(minZ, maxZ)
|
||||
+ );
|
||||
+ }
|
||||
+
|
||||
+ public static LocalRegion at(int x, int z, int radius) {
|
||||
+ return new LocalRegion(x-radius, z-radius, x+radius, z+radius);
|
||||
+ }
|
||||
+
|
||||
+ public boolean intersects(LocalRegion region) {
|
||||
+ return (this.minX < region.minX() && this.maxX > region.minX() || this.maxX > region.maxX() && this.minX < region.maxX())
|
||||
+ && (this.minZ < region.minZ() && this.maxZ > region.minZ() || this.maxZ > region.maxZ() && this.minZ < region.maxZ());
|
||||
+ }
|
||||
+
|
||||
+ public boolean contains(LocalRegion region) {
|
||||
+ return this.minX < region.minX() && this.maxX > region.maxX()
|
||||
+ && this.maxZ < region.minZ() && this.maxZ > region.maxZ();
|
||||
+ }
|
||||
+
|
||||
+ public boolean contains(int x, int z) {
|
||||
+ return this.minX <= x && this.maxX >= x && this.minZ <= z && this.maxZ >= z;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/me/samsuik/sakura/local/LocalValueKey.java b/src/main/java/me/samsuik/sakura/local/LocalValueKey.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..4a1540d4f6125bd2a8a4f6b7e645a3eb30e35837
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/samsuik/sakura/local/LocalValueKey.java
|
||||
@@ -0,0 +1,23 @@
|
||||
+package me.samsuik.sakura.local;
|
||||
+
|
||||
+import org.bukkit.NamespacedKey;
|
||||
+import org.jspecify.annotations.NullMarked;
|
||||
+
|
||||
+import java.util.function.Supplier;
|
||||
+
|
||||
+@NullMarked
|
||||
+public record LocalValueKey<T>(NamespacedKey key, Supplier<T> defaultSupplier) {
|
||||
+ @Override
|
||||
+ public boolean equals(Object o) {
|
||||
+ if (this == o) return true;
|
||||
+ if (o == null || this.getClass() != o.getClass()) return false;
|
||||
+
|
||||
+ LocalValueKey<?> that = (LocalValueKey<?>) o;
|
||||
+ return this.key.equals(that.key);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public int hashCode() {
|
||||
+ return this.key.hashCode();
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/me/samsuik/sakura/local/LocalValueKeys.java b/src/main/java/me/samsuik/sakura/local/LocalValueKeys.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..54c3693c97d5049882d7c10e14fc79ef6c76b1fc
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/samsuik/sakura/local/LocalValueKeys.java
|
||||
@@ -0,0 +1,25 @@
|
||||
+package me.samsuik.sakura.local;
|
||||
+
|
||||
+import me.samsuik.sakura.physics.PhysicsVersion;
|
||||
+import me.samsuik.sakura.redstone.RedstoneImplementation;
|
||||
+import org.bukkit.Material;
|
||||
+import org.bukkit.NamespacedKey;
|
||||
+
|
||||
+import java.util.HashMap;
|
||||
+import java.util.Map;
|
||||
+import java.util.function.Supplier;
|
||||
+
|
||||
+public final class LocalValueKeys {
|
||||
+ private static final String NAMESPACE = "sakura";
|
||||
+
|
||||
+ public static final LocalValueKey<PhysicsVersion> PHYSICS_VERSION = create("physics-version", () -> PhysicsVersion.LATEST);
|
||||
+ public static final LocalValueKey<Map<Material, Map.Entry<Integer, Float>>> DURABLE_MATERIALS = create("durable-materials", HashMap::new);
|
||||
+ public static final LocalValueKey<RedstoneImplementation> REDSTONE_IMPLEMENTATION = create("redstone-implementation", () -> RedstoneImplementation.VANILLA);
|
||||
+ public static final LocalValueKey<Boolean> CONSISTENT_EXPLOSION_RADIUS = create("consistent-radius", () -> false);
|
||||
+ public static final LocalValueKey<Boolean> REDSTONE_CACHE = create("redstone-cache", () -> false);
|
||||
+ public static final LocalValueKey<Integer> LAVA_FLOW_SPEED = create("lava-flow-speed", () -> -1);
|
||||
+
|
||||
+ private static <T> LocalValueKey<T> create(String key, Supplier<T> supplier) {
|
||||
+ return new LocalValueKey<>(new NamespacedKey(NAMESPACE, key), supplier);
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/me/samsuik/sakura/local/storage/LocalStorageHandler.java b/src/main/java/me/samsuik/sakura/local/storage/LocalStorageHandler.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..220a12eddf3aeaeb7adfd6404b5225e392439ca8
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/samsuik/sakura/local/storage/LocalStorageHandler.java
|
||||
@@ -0,0 +1,22 @@
|
||||
+package me.samsuik.sakura.local.storage;
|
||||
+
|
||||
+import me.samsuik.sakura.local.LocalRegion;
|
||||
+import org.bukkit.Location;
|
||||
+
|
||||
+import java.util.List;
|
||||
+
|
||||
+public interface LocalStorageHandler {
|
||||
+ LocalRegion locate(Location location, int searchDistance);
|
||||
+
|
||||
+ LocalRegion locate(int x, int z, int searchDistance);
|
||||
+
|
||||
+ LocalValueStorage get(LocalRegion region);
|
||||
+
|
||||
+ boolean has(LocalRegion region);
|
||||
+
|
||||
+ void put(LocalRegion region, LocalValueStorage storage);
|
||||
+
|
||||
+ void remove(LocalRegion region);
|
||||
+
|
||||
+ List<LocalRegion> regions();
|
||||
+}
|
||||
diff --git a/src/main/java/me/samsuik/sakura/local/storage/LocalValueStorage.java b/src/main/java/me/samsuik/sakura/local/storage/LocalValueStorage.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..cbaaa24b504f3a2478c9db4e3b8ef0095b6e2c80
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/samsuik/sakura/local/storage/LocalValueStorage.java
|
||||
@@ -0,0 +1,50 @@
|
||||
+package me.samsuik.sakura.local.storage;
|
||||
+
|
||||
+import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||
+import me.samsuik.sakura.local.LocalValueKey;
|
||||
+import org.jspecify.annotations.NullMarked;
|
||||
+import org.jspecify.annotations.Nullable;
|
||||
+
|
||||
+import java.util.Map;
|
||||
+import java.util.Optional;
|
||||
+
|
||||
+@NullMarked
|
||||
+@SuppressWarnings("unchecked")
|
||||
+public final class LocalValueStorage {
|
||||
+ private final Map<LocalValueKey<?>, Object> map = new Object2ObjectOpenHashMap<>();
|
||||
+
|
||||
+ public <T> void set(LocalValueKey<T> key, T insert) {
|
||||
+ this.map.put(key, insert);
|
||||
+ }
|
||||
+
|
||||
+ public void remove(LocalValueKey<?> key) {
|
||||
+ this.map.remove(key);
|
||||
+ }
|
||||
+
|
||||
+ public <T> Optional<T> get(LocalValueKey<T> key) {
|
||||
+ T value = (T) this.map.get(key);
|
||||
+ return Optional.ofNullable(value);
|
||||
+ }
|
||||
+
|
||||
+ public <T> T getOrDefault(LocalValueKey<T> key, T def) {
|
||||
+ return (T) this.map.getOrDefault(key, def);
|
||||
+ }
|
||||
+
|
||||
+ public boolean exists(LocalValueKey<?> key) {
|
||||
+ return this.map.containsKey(key);
|
||||
+ }
|
||||
+
|
||||
+ @Nullable
|
||||
+ public <T> T value(LocalValueKey<T> key) {
|
||||
+ return (T) this.map.get(key);
|
||||
+ }
|
||||
+
|
||||
+ public <T> T value(LocalValueKey<T> key, boolean returnDefault) {
|
||||
+ T val = (T) this.map.get(key);
|
||||
+ if (!returnDefault || val != null)
|
||||
+ return val;
|
||||
+ // update value
|
||||
+ this.set(key, val = key.defaultSupplier().get());
|
||||
+ return val;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/me/samsuik/sakura/physics/PhysicsVersion.java b/src/main/java/me/samsuik/sakura/physics/PhysicsVersion.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..685fefb4ac36153f038b28452e3b29ded52cff07
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/samsuik/sakura/physics/PhysicsVersion.java
|
||||
@@ -0,0 +1,74 @@
|
||||
+package me.samsuik.sakura.physics;
|
||||
+
|
||||
+import org.jspecify.annotations.NullMarked;
|
||||
+
|
||||
+@NullMarked
|
||||
+public enum PhysicsVersion {
|
||||
+ LEGACY("legacy", 1_0_0), // replicates patched 1.8.8 paper mechanics
|
||||
+ v1_8_2("1.8.2", 1_8_2), // vanilla mechanics
|
||||
+ v1_9("1.9", 1_9_0),
|
||||
+ v1_10("1.10", 1_10_0),
|
||||
+ v1_11("1.11", 1_11_0),
|
||||
+ v1_12("1.12", 1_12_0),
|
||||
+ v1_13("1.13", 1_13_0),
|
||||
+ v1_14("1.14", 1_14_0),
|
||||
+ v1_16("1.16", 1_16_0),
|
||||
+ v1_17("1.17", 1_17_0),
|
||||
+ v1_18_2("1.18.2", 1_18_2),
|
||||
+ v1_19_3("1.19.3", 1_19_3),
|
||||
+ v1_20("1.20", 1_20_0),
|
||||
+ v1_21_2("1.21.2", 1_21_2),
|
||||
+ LATEST("latest", 9_99_9); // latest version
|
||||
+
|
||||
+ private final String friendlyName;
|
||||
+ private final int version;
|
||||
+
|
||||
+ PhysicsVersion(String friendlyName, int version) {
|
||||
+ this.friendlyName = friendlyName;
|
||||
+ this.version = version;
|
||||
+ }
|
||||
+
|
||||
+ public boolean isLegacy() {
|
||||
+ return this == LEGACY;
|
||||
+ }
|
||||
+
|
||||
+ public boolean afterOrEqual(int version) {
|
||||
+ return this.version >= version;
|
||||
+ }
|
||||
+
|
||||
+ public boolean before(int version) {
|
||||
+ return this.version < version;
|
||||
+ }
|
||||
+
|
||||
+ public boolean is(int version) {
|
||||
+ return this.version == version;
|
||||
+ }
|
||||
+
|
||||
+ public boolean isWithin(int min, int max) {
|
||||
+ return this.version >= min && this.version <= max;
|
||||
+ }
|
||||
+
|
||||
+ public int getVersion() {
|
||||
+ return this.version;
|
||||
+ }
|
||||
+
|
||||
+ public String getFriendlyName() {
|
||||
+ return this.friendlyName;
|
||||
+ }
|
||||
+
|
||||
+ public static PhysicsVersion from(String string) {
|
||||
+ int parsedVersion = Integer.MIN_VALUE;
|
||||
+ try {
|
||||
+ String versionString = string.replace(".", "");
|
||||
+ parsedVersion = Integer.parseInt(versionString);
|
||||
+ } catch (NumberFormatException nfe) {
|
||||
+ // ignored
|
||||
+ }
|
||||
+ for (PhysicsVersion ver : values()) {
|
||||
+ if (ver.name().equalsIgnoreCase(string) || ver.getFriendlyName().equalsIgnoreCase(string) || ver.is(parsedVersion)) {
|
||||
+ return ver;
|
||||
+ }
|
||||
+ }
|
||||
+ return LATEST;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/me/samsuik/sakura/redstone/RedstoneImplementation.java b/src/main/java/me/samsuik/sakura/redstone/RedstoneImplementation.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..bfb5e9ec99dfdd6f4664ddb8191496706bc0d2a1
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/samsuik/sakura/redstone/RedstoneImplementation.java
|
||||
@@ -0,0 +1,20 @@
|
||||
+package me.samsuik.sakura.redstone;
|
||||
+
|
||||
+import org.jspecify.annotations.NullMarked;
|
||||
+
|
||||
+@NullMarked
|
||||
+public enum RedstoneImplementation {
|
||||
+ VANILLA("vanilla"),
|
||||
+ EIGENCRAFT("eigencraft"),
|
||||
+ ALTERNATE_CURRENT("alternate-current");
|
||||
+
|
||||
+ private final String friendlyName;
|
||||
+
|
||||
+ RedstoneImplementation(String friendlyName) {
|
||||
+ this.friendlyName = friendlyName;
|
||||
+ }
|
||||
+
|
||||
+ public String getFriendlyName() {
|
||||
+ return this.friendlyName;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java
|
||||
index bef54a6c8290e09cbaac20b03dde8dfb902c96b0..93236dc21f2373983bca1fcfb470690395e7406c 100644
|
||||
--- a/src/main/java/org/bukkit/World.java
|
||||
+++ b/src/main/java/org/bukkit/World.java
|
||||
@@ -205,6 +205,10 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
|
||||
return new Location(this, x, y, z);
|
||||
}
|
||||
// Paper end
|
||||
+ // Sakura start
|
||||
+ @NotNull
|
||||
+ me.samsuik.sakura.local.storage.LocalStorageHandler getStorageHandler();
|
||||
+ // Sakura end
|
||||
|
||||
/**
|
||||
* Gets the highest non-empty (impassable) block at the given coordinates.
|
||||
23
migrate/api/0007-Entity-tracking-range-modifier.patch
Normal file
23
migrate/api/0007-Entity-tracking-range-modifier.patch
Normal file
@@ -0,0 +1,23 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Samsuik <kfian294ma4@gmail.com>
|
||||
Date: Tue, 18 Jun 2024 13:34:39 +0100
|
||||
Subject: [PATCH] Entity tracking range modifier
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java
|
||||
index 5b95970ff306212a71e0f880a4968fe36243202b..9fd8f198acf87eb2ed613a54057536bf46032953 100644
|
||||
--- a/src/main/java/org/bukkit/entity/Player.java
|
||||
+++ b/src/main/java/org/bukkit/entity/Player.java
|
||||
@@ -70,6 +70,12 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
|
||||
VisibilitySettings getVisibility();
|
||||
// Sakura end
|
||||
|
||||
+ // Sakura start - entity tracking range modifier
|
||||
+ double getTrackingRangeModifier();
|
||||
+
|
||||
+ void setTrackingRangeModifier(double mod);
|
||||
+ // Sakura end - entity tracking range modifier
|
||||
+
|
||||
// Paper start
|
||||
@Override
|
||||
default net.kyori.adventure.identity.@NotNull Identity identity() {
|
||||
Reference in New Issue
Block a user