Skip to content

Commit

Permalink
Updated Upstream (Gale/Purpur)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreeam-qwq committed May 9, 2024
1 parent fd42ea1 commit c24bd64
Show file tree
Hide file tree
Showing 10 changed files with 92 additions and 45 deletions.
1 change: 0 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ subprojects {
maven("https://hub.spigotmc.org/nexus/content/groups/public/")
maven("https://jitpack.io")
maven("https://repo.codemc.io/repository/maven-public/")
maven("https://s01.oss.sonatype.org/content/repositories/snapshots/") // TODO - Adventure snapshot
}
}

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
group = cn.dreeam.leaf
version = 1.20.6-R0.1-SNAPSHOT

galeCommit = 0e950b05e9b6c44bcb0b8f6e7073a40562b03733
galeCommit = 7bede3340526bc44ba04a743e11529feaea9aa45

org.gradle.caching = true
org.gradle.parallel = true
Expand Down
2 changes: 1 addition & 1 deletion patches/api/0003-Purpur-API-Changes.patch
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Subject: [PATCH] Purpur API Changes
Original license: MIT
Original project: https://github.com/PurpurMC/Purpur

Commit: e1a0fc3b6a3cde39edd367884480df9a583b63b7
Commit: 8aa793450315a361548f5e1dce4edf18e606bf51

Patches below are removed in this patch:
Pufferfish-API-Changes.patch
Expand Down
8 changes: 4 additions & 4 deletions patches/api/0005-Bump-Dependencies.patch
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ Subject: [PATCH] Bump Dependencies


diff --git a/build.gradle.kts b/build.gradle.kts
index a085f6fa2cfb3721752b38096a2c35fcdd114d02..b3410e3fcead1deec4c052bf813a243f55b3b0cd 100644
index 03ea85ce7d8724518ae0e07dcc6495e99f38f67c..01fd7ac998aef82923efc54c3341e46b2f19235c 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -12,8 +12,10 @@ java {
val annotationsVersion = "24.1.0"
val bungeeCordChatVersion = "1.20-R0.2"
val adventureVersion = "4.17.0-SNAPSHOT"
val adventureVersion = "4.17.0"
-val slf4jVersion = "2.0.9"
-val log4jVersion = "2.17.1"
+// Leaf start - Bump Dependencies
Expand Down Expand Up @@ -94,8 +94,8 @@ index a085f6fa2cfb3721752b38096a2c35fcdd114d02..b3410e3fcead1deec4c052bf813a243f
// Paper end
// Paper start
@@ -159,9 +165,9 @@ tasks.withType<Javadoc> {
//"https://jd.advntr.dev/text-serializer-plain/$adventureVersion/",
//"https://jd.advntr.dev/text-logger-slf4j/$adventureVersion/",
"https://jd.advntr.dev/text-serializer-plain/$adventureVersion/",
"https://jd.advntr.dev/text-logger-slf4j/$adventureVersion/",
"https://javadoc.io/doc/org.slf4j/slf4j-api/$slf4jVersion/",
- "https://javadoc.io/doc/org.apache.logging.log4j/log4j-api/$log4jVersion/",
+ "https://javadoc.io/doc/org.apache.logging.log4j/log4j-api/2.20.0", // Leaf - Bump Dependencies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Subject: [PATCH] Purpur generated-api Changes
Original license: MIT
Original project: https://github.com/PurpurMC/Purpur

Commit: e1a0fc3b6a3cde39edd367884480df9a583b63b7
Commit: 8aa793450315a361548f5e1dce4edf18e606bf51

diff --git a/com/destroystokyo/paper/entity/ai/VanillaGoal.java b/com/destroystokyo/paper/entity/ai/VanillaGoal.java
index 43f4deacef349502cbb207aafc4f9cb7a75177c5..6b692c24a62e2172116a6b9c371b1c0e2411c27e 100644
Expand Down
86 changes: 67 additions & 19 deletions patches/server/0010-Purpur-Server-Changes.patch
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Fix-pufferfish-issues.patch
Original license: MIT
Original project: https://github.com/PurpurMC/Purpur

Commit: e1a0fc3b6a3cde39edd367884480df9a583b63b7
Commit: 8aa793450315a361548f5e1dce4edf18e606bf51

Patches below are removed in this patch:
Metrics changes in Purpur-config-files.patch
Expand All @@ -32,7 +32,7 @@ Remove-Mojang-Profiler.patch
MC-121706-Fix-mobs-not-looking-up-and-down-when-stra.patch

diff --git a/build.gradle.kts b/build.gradle.kts
index 663d5bfd7c541a193a1636e6f6f8ae5b656b080b..2e0bb52941718f4ae2600e293bbe4126d0889f40 100644
index f9dc6deb2e5e94bfd4aff747699a90423c4391a1..aa9098d9a86ccac64777aeba875d724a6691c588 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -63,6 +63,12 @@ dependencies {
Expand Down Expand Up @@ -712,7 +712,7 @@ index bbeb88843f210abdf1cafed11394380cfcab0e09..e68ecaf8d60517fe6398338702a7a796
Bootstrap.bootStrap();
Bootstrap.validate();
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index fffe9e1c307e83b0dcb6c40bf0820f9f9f5c4528..0b4f7dcb082e758cfdce646c61175a48c0c1f5ec 100644
index fffe9e1c307e83b0dcb6c40bf0820f9f9f5c4528..05725e2aed4ad03685bdadbf3bb898da3e62c1b7 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -285,6 +285,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
Expand Down Expand Up @@ -756,15 +756,32 @@ index fffe9e1c307e83b0dcb6c40bf0820f9f9f5c4528..0b4f7dcb082e758cfdce646c61175a48
this.isRestarting = isRestarting;
this.hasLoggedStop = true; // Paper - Debugging
if (isDebugging()) io.papermc.paper.util.TraceUtil.dumpTraceForThread("Server stopped"); // Paper - Debugging
@@ -1212,6 +1225,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -1170,6 +1183,16 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
}
// Paper end - Add onboarding message for initial server start

+ // Purpur start
+ if (!Boolean.getBoolean("Purpur.IReallyDontWantStartupCommands") && !org.purpurmc.purpur.PurpurConfig.startupCommands.isEmpty()) {
+ LOGGER.info("Purpur: Running startup commands specified in purpur.yml.");
+ for (final String startupCommand : org.purpurmc.purpur.PurpurConfig.startupCommands) {
+ LOGGER.info("Purpur: Running the following command: \"{}\"", startupCommand);
+ ((DedicatedServer) this).handleConsoleInput(startupCommand, this.createCommandSourceStack());
+ }
+ }
+ // Purpur end
+
while (this.running) {
// Paper start - rewrite chunk system
// guarantee that nothing can stop the server from halting if it can at least still tick
@@ -1212,6 +1235,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
this.recentTps[0] = tps1.getAverage();
this.recentTps[1] = tps5.getAverage();
this.recentTps[2] = tps15.getAverage();
+ lagging = recentTps[0] < org.purpurmc.purpur.PurpurConfig.laggingThreshold; // Purpur
tickSection = currentTime;
}
// Paper end - further improve server tick loop
@@ -1229,6 +1243,12 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -1229,6 +1253,12 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
lastTickProperTime = (System.nanoTime() - tickProperStart) / 1000000L; // Gale - YAPFA - last tick time
this.mayHaveDelayedTasks = true;
this.delayedTasksMaxNextTickTimeNanos = Math.max(Util.getNanos() + i, this.nextTickTimeNanos);
Expand All @@ -777,7 +794,7 @@ index fffe9e1c307e83b0dcb6c40bf0820f9f9f5c4528..0b4f7dcb082e758cfdce646c61175a48
this.startMeasuringTaskExecutionTime();
this.waitUntilNextTick();
this.finishMeasuringTaskExecutionTime();
@@ -1725,7 +1745,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -1725,7 +1755,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
long worldTime = level.getGameTime();
final ClientboundSetTimePacket worldPacket = new ClientboundSetTimePacket(worldTime, dayTime, doDaylight);
for (Player entityhuman : level.players()) {
Expand All @@ -786,7 +803,7 @@ index fffe9e1c307e83b0dcb6c40bf0820f9f9f5c4528..0b4f7dcb082e758cfdce646c61175a48
continue;
}
ServerPlayer entityplayer = (ServerPlayer) entityhuman;
@@ -1746,6 +1766,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -1746,6 +1776,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
worldserver.hasEntityMoveEvent = io.papermc.paper.event.entity.EntityMoveEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper - Add EntityMoveEvent
net.minecraft.world.level.block.entity.HopperBlockEntity.skipHopperEvents = worldserver.paperConfig().hopper.disableMoveEvent || org.bukkit.event.inventory.InventoryMoveItemEvent.getHandlerList().getRegisteredListeners().length == 0; // Paper - Perf: Optimize Hoppers
worldserver.updateLagCompensationTick(); // Paper - lag compensation
Expand Down Expand Up @@ -13748,15 +13765,12 @@ index eb74d45ad458b80cf8455297c3bc550186adaea3..ef01856c487e4ab982996e0153761823
return InteractionResultHolder.fail(itemstack);
} else {
diff --git a/src/main/java/net/minecraft/world/item/BowItem.java b/src/main/java/net/minecraft/world/item/BowItem.java
index 5ca843df5b4caa668953e5e36a9b20fabeb35046..ff39d3614f360918d74b54b817bc227f89d34c9c 100644
index 5ca843df5b4caa668953e5e36a9b20fabeb35046..8bca38ec152f9612298bf6b3e10e7e0566ec3b78 100644
--- a/src/main/java/net/minecraft/world/item/BowItem.java
+++ b/src/main/java/net/minecraft/world/item/BowItem.java
@@ -29,9 +29,9 @@ public class BowItem extends ProjectileWeaponItem {
int i = this.getUseDuration(stack) - remainingUseTicks;
float f = getPowerForTime(i);
@@ -31,7 +31,7 @@ public class BowItem extends ProjectileWeaponItem {
if (!((double)f < 0.1)) {
- List<ItemStack> list = draw(stack, itemStack, player);
+ List<ItemStack> list = draw(stack, itemStack, player, !((itemStack.is(Items.ARROW) && world.purpurConfig.infinityWorksWithNormalArrows) || (itemStack.is(Items.TIPPED_ARROW) && world.purpurConfig.infinityWorksWithTippedArrows) || (itemStack.is(Items.SPECTRAL_ARROW) && world.purpurConfig.infinityWorksWithSpectralArrows)));
List<ItemStack> list = draw(stack, itemStack, player);
if (!world.isClientSide() && !list.isEmpty()) {
- this.shoot(world, player, player.getUsedItemHand(), stack, list, f * 3.0F, 1.0F, f == 1.0F, null);
+ this.shoot(world, player, player.getUsedItemHand(), stack, list, f * 3.0F, (float) world.purpurConfig.bowProjectileOffset, f == 1.0F, null); // Purpur
Expand All @@ -13768,7 +13782,7 @@ index 5ca843df5b4caa668953e5e36a9b20fabeb35046..ff39d3614f360918d74b54b817bc227f
ItemStack itemStack = user.getItemInHand(hand);
boolean bl = !user.getProjectile(itemStack).isEmpty();
- if (!user.hasInfiniteMaterials() && !bl) {
+ if (!(world.purpurConfig.infinityWorksWithoutArrows && net.minecraft.world.item.enchantment.EnchantmentHelper.getItemEnchantmentLevel(net.minecraft.world.item.enchantment.Enchantments.INFINITY, itemStack) > 0) && !user.hasInfiniteMaterials() && !bl) {
+ if (!(world.purpurConfig.infinityWorksWithoutArrows && net.minecraft.world.item.enchantment.EnchantmentHelper.getItemEnchantmentLevel(net.minecraft.world.item.enchantment.Enchantments.INFINITY, itemStack) > 0) && !user.hasInfiniteMaterials() && !bl) { // Purpur
return InteractionResultHolder.fail(itemStack);
} else {
user.startUsingItem(hand);
Expand Down Expand Up @@ -14119,10 +14133,10 @@ index 774c982f28b4f127fc3f036c19dfb47fb9ae3264..d49b60e7e643498b49c03593dc0da2f8
// Paper end - Add PlayerNameEntityEvent
mob.setPersistenceRequired();
diff --git a/src/main/java/net/minecraft/world/item/ProjectileWeaponItem.java b/src/main/java/net/minecraft/world/item/ProjectileWeaponItem.java
index d27e83c08c45b8514207f26e48ceb1a91ded94be..8f01772a7b06b2acf96a3f922cb9b481f634680b 100644
index d27e83c08c45b8514207f26e48ceb1a91ded94be..4f352c48007107e1306147310eec53ae17b2d9f0 100644
--- a/src/main/java/net/minecraft/world/item/ProjectileWeaponItem.java
+++ b/src/main/java/net/minecraft/world/item/ProjectileWeaponItem.java
@@ -131,6 +131,14 @@ public abstract class ProjectileWeaponItem extends Item {
@@ -131,11 +131,26 @@ public abstract class ProjectileWeaponItem extends Item {
entityarrow.setPierceLevel((byte) k);
}

Expand All @@ -14137,6 +14151,28 @@ index d27e83c08c45b8514207f26e48ceb1a91ded94be..8f01772a7b06b2acf96a3f922cb9b481
return entityarrow;
}

protected static boolean hasInfiniteArrows(ItemStack weaponStack, ItemStack projectileStack, boolean creative) {
- return creative || projectileStack.is(Items.ARROW) && EnchantmentHelper.getItemEnchantmentLevel(Enchantments.INFINITY, weaponStack) > 0;
+ // Purpur start
+ return hasInfiniteArrows(weaponStack, projectileStack, creative, null);
+ }
+
+ protected static boolean hasInfiniteArrows(ItemStack weaponStack, ItemStack projectileStack, boolean creative, @javax.annotation.Nullable Level level) {
+ boolean canBeInfinity = level == null ? projectileStack.is(Items.ARROW) : ((projectileStack.is(Items.ARROW) && level.purpurConfig.infinityWorksWithNormalArrows) || (projectileStack.is(Items.TIPPED_ARROW) && level.purpurConfig.infinityWorksWithTippedArrows) || (projectileStack.is(Items.SPECTRAL_ARROW) && level.purpurConfig.infinityWorksWithSpectralArrows));
+ return creative || canBeInfinity && EnchantmentHelper.getItemEnchantmentLevel(Enchantments.INFINITY, weaponStack) > 0;
+ // Purpur end
}

protected static List<ItemStack> draw(ItemStack weaponStack, ItemStack projectileStack, LivingEntity shooter) {
@@ -161,7 +176,7 @@ public abstract class ProjectileWeaponItem extends Item {
}

protected static ItemStack useAmmo(ItemStack weaponStack, ItemStack projectileStack, LivingEntity shooter, boolean multishot) {
- boolean flag1 = !multishot && !ProjectileWeaponItem.hasInfiniteArrows(weaponStack, projectileStack, shooter.hasInfiniteMaterials());
+ boolean flag1 = !multishot && !ProjectileWeaponItem.hasInfiniteArrows(weaponStack, projectileStack, shooter.hasInfiniteMaterials(), shooter.level()); // Purpur
ItemStack itemstack2;

if (!flag1) {
diff --git a/src/main/java/net/minecraft/world/item/ShovelItem.java b/src/main/java/net/minecraft/world/item/ShovelItem.java
index 24f6a158e4759aac3be8da4cf5e0d40bd295355b..6b7dbb570f8a698c87c6bce992d84d87b55176e6 100644
--- a/src/main/java/net/minecraft/world/item/ShovelItem.java
Expand Down Expand Up @@ -17870,10 +17906,10 @@ index 52649f82351ab4f675c3cc3cd6640956b0f76b91..eb51c88c7a0658190d3a8bfd5d18dca7
DefaultPermissions.registerPermission(CommandPermissions.PREFIX + "seed", "Allows the user to view the seed of the world", PermissionDefault.OP, commands);
diff --git a/src/main/java/org/purpurmc/purpur/PurpurConfig.java b/src/main/java/org/purpurmc/purpur/PurpurConfig.java
new file mode 100644
index 0000000000000000000000000000000000000000..8facd29bac314d4b8897113460f78ea7ed3e82b6
index 0000000000000000000000000000000000000000..eaa8b63b0fb1f0ebefba9014cfec7f1065332171
--- /dev/null
+++ b/src/main/java/org/purpurmc/purpur/PurpurConfig.java
@@ -0,0 +1,570 @@
@@ -0,0 +1,582 @@
+package org.purpurmc.purpur;
+
+import com.google.common.base.Throwables;
Expand Down Expand Up @@ -18023,7 +18059,7 @@ index 0000000000000000000000000000000000000000..8facd29bac314d4b8897113460f78ea7
+ return config.getInt(path, config.getInt(path));
+ }
+
+ private static <T> List getList(String path, T def) {
+ private static <T> List<?> getList(String path, T def) {
+ config.addDefault(path, def);
+ return config.getList(path, config.getList(path));
+ }
Expand Down Expand Up @@ -18443,6 +18479,18 @@ index 0000000000000000000000000000000000000000..8facd29bac314d4b8897113460f78ea7
+ private static void registerMinecraftDebugCommands() {
+ registerMinecraftDebugCommands = getBoolean("settings.register-minecraft-debug-commands", registerMinecraftDebugCommands);
+ }
+
+ public static List<String> startupCommands = new ArrayList<>();
+ private static void startupCommands() {
+ startupCommands.clear();
+ getList("settings.startup-commands", new ArrayList<String>()).forEach(line -> {
+ String command = line.toString();
+ if (command.startsWith("/")) {
+ command = command.substring(1);
+ }
+ startupCommands.add(command);
+ });
+ }
+}
diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
new file mode 100644
Expand Down
4 changes: 2 additions & 2 deletions patches/server/0011-Fix-Pufferfish-and-Purpur-patches.patch
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Subject: [PATCH] Fix Pufferfish and Purpur patches


diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 0b4f7dcb082e758cfdce646c61175a48c0c1f5ec..dea8fef7abe8cfb7dabd8ae4aad748134f7bd47f 100644
index 05725e2aed4ad03685bdadbf3bb898da3e62c1b7..367180dee333b071cfed805356b1def5201efaa9 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -296,7 +296,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
Expand Down Expand Up @@ -34,7 +34,7 @@ index 0b4f7dcb082e758cfdce646c61175a48c0c1f5ec..dea8fef7abe8cfb7dabd8ae4aad74813
// CraftBukkit start
if (this.server != null) {
this.server.disablePlugins();
@@ -1222,9 +1223,12 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -1232,9 +1233,12 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
tps15.add(currentTps, diff);

// Backwards compat with bad plugins
Expand Down
4 changes: 2 additions & 2 deletions patches/server/0012-Purpur-Configurable-server-mod-name.patch
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ Original license: MIT
Original project: https://github.com/PurpurMC/Purpur

diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index dea8fef7abe8cfb7dabd8ae4aad748134f7bd47f..20ec096a3a466f3b97e1723ffc5cc96848ce23e3 100644
index 367180dee333b071cfed805356b1def5201efaa9..9b6e36894f545670c4581a8c8452c183336adf93 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1913,7 +1913,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -1923,7 +1923,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa

@DontObfuscate
public String getServerModName() {
Expand Down
Loading

0 comments on commit c24bd64

Please sign in to comment.