Start working on 1.19.4
This commit is contained in:
parent
155aa36d89
commit
2ed604cf72
1390 changed files with 238 additions and 262 deletions
172
patches/unapplied/server/0002-Remap-fixes.patch
Normal file
172
patches/unapplied/server/0002-Remap-fixes.patch
Normal file
|
@ -0,0 +1,172 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Kyle Wood <kyle@denwav.dev>
|
||||
Date: Fri, 11 Jun 2021 05:25:03 -0500
|
||||
Subject: [PATCH] Remap fixes
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/core/BlockPos.java b/src/main/java/net/minecraft/core/BlockPos.java
|
||||
index 954cf20fb9fbf331fe6314590a3edbe73118ceca..d4c46f44f7a998121482c2fc56d7986881d489d8 100644
|
||||
--- a/src/main/java/net/minecraft/core/BlockPos.java
|
||||
+++ b/src/main/java/net/minecraft/core/BlockPos.java
|
||||
@@ -274,9 +274,11 @@ public class BlockPos extends Vec3i {
|
||||
|
||||
public static Iterable<BlockPos> withinManhattan(BlockPos center, int rangeX, int rangeY, int rangeZ) {
|
||||
int i = rangeX + rangeY + rangeZ;
|
||||
- int j = center.getX();
|
||||
- int k = center.getY();
|
||||
- int l = center.getZ();
|
||||
+ // Paper start - rename variables to fix conflict with anonymous class (remap fix)
|
||||
+ int centerX = center.getX();
|
||||
+ int centerY = center.getY();
|
||||
+ int centerZ = center.getZ();
|
||||
+ // Paper end
|
||||
return () -> {
|
||||
return new AbstractIterator<BlockPos>() {
|
||||
private final BlockPos.MutableBlockPos cursor = new BlockPos.MutableBlockPos();
|
||||
@@ -291,7 +293,7 @@ public class BlockPos extends Vec3i {
|
||||
protected BlockPos computeNext() {
|
||||
if (this.zMirror) {
|
||||
this.zMirror = false;
|
||||
- this.cursor.setZ(l - (this.cursor.getZ() - l));
|
||||
+ this.cursor.setZ(centerZ - (this.cursor.getZ() - centerZ)); // Paper - remap fix
|
||||
return this.cursor;
|
||||
} else {
|
||||
BlockPos blockPos;
|
||||
@@ -317,7 +319,7 @@ public class BlockPos extends Vec3i {
|
||||
int k = this.currentDepth - Math.abs(i) - Math.abs(j);
|
||||
if (k <= rangeZ) {
|
||||
this.zMirror = k != 0;
|
||||
- blockPos = this.cursor.set(j + i, k + j, l + k);
|
||||
+ blockPos = this.cursor.set(centerX + i, centerY + j, centerZ + k); // Paper - remap fix
|
||||
}
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
index b1ecaf47486eaa876e2286eae894b47ecf3a0849..01438ee9ad7a64ac4fd124d97029f87b49c25d5d 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
@@ -1419,9 +1419,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
LevelChunk chunk1;
|
||||
|
||||
if (chunk instanceof LevelChunk) {
|
||||
- LevelChunk chunk1 = (LevelChunk) chunk;
|
||||
-
|
||||
- chunk1 = chunk1;
|
||||
+ chunk1 = (LevelChunk) chunk; // Paper - remap fix
|
||||
} else {
|
||||
chunk1 = this.level.getChunk(chunkcoordintpair.x, chunkcoordintpair.z);
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/BehaviorUtils.java b/src/main/java/net/minecraft/world/entity/ai/behavior/BehaviorUtils.java
|
||||
index 8f0a2f8d3a34c6b97bc7a933272ccf2689576c76..b9fcff8862e624644fdb73afcb3ef2106b0a76fc 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/behavior/BehaviorUtils.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/BehaviorUtils.java
|
||||
@@ -173,11 +173,11 @@ public class BehaviorUtils {
|
||||
|
||||
return optional.map((uuid) -> {
|
||||
return ((ServerLevel) entity.level).getEntity(uuid);
|
||||
- }).map((entity) -> {
|
||||
+ }).map((entity1) -> { // Paper - remap fix
|
||||
LivingEntity entityliving1;
|
||||
|
||||
- if (entity instanceof LivingEntity) {
|
||||
- LivingEntity entityliving2 = (LivingEntity) entity;
|
||||
+ if (entity1 instanceof LivingEntity) { // Paper - remap fix
|
||||
+ LivingEntity entityliving2 = (LivingEntity) entity1; // Paper - remap fix
|
||||
|
||||
entityliving1 = entityliving2;
|
||||
} else {
|
||||
diff --git a/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java b/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java
|
||||
index 0b76584d85194f0b60ed51f577353bfead0489f5..d025df087e7b87fbc89a722226f2f2263c54ac47 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java
|
||||
@@ -192,7 +192,7 @@ public class RecipeManager extends SimpleJsonResourceReloadListener {
|
||||
Builder<ResourceLocation, Recipe<?>> builder = ImmutableMap.builder();
|
||||
|
||||
recipes.forEach((irecipe) -> {
|
||||
- Map<ResourceLocation, Recipe<?>> map1 = (Map) map.computeIfAbsent(irecipe.getType(), (recipes) -> {
|
||||
+ Map<ResourceLocation, Recipe<?>> map1 = (Map) map.computeIfAbsent(irecipe.getType(), (recipes_) -> { // Paper - remap fix
|
||||
return new Object2ObjectLinkedOpenHashMap<>(); // CraftBukkit
|
||||
});
|
||||
ResourceLocation minecraftkey = irecipe.getId();
|
||||
diff --git a/src/test/java/org/bukkit/DyeColorsTest.java b/src/test/java/org/bukkit/DyeColorsTest.java
|
||||
index ad52c3fc6210939a39ef77a382c640a24ee44838..6b7dd01778f0a5d3a96d2d04af4b525d17efbfba 100644
|
||||
--- a/src/test/java/org/bukkit/DyeColorsTest.java
|
||||
+++ b/src/test/java/org/bukkit/DyeColorsTest.java
|
||||
@@ -4,7 +4,6 @@ import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
-import net.minecraft.world.item.DyeColor;
|
||||
import org.bukkit.support.AbstractTestingBase;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -29,7 +28,7 @@ public class DyeColorsTest extends AbstractTestingBase {
|
||||
@Test
|
||||
public void checkColor() {
|
||||
Color color = this.dye.getColor();
|
||||
- float[] nmsColorArray = DyeColor.byId(this.dye.getWoolData()).getTextureDiffuseColors();
|
||||
+ float[] nmsColorArray = net.minecraft.world.item.DyeColor.byId(this.dye.getWoolData()).getTextureDiffuseColors(); // Paper - remap fix
|
||||
Color nmsColor = Color.fromRGB((int) (nmsColorArray[0] * 255), (int) (nmsColorArray[1] * 255), (int) (nmsColorArray[2] * 255));
|
||||
assertThat(color, is(nmsColor));
|
||||
}
|
||||
@@ -37,7 +36,7 @@ public class DyeColorsTest extends AbstractTestingBase {
|
||||
@Test
|
||||
public void checkFireworkColor() {
|
||||
Color color = this.dye.getFireworkColor();
|
||||
- int nmsColor = DyeColor.byId(this.dye.getWoolData()).getFireworkColor();
|
||||
+ int nmsColor = net.minecraft.world.item.DyeColor.byId(this.dye.getWoolData()).getFireworkColor(); // Paper - remap fix
|
||||
assertThat(color, is(Color.fromRGB(nmsColor)));
|
||||
}
|
||||
}
|
||||
diff --git a/src/test/java/org/bukkit/entity/EntityTypesTest.java b/src/test/java/org/bukkit/entity/EntityTypesTest.java
|
||||
index b1de312e902c83a2f95d80040abb9255e64431a9..aafa6f472c82f851fe7f5ae3111488bb732d0bcc 100644
|
||||
--- a/src/test/java/org/bukkit/entity/EntityTypesTest.java
|
||||
+++ b/src/test/java/org/bukkit/entity/EntityTypesTest.java
|
||||
@@ -5,7 +5,6 @@ import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
-import net.minecraft.world.entity.EntityType;
|
||||
import org.bukkit.support.AbstractTestingBase;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
@@ -16,8 +15,8 @@ public class EntityTypesTest extends AbstractTestingBase {
|
||||
public void testMaps() {
|
||||
Set<EntityType> allBukkit = Arrays.stream(EntityType.values()).filter((b) -> b.getName() != null).collect(Collectors.toSet());
|
||||
|
||||
- for (EntityType<?> nms : BuiltInRegistries.ENTITY_TYPE) {
|
||||
- ResourceLocation key = EntityType.getKey(nms);
|
||||
+ for (net.minecraft.world.entity.EntityType<?> nms : BuiltInRegistries.ENTITY_TYPE) { // Paper - remap fix
|
||||
+ ResourceLocation key = net.minecraft.world.entity.EntityType.getKey(nms); // Paper - remap fix
|
||||
|
||||
org.bukkit.entity.EntityType bukkit = org.bukkit.entity.EntityType.fromName(key.getPath());
|
||||
Assert.assertNotNull("Missing nms->bukkit " + key, bukkit);
|
||||
diff --git a/src/test/java/org/bukkit/entity/PandaGeneTest.java b/src/test/java/org/bukkit/entity/PandaGeneTest.java
|
||||
index 76e2ad676ae68846bdff3c3ef711751445fb0f3c..feee17192bca55a9cf1b2fc5b9609b888db77763 100644
|
||||
--- a/src/test/java/org/bukkit/entity/PandaGeneTest.java
|
||||
+++ b/src/test/java/org/bukkit/entity/PandaGeneTest.java
|
||||
@@ -1,6 +1,5 @@
|
||||
package org.bukkit.entity;
|
||||
|
||||
-import net.minecraft.world.entity.animal.Panda;
|
||||
import org.bukkit.craftbukkit.entity.CraftPanda;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
@@ -10,7 +9,7 @@ public class PandaGeneTest {
|
||||
@Test
|
||||
public void testBukkit() {
|
||||
for (Panda.Gene gene : Panda.Gene.values()) {
|
||||
- Panda.Gene nms = CraftPanda.toNms(gene);
|
||||
+ net.minecraft.world.entity.animal.Panda.Gene nms = CraftPanda.toNms(gene); // Paper - remap fix
|
||||
|
||||
Assert.assertNotNull("NMS gene null for " + gene, nms);
|
||||
Assert.assertEquals("Recessive status did not match " + gene, gene.isRecessive(), nms.isRecessive());
|
||||
@@ -20,7 +19,7 @@ public class PandaGeneTest {
|
||||
|
||||
@Test
|
||||
public void testNMS() {
|
||||
- for (Panda.Gene gene : Panda.Gene.values()) {
|
||||
+ for (net.minecraft.world.entity.animal.Panda.Gene gene : net.minecraft.world.entity.animal.Panda.Gene.values()) { // Paper - remap fix
|
||||
org.bukkit.entity.Panda.Gene bukkit = CraftPanda.fromNms(gene);
|
||||
|
||||
Assert.assertNotNull("Bukkit gene null for " + gene, bukkit);
|
94
patches/unapplied/server/0003-Build-system-changes.patch
Normal file
94
patches/unapplied/server/0003-Build-system-changes.patch
Normal file
|
@ -0,0 +1,94 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Zach Brown <zach.brown@destroystokyo.com>
|
||||
Date: Mon, 29 Feb 2016 20:40:33 -0600
|
||||
Subject: [PATCH] Build system changes
|
||||
|
||||
|
||||
diff --git a/build.gradle.kts b/build.gradle.kts
|
||||
index c9950851db38df64fd82a3a549072d240e37d64d..ce176ef04e211b82020fa082b9cb1bdc4769a526 100644
|
||||
--- a/build.gradle.kts
|
||||
+++ b/build.gradle.kts
|
||||
@@ -9,10 +9,9 @@ plugins {
|
||||
dependencies {
|
||||
implementation(project(":paper-api"))
|
||||
implementation("jline:jline:2.12.1")
|
||||
- implementation("org.apache.logging.log4j:log4j-iostreams:2.19.0") {
|
||||
- exclude(group = "org.apache.logging.log4j", module = "log4j-api")
|
||||
- }
|
||||
+ implementation("org.apache.logging.log4j:log4j-iostreams:2.19.0") // Paper - remove exclusion
|
||||
implementation("org.ow2.asm:asm:9.4")
|
||||
+ implementation("org.ow2.asm:asm-commons:9.4") // Paper - ASM event executor generation
|
||||
implementation("commons-lang:commons-lang:2.6")
|
||||
runtimeOnly("org.xerial:sqlite-jdbc:3.36.0.3")
|
||||
runtimeOnly("mysql:mysql-connector-java:8.0.29")
|
||||
@@ -23,6 +22,8 @@ dependencies {
|
||||
|
||||
testImplementation("junit:junit:4.13.2")
|
||||
testImplementation("org.hamcrest:hamcrest-library:1.3")
|
||||
+
|
||||
+ implementation("io.netty:netty-all:4.1.87.Final"); // Paper - Bump netty
|
||||
}
|
||||
|
||||
val craftbukkitPackageVersion = "1_19_R2" // Paper
|
||||
@@ -34,6 +35,7 @@ tasks.jar {
|
||||
val gitHash = git("rev-parse", "--short=7", "HEAD").getText().trim()
|
||||
val implementationVersion = System.getenv("BUILD_NUMBER") ?: "\"$gitHash\""
|
||||
val date = git("show", "-s", "--format=%ci", gitHash).getText().trim() // Paper
|
||||
+ val gitBranch = git("rev-parse", "--abbrev-ref", "HEAD").getText().trim() // Paper
|
||||
attributes(
|
||||
"Main-Class" to "org.bukkit.craftbukkit.Main",
|
||||
"Implementation-Title" to "CraftBukkit",
|
||||
@@ -42,6 +44,9 @@ tasks.jar {
|
||||
"Specification-Title" to "Bukkit",
|
||||
"Specification-Version" to project.version,
|
||||
"Specification-Vendor" to "Bukkit Team",
|
||||
+ "Git-Branch" to gitBranch, // Paper
|
||||
+ "Git-Commit" to gitHash, // Paper
|
||||
+ "CraftBukkit-Package-Version" to craftbukkitPackageVersion, // Paper
|
||||
)
|
||||
for (tld in setOf("net", "com", "org")) {
|
||||
attributes("$tld/bukkit", "Sealed" to true)
|
||||
@@ -75,6 +80,17 @@ tasks.shadowJar {
|
||||
}
|
||||
}
|
||||
|
||||
+// Paper start
|
||||
+val scanJar = tasks.register("scanJarForBadCalls", io.papermc.paperweight.tasks.ScanJarForBadCalls::class) {
|
||||
+ badAnnotations.add("Lio/papermc/paper/annotation/DoNotUse;")
|
||||
+ jarToScan.set(tasks.shadowJar.flatMap { it.archiveFile })
|
||||
+ classpath.from(configurations.compileClasspath)
|
||||
+}
|
||||
+tasks.check {
|
||||
+ dependsOn(scanJar)
|
||||
+}
|
||||
+// Paper end
|
||||
+
|
||||
tasks.test {
|
||||
exclude("org/bukkit/craftbukkit/inventory/ItemStack*Test.class")
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||
index 2e216027fc38fabf3e3e49dbc310ecb648ab63d6..2ae4dbd8cc49efb93ecceeb9a7a08e1a8af1d84a 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||
@@ -192,7 +192,7 @@ public class Main {
|
||||
}
|
||||
|
||||
if (Main.class.getPackage().getImplementationVendor() != null && System.getProperty("IReallyKnowWhatIAmDoingISwear") == null) {
|
||||
- Date buildDate = new Date(Integer.parseInt(Main.class.getPackage().getImplementationVendor()) * 1000L);
|
||||
+ Date buildDate = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z").parse(Main.class.getPackage().getImplementationVendor()); // Paper
|
||||
|
||||
Calendar deadline = Calendar.getInstance();
|
||||
deadline.add(Calendar.DAY_OF_YEAR, -28);
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/util/Versioning.java b/src/main/java/org/bukkit/craftbukkit/util/Versioning.java
|
||||
index 93046379d0cefd5d3236fc59e698809acdc18f80..774556a62eb240da42e84db4502e2ed43495be17 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/util/Versioning.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/util/Versioning.java
|
||||
@@ -11,7 +11,7 @@ public final class Versioning {
|
||||
public static String getBukkitVersion() {
|
||||
String result = "Unknown-Version";
|
||||
|
||||
- InputStream stream = Bukkit.class.getClassLoader().getResourceAsStream("META-INF/maven/org.spigotmc/spigot-api/pom.properties");
|
||||
+ InputStream stream = Bukkit.class.getClassLoader().getResourceAsStream("META-INF/maven/io.papermc.paper/paper-api/pom.properties");
|
||||
Properties properties = new Properties();
|
||||
|
||||
if (stream != null) {
|
281
patches/unapplied/server/0004-Test-changes.patch
Normal file
281
patches/unapplied/server/0004-Test-changes.patch
Normal file
|
@ -0,0 +1,281 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Mon, 13 Feb 2023 14:14:56 -0800
|
||||
Subject: [PATCH] Test changes
|
||||
|
||||
|
||||
diff --git a/build.gradle.kts b/build.gradle.kts
|
||||
index ce176ef04e211b82020fa082b9cb1bdc4769a526..15456e54d8a392e702a30dfb3d06a3f74156dce7 100644
|
||||
--- a/build.gradle.kts
|
||||
+++ b/build.gradle.kts
|
||||
@@ -12,6 +12,7 @@ dependencies {
|
||||
implementation("org.apache.logging.log4j:log4j-iostreams:2.19.0") // Paper - remove exclusion
|
||||
implementation("org.ow2.asm:asm:9.4")
|
||||
implementation("org.ow2.asm:asm-commons:9.4") // Paper - ASM event executor generation
|
||||
+ testImplementation("org.mockito:mockito-core:4.9.0") // Paper - switch to mockito
|
||||
implementation("commons-lang:commons-lang:2.6")
|
||||
runtimeOnly("org.xerial:sqlite-jdbc:3.36.0.3")
|
||||
runtimeOnly("mysql:mysql-connector-java:8.0.29")
|
||||
diff --git a/src/test/java/io/papermc/paper/testing/DummyServer.java b/src/test/java/io/papermc/paper/testing/DummyServer.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..c6503ff76f56bab5f383f0ca17d137155e9be447
|
||||
--- /dev/null
|
||||
+++ b/src/test/java/io/papermc/paper/testing/DummyServer.java
|
||||
@@ -0,0 +1,67 @@
|
||||
+package io.papermc.paper.testing;
|
||||
+
|
||||
+import java.util.logging.Logger;
|
||||
+import org.bukkit.Bukkit;
|
||||
+import org.bukkit.Material;
|
||||
+import org.bukkit.NamespacedKey;
|
||||
+import org.bukkit.Server;
|
||||
+import org.bukkit.command.SimpleCommandMap;
|
||||
+import org.bukkit.craftbukkit.CraftRegistry;
|
||||
+import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftItemFactory;
|
||||
+import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||
+import org.bukkit.craftbukkit.util.CraftNamespacedKey;
|
||||
+import org.bukkit.plugin.PluginManager;
|
||||
+import org.bukkit.plugin.SimplePluginManager;
|
||||
+import org.bukkit.support.AbstractTestingBase;
|
||||
+import org.mockito.Mockito;
|
||||
+
|
||||
+import static org.mockito.Mockito.any;
|
||||
+import static org.mockito.Mockito.mock;
|
||||
+import static org.mockito.Mockito.when;
|
||||
+
|
||||
+public final class DummyServer {
|
||||
+
|
||||
+ @SuppressWarnings({"deprecation", "removal"})
|
||||
+ public static void setup() {
|
||||
+ //noinspection ConstantValue
|
||||
+ if (Bukkit.getServer() != null) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ final Server dummyServer = mock(Server.class, Mockito.withSettings().stubOnly());
|
||||
+
|
||||
+ final Logger logger = Logger.getLogger(DummyServer.class.getCanonicalName());
|
||||
+ when(dummyServer.getLogger()).thenReturn(logger);
|
||||
+ when(dummyServer.getName()).thenReturn(DummyServer.class.getSimpleName());
|
||||
+ when(dummyServer.getVersion()).thenReturn("Version_" + DummyServer.class.getPackage().getImplementationVersion());
|
||||
+ when(dummyServer.getBukkitVersion()).thenReturn("BukkitVersion_" + DummyServer.class.getPackage().getImplementationVersion());
|
||||
+
|
||||
+ final Thread currentThread = Thread.currentThread();
|
||||
+ when(dummyServer.isPrimaryThread()).thenAnswer(ignored -> Thread.currentThread().equals(currentThread));
|
||||
+
|
||||
+ when(dummyServer.getItemFactory()).thenReturn(CraftItemFactory.instance());
|
||||
+
|
||||
+ when(dummyServer.getUnsafe()).thenAnswer(ignored -> CraftMagicNumbers.INSTANCE); // lambda for lazy load
|
||||
+
|
||||
+ when(dummyServer.createBlockData(any(Material.class))).thenAnswer(invocation -> {
|
||||
+ return CraftBlockData.newData(invocation.getArgument(0, Material.class), null);
|
||||
+ });
|
||||
+
|
||||
+ when(dummyServer.getLootTable(any(NamespacedKey.class))).thenAnswer(invocation -> {
|
||||
+ final NamespacedKey key = invocation.getArgument(0, NamespacedKey.class);
|
||||
+ return new org.bukkit.craftbukkit.CraftLootTable(key, AbstractTestingBase.DATA_PACK.getLootTables().get(CraftNamespacedKey.toMinecraft(key)));
|
||||
+ });
|
||||
+
|
||||
+ when(dummyServer.getRegistry(any())).thenAnswer(invocation -> {
|
||||
+ // LazyRegistry because the vanilla data hasn't been bootstrapped yet.
|
||||
+ return new LazyRegistry(() -> CraftRegistry.createRegistry(invocation.getArgument(0, Class.class), AbstractTestingBase.REGISTRY_CUSTOM));
|
||||
+ });
|
||||
+
|
||||
+ final PluginManager pluginManager = new SimplePluginManager(dummyServer, new SimpleCommandMap(dummyServer));
|
||||
+ when(dummyServer.getPluginManager()).thenReturn(pluginManager);
|
||||
+
|
||||
+ Bukkit.setServer(dummyServer);
|
||||
+
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/test/java/io/papermc/paper/testing/LazyRegistry.java b/src/test/java/io/papermc/paper/testing/LazyRegistry.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..8dd0df8c2cc25d37a2590a07872682230a9335f2
|
||||
--- /dev/null
|
||||
+++ b/src/test/java/io/papermc/paper/testing/LazyRegistry.java
|
||||
@@ -0,0 +1,23 @@
|
||||
+package io.papermc.paper.testing;
|
||||
+
|
||||
+import java.util.Iterator;
|
||||
+import java.util.function.Supplier;
|
||||
+import org.bukkit.Keyed;
|
||||
+import org.bukkit.NamespacedKey;
|
||||
+import org.bukkit.Registry;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import org.jetbrains.annotations.Nullable;
|
||||
+
|
||||
+public record LazyRegistry(Supplier<Registry<Keyed>> supplier) implements Registry<Keyed> {
|
||||
+
|
||||
+ @NotNull
|
||||
+ @Override
|
||||
+ public Iterator<Keyed> iterator() {
|
||||
+ return this.supplier().get().iterator();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public @Nullable Keyed get(@NotNull final NamespacedKey key) {
|
||||
+ return this.supplier().get().get(key);
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/test/java/org/bukkit/support/AbstractTestingBase.java b/src/test/java/org/bukkit/support/AbstractTestingBase.java
|
||||
index 492c1ec28a9f1facb117d05245b32231554385ad..8013cc99c063d2ca0c578c093e3112676f5361b7 100644
|
||||
--- a/src/test/java/org/bukkit/support/AbstractTestingBase.java
|
||||
+++ b/src/test/java/org/bukkit/support/AbstractTestingBase.java
|
||||
@@ -2,7 +2,6 @@ package org.bukkit.support;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.util.concurrent.MoreExecutors;
|
||||
-import java.util.Collections;
|
||||
import java.util.List;
|
||||
import net.minecraft.SharedConstants;
|
||||
import net.minecraft.commands.Commands;
|
||||
@@ -49,6 +48,7 @@ public abstract class AbstractTestingBase {
|
||||
LayeredRegistryAccess<RegistryLayer> layers = RegistryLayer.createRegistryAccess();
|
||||
layers = WorldLoader.loadAndReplaceLayer(resourceManager, layers, RegistryLayer.WORLDGEN, RegistryDataLoader.WORLDGEN_REGISTRIES);
|
||||
REGISTRY_CUSTOM = layers.compositeAccess().freeze();
|
||||
+ io.papermc.paper.testing.DummyServer.setup(); // Paper
|
||||
// Register vanilla pack
|
||||
DATA_PACK = ReloadableServerResources.loadResources(resourceManager, REGISTRY_CUSTOM, FeatureFlags.REGISTRY.allFlags(), Commands.CommandSelection.DEDICATED, 0, MoreExecutors.directExecutor(), MoreExecutors.directExecutor()).join();
|
||||
// Bind tags
|
||||
@@ -56,7 +56,6 @@ public abstract class AbstractTestingBase {
|
||||
// Biome shortcut
|
||||
BIOMES = REGISTRY_CUSTOM.registryOrThrow(Registries.BIOME);
|
||||
|
||||
- DummyServer.setup();
|
||||
DummyEnchantments.setup();
|
||||
|
||||
ImmutableList.Builder<Material> builder = ImmutableList.builder();
|
||||
diff --git a/src/test/java/org/bukkit/support/DummyServer.java b/src/test/java/org/bukkit/support/DummyServer.java
|
||||
deleted file mode 100644
|
||||
index 946497353a64421592d2bae012c9a3cb874dd5b8..0000000000000000000000000000000000000000
|
||||
--- a/src/test/java/org/bukkit/support/DummyServer.java
|
||||
+++ /dev/null
|
||||
@@ -1,127 +0,0 @@
|
||||
-package org.bukkit.support;
|
||||
-
|
||||
-import java.lang.reflect.InvocationHandler;
|
||||
-import java.lang.reflect.Method;
|
||||
-import java.lang.reflect.Proxy;
|
||||
-import java.util.HashMap;
|
||||
-import java.util.logging.Logger;
|
||||
-import org.bukkit.Bukkit;
|
||||
-import org.bukkit.Material;
|
||||
-import org.bukkit.NamespacedKey;
|
||||
-import org.bukkit.Server;
|
||||
-import org.bukkit.craftbukkit.CraftLootTable;
|
||||
-import org.bukkit.craftbukkit.CraftRegistry;
|
||||
-import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
||||
-import org.bukkit.craftbukkit.inventory.CraftItemFactory;
|
||||
-import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||
-import org.bukkit.craftbukkit.util.CraftNamespacedKey;
|
||||
-import org.bukkit.craftbukkit.util.Versioning;
|
||||
-
|
||||
-public final class DummyServer implements InvocationHandler {
|
||||
- private static interface MethodHandler {
|
||||
- Object handle(DummyServer server, Object[] args);
|
||||
- }
|
||||
- private static final HashMap<Method, MethodHandler> methods = new HashMap<Method, MethodHandler>();
|
||||
- static {
|
||||
- try {
|
||||
- methods.put(
|
||||
- Server.class.getMethod("getItemFactory"),
|
||||
- new MethodHandler() {
|
||||
- @Override
|
||||
- public Object handle(DummyServer server, Object[] args) {
|
||||
- return CraftItemFactory.instance();
|
||||
- }
|
||||
- }
|
||||
- );
|
||||
- methods.put(
|
||||
- Server.class.getMethod("getName"),
|
||||
- new MethodHandler() {
|
||||
- @Override
|
||||
- public Object handle(DummyServer server, Object[] args) {
|
||||
- return DummyServer.class.getName();
|
||||
- }
|
||||
- }
|
||||
- );
|
||||
- methods.put(
|
||||
- Server.class.getMethod("getVersion"),
|
||||
- new MethodHandler() {
|
||||
- @Override
|
||||
- public Object handle(DummyServer server, Object[] args) {
|
||||
- return DummyServer.class.getPackage().getImplementationVersion();
|
||||
- }
|
||||
- }
|
||||
- );
|
||||
- methods.put(
|
||||
- Server.class.getMethod("getBukkitVersion"),
|
||||
- new MethodHandler() {
|
||||
- @Override
|
||||
- public Object handle(DummyServer server, Object[] args) {
|
||||
- return Versioning.getBukkitVersion();
|
||||
- }
|
||||
- }
|
||||
- );
|
||||
- methods.put(
|
||||
- Server.class.getMethod("getLogger"),
|
||||
- new MethodHandler() {
|
||||
- final Logger logger = Logger.getLogger(DummyServer.class.getCanonicalName());
|
||||
- @Override
|
||||
- public Object handle(DummyServer server, Object[] args) {
|
||||
- return logger;
|
||||
- }
|
||||
- }
|
||||
- );
|
||||
- methods.put(
|
||||
- Server.class.getMethod("getUnsafe"),
|
||||
- new MethodHandler() {
|
||||
- @Override
|
||||
- public Object handle(DummyServer server, Object[] args) {
|
||||
- return CraftMagicNumbers.INSTANCE;
|
||||
- }
|
||||
- }
|
||||
- );
|
||||
- methods.put(
|
||||
- Server.class.getMethod("createBlockData", Material.class),
|
||||
- new MethodHandler() {
|
||||
- final Logger logger = Logger.getLogger(DummyServer.class.getCanonicalName());
|
||||
- @Override
|
||||
- public Object handle(DummyServer server, Object[] args) {
|
||||
- return CraftBlockData.newData((Material) args[0], null);
|
||||
- }
|
||||
- }
|
||||
- );
|
||||
- methods.put(Server.class.getMethod("getLootTable", NamespacedKey.class),
|
||||
- new MethodHandler() {
|
||||
- @Override
|
||||
- public Object handle(DummyServer server, Object[] args) {
|
||||
- NamespacedKey key = (NamespacedKey) args[0];
|
||||
- return new CraftLootTable(key, AbstractTestingBase.DATA_PACK.getLootTables().get(CraftNamespacedKey.toMinecraft(key)));
|
||||
- }
|
||||
- }
|
||||
- );
|
||||
- methods.put(Server.class.getMethod("getRegistry", Class.class),
|
||||
- new MethodHandler() {
|
||||
- @Override
|
||||
- public Object handle(DummyServer server, Object[] args) {
|
||||
- return CraftRegistry.createRegistry((Class) args[0], AbstractTestingBase.REGISTRY_CUSTOM);
|
||||
- }
|
||||
- }
|
||||
- );
|
||||
- Bukkit.setServer(Proxy.getProxyClass(Server.class.getClassLoader(), Server.class).asSubclass(Server.class).getConstructor(InvocationHandler.class).newInstance(new DummyServer()));
|
||||
- } catch (Throwable t) {
|
||||
- throw new Error(t);
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- public static void setup() {}
|
||||
-
|
||||
- private DummyServer() {};
|
||||
-
|
||||
- @Override
|
||||
- public Object invoke(Object proxy, Method method, Object[] args) {
|
||||
- MethodHandler handler = DummyServer.methods.get(method);
|
||||
- if (handler != null) {
|
||||
- return handler.handle(this, args);
|
||||
- }
|
||||
- throw new UnsupportedOperationException(String.valueOf(method));
|
||||
- }
|
||||
-}
|
4673
patches/unapplied/server/0005-Paper-config-files.patch
Normal file
4673
patches/unapplied/server/0005-Paper-config-files.patch
Normal file
File diff suppressed because it is too large
Load diff
224
patches/unapplied/server/0006-MC-Dev-fixes.patch
Normal file
224
patches/unapplied/server/0006-MC-Dev-fixes.patch
Normal file
|
@ -0,0 +1,224 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Wed, 30 Mar 2016 19:36:20 -0400
|
||||
Subject: [PATCH] MC Dev fixes
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/Util.java b/src/main/java/net/minecraft/Util.java
|
||||
index d33cce0265a85a23d726742e7752331b63449144..dc7a805d3058244ba13c2268666f274e7ec069dc 100644
|
||||
--- a/src/main/java/net/minecraft/Util.java
|
||||
+++ b/src/main/java/net/minecraft/Util.java
|
||||
@@ -370,7 +370,7 @@ public class Util {
|
||||
}
|
||||
|
||||
public static <K> Hash.Strategy<K> identityStrategy() {
|
||||
- return Util.IdentityStrategy.INSTANCE;
|
||||
+ return (Hash.Strategy<K>) Util.IdentityStrategy.INSTANCE; // Paper - decompile fix
|
||||
}
|
||||
|
||||
public static <V> CompletableFuture<List<V>> sequence(List<? extends CompletableFuture<V>> futures) {
|
||||
diff --git a/src/main/java/net/minecraft/core/BlockPos.java b/src/main/java/net/minecraft/core/BlockPos.java
|
||||
index d4c46f44f7a998121482c2fc56d7986881d489d8..6801a3aa5f2f1e9a7a72ff81c09b4944ecb8349d 100644
|
||||
--- a/src/main/java/net/minecraft/core/BlockPos.java
|
||||
+++ b/src/main/java/net/minecraft/core/BlockPos.java
|
||||
@@ -379,12 +379,12 @@ public class BlockPos extends Vec3i {
|
||||
if (this.index == l) {
|
||||
return this.endOfData();
|
||||
} else {
|
||||
- int i = this.index % i;
|
||||
- int j = this.index / i;
|
||||
- int k = j % j;
|
||||
- int l = j / j;
|
||||
+ int offsetX = this.index % i; // Paper - decomp fix
|
||||
+ int u = this.index / i; // Paper - decomp fix
|
||||
+ int offsetY = u % j; // Paper - decomp fix
|
||||
+ int offsetZ = u / j; // Paper - decomp fix
|
||||
++this.index;
|
||||
- return this.cursor.set(startX + i, startY + k, startZ + l);
|
||||
+ return this.cursor.set(startX + offsetX, startY + offsetY, startZ + offsetZ); // Paper - decomp fix
|
||||
}
|
||||
}
|
||||
};
|
||||
diff --git a/src/main/java/net/minecraft/core/registries/BuiltInRegistries.java b/src/main/java/net/minecraft/core/registries/BuiltInRegistries.java
|
||||
index 3233f69345838af653b4259d2142169930533a69..5b8ecf5b0165ed2cd4397cdee958e97c2e8f18d5 100644
|
||||
--- a/src/main/java/net/minecraft/core/registries/BuiltInRegistries.java
|
||||
+++ b/src/main/java/net/minecraft/core/registries/BuiltInRegistries.java
|
||||
@@ -305,7 +305,7 @@ public class BuiltInRegistries {
|
||||
LOADERS.put(resourceLocation, () -> {
|
||||
return initializer.run(registry);
|
||||
});
|
||||
- WRITABLE_REGISTRY.register(key, registry, lifecycle);
|
||||
+ WRITABLE_REGISTRY.register((ResourceKey) key, registry, lifecycle); // Paper - decompile fix
|
||||
return registry;
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/nbt/NbtUtils.java b/src/main/java/net/minecraft/nbt/NbtUtils.java
|
||||
index 24e864d1cd376e9f94cfa68fd06f96b239eed888..c0fe7c576f2361e599bc23003da7c49bb7cb62b2 100644
|
||||
--- a/src/main/java/net/minecraft/nbt/NbtUtils.java
|
||||
+++ b/src/main/java/net/minecraft/nbt/NbtUtils.java
|
||||
@@ -505,7 +505,7 @@ public final class NbtUtils {
|
||||
}
|
||||
|
||||
public static CompoundTag update(DataFixer fixer, DataFixTypes fixTypes, CompoundTag compound, int oldVersion, int targetVersion) {
|
||||
- return fixer.update(fixTypes.getType(), new Dynamic<>(NbtOps.INSTANCE, compound), oldVersion, targetVersion).getValue();
|
||||
+ return (CompoundTag) fixer.update(fixTypes.getType(), new Dynamic<>(NbtOps.INSTANCE, compound), oldVersion, targetVersion).getValue(); // Paper - decompile fix
|
||||
}
|
||||
|
||||
public static Component toPrettyComponent(Tag element) {
|
||||
diff --git a/src/main/java/net/minecraft/network/chat/ComponentUtils.java b/src/main/java/net/minecraft/network/chat/ComponentUtils.java
|
||||
index 2df8fa1ae2dc58291add80fae0599ee4ff5066ee..ed7e1a6fc745df745d5bc79623948bb1015c9252 100644
|
||||
--- a/src/main/java/net/minecraft/network/chat/ComponentUtils.java
|
||||
+++ b/src/main/java/net/minecraft/network/chat/ComponentUtils.java
|
||||
@@ -138,8 +138,7 @@ public class ComponentUtils {
|
||||
ComponentContents string = text.getContents();
|
||||
if (string instanceof TranslatableContents) {
|
||||
TranslatableContents translatableContents = (TranslatableContents)string;
|
||||
- String string = translatableContents.getKey();
|
||||
- return Language.getInstance().has(string);
|
||||
+ return Language.getInstance().has(translatableContents.getKey()); // Paper - decompile fix
|
||||
}
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/resources/RegistryDataLoader.java b/src/main/java/net/minecraft/resources/RegistryDataLoader.java
|
||||
index bc7c6b40ec160d7d449546265b9808e15e587247..178215878c4bbf4ddb24002fcd6d1156a44494ff 100644
|
||||
--- a/src/main/java/net/minecraft/resources/RegistryDataLoader.java
|
||||
+++ b/src/main/java/net/minecraft/resources/RegistryDataLoader.java
|
||||
@@ -87,7 +87,7 @@ public class RegistryDataLoader {
|
||||
return new RegistryOps.RegistryInfoLookup() {
|
||||
@Override
|
||||
public <T> Optional<RegistryOps.RegistryInfo<T>> lookup(ResourceKey<? extends Registry<? extends T>> registryRef) {
|
||||
- return Optional.ofNullable(map.get(registryRef));
|
||||
+ return Optional.ofNullable((RegistryOps.RegistryInfo<T>) map.get(registryRef)); // Paper - decompile fix
|
||||
}
|
||||
};
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index 870db0028becd6b76af76190fae908d0031ed94d..06b1da8b559f9d545f1593d81de7b25e0a12f176 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -1747,7 +1747,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
PackRepository resourcepackrepository = this.packRepository;
|
||||
|
||||
Objects.requireNonNull(this.packRepository);
|
||||
- return stream.map(resourcepackrepository::getPack).filter(Objects::nonNull).map(Pack::open).collect(ImmutableList.toImmutableList()); // CraftBukkit - decompile error
|
||||
+ return stream.<Pack>map(resourcepackrepository::getPack).filter(Objects::nonNull).map(Pack::open).collect(ImmutableList.toImmutableList()); // CraftBukkit - decompile error // Paper - decompile error // todo: is this needed anymore?
|
||||
}, this).thenCompose((immutablelist) -> {
|
||||
MultiPackResourceManager resourcemanager = new MultiPackResourceManager(PackType.SERVER_DATA, immutablelist);
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/Ticket.java b/src/main/java/net/minecraft/server/level/Ticket.java
|
||||
index 2f66abf62d303342f5fe614fb3e35e7844497ffc..b346fa94b23d81da7da073f71dd12e672e0f079c 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/Ticket.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/Ticket.java
|
||||
@@ -21,7 +21,7 @@ public final class Ticket<T> implements Comparable<Ticket<?>> {
|
||||
return i;
|
||||
} else {
|
||||
int j = Integer.compare(System.identityHashCode(this.type), System.identityHashCode(ticket.type));
|
||||
- return j != 0 ? j : this.type.getComparator().compare(this.key, ticket.key);
|
||||
+ return j != 0 ? j : this.type.getComparator().compare(this.key, (T)ticket.key); // Paper - decompile fix
|
||||
}
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/util/SortedArraySet.java b/src/main/java/net/minecraft/util/SortedArraySet.java
|
||||
index 2dc801061025888192c3bf2c4c38b928c16a0165..ca788f0dcec4a117b410fe8348969e056b138b1e 100644
|
||||
--- a/src/main/java/net/minecraft/util/SortedArraySet.java
|
||||
+++ b/src/main/java/net/minecraft/util/SortedArraySet.java
|
||||
@@ -28,7 +28,7 @@ public class SortedArraySet<T> extends AbstractSet<T> {
|
||||
}
|
||||
|
||||
public static <T extends Comparable<T>> SortedArraySet<T> create(int initialCapacity) {
|
||||
- return new SortedArraySet<>(initialCapacity, Comparator.naturalOrder());
|
||||
+ return new SortedArraySet<>(initialCapacity, Comparator.<T>naturalOrder()); // Paper - decompile fix
|
||||
}
|
||||
|
||||
public static <T> SortedArraySet<T> create(Comparator<T> comparator) {
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/animal/camel/Camel.java b/src/main/java/net/minecraft/world/entity/animal/camel/Camel.java
|
||||
index 02c10fcdad18f7194e804d94449f291d636163a2..2222a8be261142dd7a42170ad3fe314eeea1deb5 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/animal/camel/Camel.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/animal/camel/Camel.java
|
||||
@@ -147,7 +147,7 @@ public class Camel extends AbstractHorse implements PlayerRideableJumping, Rider
|
||||
@Override
|
||||
protected void customServerAiStep() {
|
||||
this.level.getProfiler().push("camelBrain");
|
||||
- Brain<?> brain = this.getBrain();
|
||||
+ Brain<Camel> brain = (Brain<Camel>) this.getBrain(); // Paper - decompile fix
|
||||
brain.tick((ServerLevel)this.level, this);
|
||||
this.level.getProfiler().pop();
|
||||
this.level.getProfiler().push("camelActivityUpdate");
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/animal/frog/Frog.java b/src/main/java/net/minecraft/world/entity/animal/frog/Frog.java
|
||||
index 471b9258320ba0002d741267144c80c149f5f34c..8852cc6253c8bc1a9f7591cd2b0beb95bb4f4d33 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/animal/frog/Frog.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/animal/frog/Frog.java
|
||||
@@ -106,7 +106,7 @@ public class Frog extends Animal implements VariantHolder<FrogVariant> {
|
||||
|
||||
@Override
|
||||
public Brain<Frog> getBrain() {
|
||||
- return super.getBrain();
|
||||
+ return (Brain<Frog>) super.getBrain(); // Paper - decompile fix
|
||||
}
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/monster/hoglin/Hoglin.java b/src/main/java/net/minecraft/world/entity/monster/hoglin/Hoglin.java
|
||||
index 64314cf4dc53a1a0a5f676fa00503858e0120dfa..45741410a13cffe3419e34b5607b048bbcf1c3ff 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/monster/hoglin/Hoglin.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/monster/hoglin/Hoglin.java
|
||||
@@ -123,7 +123,7 @@ public class Hoglin extends Animal implements Enemy, HoglinBase {
|
||||
|
||||
@Override
|
||||
public Brain<Hoglin> getBrain() {
|
||||
- return super.getBrain();
|
||||
+ return (Brain<Hoglin>) super.getBrain(); // Paper - decompile fix
|
||||
}
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java b/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java
|
||||
index d025df087e7b87fbc89a722226f2f2263c54ac47..2f712bfc1f717ba410bf34669d7b0a919ca218cc 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/crafting/RecipeManager.java
|
||||
@@ -78,7 +78,7 @@ public class RecipeManager extends SimpleJsonResourceReloadListener {
|
||||
}
|
||||
|
||||
this.recipes = (Map) map1.entrySet().stream().collect(ImmutableMap.toImmutableMap(Entry::getKey, (entry1) -> {
|
||||
- return (entry1.getValue()); // CraftBukkit
|
||||
+ return entry1.getValue(); // CraftBukkit // Paper - decompile fix - *shrugs internally* // todo: is this needed anymore?
|
||||
}));
|
||||
this.byName = Maps.newHashMap(builder.build()); // CraftBukkit
|
||||
RecipeManager.LOGGER.info("Loaded {} recipes", map1.size());
|
||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java b/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java
|
||||
index 7798cbbae6b72d64e6129cebf1f66696f21e15f9..240c19f4a7552a01b3c48f1f6413119e4cfc2b67 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java
|
||||
@@ -56,7 +56,7 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer
|
||||
}
|
||||
|
||||
private static <T, C extends PalettedContainerRO<T>> Codec<C> codec(IdMap<T> idList, Codec<T> entryCodec, PalettedContainer.Strategy provider, T defaultValue, PalettedContainerRO.Unpacker<T, C> reader) {
|
||||
- return RecordCodecBuilder.<PalettedContainerRO.PackedData>create((instance) -> {
|
||||
+ return RecordCodecBuilder.<PalettedContainerRO.PackedData<T>>create((instance) -> { // Paper - decompile fix
|
||||
return instance.group(entryCodec.mapResult(ExtraCodecs.orElsePartial(defaultValue)).listOf().fieldOf("palette").forGetter(PalettedContainerRO.PackedData::paletteEntries), Codec.LONG_STREAM.optionalFieldOf("data").forGetter(PalettedContainerRO.PackedData::storage)).apply(instance, PalettedContainerRO.PackedData::new);
|
||||
}).comapFlatMap((serialized) -> {
|
||||
return reader.read(idList, provider, serialized);
|
||||
diff --git a/src/main/java/net/minecraft/world/level/entity/EntityLookup.java b/src/main/java/net/minecraft/world/level/entity/EntityLookup.java
|
||||
index 6b91771a4bf559881a4f3e6c98500e09b33d16e0..21a2800db22f287b9c6a8290326fdf3b94ae94b1 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/entity/EntityLookup.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/entity/EntityLookup.java
|
||||
@@ -19,7 +19,7 @@ public class EntityLookup<T extends EntityAccess> {
|
||||
public <U extends T> void getEntities(EntityTypeTest<T, U> filter, AbortableIterationConsumer<U> consumer) {
|
||||
for(T entityAccess : this.byId.values()) {
|
||||
U entityAccess2 = (U)((EntityAccess)filter.tryCast(entityAccess));
|
||||
- if (entityAccess2 != null && consumer.accept((T)entityAccess2).shouldAbort()) {
|
||||
+ if (entityAccess2 != null && consumer.accept(entityAccess2).shouldAbort()) { // Paper - decompile fix
|
||||
return;
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/level/entity/EntitySection.java b/src/main/java/net/minecraft/world/level/entity/EntitySection.java
|
||||
index 69a19dbf58cde41680d086e78b9a12ffee602dbf..5dcb7f9cab097990148f5a7c4ccbe1556afdd514 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/entity/EntitySection.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/entity/EntitySection.java
|
||||
@@ -44,7 +44,7 @@ public class EntitySection<T extends EntityAccess> {
|
||||
} else {
|
||||
for(T entityAccess : collection) {
|
||||
U entityAccess2 = (U)((EntityAccess)type.tryCast(entityAccess));
|
||||
- if (entityAccess2 != null && entityAccess.getBoundingBox().intersects(box) && consumer.accept((T)entityAccess2).shouldAbort()) {
|
||||
+ if (entityAccess2 != null && entityAccess.getBoundingBox().intersects(box) && consumer.accept(entityAccess2).shouldAbort()) { // Paper - decompile fix
|
||||
return AbortableIterationConsumer.Continuation.ABORT;
|
||||
}
|
||||
}
|
7018
patches/unapplied/server/0007-ConcurrentUtil.patch
Normal file
7018
patches/unapplied/server/0007-ConcurrentUtil.patch
Normal file
File diff suppressed because it is too large
Load diff
116
patches/unapplied/server/0008-CB-fixes.patch
Normal file
116
patches/unapplied/server/0008-CB-fixes.patch
Normal file
|
@ -0,0 +1,116 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Fri, 25 Feb 2022 07:14:48 -0800
|
||||
Subject: [PATCH] CB fixes
|
||||
|
||||
* Missing Level -> LevelStem generic in StructureCheck
|
||||
Need to use the right for injectDatafixingContext (Spottedleaf)
|
||||
|
||||
* Removed incorrect parent perm for `minecraft.debugstick.always` (Machine_Maker)
|
||||
|
||||
* Fixed method signature of Marker#addPassenger (Machine_Maker)
|
||||
|
||||
* Removed unneeded UOE in CustomWorldChunkManager (extends BiomeSource) (Machine_Maker)
|
||||
|
||||
* Honor Server#getLootTable method contract (Machine_Maker)
|
||||
|
||||
Co-authored-by: Spottedleaf <Spottedleaf@users.noreply.github.com>
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
index ae219be37c5fcec3dd3f8b08819551003e66d351..8309eb14140ebcf62ae7be1dfa0177ac7fcf83d7 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -294,7 +294,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
|
||||
long l = minecraftserver.getWorldData().worldGenOptions().seed();
|
||||
|
||||
- this.structureCheck = new StructureCheck(this.chunkSource.chunkScanner(), this.registryAccess(), minecraftserver.getStructureManager(), resourcekey, chunkgenerator, this.chunkSource.randomState(), this, chunkgenerator.getBiomeSource(), l, datafixer);
|
||||
+ this.structureCheck = new StructureCheck(this.chunkSource.chunkScanner(), this.registryAccess(), minecraftserver.getStructureManager(), this.getTypeKey(), chunkgenerator, this.chunkSource.randomState(), this, chunkgenerator.getBiomeSource(), l, datafixer); // Paper - Fix missing CB diff
|
||||
this.structureManager = new StructureManager(this, this.serverLevelData.worldGenOptions(), this.structureCheck); // CraftBukkit
|
||||
if ((this.dimension() == Level.END && this.dimensionTypeRegistration().is(BuiltinDimensionTypes.END)) || env == org.bukkit.World.Environment.THE_END) { // CraftBukkit - Allow to create EnderDragonBattle in default and custom END
|
||||
this.dragonFight = new EndDragonFight(this, this.serverLevelData.worldGenOptions().seed(), this.serverLevelData.endDragonFightData()); // CraftBukkit
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Marker.java b/src/main/java/net/minecraft/world/entity/Marker.java
|
||||
index d9f07a311ec5a253bdfb681414e1f8033a576a23..6f110ece5686d1fc73b93fb9e0a73f2c1bcf4586 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Marker.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Marker.java
|
||||
@@ -39,8 +39,9 @@ public class Marker extends Entity {
|
||||
}
|
||||
|
||||
@Override
|
||||
- protected void addPassenger(Entity passenger) {
|
||||
+ protected boolean addPassenger(Entity passenger) { // Paper - fix upstream
|
||||
passenger.stopRiding();
|
||||
+ return false; // Paper - fix upstream
|
||||
}
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/animal/camel/Camel.java b/src/main/java/net/minecraft/world/entity/animal/camel/Camel.java
|
||||
index 2222a8be261142dd7a42170ad3fe314eeea1deb5..136da73e372b59f37665743c70833e815cd0070b 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/animal/camel/Camel.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/animal/camel/Camel.java
|
||||
@@ -421,9 +421,9 @@ public class Camel extends AbstractHorse implements PlayerRideableJumping, Rider
|
||||
}
|
||||
|
||||
@Override
|
||||
- protected void actuallyHurt(DamageSource source, float amount) {
|
||||
+ protected boolean damageEntity0(DamageSource source, float amount) { // Paper - fix CB method rename issue
|
||||
this.standUpPanic();
|
||||
- super.actuallyHurt(source, amount);
|
||||
+ return super.damageEntity0(source, amount); // Paper - fix CB method rename issue
|
||||
}
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/net/minecraft/world/level/levelgen/structure/StructureCheck.java b/src/main/java/net/minecraft/world/level/levelgen/structure/StructureCheck.java
|
||||
index 99af167b02c1291f9f5fd1a195a3eb65de87002b..874f7ea643d27eec47d51a10ad472af7e8ec402e 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/levelgen/structure/StructureCheck.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/levelgen/structure/StructureCheck.java
|
||||
@@ -44,7 +44,7 @@ public class StructureCheck {
|
||||
private final Registry<Biome> biomes;
|
||||
private final Registry<Structure> structureConfigs;
|
||||
private final StructureTemplateManager structureTemplateManager;
|
||||
- private final ResourceKey<Level> dimension;
|
||||
+ private final ResourceKey<net.minecraft.world.level.dimension.LevelStem> dimension; // Paper - fix missing CB diff
|
||||
private final ChunkGenerator chunkGenerator;
|
||||
private final RandomState randomState;
|
||||
private final LevelHeightAccessor heightAccessor;
|
||||
@@ -54,7 +54,7 @@ public class StructureCheck {
|
||||
private final Long2ObjectMap<Object2IntMap<Structure>> loadedChunks = new Long2ObjectOpenHashMap<>();
|
||||
private final Map<Structure, Long2BooleanMap> featureChecks = new HashMap<>();
|
||||
|
||||
- public StructureCheck(ChunkScanAccess chunkIoWorker, RegistryAccess registryManager, StructureTemplateManager structureTemplateManager, ResourceKey<Level> worldKey, ChunkGenerator chunkGenerator, RandomState noiseConfig, LevelHeightAccessor world, BiomeSource biomeSource, long seed, DataFixer dataFixer) {
|
||||
+ public StructureCheck(ChunkScanAccess chunkIoWorker, RegistryAccess registryManager, StructureTemplateManager structureTemplateManager, ResourceKey<net.minecraft.world.level.dimension.LevelStem> worldKey, ChunkGenerator chunkGenerator, RandomState noiseConfig, LevelHeightAccessor world, BiomeSource biomeSource, long seed, DataFixer dataFixer) { // Paper - fix missing CB diff
|
||||
this.storageAccess = chunkIoWorker;
|
||||
this.registryAccess = registryManager;
|
||||
this.structureTemplateManager = structureTemplateManager;
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index 8873bf84c71c48297a360df9c99e511fa0af5b40..f29395b6bf9eebd4830bbcda7d96085fb8e3d8b0 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -2305,7 +2305,13 @@ public final class CraftServer implements Server {
|
||||
Validate.notNull(key, "NamespacedKey cannot be null");
|
||||
|
||||
LootTables registry = this.getServer().getLootTables();
|
||||
- return new CraftLootTable(key, registry.get(CraftNamespacedKey.toMinecraft(key)));
|
||||
+ // Paper start - honor method contract
|
||||
+ final ResourceLocation lootTableKey = CraftNamespacedKey.toMinecraft(key);
|
||||
+ if (!registry.getIds().contains(lootTableKey)) {
|
||||
+ return null;
|
||||
+ }
|
||||
+ return new CraftLootTable(key, registry.get(lootTableKey));
|
||||
+ // Paper end
|
||||
}
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/util/permissions/CraftDefaultPermissions.java b/src/main/java/org/bukkit/craftbukkit/util/permissions/CraftDefaultPermissions.java
|
||||
index c93eec7a81ed83dc9190417dd51acb2780d3b60d..70d3949616c63038ad3e9bd1069db5ea2fb3f3b8 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/util/permissions/CraftDefaultPermissions.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/util/permissions/CraftDefaultPermissions.java
|
||||
@@ -15,7 +15,7 @@ public final class CraftDefaultPermissions {
|
||||
DefaultPermissions.registerPermission(CraftDefaultPermissions.ROOT + ".nbt.place", "Gives the user the ability to place restricted blocks with NBT in creative", org.bukkit.permissions.PermissionDefault.OP, parent);
|
||||
DefaultPermissions.registerPermission(CraftDefaultPermissions.ROOT + ".nbt.copy", "Gives the user the ability to copy NBT in creative", org.bukkit.permissions.PermissionDefault.TRUE, parent);
|
||||
DefaultPermissions.registerPermission(CraftDefaultPermissions.ROOT + ".debugstick", "Gives the user the ability to use the debug stick in creative", org.bukkit.permissions.PermissionDefault.OP, parent);
|
||||
- DefaultPermissions.registerPermission(CraftDefaultPermissions.ROOT + ".debugstick.always", "Gives the user the ability to use the debug stick in all game modes", org.bukkit.permissions.PermissionDefault.FALSE, parent);
|
||||
+ DefaultPermissions.registerPermission(CraftDefaultPermissions.ROOT + ".debugstick.always", "Gives the user the ability to use the debug stick in all game modes", org.bukkit.permissions.PermissionDefault.FALSE/* , parent */); // Paper - should not have this parent, as it's not a "vanilla" utility
|
||||
// Spigot end
|
||||
parent.recalculatePermissibles();
|
||||
}
|
7744
patches/unapplied/server/0009-MC-Utils.patch
Normal file
7744
patches/unapplied/server/0009-MC-Utils.patch
Normal file
File diff suppressed because it is too large
Load diff
4722
patches/unapplied/server/0010-Adventure.patch
Normal file
4722
patches/unapplied/server/0010-Adventure.patch
Normal file
File diff suppressed because it is too large
Load diff
620
patches/unapplied/server/0011-Paper-command.patch
Normal file
620
patches/unapplied/server/0011-Paper-command.patch
Normal file
|
@ -0,0 +1,620 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Zach Brown <zach.brown@destroystokyo.com>
|
||||
Date: Mon, 29 Feb 2016 21:02:09 -0600
|
||||
Subject: [PATCH] Paper command
|
||||
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/command/CommandUtil.java b/src/main/java/io/papermc/paper/command/CommandUtil.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..953c30500892e5f0c55b8597bc708ea85bf56d6e
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/command/CommandUtil.java
|
||||
@@ -0,0 +1,69 @@
|
||||
+package io.papermc.paper.command;
|
||||
+
|
||||
+import com.google.common.base.Functions;
|
||||
+import com.google.common.collect.Iterables;
|
||||
+import com.google.common.collect.Lists;
|
||||
+import java.util.ArrayList;
|
||||
+import java.util.Arrays;
|
||||
+import java.util.Collection;
|
||||
+import java.util.Iterator;
|
||||
+import java.util.List;
|
||||
+import net.minecraft.resources.ResourceLocation;
|
||||
+import org.bukkit.command.CommandSender;
|
||||
+import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
+import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
+
|
||||
+@DefaultQualifier(NonNull.class)
|
||||
+public final class CommandUtil {
|
||||
+ private CommandUtil() {
|
||||
+ }
|
||||
+
|
||||
+ // Code from Mojang - copyright them
|
||||
+ public static List<String> getListMatchingLast(
|
||||
+ final CommandSender sender,
|
||||
+ final String[] args,
|
||||
+ final String... matches
|
||||
+ ) {
|
||||
+ return getListMatchingLast(sender, args, Arrays.asList(matches));
|
||||
+ }
|
||||
+
|
||||
+ public static boolean matches(final String s, final String s1) {
|
||||
+ return s1.regionMatches(true, 0, s, 0, s.length());
|
||||
+ }
|
||||
+
|
||||
+ public static List<String> getListMatchingLast(
|
||||
+ final CommandSender sender,
|
||||
+ final String[] strings,
|
||||
+ final Collection<?> collection
|
||||
+ ) {
|
||||
+ String last = strings[strings.length - 1];
|
||||
+ ArrayList<String> results = Lists.newArrayList();
|
||||
+
|
||||
+ if (!collection.isEmpty()) {
|
||||
+ Iterator iterator = Iterables.transform(collection, Functions.toStringFunction()).iterator();
|
||||
+
|
||||
+ while (iterator.hasNext()) {
|
||||
+ String s1 = (String) iterator.next();
|
||||
+
|
||||
+ if (matches(last, s1) && (sender.hasPermission(PaperCommand.BASE_PERM + s1) || sender.hasPermission("bukkit.command.paper"))) {
|
||||
+ results.add(s1);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (results.isEmpty()) {
|
||||
+ iterator = collection.iterator();
|
||||
+
|
||||
+ while (iterator.hasNext()) {
|
||||
+ Object object = iterator.next();
|
||||
+
|
||||
+ if (object instanceof ResourceLocation && matches(last, ((ResourceLocation) object).getPath())) {
|
||||
+ results.add(String.valueOf(object));
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return results;
|
||||
+ }
|
||||
+ // end copy stuff
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/command/PaperCommand.java b/src/main/java/io/papermc/paper/command/PaperCommand.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..b3a58bf4b654e336826dc04da9e2f80ff8b9a9a7
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/command/PaperCommand.java
|
||||
@@ -0,0 +1,145 @@
|
||||
+package io.papermc.paper.command;
|
||||
+
|
||||
+import io.papermc.paper.command.subcommands.EntityCommand;
|
||||
+import io.papermc.paper.command.subcommands.HeapDumpCommand;
|
||||
+import io.papermc.paper.command.subcommands.ReloadCommand;
|
||||
+import io.papermc.paper.command.subcommands.VersionCommand;
|
||||
+import it.unimi.dsi.fastutil.Pair;
|
||||
+import java.util.ArrayList;
|
||||
+import java.util.Arrays;
|
||||
+import java.util.Collections;
|
||||
+import java.util.HashMap;
|
||||
+import java.util.List;
|
||||
+import java.util.Locale;
|
||||
+import java.util.Map;
|
||||
+import java.util.Set;
|
||||
+import java.util.stream.Collectors;
|
||||
+import net.minecraft.Util;
|
||||
+import org.bukkit.Bukkit;
|
||||
+import org.bukkit.Location;
|
||||
+import org.bukkit.command.Command;
|
||||
+import org.bukkit.command.CommandSender;
|
||||
+import org.bukkit.permissions.Permission;
|
||||
+import org.bukkit.permissions.PermissionDefault;
|
||||
+import org.bukkit.plugin.PluginManager;
|
||||
+import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
+import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
+import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
+
|
||||
+import static net.kyori.adventure.text.Component.text;
|
||||
+import static net.kyori.adventure.text.format.NamedTextColor.RED;
|
||||
+
|
||||
+@DefaultQualifier(NonNull.class)
|
||||
+public final class PaperCommand extends Command {
|
||||
+ static final String BASE_PERM = "bukkit.command.paper.";
|
||||
+ // subcommand label -> subcommand
|
||||
+ private static final Map<String, PaperSubcommand> SUBCOMMANDS = Util.make(() -> {
|
||||
+ final Map<Set<String>, PaperSubcommand> commands = new HashMap<>();
|
||||
+
|
||||
+ commands.put(Set.of("heap"), new HeapDumpCommand());
|
||||
+ commands.put(Set.of("entity"), new EntityCommand());
|
||||
+ commands.put(Set.of("reload"), new ReloadCommand());
|
||||
+ commands.put(Set.of("version"), new VersionCommand());
|
||||
+
|
||||
+ return commands.entrySet().stream()
|
||||
+ .flatMap(entry -> entry.getKey().stream().map(s -> Map.entry(s, entry.getValue())))
|
||||
+ .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
|
||||
+ });
|
||||
+ // alias -> subcommand label
|
||||
+ private static final Map<String, String> ALIASES = Util.make(() -> {
|
||||
+ final Map<String, Set<String>> aliases = new HashMap<>();
|
||||
+
|
||||
+ aliases.put("version", Set.of("ver"));
|
||||
+
|
||||
+ return aliases.entrySet().stream()
|
||||
+ .flatMap(entry -> entry.getValue().stream().map(s -> Map.entry(s, entry.getKey())))
|
||||
+ .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
|
||||
+ });
|
||||
+
|
||||
+ public PaperCommand(final String name) {
|
||||
+ super(name);
|
||||
+ this.description = "Paper related commands";
|
||||
+ this.usageMessage = "/paper [" + String.join(" | ", SUBCOMMANDS.keySet()) + "]";
|
||||
+ final List<String> permissions = new ArrayList<>();
|
||||
+ permissions.add("bukkit.command.paper");
|
||||
+ permissions.addAll(SUBCOMMANDS.keySet().stream().map(s -> BASE_PERM + s).toList());
|
||||
+ this.setPermission(String.join(";", permissions));
|
||||
+ final PluginManager pluginManager = Bukkit.getServer().getPluginManager();
|
||||
+ for (final String perm : permissions) {
|
||||
+ pluginManager.addPermission(new Permission(perm, PermissionDefault.OP));
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private static boolean testPermission(final CommandSender sender, final String permission) {
|
||||
+ if (sender.hasPermission(BASE_PERM + permission) || sender.hasPermission("bukkit.command.paper")) {
|
||||
+ return true;
|
||||
+ }
|
||||
+ sender.sendMessage(text("I'm sorry, but you do not have permission to perform this command. Please contact the server administrators if you believe that this is in error.", RED));
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public List<String> tabComplete(
|
||||
+ final CommandSender sender,
|
||||
+ final String alias,
|
||||
+ final String[] args,
|
||||
+ final @Nullable Location location
|
||||
+ ) throws IllegalArgumentException {
|
||||
+ if (args.length <= 1) {
|
||||
+ return CommandUtil.getListMatchingLast(sender, args, SUBCOMMANDS.keySet());
|
||||
+ }
|
||||
+
|
||||
+ final @Nullable Pair<String, PaperSubcommand> subCommand = resolveCommand(args[0]);
|
||||
+ if (subCommand != null) {
|
||||
+ return subCommand.second().tabComplete(sender, subCommand.first(), Arrays.copyOfRange(args, 1, args.length));
|
||||
+ }
|
||||
+
|
||||
+ return Collections.emptyList();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean execute(
|
||||
+ final CommandSender sender,
|
||||
+ final String commandLabel,
|
||||
+ final String[] args
|
||||
+ ) {
|
||||
+ if (!testPermission(sender)) {
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ if (args.length == 0) {
|
||||
+ sender.sendMessage(text("Usage: " + this.usageMessage, RED));
|
||||
+ return false;
|
||||
+ }
|
||||
+ final @Nullable Pair<String, PaperSubcommand> subCommand = resolveCommand(args[0]);
|
||||
+
|
||||
+ if (subCommand == null) {
|
||||
+ sender.sendMessage(text("Usage: " + this.usageMessage, RED));
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ if (!testPermission(sender, subCommand.first())) {
|
||||
+ return true;
|
||||
+ }
|
||||
+ final String[] choppedArgs = Arrays.copyOfRange(args, 1, args.length);
|
||||
+ return subCommand.second().execute(sender, subCommand.first(), choppedArgs);
|
||||
+ }
|
||||
+
|
||||
+ private static @Nullable Pair<String, PaperSubcommand> resolveCommand(String label) {
|
||||
+ label = label.toLowerCase(Locale.ENGLISH);
|
||||
+ @Nullable PaperSubcommand subCommand = SUBCOMMANDS.get(label);
|
||||
+ if (subCommand == null) {
|
||||
+ final @Nullable String command = ALIASES.get(label);
|
||||
+ if (command != null) {
|
||||
+ label = command;
|
||||
+ subCommand = SUBCOMMANDS.get(command);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (subCommand != null) {
|
||||
+ return Pair.of(label, subCommand);
|
||||
+ }
|
||||
+
|
||||
+ return null;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/command/PaperCommands.java b/src/main/java/io/papermc/paper/command/PaperCommands.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..6a00f3d38da8107825ab1d405f337fd077b09f72
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/command/PaperCommands.java
|
||||
@@ -0,0 +1,27 @@
|
||||
+package io.papermc.paper.command;
|
||||
+
|
||||
+import net.minecraft.server.MinecraftServer;
|
||||
+import org.bukkit.command.Command;
|
||||
+
|
||||
+import java.util.HashMap;
|
||||
+import java.util.Map;
|
||||
+import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
+import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
+
|
||||
+@DefaultQualifier(NonNull.class)
|
||||
+public final class PaperCommands {
|
||||
+
|
||||
+ private PaperCommands() {
|
||||
+ }
|
||||
+
|
||||
+ private static final Map<String, Command> COMMANDS = new HashMap<>();
|
||||
+ static {
|
||||
+ COMMANDS.put("paper", new PaperCommand("paper"));
|
||||
+ }
|
||||
+
|
||||
+ public static void registerCommands(final MinecraftServer server) {
|
||||
+ COMMANDS.forEach((s, command) -> {
|
||||
+ server.server.getCommandMap().register(s, "Paper", command);
|
||||
+ });
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/command/PaperSubcommand.java b/src/main/java/io/papermc/paper/command/PaperSubcommand.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..6ff5d42a866d2752c73a766815aa190b2b0dc36f
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/command/PaperSubcommand.java
|
||||
@@ -0,0 +1,16 @@
|
||||
+package io.papermc.paper.command;
|
||||
+
|
||||
+import java.util.Collections;
|
||||
+import java.util.List;
|
||||
+import org.bukkit.command.CommandSender;
|
||||
+import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
+import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
+
|
||||
+@DefaultQualifier(NonNull.class)
|
||||
+public interface PaperSubcommand {
|
||||
+ boolean execute(CommandSender sender, String subCommand, String[] args);
|
||||
+
|
||||
+ default List<String> tabComplete(final CommandSender sender, final String subCommand, final String[] args) {
|
||||
+ return Collections.emptyList();
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/command/subcommands/EntityCommand.java b/src/main/java/io/papermc/paper/command/subcommands/EntityCommand.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..ff99336e0b8131ae161cfa5c4fc83c6905e3dbc8
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/command/subcommands/EntityCommand.java
|
||||
@@ -0,0 +1,158 @@
|
||||
+package io.papermc.paper.command.subcommands;
|
||||
+
|
||||
+import com.google.common.collect.Maps;
|
||||
+import io.papermc.paper.command.CommandUtil;
|
||||
+import io.papermc.paper.command.PaperSubcommand;
|
||||
+import java.util.Collections;
|
||||
+import java.util.List;
|
||||
+import java.util.Locale;
|
||||
+import java.util.Map;
|
||||
+import java.util.Set;
|
||||
+import java.util.stream.Collectors;
|
||||
+
|
||||
+import net.kyori.adventure.text.Component;
|
||||
+import net.kyori.adventure.text.event.ClickEvent;
|
||||
+import net.kyori.adventure.text.event.HoverEvent;
|
||||
+import net.minecraft.core.registries.BuiltInRegistries;
|
||||
+import net.minecraft.resources.ResourceLocation;
|
||||
+import net.minecraft.server.level.ServerChunkCache;
|
||||
+import net.minecraft.server.level.ServerLevel;
|
||||
+import net.minecraft.world.entity.EntityType;
|
||||
+import net.minecraft.world.level.ChunkPos;
|
||||
+import org.apache.commons.lang3.tuple.MutablePair;
|
||||
+import org.apache.commons.lang3.tuple.Pair;
|
||||
+import org.bukkit.Bukkit;
|
||||
+import org.bukkit.HeightMap;
|
||||
+import org.bukkit.World;
|
||||
+import org.bukkit.command.CommandSender;
|
||||
+import org.bukkit.craftbukkit.CraftWorld;
|
||||
+import org.bukkit.entity.Player;
|
||||
+import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
+import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
+import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
+
|
||||
+import static net.kyori.adventure.text.Component.text;
|
||||
+import static net.kyori.adventure.text.format.NamedTextColor.GREEN;
|
||||
+import static net.kyori.adventure.text.format.NamedTextColor.RED;
|
||||
+
|
||||
+@DefaultQualifier(NonNull.class)
|
||||
+public final class EntityCommand implements PaperSubcommand {
|
||||
+ @Override
|
||||
+ public boolean execute(final CommandSender sender, final String subCommand, final String[] args) {
|
||||
+ this.listEntities(sender, args);
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public List<String> tabComplete(final CommandSender sender, final String subCommand, final String[] args) {
|
||||
+ if (args.length == 1) {
|
||||
+ return CommandUtil.getListMatchingLast(sender, args, "help", "list");
|
||||
+ } else if (args.length == 2) {
|
||||
+ return CommandUtil.getListMatchingLast(sender, args, BuiltInRegistries.ENTITY_TYPE.keySet().stream().map(ResourceLocation::toString).sorted().toArray(String[]::new));
|
||||
+ }
|
||||
+ return Collections.emptyList();
|
||||
+ }
|
||||
+
|
||||
+ /*
|
||||
+ * Ported from MinecraftForge - author: LexManos <LexManos@gmail.com> - License: LGPLv2.1
|
||||
+ */
|
||||
+ private void listEntities(final CommandSender sender, final String[] args) {
|
||||
+ // help
|
||||
+ if (args.length < 1 || !args[0].toLowerCase(Locale.ENGLISH).equals("list")) {
|
||||
+ sender.sendMessage(text("Use /paper entity [list] help for more information on a specific command", RED));
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ if ("list".equals(args[0].toLowerCase(Locale.ENGLISH))) {
|
||||
+ String filter = "*";
|
||||
+ if (args.length > 1) {
|
||||
+ if (args[1].toLowerCase(Locale.ENGLISH).equals("help")) {
|
||||
+ sender.sendMessage(text("Use /paper entity list [filter] [worldName] to get entity info that matches the optional filter.", RED));
|
||||
+ return;
|
||||
+ }
|
||||
+ filter = args[1];
|
||||
+ }
|
||||
+ final String cleanfilter = filter.replace("?", ".?").replace("*", ".*?");
|
||||
+ Set<ResourceLocation> names = BuiltInRegistries.ENTITY_TYPE.keySet().stream()
|
||||
+ .filter(n -> n.toString().matches(cleanfilter))
|
||||
+ .collect(Collectors.toSet());
|
||||
+ if (names.isEmpty()) {
|
||||
+ sender.sendMessage(text("Invalid filter, does not match any entities. Use /paper entity list for a proper list", RED));
|
||||
+ sender.sendMessage(text("Usage: /paper entity list [filter] [worldName]", RED));
|
||||
+ return;
|
||||
+ }
|
||||
+ String worldName;
|
||||
+ if (args.length > 2) {
|
||||
+ worldName = args[2];
|
||||
+ } else if (sender instanceof Player) {
|
||||
+ worldName = ((Player) sender).getWorld().getName();
|
||||
+ } else {
|
||||
+ sender.sendMessage(text("Please specify the name of a world", RED));
|
||||
+ sender.sendMessage(text("To do so without a filter, specify '*' as the filter", RED));
|
||||
+ sender.sendMessage(text("Usage: /paper entity list [filter] [worldName]", RED));
|
||||
+ return;
|
||||
+ }
|
||||
+ Map<ResourceLocation, MutablePair<Integer, Map<ChunkPos, Integer>>> list = Maps.newHashMap();
|
||||
+ @Nullable World bukkitWorld = Bukkit.getWorld(worldName);
|
||||
+ if (bukkitWorld == null) {
|
||||
+ sender.sendMessage(text("Could not load world for " + worldName + ". Please select a valid world.", RED));
|
||||
+ sender.sendMessage(text("Usage: /paper entity list [filter] [worldName]", RED));
|
||||
+ return;
|
||||
+ }
|
||||
+ ServerLevel world = ((CraftWorld) bukkitWorld).getHandle();
|
||||
+ Map<ResourceLocation, Integer> nonEntityTicking = Maps.newHashMap();
|
||||
+ ServerChunkCache chunkProviderServer = world.getChunkSource();
|
||||
+ world.getAllEntities().forEach(e -> {
|
||||
+ ResourceLocation key = EntityType.getKey(e.getType());
|
||||
+
|
||||
+ MutablePair<Integer, Map<ChunkPos, Integer>> info = list.computeIfAbsent(key, k -> MutablePair.of(0, Maps.newHashMap()));
|
||||
+ ChunkPos chunk = e.chunkPosition();
|
||||
+ info.left++;
|
||||
+ info.right.put(chunk, info.right.getOrDefault(chunk, 0) + 1);
|
||||
+ if (!chunkProviderServer.isPositionTicking(e)) {
|
||||
+ nonEntityTicking.merge(key, 1, Integer::sum);
|
||||
+ }
|
||||
+ });
|
||||
+ if (names.size() == 1) {
|
||||
+ ResourceLocation name = names.iterator().next();
|
||||
+ Pair<Integer, Map<ChunkPos, Integer>> info = list.get(name);
|
||||
+ int nonTicking = nonEntityTicking.getOrDefault(name, 0);
|
||||
+ if (info == null) {
|
||||
+ sender.sendMessage(text("No entities found.", RED));
|
||||
+ return;
|
||||
+ }
|
||||
+ sender.sendMessage("Entity: " + name + " Total Ticking: " + (info.getLeft() - nonTicking) + ", Total Non-Ticking: " + nonTicking);
|
||||
+ info.getRight().entrySet().stream()
|
||||
+ .sorted((a, b) -> !a.getValue().equals(b.getValue()) ? b.getValue() - a.getValue() : a.getKey().toString().compareTo(b.getKey().toString()))
|
||||
+ .limit(10).forEach(e -> {
|
||||
+ final int x = (e.getKey().x << 4) + 8;
|
||||
+ final int z = (e.getKey().z << 4) + 8;
|
||||
+ final Component message = text(" " + e.getValue() + ": " + e.getKey().x + ", " + e.getKey().z + (chunkProviderServer.isPositionTicking(e.getKey().toLong()) ? " (Ticking)" : " (Non-Ticking)"))
|
||||
+ .hoverEvent(HoverEvent.showText(text("Click to teleport to chunk", GREEN)))
|
||||
+ .clickEvent(ClickEvent.clickEvent(ClickEvent.Action.RUN_COMMAND, "/minecraft:execute as @s in " + world.getWorld().getKey() + " run tp " + x + " " + (world.getWorld().getHighestBlockYAt(x, z, HeightMap.MOTION_BLOCKING) + 1) + " " + z));
|
||||
+ sender.sendMessage(message);
|
||||
+ });
|
||||
+ } else {
|
||||
+ List<Pair<ResourceLocation, Integer>> info = list.entrySet().stream()
|
||||
+ .filter(e -> names.contains(e.getKey()))
|
||||
+ .map(e -> Pair.of(e.getKey(), e.getValue().left))
|
||||
+ .sorted((a, b) -> !a.getRight().equals(b.getRight()) ? b.getRight() - a.getRight() : a.getKey().toString().compareTo(b.getKey().toString()))
|
||||
+ .toList();
|
||||
+
|
||||
+ if (info.isEmpty()) {
|
||||
+ sender.sendMessage(text("No entities found.", RED));
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ int count = info.stream().mapToInt(Pair::getRight).sum();
|
||||
+ int nonTickingCount = nonEntityTicking.values().stream().mapToInt(Integer::intValue).sum();
|
||||
+ sender.sendMessage("Total Ticking: " + (count - nonTickingCount) + ", Total Non-Ticking: " + nonTickingCount);
|
||||
+ info.forEach(e -> {
|
||||
+ int nonTicking = nonEntityTicking.getOrDefault(e.getKey(), 0);
|
||||
+ sender.sendMessage(" " + (e.getValue() - nonTicking) + " (" + nonTicking + ") " + ": " + e.getKey());
|
||||
+ });
|
||||
+ sender.sendMessage("* First number is ticking entities, second number is non-ticking entities");
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/command/subcommands/HeapDumpCommand.java b/src/main/java/io/papermc/paper/command/subcommands/HeapDumpCommand.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..cd2e4d792e972b8bf1e07b8961594a670ae949cf
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/command/subcommands/HeapDumpCommand.java
|
||||
@@ -0,0 +1,38 @@
|
||||
+package io.papermc.paper.command.subcommands;
|
||||
+
|
||||
+import io.papermc.paper.command.PaperSubcommand;
|
||||
+import java.time.LocalDateTime;
|
||||
+import java.time.format.DateTimeFormatter;
|
||||
+import org.bukkit.command.Command;
|
||||
+import org.bukkit.command.CommandSender;
|
||||
+import org.bukkit.craftbukkit.CraftServer;
|
||||
+import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
+import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
+
|
||||
+import static net.kyori.adventure.text.Component.text;
|
||||
+import static net.kyori.adventure.text.format.NamedTextColor.GREEN;
|
||||
+import static net.kyori.adventure.text.format.NamedTextColor.RED;
|
||||
+import static net.kyori.adventure.text.format.NamedTextColor.YELLOW;
|
||||
+
|
||||
+@DefaultQualifier(NonNull.class)
|
||||
+public final class HeapDumpCommand implements PaperSubcommand {
|
||||
+ @Override
|
||||
+ public boolean execute(final CommandSender sender, final String subCommand, final String[] args) {
|
||||
+ this.dumpHeap(sender);
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ private void dumpHeap(final CommandSender sender) {
|
||||
+ java.nio.file.Path dir = java.nio.file.Paths.get("./dumps");
|
||||
+ String name = "heap-dump-" + DateTimeFormatter.ofPattern("yyyy-MM-dd_HH.mm.ss").format(LocalDateTime.now());
|
||||
+
|
||||
+ Command.broadcastCommandMessage(sender, text("Writing JVM heap data...", YELLOW));
|
||||
+
|
||||
+ java.nio.file.Path file = CraftServer.dumpHeap(dir, name);
|
||||
+ if (file != null) {
|
||||
+ Command.broadcastCommandMessage(sender, text("Heap dump saved to " + file, GREEN));
|
||||
+ } else {
|
||||
+ Command.broadcastCommandMessage(sender, text("Failed to write heap dump, see server log for details", RED));
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/command/subcommands/ReloadCommand.java b/src/main/java/io/papermc/paper/command/subcommands/ReloadCommand.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..bd68139ae635f2ad7ec8e7a21e0056a139c4c62e
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/command/subcommands/ReloadCommand.java
|
||||
@@ -0,0 +1,33 @@
|
||||
+package io.papermc.paper.command.subcommands;
|
||||
+
|
||||
+import io.papermc.paper.command.PaperSubcommand;
|
||||
+import net.minecraft.server.MinecraftServer;
|
||||
+import org.bukkit.command.Command;
|
||||
+import org.bukkit.command.CommandSender;
|
||||
+import org.bukkit.craftbukkit.CraftServer;
|
||||
+import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
+import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
+
|
||||
+import static net.kyori.adventure.text.Component.text;
|
||||
+import static net.kyori.adventure.text.format.NamedTextColor.GREEN;
|
||||
+import static net.kyori.adventure.text.format.NamedTextColor.RED;
|
||||
+
|
||||
+@DefaultQualifier(NonNull.class)
|
||||
+public final class ReloadCommand implements PaperSubcommand {
|
||||
+ @Override
|
||||
+ public boolean execute(final CommandSender sender, final String subCommand, final String[] args) {
|
||||
+ this.doReload(sender);
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ private void doReload(final CommandSender sender) {
|
||||
+ Command.broadcastCommandMessage(sender, text("Please note that this command is not supported and may cause issues.", RED));
|
||||
+ Command.broadcastCommandMessage(sender, text("If you encounter any issues please use the /stop command to restart your server.", RED));
|
||||
+
|
||||
+ MinecraftServer server = ((CraftServer) sender.getServer()).getServer();
|
||||
+ server.paperConfigurations.reloadConfigs(server);
|
||||
+ server.server.reloadCount++;
|
||||
+
|
||||
+ Command.broadcastCommandMessage(sender, text("Paper config reload complete.", GREEN));
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/command/subcommands/VersionCommand.java b/src/main/java/io/papermc/paper/command/subcommands/VersionCommand.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..ae60bd96b5284d54676d8e7e4dd5d170b526ec1e
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/command/subcommands/VersionCommand.java
|
||||
@@ -0,0 +1,21 @@
|
||||
+package io.papermc.paper.command.subcommands;
|
||||
+
|
||||
+import io.papermc.paper.command.PaperSubcommand;
|
||||
+import net.minecraft.server.MinecraftServer;
|
||||
+import org.bukkit.command.Command;
|
||||
+import org.bukkit.command.CommandSender;
|
||||
+import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
+import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
+import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
+
|
||||
+@DefaultQualifier(NonNull.class)
|
||||
+public final class VersionCommand implements PaperSubcommand {
|
||||
+ @Override
|
||||
+ public boolean execute(final CommandSender sender, final String subCommand, final String[] args) {
|
||||
+ final @Nullable Command ver = MinecraftServer.getServer().server.getCommandMap().getCommand("version");
|
||||
+ if (ver != null) {
|
||||
+ ver.execute(sender, "paper", new String[0]);
|
||||
+ }
|
||||
+ return true;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
index 1fe07773cf9664164b29164caba22800e5a6bdae..cb6f192c11cda6230ec365e6cefb44a37416236d 100644
|
||||
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
@@ -186,6 +186,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||
// Paper start
|
||||
paperConfigurations.initializeGlobalConfiguration();
|
||||
paperConfigurations.initializeWorldDefaultsConfiguration();
|
||||
+ io.papermc.paper.command.PaperCommands.registerCommands(this);
|
||||
// Paper end
|
||||
|
||||
this.setPvpAllowed(dedicatedserverproperties.pvp);
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index 877a104e3899debd387544b740896ffbe86bb581..26ca07b5e302cc4cc02e06f5d07f6d9eb541275e 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -909,6 +909,7 @@ public final class CraftServer implements Server {
|
||||
this.commandMap.clearCommands();
|
||||
this.reloadData();
|
||||
org.spigotmc.SpigotConfig.registerCommands(); // Spigot
|
||||
+ io.papermc.paper.command.PaperCommands.registerCommands(this.console); // Paper
|
||||
this.overrideAllCommandBlockCommands = this.commandsConfiguration.getStringList("command-block-overrides").contains("*");
|
||||
this.ignoreVanillaPermissions = this.commandsConfiguration.getBoolean("ignore-vanilla-permissions");
|
||||
|
||||
@@ -2438,6 +2439,34 @@ public final class CraftServer implements Server {
|
||||
// Spigot end
|
||||
|
||||
// Paper start
|
||||
+ @SuppressWarnings({"rawtypes", "unchecked"})
|
||||
+ public static java.nio.file.Path dumpHeap(java.nio.file.Path dir, String name) {
|
||||
+ try {
|
||||
+ java.nio.file.Files.createDirectories(dir);
|
||||
+
|
||||
+ javax.management.MBeanServer server = java.lang.management.ManagementFactory.getPlatformMBeanServer();
|
||||
+ java.nio.file.Path file;
|
||||
+
|
||||
+ try {
|
||||
+ Class clazz = Class.forName("openj9.lang.management.OpenJ9DiagnosticsMXBean");
|
||||
+ Object openj9Mbean = java.lang.management.ManagementFactory.newPlatformMXBeanProxy(server, "openj9.lang.management:type=OpenJ9Diagnostics", clazz);
|
||||
+ java.lang.reflect.Method m = clazz.getMethod("triggerDumpToFile", String.class, String.class);
|
||||
+ file = dir.resolve(name + ".phd");
|
||||
+ m.invoke(openj9Mbean, "heap", file.toString());
|
||||
+ } catch (ClassNotFoundException e) {
|
||||
+ Class clazz = Class.forName("com.sun.management.HotSpotDiagnosticMXBean");
|
||||
+ Object hotspotMBean = java.lang.management.ManagementFactory.newPlatformMXBeanProxy(server, "com.sun.management:type=HotSpotDiagnostic", clazz);
|
||||
+ java.lang.reflect.Method m = clazz.getMethod("dumpHeap", String.class, boolean.class);
|
||||
+ file = dir.resolve(name + ".hprof");
|
||||
+ m.invoke(hotspotMBean, file.toString(), true);
|
||||
+ }
|
||||
+
|
||||
+ return file;
|
||||
+ } catch (Throwable t) {
|
||||
+ Bukkit.getLogger().log(Level.SEVERE, "Could not write heap", t);
|
||||
+ return null;
|
||||
+ }
|
||||
+ }
|
||||
private Iterable<? extends net.kyori.adventure.audience.Audience> adventure$audiences;
|
||||
@Override
|
||||
public Iterable<? extends net.kyori.adventure.audience.Audience> audiences() {
|
731
patches/unapplied/server/0012-Paper-Metrics.patch
Normal file
731
patches/unapplied/server/0012-Paper-Metrics.patch
Normal file
|
@ -0,0 +1,731 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Zach Brown <zach.brown@destroystokyo.com>
|
||||
Date: Fri, 24 Mar 2017 23:56:01 -0500
|
||||
Subject: [PATCH] Paper Metrics
|
||||
|
||||
Removes Spigot's mcstats metrics in favor of a system using bStats
|
||||
|
||||
To disable for privacy or other reasons go to the bStats folder in your plugins folder
|
||||
and edit the config.yml file present there.
|
||||
|
||||
Please keep in mind the data collected is anonymous and collection should have no
|
||||
tangible effect on server performance. The data is used to allow the authors of
|
||||
PaperMC to track version and platform usage so that we can make better management
|
||||
decisions on behalf of the project.
|
||||
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/Metrics.java b/src/main/java/com/destroystokyo/paper/Metrics.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..6aaed8e8bf8c721fc834da5c76ac72a4c3e92458
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/com/destroystokyo/paper/Metrics.java
|
||||
@@ -0,0 +1,678 @@
|
||||
+package com.destroystokyo.paper;
|
||||
+
|
||||
+import net.minecraft.server.MinecraftServer;
|
||||
+import org.bukkit.Bukkit;
|
||||
+import org.bukkit.configuration.file.YamlConfiguration;
|
||||
+import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||
+import org.bukkit.plugin.Plugin;
|
||||
+
|
||||
+import org.json.simple.JSONArray;
|
||||
+import org.json.simple.JSONObject;
|
||||
+
|
||||
+import javax.net.ssl.HttpsURLConnection;
|
||||
+import java.io.ByteArrayOutputStream;
|
||||
+import java.io.DataOutputStream;
|
||||
+import java.io.File;
|
||||
+import java.io.IOException;
|
||||
+import java.net.URL;
|
||||
+import java.util.*;
|
||||
+import java.util.concurrent.Callable;
|
||||
+import java.util.concurrent.Executors;
|
||||
+import java.util.concurrent.ScheduledExecutorService;
|
||||
+import java.util.concurrent.TimeUnit;
|
||||
+import java.util.logging.Level;
|
||||
+import java.util.logging.Logger;
|
||||
+import java.util.regex.Matcher;
|
||||
+import java.util.regex.Pattern;
|
||||
+import java.util.zip.GZIPOutputStream;
|
||||
+
|
||||
+/**
|
||||
+ * bStats collects some data for plugin authors.
|
||||
+ *
|
||||
+ * Check out https://bStats.org/ to learn more about bStats!
|
||||
+ */
|
||||
+public class Metrics {
|
||||
+
|
||||
+ // Executor service for requests
|
||||
+ // We use an executor service because the Bukkit scheduler is affected by server lags
|
||||
+ private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
|
||||
+
|
||||
+ // The version of this bStats class
|
||||
+ public static final int B_STATS_VERSION = 1;
|
||||
+
|
||||
+ // The url to which the data is sent
|
||||
+ private static final String URL = "https://bStats.org/submitData/server-implementation";
|
||||
+
|
||||
+ // Should failed requests be logged?
|
||||
+ private static boolean logFailedRequests = false;
|
||||
+
|
||||
+ // The logger for the failed requests
|
||||
+ private static Logger logger = Logger.getLogger("bStats");
|
||||
+
|
||||
+ // The name of the server software
|
||||
+ private final String name;
|
||||
+
|
||||
+ // The uuid of the server
|
||||
+ private final String serverUUID;
|
||||
+
|
||||
+ // A list with all custom charts
|
||||
+ private final List<CustomChart> charts = new ArrayList<>();
|
||||
+
|
||||
+ /**
|
||||
+ * Class constructor.
|
||||
+ *
|
||||
+ * @param name The name of the server software.
|
||||
+ * @param serverUUID The uuid of the server.
|
||||
+ * @param logFailedRequests Whether failed requests should be logged or not.
|
||||
+ * @param logger The logger for the failed requests.
|
||||
+ */
|
||||
+ public Metrics(String name, String serverUUID, boolean logFailedRequests, Logger logger) {
|
||||
+ this.name = name;
|
||||
+ this.serverUUID = serverUUID;
|
||||
+ Metrics.logFailedRequests = logFailedRequests;
|
||||
+ Metrics.logger = logger;
|
||||
+
|
||||
+ // Start submitting the data
|
||||
+ startSubmitting();
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Adds a custom chart.
|
||||
+ *
|
||||
+ * @param chart The chart to add.
|
||||
+ */
|
||||
+ public void addCustomChart(CustomChart chart) {
|
||||
+ if (chart == null) {
|
||||
+ throw new IllegalArgumentException("Chart cannot be null!");
|
||||
+ }
|
||||
+ charts.add(chart);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Starts the Scheduler which submits our data every 30 minutes.
|
||||
+ */
|
||||
+ private void startSubmitting() {
|
||||
+ final Runnable submitTask = this::submitData;
|
||||
+
|
||||
+ // Many servers tend to restart at a fixed time at xx:00 which causes an uneven distribution of requests on the
|
||||
+ // bStats backend. To circumvent this problem, we introduce some randomness into the initial and second delay.
|
||||
+ // WARNING: You must not modify any part of this Metrics class, including the submit delay or frequency!
|
||||
+ // WARNING: Modifying this code will get your plugin banned on bStats. Just don't do it!
|
||||
+ long initialDelay = (long) (1000 * 60 * (3 + Math.random() * 3));
|
||||
+ long secondDelay = (long) (1000 * 60 * (Math.random() * 30));
|
||||
+ scheduler.schedule(submitTask, initialDelay, TimeUnit.MILLISECONDS);
|
||||
+ scheduler.scheduleAtFixedRate(submitTask, initialDelay + secondDelay, 1000 * 60 * 30, TimeUnit.MILLISECONDS);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the plugin specific data.
|
||||
+ *
|
||||
+ * @return The plugin specific data.
|
||||
+ */
|
||||
+ private JSONObject getPluginData() {
|
||||
+ JSONObject data = new JSONObject();
|
||||
+
|
||||
+ data.put("pluginName", name); // Append the name of the server software
|
||||
+ JSONArray customCharts = new JSONArray();
|
||||
+ for (CustomChart customChart : charts) {
|
||||
+ // Add the data of the custom charts
|
||||
+ JSONObject chart = customChart.getRequestJsonObject();
|
||||
+ if (chart == null) { // If the chart is null, we skip it
|
||||
+ continue;
|
||||
+ }
|
||||
+ customCharts.add(chart);
|
||||
+ }
|
||||
+ data.put("customCharts", customCharts);
|
||||
+
|
||||
+ return data;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the server specific data.
|
||||
+ *
|
||||
+ * @return The server specific data.
|
||||
+ */
|
||||
+ private JSONObject getServerData() {
|
||||
+ // OS specific data
|
||||
+ String osName = System.getProperty("os.name");
|
||||
+ String osArch = System.getProperty("os.arch");
|
||||
+ String osVersion = System.getProperty("os.version");
|
||||
+ int coreCount = Runtime.getRuntime().availableProcessors();
|
||||
+
|
||||
+ JSONObject data = new JSONObject();
|
||||
+
|
||||
+ data.put("serverUUID", serverUUID);
|
||||
+
|
||||
+ data.put("osName", osName);
|
||||
+ data.put("osArch", osArch);
|
||||
+ data.put("osVersion", osVersion);
|
||||
+ data.put("coreCount", coreCount);
|
||||
+
|
||||
+ return data;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Collects the data and sends it afterwards.
|
||||
+ */
|
||||
+ private void submitData() {
|
||||
+ final JSONObject data = getServerData();
|
||||
+
|
||||
+ JSONArray pluginData = new JSONArray();
|
||||
+ pluginData.add(getPluginData());
|
||||
+ data.put("plugins", pluginData);
|
||||
+
|
||||
+ try {
|
||||
+ // We are still in the Thread of the timer, so nothing get blocked :)
|
||||
+ sendData(data);
|
||||
+ } catch (Exception e) {
|
||||
+ // Something went wrong! :(
|
||||
+ if (logFailedRequests) {
|
||||
+ logger.log(Level.WARNING, "Could not submit stats of " + name, e);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Sends the data to the bStats server.
|
||||
+ *
|
||||
+ * @param data The data to send.
|
||||
+ * @throws Exception If the request failed.
|
||||
+ */
|
||||
+ private static void sendData(JSONObject data) throws Exception {
|
||||
+ if (data == null) {
|
||||
+ throw new IllegalArgumentException("Data cannot be null!");
|
||||
+ }
|
||||
+ HttpsURLConnection connection = (HttpsURLConnection) new URL(URL).openConnection();
|
||||
+
|
||||
+ // Compress the data to save bandwidth
|
||||
+ byte[] compressedData = compress(data.toString());
|
||||
+
|
||||
+ // Add headers
|
||||
+ connection.setRequestMethod("POST");
|
||||
+ connection.addRequestProperty("Accept", "application/json");
|
||||
+ connection.addRequestProperty("Connection", "close");
|
||||
+ connection.addRequestProperty("Content-Encoding", "gzip"); // We gzip our request
|
||||
+ connection.addRequestProperty("Content-Length", String.valueOf(compressedData.length));
|
||||
+ connection.setRequestProperty("Content-Type", "application/json"); // We send our data in JSON format
|
||||
+ connection.setRequestProperty("User-Agent", "MC-Server/" + B_STATS_VERSION);
|
||||
+
|
||||
+ // Send data
|
||||
+ connection.setDoOutput(true);
|
||||
+ DataOutputStream outputStream = new DataOutputStream(connection.getOutputStream());
|
||||
+ outputStream.write(compressedData);
|
||||
+ outputStream.flush();
|
||||
+ outputStream.close();
|
||||
+
|
||||
+ connection.getInputStream().close(); // We don't care about the response - Just send our data :)
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gzips the given String.
|
||||
+ *
|
||||
+ * @param str The string to gzip.
|
||||
+ * @return The gzipped String.
|
||||
+ * @throws IOException If the compression failed.
|
||||
+ */
|
||||
+ private static byte[] compress(final String str) throws IOException {
|
||||
+ if (str == null) {
|
||||
+ return null;
|
||||
+ }
|
||||
+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
+ GZIPOutputStream gzip = new GZIPOutputStream(outputStream);
|
||||
+ gzip.write(str.getBytes("UTF-8"));
|
||||
+ gzip.close();
|
||||
+ return outputStream.toByteArray();
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Represents a custom chart.
|
||||
+ */
|
||||
+ public static abstract class CustomChart {
|
||||
+
|
||||
+ // The id of the chart
|
||||
+ final String chartId;
|
||||
+
|
||||
+ /**
|
||||
+ * Class constructor.
|
||||
+ *
|
||||
+ * @param chartId The id of the chart.
|
||||
+ */
|
||||
+ CustomChart(String chartId) {
|
||||
+ if (chartId == null || chartId.isEmpty()) {
|
||||
+ throw new IllegalArgumentException("ChartId cannot be null or empty!");
|
||||
+ }
|
||||
+ this.chartId = chartId;
|
||||
+ }
|
||||
+
|
||||
+ private JSONObject getRequestJsonObject() {
|
||||
+ JSONObject chart = new JSONObject();
|
||||
+ chart.put("chartId", chartId);
|
||||
+ try {
|
||||
+ JSONObject data = getChartData();
|
||||
+ if (data == null) {
|
||||
+ // If the data is null we don't send the chart.
|
||||
+ return null;
|
||||
+ }
|
||||
+ chart.put("data", data);
|
||||
+ } catch (Throwable t) {
|
||||
+ if (logFailedRequests) {
|
||||
+ logger.log(Level.WARNING, "Failed to get data for custom chart with id " + chartId, t);
|
||||
+ }
|
||||
+ return null;
|
||||
+ }
|
||||
+ return chart;
|
||||
+ }
|
||||
+
|
||||
+ protected abstract JSONObject getChartData() throws Exception;
|
||||
+
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Represents a custom simple pie.
|
||||
+ */
|
||||
+ public static class SimplePie extends CustomChart {
|
||||
+
|
||||
+ private final Callable<String> callable;
|
||||
+
|
||||
+ /**
|
||||
+ * Class constructor.
|
||||
+ *
|
||||
+ * @param chartId The id of the chart.
|
||||
+ * @param callable The callable which is used to request the chart data.
|
||||
+ */
|
||||
+ public SimplePie(String chartId, Callable<String> callable) {
|
||||
+ super(chartId);
|
||||
+ this.callable = callable;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ protected JSONObject getChartData() throws Exception {
|
||||
+ JSONObject data = new JSONObject();
|
||||
+ String value = callable.call();
|
||||
+ if (value == null || value.isEmpty()) {
|
||||
+ // Null = skip the chart
|
||||
+ return null;
|
||||
+ }
|
||||
+ data.put("value", value);
|
||||
+ return data;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Represents a custom advanced pie.
|
||||
+ */
|
||||
+ public static class AdvancedPie extends CustomChart {
|
||||
+
|
||||
+ private final Callable<Map<String, Integer>> callable;
|
||||
+
|
||||
+ /**
|
||||
+ * Class constructor.
|
||||
+ *
|
||||
+ * @param chartId The id of the chart.
|
||||
+ * @param callable The callable which is used to request the chart data.
|
||||
+ */
|
||||
+ public AdvancedPie(String chartId, Callable<Map<String, Integer>> callable) {
|
||||
+ super(chartId);
|
||||
+ this.callable = callable;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ protected JSONObject getChartData() throws Exception {
|
||||
+ JSONObject data = new JSONObject();
|
||||
+ JSONObject values = new JSONObject();
|
||||
+ Map<String, Integer> map = callable.call();
|
||||
+ if (map == null || map.isEmpty()) {
|
||||
+ // Null = skip the chart
|
||||
+ return null;
|
||||
+ }
|
||||
+ boolean allSkipped = true;
|
||||
+ for (Map.Entry<String, Integer> entry : map.entrySet()) {
|
||||
+ if (entry.getValue() == 0) {
|
||||
+ continue; // Skip this invalid
|
||||
+ }
|
||||
+ allSkipped = false;
|
||||
+ values.put(entry.getKey(), entry.getValue());
|
||||
+ }
|
||||
+ if (allSkipped) {
|
||||
+ // Null = skip the chart
|
||||
+ return null;
|
||||
+ }
|
||||
+ data.put("values", values);
|
||||
+ return data;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Represents a custom drilldown pie.
|
||||
+ */
|
||||
+ public static class DrilldownPie extends CustomChart {
|
||||
+
|
||||
+ private final Callable<Map<String, Map<String, Integer>>> callable;
|
||||
+
|
||||
+ /**
|
||||
+ * Class constructor.
|
||||
+ *
|
||||
+ * @param chartId The id of the chart.
|
||||
+ * @param callable The callable which is used to request the chart data.
|
||||
+ */
|
||||
+ public DrilldownPie(String chartId, Callable<Map<String, Map<String, Integer>>> callable) {
|
||||
+ super(chartId);
|
||||
+ this.callable = callable;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public JSONObject getChartData() throws Exception {
|
||||
+ JSONObject data = new JSONObject();
|
||||
+ JSONObject values = new JSONObject();
|
||||
+ Map<String, Map<String, Integer>> map = callable.call();
|
||||
+ if (map == null || map.isEmpty()) {
|
||||
+ // Null = skip the chart
|
||||
+ return null;
|
||||
+ }
|
||||
+ boolean reallyAllSkipped = true;
|
||||
+ for (Map.Entry<String, Map<String, Integer>> entryValues : map.entrySet()) {
|
||||
+ JSONObject value = new JSONObject();
|
||||
+ boolean allSkipped = true;
|
||||
+ for (Map.Entry<String, Integer> valueEntry : map.get(entryValues.getKey()).entrySet()) {
|
||||
+ value.put(valueEntry.getKey(), valueEntry.getValue());
|
||||
+ allSkipped = false;
|
||||
+ }
|
||||
+ if (!allSkipped) {
|
||||
+ reallyAllSkipped = false;
|
||||
+ values.put(entryValues.getKey(), value);
|
||||
+ }
|
||||
+ }
|
||||
+ if (reallyAllSkipped) {
|
||||
+ // Null = skip the chart
|
||||
+ return null;
|
||||
+ }
|
||||
+ data.put("values", values);
|
||||
+ return data;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Represents a custom single line chart.
|
||||
+ */
|
||||
+ public static class SingleLineChart extends CustomChart {
|
||||
+
|
||||
+ private final Callable<Integer> callable;
|
||||
+
|
||||
+ /**
|
||||
+ * Class constructor.
|
||||
+ *
|
||||
+ * @param chartId The id of the chart.
|
||||
+ * @param callable The callable which is used to request the chart data.
|
||||
+ */
|
||||
+ public SingleLineChart(String chartId, Callable<Integer> callable) {
|
||||
+ super(chartId);
|
||||
+ this.callable = callable;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ protected JSONObject getChartData() throws Exception {
|
||||
+ JSONObject data = new JSONObject();
|
||||
+ int value = callable.call();
|
||||
+ if (value == 0) {
|
||||
+ // Null = skip the chart
|
||||
+ return null;
|
||||
+ }
|
||||
+ data.put("value", value);
|
||||
+ return data;
|
||||
+ }
|
||||
+
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Represents a custom multi line chart.
|
||||
+ */
|
||||
+ public static class MultiLineChart extends CustomChart {
|
||||
+
|
||||
+ private final Callable<Map<String, Integer>> callable;
|
||||
+
|
||||
+ /**
|
||||
+ * Class constructor.
|
||||
+ *
|
||||
+ * @param chartId The id of the chart.
|
||||
+ * @param callable The callable which is used to request the chart data.
|
||||
+ */
|
||||
+ public MultiLineChart(String chartId, Callable<Map<String, Integer>> callable) {
|
||||
+ super(chartId);
|
||||
+ this.callable = callable;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ protected JSONObject getChartData() throws Exception {
|
||||
+ JSONObject data = new JSONObject();
|
||||
+ JSONObject values = new JSONObject();
|
||||
+ Map<String, Integer> map = callable.call();
|
||||
+ if (map == null || map.isEmpty()) {
|
||||
+ // Null = skip the chart
|
||||
+ return null;
|
||||
+ }
|
||||
+ boolean allSkipped = true;
|
||||
+ for (Map.Entry<String, Integer> entry : map.entrySet()) {
|
||||
+ if (entry.getValue() == 0) {
|
||||
+ continue; // Skip this invalid
|
||||
+ }
|
||||
+ allSkipped = false;
|
||||
+ values.put(entry.getKey(), entry.getValue());
|
||||
+ }
|
||||
+ if (allSkipped) {
|
||||
+ // Null = skip the chart
|
||||
+ return null;
|
||||
+ }
|
||||
+ data.put("values", values);
|
||||
+ return data;
|
||||
+ }
|
||||
+
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Represents a custom simple bar chart.
|
||||
+ */
|
||||
+ public static class SimpleBarChart extends CustomChart {
|
||||
+
|
||||
+ private final Callable<Map<String, Integer>> callable;
|
||||
+
|
||||
+ /**
|
||||
+ * Class constructor.
|
||||
+ *
|
||||
+ * @param chartId The id of the chart.
|
||||
+ * @param callable The callable which is used to request the chart data.
|
||||
+ */
|
||||
+ public SimpleBarChart(String chartId, Callable<Map<String, Integer>> callable) {
|
||||
+ super(chartId);
|
||||
+ this.callable = callable;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ protected JSONObject getChartData() throws Exception {
|
||||
+ JSONObject data = new JSONObject();
|
||||
+ JSONObject values = new JSONObject();
|
||||
+ Map<String, Integer> map = callable.call();
|
||||
+ if (map == null || map.isEmpty()) {
|
||||
+ // Null = skip the chart
|
||||
+ return null;
|
||||
+ }
|
||||
+ for (Map.Entry<String, Integer> entry : map.entrySet()) {
|
||||
+ JSONArray categoryValues = new JSONArray();
|
||||
+ categoryValues.add(entry.getValue());
|
||||
+ values.put(entry.getKey(), categoryValues);
|
||||
+ }
|
||||
+ data.put("values", values);
|
||||
+ return data;
|
||||
+ }
|
||||
+
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Represents a custom advanced bar chart.
|
||||
+ */
|
||||
+ public static class AdvancedBarChart extends CustomChart {
|
||||
+
|
||||
+ private final Callable<Map<String, int[]>> callable;
|
||||
+
|
||||
+ /**
|
||||
+ * Class constructor.
|
||||
+ *
|
||||
+ * @param chartId The id of the chart.
|
||||
+ * @param callable The callable which is used to request the chart data.
|
||||
+ */
|
||||
+ public AdvancedBarChart(String chartId, Callable<Map<String, int[]>> callable) {
|
||||
+ super(chartId);
|
||||
+ this.callable = callable;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ protected JSONObject getChartData() throws Exception {
|
||||
+ JSONObject data = new JSONObject();
|
||||
+ JSONObject values = new JSONObject();
|
||||
+ Map<String, int[]> map = callable.call();
|
||||
+ if (map == null || map.isEmpty()) {
|
||||
+ // Null = skip the chart
|
||||
+ return null;
|
||||
+ }
|
||||
+ boolean allSkipped = true;
|
||||
+ for (Map.Entry<String, int[]> entry : map.entrySet()) {
|
||||
+ if (entry.getValue().length == 0) {
|
||||
+ continue; // Skip this invalid
|
||||
+ }
|
||||
+ allSkipped = false;
|
||||
+ JSONArray categoryValues = new JSONArray();
|
||||
+ for (int categoryValue : entry.getValue()) {
|
||||
+ categoryValues.add(categoryValue);
|
||||
+ }
|
||||
+ values.put(entry.getKey(), categoryValues);
|
||||
+ }
|
||||
+ if (allSkipped) {
|
||||
+ // Null = skip the chart
|
||||
+ return null;
|
||||
+ }
|
||||
+ data.put("values", values);
|
||||
+ return data;
|
||||
+ }
|
||||
+
|
||||
+ }
|
||||
+
|
||||
+ public static class PaperMetrics {
|
||||
+ public static void startMetrics() {
|
||||
+ // Get the config file
|
||||
+ File configFile = new File(new File((File) MinecraftServer.getServer().options.valueOf("plugins"), "bStats"), "config.yml");
|
||||
+ YamlConfiguration config = YamlConfiguration.loadConfiguration(configFile);
|
||||
+
|
||||
+ // Check if the config file exists
|
||||
+ if (!config.isSet("serverUuid")) {
|
||||
+
|
||||
+ // Add default values
|
||||
+ config.addDefault("enabled", true);
|
||||
+ // Every server gets it's unique random id.
|
||||
+ config.addDefault("serverUuid", UUID.randomUUID().toString());
|
||||
+ // Should failed request be logged?
|
||||
+ config.addDefault("logFailedRequests", false);
|
||||
+
|
||||
+ // Inform the server owners about bStats
|
||||
+ config.options().header(
|
||||
+ "bStats collects some data for plugin authors like how many servers are using their plugins.\n" +
|
||||
+ "To honor their work, you should not disable it.\n" +
|
||||
+ "This has nearly no effect on the server performance!\n" +
|
||||
+ "Check out https://bStats.org/ to learn more :)"
|
||||
+ ).copyDefaults(true);
|
||||
+ try {
|
||||
+ config.save(configFile);
|
||||
+ } catch (IOException ignored) {
|
||||
+ }
|
||||
+ }
|
||||
+ // Load the data
|
||||
+ String serverUUID = config.getString("serverUuid");
|
||||
+ boolean logFailedRequests = config.getBoolean("logFailedRequests", false);
|
||||
+ // Only start Metrics, if it's enabled in the config
|
||||
+ if (config.getBoolean("enabled", true)) {
|
||||
+ Metrics metrics = new Metrics("Paper", serverUUID, logFailedRequests, Bukkit.getLogger());
|
||||
+
|
||||
+ metrics.addCustomChart(new Metrics.SimplePie("minecraft_version", () -> {
|
||||
+ String minecraftVersion = Bukkit.getVersion();
|
||||
+ minecraftVersion = minecraftVersion.substring(minecraftVersion.indexOf("MC: ") + 4, minecraftVersion.length() - 1);
|
||||
+ return minecraftVersion;
|
||||
+ }));
|
||||
+
|
||||
+ metrics.addCustomChart(new Metrics.SingleLineChart("players", () -> Bukkit.getOnlinePlayers().size()));
|
||||
+ metrics.addCustomChart(new Metrics.SimplePie("online_mode", () -> Bukkit.getOnlineMode() ? "online" : "offline"));
|
||||
+ final String paperVersion;
|
||||
+ final String implVersion = org.bukkit.craftbukkit.Main.class.getPackage().getImplementationVersion();
|
||||
+ if (implVersion != null) {
|
||||
+ final String buildOrHash = implVersion.substring(implVersion.lastIndexOf('-') + 1);
|
||||
+ paperVersion = "git-Paper-%s-%s".formatted(Bukkit.getServer().getMinecraftVersion(), buildOrHash);
|
||||
+ } else {
|
||||
+ paperVersion = "unknown";
|
||||
+ }
|
||||
+ metrics.addCustomChart(new Metrics.SimplePie("paper_version", () -> paperVersion));
|
||||
+
|
||||
+ metrics.addCustomChart(new Metrics.DrilldownPie("java_version", () -> {
|
||||
+ Map<String, Map<String, Integer>> map = new HashMap<>();
|
||||
+ String javaVersion = System.getProperty("java.version");
|
||||
+ Map<String, Integer> entry = new HashMap<>();
|
||||
+ entry.put(javaVersion, 1);
|
||||
+
|
||||
+ // http://openjdk.java.net/jeps/223
|
||||
+ // Java decided to change their versioning scheme and in doing so modified the java.version system
|
||||
+ // property to return $major[.$minor][.$secuity][-ea], as opposed to 1.$major.0_$identifier
|
||||
+ // we can handle pre-9 by checking if the "major" is equal to "1", otherwise, 9+
|
||||
+ String majorVersion = javaVersion.split("\\.")[0];
|
||||
+ String release;
|
||||
+
|
||||
+ int indexOf = javaVersion.lastIndexOf('.');
|
||||
+
|
||||
+ if (majorVersion.equals("1")) {
|
||||
+ release = "Java " + javaVersion.substring(0, indexOf);
|
||||
+ } else {
|
||||
+ // of course, it really wouldn't be all that simple if they didn't add a quirk, now would it
|
||||
+ // valid strings for the major may potentially include values such as -ea to deannotate a pre release
|
||||
+ Matcher versionMatcher = Pattern.compile("\\d+").matcher(majorVersion);
|
||||
+ if (versionMatcher.find()) {
|
||||
+ majorVersion = versionMatcher.group(0);
|
||||
+ }
|
||||
+ release = "Java " + majorVersion;
|
||||
+ }
|
||||
+ map.put(release, entry);
|
||||
+
|
||||
+ return map;
|
||||
+ }));
|
||||
+
|
||||
+ metrics.addCustomChart(new Metrics.DrilldownPie("legacy_plugins", () -> {
|
||||
+ Map<String, Map<String, Integer>> map = new HashMap<>();
|
||||
+
|
||||
+ // count legacy plugins
|
||||
+ int legacy = 0;
|
||||
+ for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
|
||||
+ if (CraftMagicNumbers.isLegacy(plugin.getDescription())) {
|
||||
+ legacy++;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ // insert real value as lower dimension
|
||||
+ Map<String, Integer> entry = new HashMap<>();
|
||||
+ entry.put(String.valueOf(legacy), 1);
|
||||
+
|
||||
+ // create buckets as higher dimension
|
||||
+ if (legacy == 0) {
|
||||
+ map.put("0 \uD83D\uDE0E", entry); // :sunglasses:
|
||||
+ } else if (legacy <= 5) {
|
||||
+ map.put("1-5", entry);
|
||||
+ } else if (legacy <= 10) {
|
||||
+ map.put("6-10", entry);
|
||||
+ } else if (legacy <= 25) {
|
||||
+ map.put("11-25", entry);
|
||||
+ } else if (legacy <= 50) {
|
||||
+ map.put("26-50", entry);
|
||||
+ } else {
|
||||
+ map.put("50+ \uD83D\uDE2D", entry); // :cry:
|
||||
+ }
|
||||
+
|
||||
+ return map;
|
||||
+ }));
|
||||
+ }
|
||||
+
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
index cb6f192c11cda6230ec365e6cefb44a37416236d..11006df8797334da69801cdb9aa34b0f941cf90d 100644
|
||||
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
@@ -187,6 +187,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||
paperConfigurations.initializeGlobalConfiguration();
|
||||
paperConfigurations.initializeWorldDefaultsConfiguration();
|
||||
io.papermc.paper.command.PaperCommands.registerCommands(this);
|
||||
+ com.destroystokyo.paper.Metrics.PaperMetrics.startMetrics();
|
||||
// Paper end
|
||||
|
||||
this.setPvpAllowed(dedicatedserverproperties.pvp);
|
||||
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
|
||||
index 83eabc34d952bbb13ec4b4bdcf34f647189c0b46..0a0aa6de31a94a701074cc5f43c94be7515a185c 100644
|
||||
--- a/src/main/java/org/spigotmc/SpigotConfig.java
|
||||
+++ b/src/main/java/org/spigotmc/SpigotConfig.java
|
||||
@@ -83,6 +83,7 @@ public class SpigotConfig
|
||||
MinecraftServer.getServer().server.getCommandMap().register( entry.getKey(), "Spigot", entry.getValue() );
|
||||
}
|
||||
|
||||
+ /* // Paper - Replace with our own
|
||||
if ( SpigotConfig.metrics == null )
|
||||
{
|
||||
try
|
||||
@@ -94,6 +95,7 @@ public class SpigotConfig
|
||||
Bukkit.getServer().getLogger().log( Level.SEVERE, "Could not start metrics service", ex );
|
||||
}
|
||||
}
|
||||
+ */ // Paper end
|
||||
}
|
||||
|
||||
public static void readConfig(Class<?> clazz, Object instance) // Paper - package-private -> public
|
7348
patches/unapplied/server/0013-Paper-Plugins.patch
Normal file
7348
patches/unapplied/server/0013-Paper-Plugins.patch
Normal file
File diff suppressed because it is too large
Load diff
2114
patches/unapplied/server/0014-Timings-v2.patch
Normal file
2114
patches/unapplied/server/0014-Timings-v2.patch
Normal file
File diff suppressed because it is too large
Load diff
22916
patches/unapplied/server/0015-Rewrite-dataconverter-system.patch
Normal file
22916
patches/unapplied/server/0015-Rewrite-dataconverter-system.patch
Normal file
File diff suppressed because one or more lines are too long
5298
patches/unapplied/server/0016-Starlight.patch
Normal file
5298
patches/unapplied/server/0016-Starlight.patch
Normal file
File diff suppressed because it is too large
Load diff
105
patches/unapplied/server/0017-Add-TickThread.patch
Normal file
105
patches/unapplied/server/0017-Add-TickThread.patch
Normal file
|
@ -0,0 +1,105 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
|
||||
Date: Sun, 3 Mar 2019 20:53:18 -0800
|
||||
Subject: [PATCH] Add TickThread
|
||||
|
||||
Placeholder patch, to be used by chunksystem rewrite
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/util/TickThread.java b/src/main/java/io/papermc/paper/util/TickThread.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..d59885ee9c8b29d5bac34dce0597e345e5358c77
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/util/TickThread.java
|
||||
@@ -0,0 +1,79 @@
|
||||
+package io.papermc.paper.util;
|
||||
+
|
||||
+import net.minecraft.server.MinecraftServer;
|
||||
+import net.minecraft.server.level.ServerLevel;
|
||||
+import net.minecraft.world.entity.Entity;
|
||||
+import org.bukkit.Bukkit;
|
||||
+import java.util.concurrent.atomic.AtomicInteger;
|
||||
+
|
||||
+public final class TickThread extends Thread {
|
||||
+
|
||||
+ public static final boolean STRICT_THREAD_CHECKS = Boolean.getBoolean("paper.strict-thread-checks");
|
||||
+
|
||||
+ static {
|
||||
+ if (STRICT_THREAD_CHECKS) {
|
||||
+ MinecraftServer.LOGGER.warn("Strict thread checks enabled - performance may suffer");
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public static void softEnsureTickThread(final String reason) {
|
||||
+ if (!STRICT_THREAD_CHECKS) {
|
||||
+ return;
|
||||
+ }
|
||||
+ ensureTickThread(reason);
|
||||
+ }
|
||||
+
|
||||
+ public static void ensureTickThread(final String reason) {
|
||||
+ if (!isTickThread()) {
|
||||
+ MinecraftServer.LOGGER.error("Thread " + Thread.currentThread().getName() + " failed main thread check: " + reason, new Throwable());
|
||||
+ throw new IllegalStateException(reason);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public static void ensureTickThread(final ServerLevel world, final int chunkX, final int chunkZ, final String reason) {
|
||||
+ if (!isTickThreadFor(world, chunkX, chunkZ)) {
|
||||
+ MinecraftServer.LOGGER.error("Thread " + Thread.currentThread().getName() + " failed main thread check: " + reason, new Throwable());
|
||||
+ throw new IllegalStateException(reason);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public static void ensureTickThread(final Entity entity, final String reason) {
|
||||
+ if (!isTickThreadFor(entity)) {
|
||||
+ MinecraftServer.LOGGER.error("Thread " + Thread.currentThread().getName() + " failed main thread check: " + reason, new Throwable());
|
||||
+ throw new IllegalStateException(reason);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public final int id; /* We don't override getId as the spec requires that it be unique (with respect to all other threads) */
|
||||
+
|
||||
+ private static final AtomicInteger ID_GENERATOR = new AtomicInteger();
|
||||
+
|
||||
+ public TickThread(final String name) {
|
||||
+ this(null, name);
|
||||
+ }
|
||||
+
|
||||
+ public TickThread(final Runnable run, final String name) {
|
||||
+ this(run, name, ID_GENERATOR.incrementAndGet());
|
||||
+ }
|
||||
+
|
||||
+ private TickThread(final Runnable run, final String name, final int id) {
|
||||
+ super(run, name);
|
||||
+ this.id = id;
|
||||
+ }
|
||||
+
|
||||
+ public static TickThread getCurrentTickThread() {
|
||||
+ return (TickThread)Thread.currentThread();
|
||||
+ }
|
||||
+
|
||||
+ public static boolean isTickThread() {
|
||||
+ return Bukkit.isPrimaryThread();
|
||||
+ }
|
||||
+
|
||||
+ public static boolean isTickThreadFor(final ServerLevel world, final int chunkX, final int chunkZ) {
|
||||
+ return Bukkit.isPrimaryThread();
|
||||
+ }
|
||||
+
|
||||
+ public static boolean isTickThreadFor(final Entity entity) {
|
||||
+ return Bukkit.isPrimaryThread();
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/org/spigotmc/AsyncCatcher.java b/src/main/java/org/spigotmc/AsyncCatcher.java
|
||||
index bbf0d9d9c44fe8d7add2f978994ec129420814c7..78669fa035b7537ff7e533cf32aaf2995625424f 100644
|
||||
--- a/src/main/java/org/spigotmc/AsyncCatcher.java
|
||||
+++ b/src/main/java/org/spigotmc/AsyncCatcher.java
|
||||
@@ -9,7 +9,7 @@ public class AsyncCatcher
|
||||
|
||||
public static void catchOp(String reason)
|
||||
{
|
||||
- if ( AsyncCatcher.enabled && Thread.currentThread() != MinecraftServer.getServer().serverThread )
|
||||
+ if ( (AsyncCatcher.enabled || io.papermc.paper.util.TickThread.STRICT_THREAD_CHECKS) && Thread.currentThread() != MinecraftServer.getServer().serverThread ) // Paper
|
||||
{
|
||||
throw new IllegalStateException( "Asynchronous " + reason + "!" );
|
||||
}
|
18182
patches/unapplied/server/0018-Rewrite-chunk-system.patch
Normal file
18182
patches/unapplied/server/0018-Rewrite-chunk-system.patch
Normal file
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,65 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
|
||||
Date: Tue, 18 May 2021 14:39:44 -0700
|
||||
Subject: [PATCH] Add command line option to load extra plugin jars not in the
|
||||
plugins folder
|
||||
|
||||
ex: java -jar paperclip.jar nogui -add-plugin=/path/to/plugin.jar -add-plugin=/path/to/another/plugin_jar.jar
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index d6f858ee1245b313024c36ac2a0edd09b9307bca..d82e0dd38ef2b32d82e906d5bc71b46052eb0625 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -420,6 +420,35 @@ public final class CraftServer implements Server {
|
||||
io.papermc.paper.plugin.entrypoint.LaunchEntryPointHandler.INSTANCE.enter(io.papermc.paper.plugin.entrypoint.Entrypoint.PLUGIN); // Paper - replace implementation
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ @Override
|
||||
+ public File getPluginsFolder() {
|
||||
+ return (File) this.console.options.valueOf("plugins");
|
||||
+ }
|
||||
+
|
||||
+ private List<File> extraPluginJars() {
|
||||
+ @SuppressWarnings("unchecked")
|
||||
+ final List<File> jars = (List<File>) this.console.options.valuesOf("add-plugin");
|
||||
+ final List<File> list = new ArrayList<>();
|
||||
+ for (final File file : jars) {
|
||||
+ if (!file.exists()) {
|
||||
+ net.minecraft.server.MinecraftServer.LOGGER.warn("File '{}' specified through 'add-plugin' argument does not exist, cannot load a plugin from it!", file.getAbsolutePath());
|
||||
+ continue;
|
||||
+ }
|
||||
+ if (!file.isFile()) {
|
||||
+ net.minecraft.server.MinecraftServer.LOGGER.warn("File '{}' specified through 'add-plugin' argument is not a file, cannot load a plugin from it!", file.getAbsolutePath());
|
||||
+ continue;
|
||||
+ }
|
||||
+ if (!file.getName().endsWith(".jar")) {
|
||||
+ net.minecraft.server.MinecraftServer.LOGGER.warn("File '{}' specified through 'add-plugin' argument is not a jar file, cannot load a plugin from it!", file.getAbsolutePath());
|
||||
+ continue;
|
||||
+ }
|
||||
+ list.add(file);
|
||||
+ }
|
||||
+ return list;
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
public void enablePlugins(PluginLoadOrder type) {
|
||||
if (type == PluginLoadOrder.STARTUP) {
|
||||
this.helpMap.clear();
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||
index 481c1f853bbe81da123cfb3f79ed4509cf127db8..985aae207e23584519b4c096f2aaaf0e80b6c163 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||
@@ -149,6 +149,12 @@ public class Main {
|
||||
.ofType(File.class)
|
||||
.defaultsTo(new File("paper.yml"))
|
||||
.describedAs("Yml file");
|
||||
+
|
||||
+ acceptsAll(asList("add-plugin", "add-extra-plugin-jar"), "Specify paths to extra plugin jars to be loaded in addition to those in the plugins folder. This argument can be specified multiple times, once for each extra plugin jar path.")
|
||||
+ .withRequiredArg()
|
||||
+ .ofType(File.class)
|
||||
+ .defaultsTo(new File[] {})
|
||||
+ .describedAs("Jar file");
|
||||
// Paper end
|
||||
}
|
||||
};
|
|
@ -0,0 +1,92 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Zach Brown <zach.brown@destroystokyo.com>
|
||||
Date: Tue, 1 Mar 2016 13:02:51 -0600
|
||||
Subject: [PATCH] Configurable cactus bamboo and reed growth heights
|
||||
|
||||
Bamboo - Both the minimum fully-grown heights and the maximum are configurable
|
||||
- Machine_Maker
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/BambooStalkBlock.java b/src/main/java/net/minecraft/world/level/block/BambooStalkBlock.java
|
||||
index 0d05ad9c0b5043e58d639041cfe3fb7a27f373a3..a5d391af2c6b733d653188f4aeeec2afffd96adf 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/BambooStalkBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/BambooStalkBlock.java
|
||||
@@ -130,7 +130,7 @@ public class BambooStalkBlock extends Block implements BonemealableBlock {
|
||||
if (random.nextFloat() < (world.spigotConfig.bambooModifier / (100.0f * 3)) && world.isEmptyBlock(pos.above()) && world.getRawBrightness(pos.above(), 0) >= 9) { // Spigot - SPIGOT-7159: Better modifier resolution
|
||||
int i = this.getHeightBelowUpToMax(world, pos) + 1;
|
||||
|
||||
- if (i < 16) {
|
||||
+ if (i < world.paperConfig().maxGrowthHeight.bamboo.max) { // Paper
|
||||
this.growBamboo(state, world, pos, random, i);
|
||||
}
|
||||
}
|
||||
@@ -161,7 +161,7 @@ public class BambooStalkBlock extends Block implements BonemealableBlock {
|
||||
int i = this.getHeightAboveUpToMax(world, pos);
|
||||
int j = this.getHeightBelowUpToMax(world, pos);
|
||||
|
||||
- return i + j + 1 < 16 && (Integer) world.getBlockState(pos.above(i)).getValue(BambooStalkBlock.STAGE) != 1;
|
||||
+ return i + j + 1 < ((Level) world).paperConfig().maxGrowthHeight.bamboo.max && (Integer) world.getBlockState(pos.above(i)).getValue(BambooStalkBlock.STAGE) != 1; // Paper
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -180,7 +180,7 @@ public class BambooStalkBlock extends Block implements BonemealableBlock {
|
||||
BlockPos blockposition1 = pos.above(i);
|
||||
BlockState iblockdata1 = world.getBlockState(blockposition1);
|
||||
|
||||
- if (k >= 16 || !iblockdata1.is(Blocks.BAMBOO) || (Integer) iblockdata1.getValue(BambooStalkBlock.STAGE) == 1 || !world.isEmptyBlock(blockposition1.above())) { // CraftBukkit - If the BlockSpreadEvent was cancelled, we have no bamboo here
|
||||
+ if (k >= world.paperConfig().maxGrowthHeight.bamboo.max || !iblockdata1.is(Blocks.BAMBOO) || (Integer) iblockdata1.getValue(BambooStalkBlock.STAGE) == 1 || !world.isEmptyBlock(blockposition1.above())) { // CraftBukkit - If the BlockSpreadEvent was cancelled, we have no bamboo here // Paper - Configurable cactus bamboo and reed growth heights
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -221,7 +221,7 @@ public class BambooStalkBlock extends Block implements BonemealableBlock {
|
||||
}
|
||||
|
||||
int j = (Integer) state.getValue(BambooStalkBlock.AGE) != 1 && !iblockdata2.is(Blocks.BAMBOO) ? 0 : 1;
|
||||
- int k = (height < 11 || random.nextFloat() >= 0.25F) && height != 15 ? 0 : 1;
|
||||
+ int k = (height < world.paperConfig().maxGrowthHeight.bamboo.min || random.nextFloat() >= 0.25F) && height != (world.paperConfig().maxGrowthHeight.bamboo.max - 1) ? 0 : 1; // Paper
|
||||
|
||||
// CraftBukkit start
|
||||
if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(world, pos, pos.above(), (BlockState) ((BlockState) ((BlockState) this.defaultBlockState().setValue(BambooStalkBlock.AGE, j)).setValue(BambooStalkBlock.LEAVES, blockpropertybamboosize)).setValue(BambooStalkBlock.STAGE, k), 3)) {
|
||||
@@ -236,7 +236,7 @@ public class BambooStalkBlock extends Block implements BonemealableBlock {
|
||||
protected int getHeightAboveUpToMax(BlockGetter world, BlockPos pos) {
|
||||
int i;
|
||||
|
||||
- for (i = 0; i < 16 && world.getBlockState(pos.above(i + 1)).is(Blocks.BAMBOO); ++i) {
|
||||
+ for (i = 0; i < ((Level) world).paperConfig().maxGrowthHeight.bamboo.max && world.getBlockState(pos.above(i + 1)).is(Blocks.BAMBOO); ++i) { // Paper
|
||||
;
|
||||
}
|
||||
|
||||
@@ -246,7 +246,7 @@ public class BambooStalkBlock extends Block implements BonemealableBlock {
|
||||
protected int getHeightBelowUpToMax(BlockGetter world, BlockPos pos) {
|
||||
int i;
|
||||
|
||||
- for (i = 0; i < 16 && world.getBlockState(pos.below(i + 1)).is(Blocks.BAMBOO); ++i) {
|
||||
+ for (i = 0; i < ((Level) world).paperConfig().maxGrowthHeight.bamboo.max && world.getBlockState(pos.below(i + 1)).is(Blocks.BAMBOO); ++i) { // Paper
|
||||
;
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/CactusBlock.java b/src/main/java/net/minecraft/world/level/block/CactusBlock.java
|
||||
index ea052e4a5e5cb23609129fd08869bcd38f675cd0..7f137f43f725cd2866e10f0ade40d4906b64fac1 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/CactusBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/CactusBlock.java
|
||||
@@ -55,7 +55,7 @@ public class CactusBlock extends Block {
|
||||
;
|
||||
}
|
||||
|
||||
- if (i < 3) {
|
||||
+ if (i < world.paperConfig().maxGrowthHeight.cactus) { // Paper - Configurable growth height
|
||||
int j = (Integer) state.getValue(CactusBlock.AGE);
|
||||
|
||||
int modifier = world.spigotConfig.cactusModifier; // Spigot - SPIGOT-7159: Better modifier resolution
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/SugarCaneBlock.java b/src/main/java/net/minecraft/world/level/block/SugarCaneBlock.java
|
||||
index 2aa81f93a2e1e94d0788b4d7b67f94494101c397..6b400a4759c8c8612a3b5c96ca0d87ef9dc71435 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/SugarCaneBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/SugarCaneBlock.java
|
||||
@@ -52,7 +52,7 @@ public class SugarCaneBlock extends Block {
|
||||
;
|
||||
}
|
||||
|
||||
- if (i < 3) {
|
||||
+ if (i < world.paperConfig().maxGrowthHeight.reeds) { // Paper - Configurable growth height
|
||||
int j = (Integer) state.getValue(SugarCaneBlock.AGE);
|
||||
|
||||
int modifier = world.spigotConfig.caneModifier; // Spigot - SPIGOT-7159: Better modifier resolution
|
|
@ -0,0 +1,30 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Zach Brown <zach.brown@destroystokyo.com>
|
||||
Date: Tue, 1 Mar 2016 13:09:16 -0600
|
||||
Subject: [PATCH] Configurable baby zombie movement speed
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/monster/Zombie.java b/src/main/java/net/minecraft/world/entity/monster/Zombie.java
|
||||
index 251487682550af7492068bd461bf0c61760de0fa..8ea60d388fff4a6368652ff96f648e5880053a2b 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/monster/Zombie.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/monster/Zombie.java
|
||||
@@ -77,6 +77,7 @@ public class Zombie extends Monster {
|
||||
|
||||
private static final UUID SPEED_MODIFIER_BABY_UUID = UUID.fromString("B9766B59-9566-4402-BC1F-2EE2A276D836");
|
||||
private static final AttributeModifier SPEED_MODIFIER_BABY = new AttributeModifier(Zombie.SPEED_MODIFIER_BABY_UUID, "Baby speed boost", 0.5D, AttributeModifier.Operation.MULTIPLY_BASE);
|
||||
+ private final AttributeModifier babyModifier = new net.minecraft.world.entity.ai.attributes.AttributeModifier(SPEED_MODIFIER_BABY.getId(), SPEED_MODIFIER_BABY.getName(), this.level.paperConfig().entities.behavior.babyZombieMovementModifier, SPEED_MODIFIER_BABY.getOperation()); // Paper - Make baby speed configurable
|
||||
private static final EntityDataAccessor<Boolean> DATA_BABY_ID = SynchedEntityData.defineId(Zombie.class, EntityDataSerializers.BOOLEAN);
|
||||
private static final EntityDataAccessor<Integer> DATA_SPECIAL_TYPE_ID = SynchedEntityData.defineId(Zombie.class, EntityDataSerializers.INT);
|
||||
public static final EntityDataAccessor<Boolean> DATA_DROWNED_CONVERSION_ID = SynchedEntityData.defineId(Zombie.class, EntityDataSerializers.BOOLEAN);
|
||||
@@ -185,9 +186,9 @@ public class Zombie extends Monster {
|
||||
if (this.level != null && !this.level.isClientSide) {
|
||||
AttributeInstance attributemodifiable = this.getAttribute(Attributes.MOVEMENT_SPEED);
|
||||
|
||||
- attributemodifiable.removeModifier(Zombie.SPEED_MODIFIER_BABY);
|
||||
+ attributemodifiable.removeModifier(this.babyModifier); // Paper
|
||||
if (baby) {
|
||||
- attributemodifiable.addTransientModifier(Zombie.SPEED_MODIFIER_BABY);
|
||||
+ attributemodifiable.addTransientModifier(this.babyModifier); // Paper
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Zach Brown <zach.brown@destroystokyo.com>
|
||||
Date: Tue, 1 Mar 2016 13:14:11 -0600
|
||||
Subject: [PATCH] Configurable fishing time ranges
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java b/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java
|
||||
index f0cb2fa768adf1ffe68a00457d39a7749899ac6b..9d0df8d64a2cfd2458295a214829f277798030f0 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java
|
||||
@@ -86,6 +86,10 @@ public class FishingHook extends Projectile {
|
||||
this.noCulling = true;
|
||||
this.luck = Math.max(0, luckOfTheSeaLevel);
|
||||
this.lureSpeed = Math.max(0, lureLevel);
|
||||
+ // Paper start
|
||||
+ minWaitTime = world.paperConfig().fishingTimeRange.minimum;
|
||||
+ maxWaitTime = world.paperConfig().fishingTimeRange.maximum;
|
||||
+ // Paper end
|
||||
}
|
||||
|
||||
public FishingHook(EntityType<? extends FishingHook> type, Level world) {
|
||||
@@ -401,7 +405,7 @@ public class FishingHook extends Projectile {
|
||||
} else {
|
||||
// CraftBukkit start - logic to modify fishing wait time
|
||||
this.timeUntilLured = Mth.nextInt(this.random, this.minWaitTime, this.maxWaitTime);
|
||||
- this.timeUntilLured -= (this.applyLure) ? this.lureSpeed * 20 * 5 : 0;
|
||||
+ this.timeUntilLured -= (this.applyLure) ? (this.lureSpeed * 20 * 5 >= this.maxWaitTime ? this.timeUntilLured - 1 : this.lureSpeed * 20 * 5) : 0; // Paper - Fix Lure infinite loop
|
||||
// CraftBukkit end
|
||||
}
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Zach Brown <zach.brown@destroystokyo.com>
|
||||
Date: Tue, 1 Mar 2016 13:24:16 -0600
|
||||
Subject: [PATCH] Allow nerfed mobs to jump and take water damage
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
index 10949455cc92ed6cb537fd7f148714c7ade4e360..c4b28340d62a89d6f896357c93fd933fe6cd934b 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
@@ -110,6 +110,7 @@ public abstract class Mob extends LivingEntity {
|
||||
private final BodyRotationControl bodyRotationControl;
|
||||
protected PathNavigation navigation;
|
||||
public GoalSelector goalSelector;
|
||||
+ @Nullable public net.minecraft.world.entity.ai.goal.FloatGoal goalFloat; // Paper
|
||||
public GoalSelector targetSelector;
|
||||
@Nullable
|
||||
private LivingEntity target;
|
||||
@@ -836,7 +837,17 @@ public abstract class Mob extends LivingEntity {
|
||||
@Override
|
||||
protected final void serverAiStep() {
|
||||
++this.noActionTime;
|
||||
- if (!this.aware) return; // CraftBukkit
|
||||
+ if (!this.aware) { // Paper start - Allow nerfed mobs to jump, float and take water damage
|
||||
+ if (goalFloat != null) {
|
||||
+ if (goalFloat.canUse()) goalFloat.tick();
|
||||
+ this.getJumpControl().tick();
|
||||
+ }
|
||||
+ if (this.isSensitiveToWater() && isInWaterRainOrBubble()) {
|
||||
+ hurt(DamageSource.DROWN, 1.0F);
|
||||
+ }
|
||||
+ return;
|
||||
+ }
|
||||
+ // Paper end
|
||||
this.level.getProfiler().push("sensing");
|
||||
this.sensing.tick();
|
||||
this.level.getProfiler().pop();
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/FloatGoal.java b/src/main/java/net/minecraft/world/entity/ai/goal/FloatGoal.java
|
||||
index 01950951ea06e43bedeeede489a112e577617829..7093c62be53fe99ed9880fc8ddaa07440fe4f715 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/goal/FloatGoal.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/goal/FloatGoal.java
|
||||
@@ -9,6 +9,7 @@ public class FloatGoal extends Goal {
|
||||
|
||||
public FloatGoal(Mob mob) {
|
||||
this.mob = mob;
|
||||
+ if (mob.getCommandSenderWorld().paperConfig().entities.behavior.spawnerNerfedMobsShouldJump) mob.goalFloat = this; // Paper
|
||||
this.setFlags(EnumSet.of(Goal.Flag.JUMP));
|
||||
mob.getNavigation().setCanFloat(true);
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Suddenly <suddenly@suddenly.coffee>
|
||||
Date: Tue, 1 Mar 2016 13:51:54 -0600
|
||||
Subject: [PATCH] Add configurable despawn distances for living entities
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
index c4b28340d62a89d6f896357c93fd933fe6cd934b..99218eac34374a4d13451cfec15006c3bf0d755f 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
@@ -812,14 +812,14 @@ public abstract class Mob extends LivingEntity {
|
||||
|
||||
if (entityhuman != null) {
|
||||
double d0 = entityhuman.distanceToSqr((Entity) this);
|
||||
- int i = this.getType().getCategory().getDespawnDistance();
|
||||
+ int i = this.level.paperConfig().entities.spawning.despawnRanges.get(this.getType().getCategory()).hard(); // Paper - custom despawn distances
|
||||
int j = i * i;
|
||||
|
||||
if (d0 > (double) j && this.removeWhenFarAway(d0)) {
|
||||
this.discard();
|
||||
}
|
||||
|
||||
- int k = this.getType().getCategory().getNoDespawnDistance();
|
||||
+ int k = this.level.paperConfig().entities.spawning.despawnRanges.get(this.getType().getCategory()).soft(); // Paper - custom despawn distances
|
||||
int l = k * k;
|
||||
|
||||
if (this.noActionTime > 600 && this.random.nextInt(800) == 0 && d0 > (double) l && this.removeWhenFarAway(d0)) {
|
|
@ -0,0 +1,18 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Zach Brown <zach.brown@destroystokyo.com>
|
||||
Date: Thu, 3 Mar 2016 03:53:43 -0600
|
||||
Subject: [PATCH] Allow for toggling of spawn chunks
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
||||
index 5ed57b1156b1f358fb7d1d876becfc06f47ffe3b..4b2aadae3a7595a5aee2bc71216adc34fa0f2cf9 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/Level.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
||||
@@ -256,6 +256,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
||||
});
|
||||
// CraftBukkit end
|
||||
timings = new co.aikar.timings.WorldTimingsHandler(this); // Paper - code below can generate new world and access timings
|
||||
+ this.keepSpawnInMemory = this.paperConfig().spawn.keepSpawnLoaded; // Paper
|
||||
this.entityLimiter = new org.spigotmc.TickLimiter(spigotConfig.entityMaxTickTime);
|
||||
this.tileLimiter = new org.spigotmc.TickLimiter(spigotConfig.tileMaxTickTime);
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Byteflux <byte@byteflux.net>
|
||||
Date: Tue, 1 Mar 2016 14:14:15 -0600
|
||||
Subject: [PATCH] Drop falling block and tnt entities at the specified height
|
||||
|
||||
Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
|
||||
index c186ea200e196ff97a9bbe78d4e550ccba2d40ac..c125564cfca5c4a616e11b334a9ec7929ebea496 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
|
||||
@@ -139,6 +139,17 @@ public class FallingBlockEntity extends Entity {
|
||||
}
|
||||
|
||||
this.move(MoverType.SELF, this.getDeltaMovement());
|
||||
+
|
||||
+ // Paper start - Configurable EntityFallingBlock height nerf
|
||||
+ if (this.level.paperConfig().fixes.fallingBlockHeightNerf.test(v -> this.getY() > v)) {
|
||||
+ if (this.dropItem && this.level.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) {
|
||||
+ this.spawnAtLocation(block);
|
||||
+ }
|
||||
+
|
||||
+ this.discard();
|
||||
+ return;
|
||||
+ }
|
||||
+ // Paper end
|
||||
if (!this.level.isClientSide) {
|
||||
BlockPos blockposition = this.blockPosition();
|
||||
boolean flag = this.blockState.getBlock() instanceof ConcretePowderBlock;
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
|
||||
index dd3eee50509f5388e78e0908e83925c43ab20628..43ec4bc45a3e553fbbf47aaf613f6e0aad2319cf 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
|
||||
@@ -65,6 +65,12 @@ public class PrimedTnt extends Entity {
|
||||
}
|
||||
|
||||
this.move(MoverType.SELF, this.getDeltaMovement());
|
||||
+ // Paper start - Configurable TNT entity height nerf
|
||||
+ if (this.level.paperConfig().fixes.tntEntityHeightNerf.test(v -> this.getY() > v)) {
|
||||
+ this.discard();
|
||||
+ return;
|
||||
+ }
|
||||
+ // Paper end
|
||||
this.setDeltaMovement(this.getDeltaMovement().scale(0.98D));
|
||||
if (this.onGround) {
|
||||
this.setDeltaMovement(this.getDeltaMovement().multiply(0.7D, -0.5D, 0.7D));
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/vehicle/MinecartTNT.java b/src/main/java/net/minecraft/world/entity/vehicle/MinecartTNT.java
|
||||
index db40c7a11dba6450ac9c1107b226aff5858867c9..3e2407e00e56b8648bc6b084ba016ddccf40a53b 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/vehicle/MinecartTNT.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/vehicle/MinecartTNT.java
|
||||
@@ -52,6 +52,12 @@ public class MinecartTNT extends AbstractMinecart {
|
||||
public void tick() {
|
||||
super.tick();
|
||||
if (this.fuse > 0) {
|
||||
+ // Paper start - Configurable TNT entity height nerf
|
||||
+ if (this.level.paperConfig().fixes.tntEntityHeightNerf.test(v -> this.getY() > v)) {
|
||||
+ this.discard();
|
||||
+ return;
|
||||
+ }
|
||||
+ // Paper end
|
||||
--this.fuse;
|
||||
this.level.addParticle(ParticleTypes.SMOKE, this.getX(), this.getY() + 0.5D, this.getZ(), 0.0D, 0.0D, 0.0D);
|
||||
} else if (this.fuse == 0) {
|
|
@ -0,0 +1,104 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Zach Brown <zach.brown@destroystokyo.com>
|
||||
Date: Tue, 1 Mar 2016 14:32:43 -0600
|
||||
Subject: [PATCH] Show 'Paper' in client crashes, server lists, and Mojang
|
||||
stats
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index e9f4ffec4b659f3300daa0138f6e955a8d97786d..e2e66fd4bd34e0ceaab350214a50ddbb1dc76184 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -1433,7 +1433,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
|
||||
@DontObfuscate
|
||||
public String getServerModName() {
|
||||
- return "Spigot"; // Spigot - Spigot > // CraftBukkit - cb > vanilla!
|
||||
+ return "Paper"; // Paper - Paper > // Spigot - Spigot > // CraftBukkit - cb > vanilla!
|
||||
}
|
||||
|
||||
public SystemReport fillSystemReport(SystemReport details) {
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index d82e0dd38ef2b32d82e906d5bc71b46052eb0625..e5aa25abee4d4c5447920e64ad45acf9763dedf0 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -259,7 +259,7 @@ import org.yaml.snakeyaml.error.MarkedYAMLException;
|
||||
import net.md_5.bungee.api.chat.BaseComponent; // Spigot
|
||||
|
||||
public final class CraftServer implements Server {
|
||||
- private final String serverName = "CraftBukkit";
|
||||
+ private final String serverName = "Paper"; // Paper
|
||||
private final String serverVersion;
|
||||
private final String bukkitVersion = Versioning.getBukkitVersion();
|
||||
private final Logger logger = Logger.getLogger("Minecraft");
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||
index 985aae207e23584519b4c096f2aaaf0e80b6c163..49f6d20706e8fb94c41834f5addcd015d18acd7e 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||
@@ -223,12 +223,25 @@ public class Main {
|
||||
deadline.add(Calendar.DAY_OF_YEAR, -28);
|
||||
if (buildDate.before(deadline.getTime())) {
|
||||
System.err.println("*** Error, this build is outdated ***");
|
||||
- System.err.println("*** Please download a new build as per instructions from https://www.spigotmc.org/go/outdated-spigot ***");
|
||||
+ System.err.println("*** Please download a new build as per instructions from https://papermc.io/downloads ***"); // Paper
|
||||
System.err.println("*** Server will start in 20 seconds ***");
|
||||
Thread.sleep(TimeUnit.SECONDS.toMillis(20));
|
||||
}
|
||||
}
|
||||
|
||||
+ // Paper start - Log Java and OS versioning to help with debugging plugin issues
|
||||
+ java.lang.management.RuntimeMXBean runtimeMX = java.lang.management.ManagementFactory.getRuntimeMXBean();
|
||||
+ java.lang.management.OperatingSystemMXBean osMX = java.lang.management.ManagementFactory.getOperatingSystemMXBean();
|
||||
+ if (runtimeMX != null && osMX != null) {
|
||||
+ String javaInfo = "Java " + runtimeMX.getSpecVersion() + " (" + runtimeMX.getVmName() + " " + runtimeMX.getVmVersion() + ")";
|
||||
+ String osInfo = "Host: " + osMX.getName() + " " + osMX.getVersion() + " (" + osMX.getArch() + ")";
|
||||
+
|
||||
+ System.out.println("System Info: " + javaInfo + " " + osInfo);
|
||||
+ } else {
|
||||
+ System.out.println("Unable to read system info");
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
System.out.println("Loading libraries, please wait...");
|
||||
net.minecraft.server.Main.main(options);
|
||||
} catch (Throwable t) {
|
||||
diff --git a/src/main/java/org/spigotmc/WatchdogThread.java b/src/main/java/org/spigotmc/WatchdogThread.java
|
||||
index f1194eb6fdfba60959e00080d0562f2820d13b27..11d7ede26b46d0bf9cced65e8c3bcc41c8b66dbf 100644
|
||||
--- a/src/main/java/org/spigotmc/WatchdogThread.java
|
||||
+++ b/src/main/java/org/spigotmc/WatchdogThread.java
|
||||
@@ -19,7 +19,7 @@ public final class WatchdogThread extends io.papermc.paper.util.TickThread // Pa
|
||||
|
||||
private WatchdogThread(long timeoutTime, boolean restart)
|
||||
{
|
||||
- super( "Spigot Watchdog Thread" );
|
||||
+ super( "Paper Watchdog Thread" );
|
||||
this.timeoutTime = timeoutTime;
|
||||
this.restart = restart;
|
||||
}
|
||||
@@ -65,14 +65,14 @@ public final class WatchdogThread extends io.papermc.paper.util.TickThread // Pa
|
||||
{
|
||||
Logger log = Bukkit.getServer().getLogger();
|
||||
log.log( Level.SEVERE, "------------------------------" );
|
||||
- log.log( Level.SEVERE, "The server has stopped responding! This is (probably) not a Spigot bug." );
|
||||
+ log.log( Level.SEVERE, "The server has stopped responding! This is (probably) not a Paper bug." ); // Paper
|
||||
log.log( Level.SEVERE, "If you see a plugin in the Server thread dump below, then please report it to that author" );
|
||||
log.log( Level.SEVERE, "\t *Especially* if it looks like HTTP or MySQL operations are occurring" );
|
||||
log.log( Level.SEVERE, "If you see a world save or edit, then it means you did far more than your server can handle at once" );
|
||||
log.log( Level.SEVERE, "\t If this is the case, consider increasing timeout-time in spigot.yml but note that this will replace the crash with LARGE lag spikes" );
|
||||
- log.log( Level.SEVERE, "If you are unsure or still think this is a Spigot bug, please report to https://www.spigotmc.org/" );
|
||||
+ log.log( Level.SEVERE, "If you are unsure or still think this is a Paper bug, please report this to https://github.com/PaperMC/Paper/issues" );
|
||||
log.log( Level.SEVERE, "Be sure to include ALL relevant console errors and Minecraft crash reports" );
|
||||
- log.log( Level.SEVERE, "Spigot version: " + Bukkit.getServer().getVersion() );
|
||||
+ log.log( Level.SEVERE, "Paper version: " + Bukkit.getServer().getVersion() );
|
||||
//
|
||||
if ( net.minecraft.world.level.Level.lastPhysicsProblem != null )
|
||||
{
|
||||
@@ -82,7 +82,7 @@ public final class WatchdogThread extends io.papermc.paper.util.TickThread // Pa
|
||||
}
|
||||
//
|
||||
log.log( Level.SEVERE, "------------------------------" );
|
||||
- log.log( Level.SEVERE, "Server thread dump (Look for plugins here before reporting to Spigot!):" );
|
||||
+ log.log( Level.SEVERE, "Server thread dump (Look for plugins here before reporting to Paper!):" ); // Paper
|
||||
io.papermc.paper.chunk.system.scheduling.ChunkTaskScheduler.dumpAllChunkLoadInfo(isLongTimeout); // Paper // Paper - rewrite chunk system
|
||||
WatchdogThread.dumpThread( ManagementFactory.getThreadMXBean().getThreadInfo( MinecraftServer.getServer().serverThread.getId(), Integer.MAX_VALUE ), log );
|
||||
log.log( Level.SEVERE, "------------------------------" );
|
|
@ -0,0 +1,157 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Zach Brown <zach@zachbr.io>
|
||||
Date: Mon, 27 May 2019 03:40:05 -0500
|
||||
Subject: [PATCH] Implement Paper VersionChecker
|
||||
|
||||
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java b/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..351159bbdb0c8045f4983f54dee34430dbcc423e
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
|
||||
@@ -0,0 +1,129 @@
|
||||
+package com.destroystokyo.paper;
|
||||
+
|
||||
+import com.destroystokyo.paper.util.VersionFetcher;
|
||||
+import com.google.common.base.Charsets;
|
||||
+import com.google.common.io.Resources;
|
||||
+import com.google.gson.*;
|
||||
+import net.kyori.adventure.text.Component;
|
||||
+import net.kyori.adventure.text.event.ClickEvent;
|
||||
+import net.kyori.adventure.text.format.NamedTextColor;
|
||||
+
|
||||
+import javax.annotation.Nonnull;
|
||||
+import javax.annotation.Nullable;
|
||||
+import java.io.*;
|
||||
+import java.net.HttpURLConnection;
|
||||
+import java.net.URL;
|
||||
+import java.util.stream.StreamSupport;
|
||||
+
|
||||
+public class PaperVersionFetcher implements VersionFetcher {
|
||||
+ private static final java.util.regex.Pattern VER_PATTERN = java.util.regex.Pattern.compile("^([0-9\\.]*)\\-.*R"); // R is an anchor, will always give '-R' at end
|
||||
+ private static final String GITHUB_BRANCH_NAME = "master";
|
||||
+ private static final String DOWNLOAD_PAGE = "https://papermc.io/downloads";
|
||||
+ private static @Nullable String mcVer;
|
||||
+
|
||||
+ @Override
|
||||
+ public long getCacheTime() {
|
||||
+ return 720000;
|
||||
+ }
|
||||
+
|
||||
+ @Nonnull
|
||||
+ @Override
|
||||
+ public Component getVersionMessage(@Nonnull String serverVersion) {
|
||||
+ String[] parts = serverVersion.substring("git-Paper-".length()).split("[-\\s]");
|
||||
+ return getUpdateStatusMessage("PaperMC/Paper", GITHUB_BRANCH_NAME, parts[0]);
|
||||
+ }
|
||||
+
|
||||
+ private static @Nullable String getMinecraftVersion() {
|
||||
+ if (mcVer == null) {
|
||||
+ java.util.regex.Matcher matcher = VER_PATTERN.matcher(org.bukkit.Bukkit.getBukkitVersion());
|
||||
+ if (matcher.find()) {
|
||||
+ String result = matcher.group();
|
||||
+ mcVer = result.substring(0, result.length() - 2); // strip 'R' anchor and trailing '-'
|
||||
+ } else {
|
||||
+ org.bukkit.Bukkit.getLogger().warning("Unable to match version to pattern! Report to PaperMC!");
|
||||
+ org.bukkit.Bukkit.getLogger().warning("Pattern: " + VER_PATTERN.toString());
|
||||
+ org.bukkit.Bukkit.getLogger().warning("Version: " + org.bukkit.Bukkit.getBukkitVersion());
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return mcVer;
|
||||
+ }
|
||||
+
|
||||
+ private static Component getUpdateStatusMessage(@Nonnull String repo, @Nonnull String branch, @Nonnull String versionInfo) {
|
||||
+ int distance;
|
||||
+ try {
|
||||
+ int jenkinsBuild = Integer.parseInt(versionInfo);
|
||||
+ distance = fetchDistanceFromSiteApi(jenkinsBuild, getMinecraftVersion());
|
||||
+ } catch (NumberFormatException ignored) {
|
||||
+ versionInfo = versionInfo.replace("\"", "");
|
||||
+ distance = fetchDistanceFromGitHub(repo, branch, versionInfo);
|
||||
+ }
|
||||
+
|
||||
+ switch (distance) {
|
||||
+ case -1:
|
||||
+ return Component.text("Error obtaining version information", NamedTextColor.YELLOW);
|
||||
+ case 0:
|
||||
+ return Component.text("You are running the latest version", NamedTextColor.GREEN);
|
||||
+ case -2:
|
||||
+ return Component.text("Unknown version", NamedTextColor.YELLOW);
|
||||
+ default:
|
||||
+ return Component.text("You are " + distance + " version(s) behind", NamedTextColor.YELLOW)
|
||||
+ .append(Component.newline())
|
||||
+ .append(Component.text("Download the new version at: ")
|
||||
+ .append(Component.text(DOWNLOAD_PAGE, NamedTextColor.GOLD)
|
||||
+ .hoverEvent(Component.text("Click to open", NamedTextColor.WHITE))
|
||||
+ .clickEvent(ClickEvent.openUrl(DOWNLOAD_PAGE))));
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private static int fetchDistanceFromSiteApi(int jenkinsBuild, @Nullable String siteApiVersion) {
|
||||
+ if (siteApiVersion == null) { return -1; }
|
||||
+ try {
|
||||
+ try (BufferedReader reader = Resources.asCharSource(
|
||||
+ new URL("https://api.papermc.io/v2/projects/paper/versions/" + siteApiVersion),
|
||||
+ Charsets.UTF_8
|
||||
+ ).openBufferedStream()) {
|
||||
+ JsonObject json = new Gson().fromJson(reader, JsonObject.class);
|
||||
+ JsonArray builds = json.getAsJsonArray("builds");
|
||||
+ int latest = StreamSupport.stream(builds.spliterator(), false)
|
||||
+ .mapToInt(e -> e.getAsInt())
|
||||
+ .max()
|
||||
+ .getAsInt();
|
||||
+ return latest - jenkinsBuild;
|
||||
+ } catch (JsonSyntaxException ex) {
|
||||
+ ex.printStackTrace();
|
||||
+ return -1;
|
||||
+ }
|
||||
+ } catch (IOException e) {
|
||||
+ e.printStackTrace();
|
||||
+ return -1;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ // Contributed by Techcable <Techcable@outlook.com> in GH-65
|
||||
+ private static int fetchDistanceFromGitHub(@Nonnull String repo, @Nonnull String branch, @Nonnull String hash) {
|
||||
+ try {
|
||||
+ HttpURLConnection connection = (HttpURLConnection) new URL("https://api.github.com/repos/" + repo + "/compare/" + branch + "..." + hash).openConnection();
|
||||
+ connection.connect();
|
||||
+ if (connection.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND) return -2; // Unknown commit
|
||||
+ try (BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), Charsets.UTF_8))) {
|
||||
+ JsonObject obj = new Gson().fromJson(reader, JsonObject.class);
|
||||
+ String status = obj.get("status").getAsString();
|
||||
+ switch (status) {
|
||||
+ case "identical":
|
||||
+ return 0;
|
||||
+ case "behind":
|
||||
+ return obj.get("behind_by").getAsInt();
|
||||
+ default:
|
||||
+ return -1;
|
||||
+ }
|
||||
+ } catch (JsonSyntaxException | NumberFormatException e) {
|
||||
+ e.printStackTrace();
|
||||
+ return -1;
|
||||
+ }
|
||||
+ } catch (IOException e) {
|
||||
+ e.printStackTrace();
|
||||
+ return -1;
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||||
index d22210c6aaeed8ac6df296f47a699f2e5b67abf4..289276ae40409868c6293c5ab3bafe54c2ccf15c 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||||
@@ -455,6 +455,11 @@ public final class CraftMagicNumbers implements UnsafeValues {
|
||||
public String getTimingsServerName() {
|
||||
return io.papermc.paper.configuration.GlobalConfiguration.get().timings.serverName;
|
||||
}
|
||||
+
|
||||
+ @Override
|
||||
+ public com.destroystokyo.paper.util.VersionFetcher getVersionFetcher() {
|
||||
+ return new com.destroystokyo.paper.PaperVersionFetcher();
|
||||
+ }
|
||||
// Paper end
|
||||
|
||||
/**
|
|
@ -0,0 +1,214 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Kyle Wood <kyle@denwav.dev>
|
||||
Date: Thu, 1 Mar 2018 19:37:52 -0600
|
||||
Subject: [PATCH] Add version history to version command
|
||||
|
||||
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java b/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
|
||||
index 351159bbdb0c8045f4983f54dee34430dbcc423e..bf42969859545a8a520923ef1836ffa4a5cc24a0 100644
|
||||
--- a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
|
||||
+++ b/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
|
||||
@@ -7,6 +7,8 @@ import com.google.gson.*;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.event.ClickEvent;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
+import net.kyori.adventure.text.format.TextDecoration;
|
||||
+import net.kyori.adventure.text.TextComponent;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
@@ -30,7 +32,10 @@ public class PaperVersionFetcher implements VersionFetcher {
|
||||
@Override
|
||||
public Component getVersionMessage(@Nonnull String serverVersion) {
|
||||
String[] parts = serverVersion.substring("git-Paper-".length()).split("[-\\s]");
|
||||
- return getUpdateStatusMessage("PaperMC/Paper", GITHUB_BRANCH_NAME, parts[0]);
|
||||
+ final Component updateMessage = getUpdateStatusMessage("PaperMC/Paper", GITHUB_BRANCH_NAME, parts[0]);
|
||||
+ final Component history = getHistory();
|
||||
+
|
||||
+ return history != null ? TextComponent.ofChildren(updateMessage, Component.newline(), history) : updateMessage;
|
||||
}
|
||||
|
||||
private static @Nullable String getMinecraftVersion() {
|
||||
@@ -126,4 +131,19 @@ public class PaperVersionFetcher implements VersionFetcher {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
+
|
||||
+ @Nullable
|
||||
+ private Component getHistory() {
|
||||
+ final VersionHistoryManager.VersionData data = VersionHistoryManager.INSTANCE.getVersionData();
|
||||
+ if (data == null) {
|
||||
+ return null;
|
||||
+ }
|
||||
+
|
||||
+ final String oldVersion = data.getOldVersion();
|
||||
+ if (oldVersion == null) {
|
||||
+ return null;
|
||||
+ }
|
||||
+
|
||||
+ return Component.text("Previous version: " + oldVersion, NamedTextColor.GRAY, TextDecoration.ITALIC);
|
||||
+ }
|
||||
}
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/VersionHistoryManager.java b/src/main/java/com/destroystokyo/paper/VersionHistoryManager.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..aac3f66cb23d260729c2a48d8710a9de2346aa22
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/com/destroystokyo/paper/VersionHistoryManager.java
|
||||
@@ -0,0 +1,145 @@
|
||||
+package com.destroystokyo.paper;
|
||||
+
|
||||
+import com.google.common.base.MoreObjects;
|
||||
+import com.google.gson.Gson;
|
||||
+import com.google.gson.JsonSyntaxException;
|
||||
+import java.io.BufferedReader;
|
||||
+import java.io.BufferedWriter;
|
||||
+import java.io.IOException;
|
||||
+import java.nio.charset.StandardCharsets;
|
||||
+import java.nio.file.Files;
|
||||
+import java.nio.file.Path;
|
||||
+import java.nio.file.Paths;
|
||||
+import java.nio.file.StandardOpenOption;
|
||||
+import java.util.Objects;
|
||||
+import java.util.logging.Level;
|
||||
+import java.util.logging.Logger;
|
||||
+import org.bukkit.Bukkit;
|
||||
+
|
||||
+import javax.annotation.Nonnull;
|
||||
+import javax.annotation.Nullable;
|
||||
+
|
||||
+public enum VersionHistoryManager {
|
||||
+ INSTANCE;
|
||||
+
|
||||
+ private final Gson gson = new Gson();
|
||||
+
|
||||
+ private final Logger logger = Bukkit.getLogger();
|
||||
+
|
||||
+ private VersionData currentData = null;
|
||||
+
|
||||
+ VersionHistoryManager() {
|
||||
+ final Path path = Paths.get("version_history.json");
|
||||
+
|
||||
+ if (Files.exists(path)) {
|
||||
+ // Basic file santiy checks
|
||||
+ if (!Files.isRegularFile(path)) {
|
||||
+ if (Files.isDirectory(path)) {
|
||||
+ logger.severe(path + " is a directory, cannot be used for version history");
|
||||
+ } else {
|
||||
+ logger.severe(path + " is not a regular file, cannot be used for version history");
|
||||
+ }
|
||||
+ // We can't continue
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ try (final BufferedReader reader = Files.newBufferedReader(path, StandardCharsets.UTF_8)) {
|
||||
+ currentData = gson.fromJson(reader, VersionData.class);
|
||||
+ } catch (final IOException e) {
|
||||
+ logger.log(Level.SEVERE, "Failed to read version history file '" + path + "'", e);
|
||||
+ return;
|
||||
+ } catch (final JsonSyntaxException e) {
|
||||
+ logger.log(Level.SEVERE, "Invalid json syntax for file '" + path + "'", e);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ final String version = Bukkit.getVersion();
|
||||
+ if (version == null) {
|
||||
+ logger.severe("Failed to retrieve current version");
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ if (!version.equals(currentData.getCurrentVersion())) {
|
||||
+ // The version appears to have changed
|
||||
+ currentData.setOldVersion(currentData.getCurrentVersion());
|
||||
+ currentData.setCurrentVersion(version);
|
||||
+ writeFile(path);
|
||||
+ }
|
||||
+ } else {
|
||||
+ // File doesn't exist, start fresh
|
||||
+ currentData = new VersionData();
|
||||
+ // oldVersion is null
|
||||
+ currentData.setCurrentVersion(Bukkit.getVersion());
|
||||
+ writeFile(path);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private void writeFile(@Nonnull final Path path) {
|
||||
+ try (final BufferedWriter writer = Files.newBufferedWriter(
|
||||
+ path,
|
||||
+ StandardCharsets.UTF_8,
|
||||
+ StandardOpenOption.WRITE,
|
||||
+ StandardOpenOption.CREATE,
|
||||
+ StandardOpenOption.TRUNCATE_EXISTING
|
||||
+ )) {
|
||||
+ gson.toJson(currentData, writer);
|
||||
+ } catch (final IOException e) {
|
||||
+ logger.log(Level.SEVERE, "Failed to write to version history file", e);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @Nullable
|
||||
+ public VersionData getVersionData() {
|
||||
+ return currentData;
|
||||
+ }
|
||||
+
|
||||
+ public static class VersionData {
|
||||
+ private String oldVersion;
|
||||
+
|
||||
+ private String currentVersion;
|
||||
+
|
||||
+ @Nullable
|
||||
+ public String getOldVersion() {
|
||||
+ return oldVersion;
|
||||
+ }
|
||||
+
|
||||
+ public void setOldVersion(@Nullable String oldVersion) {
|
||||
+ this.oldVersion = oldVersion;
|
||||
+ }
|
||||
+
|
||||
+ @Nullable
|
||||
+ public String getCurrentVersion() {
|
||||
+ return currentVersion;
|
||||
+ }
|
||||
+
|
||||
+ public void setCurrentVersion(@Nullable String currentVersion) {
|
||||
+ this.currentVersion = currentVersion;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String toString() {
|
||||
+ return MoreObjects.toStringHelper(this)
|
||||
+ .add("oldVersion", oldVersion)
|
||||
+ .add("currentVersion", currentVersion)
|
||||
+ .toString();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean equals(@Nullable Object o) {
|
||||
+ if (this == o) {
|
||||
+ return true;
|
||||
+ }
|
||||
+ if (o == null || getClass() != o.getClass()) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ final VersionData versionData = (VersionData) o;
|
||||
+ return Objects.equals(oldVersion, versionData.oldVersion) &&
|
||||
+ Objects.equals(currentVersion, versionData.currentVersion);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public int hashCode() {
|
||||
+ return Objects.hash(oldVersion, currentVersion);
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
index 8318af4db5fa7242b5cb2ae50fd08174017d6f7d..18f7d73fd8a780753e2249a9fec6bb335ebfdeed 100644
|
||||
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
@@ -189,6 +189,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||
paperConfigurations.initializeWorldDefaultsConfiguration();
|
||||
io.papermc.paper.command.PaperCommands.registerCommands(this);
|
||||
com.destroystokyo.paper.Metrics.PaperMetrics.startMetrics();
|
||||
+ com.destroystokyo.paper.VersionHistoryManager.INSTANCE.getClass(); // load version history now
|
||||
// Paper end
|
||||
|
||||
this.setPvpAllowed(dedicatedserverproperties.pvp);
|
163
patches/unapplied/server/0030-Player-affects-spawning-API.patch
Normal file
163
patches/unapplied/server/0030-Player-affects-spawning-API.patch
Normal file
|
@ -0,0 +1,163 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jedediah Smith <jedediah@silencegreys.com>
|
||||
Date: Tue, 1 Mar 2016 14:47:52 -0600
|
||||
Subject: [PATCH] Player affects spawning API
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/EntitySelector.java b/src/main/java/net/minecraft/world/entity/EntitySelector.java
|
||||
index 5c3b11f738c1ea19981cc878aa6c2323497391a0..6fd874a83a248e6a7d427d18d11fc608544662c5 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/EntitySelector.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/EntitySelector.java
|
||||
@@ -29,6 +29,11 @@ public final class EntitySelector {
|
||||
public static final Predicate<Entity> CAN_BE_COLLIDED_WITH = EntitySelector.NO_SPECTATORS.and(Entity::canBeCollidedWith);
|
||||
|
||||
private EntitySelector() {}
|
||||
+ // Paper start
|
||||
+ public static final Predicate<Entity> PLAYER_AFFECTS_SPAWNING = (entity) -> {
|
||||
+ return !entity.isSpectator() && entity.isAlive() && entity instanceof Player player && player.affectsSpawning;
|
||||
+ };
|
||||
+ // Paper end
|
||||
|
||||
public static Predicate<Entity> withinDistance(double x, double y, double z, double max) {
|
||||
double d4 = max * max;
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
index 99218eac34374a4d13451cfec15006c3bf0d755f..bb7c459c126be789bb12d08a569fe344e08914b8 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||
@@ -808,7 +808,7 @@ public abstract class Mob extends LivingEntity {
|
||||
if (this.level.getDifficulty() == Difficulty.PEACEFUL && this.shouldDespawnInPeaceful()) {
|
||||
this.discard();
|
||||
} else if (!this.isPersistenceRequired() && !this.requiresCustomPersistence()) {
|
||||
- Player entityhuman = this.level.getNearestPlayer(this, -1.0D);
|
||||
+ Player entityhuman = this.level.findNearbyPlayer(this, -1.0D, EntitySelector.PLAYER_AFFECTS_SPAWNING); // Paper
|
||||
|
||||
if (entityhuman != null) {
|
||||
double d0 = entityhuman.distanceToSqr((Entity) this);
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/animal/horse/SkeletonTrapGoal.java b/src/main/java/net/minecraft/world/entity/animal/horse/SkeletonTrapGoal.java
|
||||
index e368478dba01a9b11adf23ed64bed61c73a78a28..17fda4857f74d2994525262472700e7788dec383 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/animal/horse/SkeletonTrapGoal.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/animal/horse/SkeletonTrapGoal.java
|
||||
@@ -25,7 +25,7 @@ public class SkeletonTrapGoal extends Goal {
|
||||
|
||||
@Override
|
||||
public boolean canUse() {
|
||||
- return this.horse.level.hasNearbyAlivePlayer(this.horse.getX(), this.horse.getY(), this.horse.getZ(), 10.0D);
|
||||
+ return this.horse.level.hasNearbyAlivePlayerThatAffectsSpawning(this.horse.getX(), this.horse.getY(), this.horse.getZ(), 10.0D); // Paper - Affects Spawning API
|
||||
}
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/monster/Silverfish.java b/src/main/java/net/minecraft/world/entity/monster/Silverfish.java
|
||||
index 87f66fd33e404367d924137b2d8aac3b06937f43..2dcda3b03796655da443e1b3dd68c6f6bca20d21 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/monster/Silverfish.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/monster/Silverfish.java
|
||||
@@ -127,7 +127,7 @@ public class Silverfish extends Monster {
|
||||
if (checkAnyLightMonsterSpawnRules(type, world, spawnReason, pos, random)) {
|
||||
Player entityhuman = world.getNearestPlayer((double) pos.getX() + 0.5D, (double) pos.getY() + 0.5D, (double) pos.getZ() + 0.5D, 5.0D, true);
|
||||
|
||||
- return entityhuman == null;
|
||||
+ return !(entityhuman != null && !entityhuman.affectsSpawning) && entityhuman == null; // Paper - Affects Spawning API
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/monster/Zombie.java b/src/main/java/net/minecraft/world/entity/monster/Zombie.java
|
||||
index 8ea60d388fff4a6368652ff96f648e5880053a2b..8ecbb64f9db9346757c5597404489496a0945508 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/monster/Zombie.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/monster/Zombie.java
|
||||
@@ -325,7 +325,7 @@ public class Zombie extends Monster {
|
||||
|
||||
if (NaturalSpawner.isSpawnPositionOk(entitypositiontypes_surface, this.level, blockposition, entitytypes) && SpawnPlacements.checkSpawnRules(entitytypes, worldserver, MobSpawnType.REINFORCEMENT, blockposition, this.level.random)) {
|
||||
entityzombie.setPos((double) i1, (double) j1, (double) k1);
|
||||
- if (!this.level.hasNearbyAlivePlayer((double) i1, (double) j1, (double) k1, 7.0D) && this.level.isUnobstructed(entityzombie) && this.level.noCollision((Entity) entityzombie) && !this.level.containsAnyLiquid(entityzombie.getBoundingBox())) {
|
||||
+ if (!this.level.hasNearbyAlivePlayerThatAffectsSpawning((double) i1, (double) j1, (double) k1, 7.0D) && this.level.isUnobstructed(entityzombie) && this.level.noCollision((Entity) entityzombie) && !this.level.containsAnyLiquid(entityzombie.getBoundingBox())) { // Paper - Affects Spawning API
|
||||
entityzombie.setTarget(entityliving, EntityTargetEvent.TargetReason.REINFORCEMENT_TARGET, true); // CraftBukkit
|
||||
entityzombie.finalizeSpawn(worldserver, this.level.getCurrentDifficultyAt(entityzombie.blockPosition()), MobSpawnType.REINFORCEMENT, (SpawnGroupData) null, (CompoundTag) null);
|
||||
worldserver.addFreshEntityWithPassengers(entityzombie, CreatureSpawnEvent.SpawnReason.REINFORCEMENTS); // CraftBukkit
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java
|
||||
index 47b5ef810348f8c702acb09b280b41b6b7227b6f..60fb74537fdc96005cbf6aa1670e773c0faa2f26 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/player/Player.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java
|
||||
@@ -179,6 +179,9 @@ public abstract class Player extends LivingEntity {
|
||||
private Optional<GlobalPos> lastDeathLocation;
|
||||
@Nullable
|
||||
public FishingHook fishing;
|
||||
+ // Paper start
|
||||
+ public boolean affectsSpawning = true;
|
||||
+ // Paper end
|
||||
|
||||
// CraftBukkit start
|
||||
public boolean fauxSleeping;
|
||||
diff --git a/src/main/java/net/minecraft/world/level/BaseSpawner.java b/src/main/java/net/minecraft/world/level/BaseSpawner.java
|
||||
index f035206f2f59cb293d503c638ff06333a797a7a9..3e83bff81a0656d5e1d079ad9e63c7d27561c8e3 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/BaseSpawner.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/BaseSpawner.java
|
||||
@@ -54,7 +54,7 @@ public abstract class BaseSpawner {
|
||||
}
|
||||
|
||||
public boolean isNearPlayer(Level world, BlockPos pos) {
|
||||
- return world.hasNearbyAlivePlayer((double) pos.getX() + 0.5D, (double) pos.getY() + 0.5D, (double) pos.getZ() + 0.5D, (double) this.requiredPlayerRange);
|
||||
+ return world.hasNearbyAlivePlayerThatAffectsSpawning((double) pos.getX() + 0.5D, (double) pos.getY() + 0.5D, (double) pos.getZ() + 0.5D, (double) this.requiredPlayerRange); // Paper - Affects Spawning API
|
||||
}
|
||||
|
||||
public void clientTick(Level world, BlockPos pos) {
|
||||
diff --git a/src/main/java/net/minecraft/world/level/EntityGetter.java b/src/main/java/net/minecraft/world/level/EntityGetter.java
|
||||
index be6e3e21ad62da01e5e2dd78e300cbc8efdbeb42..ea98625fe7c00743b8df74a24e6d4b75df4189a5 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/EntityGetter.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/EntityGetter.java
|
||||
@@ -82,6 +82,11 @@ public interface EntityGetter {
|
||||
}
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ default @Nullable Player findNearbyPlayer(Entity entity, double maxDistance, @Nullable Predicate<Entity> predicate) {
|
||||
+ return this.getNearestPlayer(entity.getX(), entity.getY(), entity.getZ(), maxDistance, predicate);
|
||||
+ }
|
||||
+ // Paper end
|
||||
@Nullable
|
||||
default Player getNearestPlayer(double x, double y, double z, double maxDistance, @Nullable Predicate<Entity> targetPredicate) {
|
||||
double d = -1.0D;
|
||||
@@ -111,6 +116,20 @@ public interface EntityGetter {
|
||||
return this.getNearestPlayer(x, y, z, maxDistance, predicate);
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ default boolean hasNearbyAlivePlayerThatAffectsSpawning(double x, double y, double z, double range) {
|
||||
+ for (Player player : this.players()) {
|
||||
+ if (EntitySelector.PLAYER_AFFECTS_SPAWNING.test(player)) { // combines NO_SPECTATORS and LIVING_ENTITY_STILL_ALIVE with an "affects spawning" check
|
||||
+ double distanceSqr = player.distanceToSqr(x, y, z);
|
||||
+ if (range < 0.0D || distanceSqr < range * range) {
|
||||
+ return true;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ return false;
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
default boolean hasNearbyAlivePlayer(double x, double y, double z, double range) {
|
||||
for(Player player : this.players()) {
|
||||
if (EntitySelector.NO_SPECTATORS.test(player) && EntitySelector.LIVING_ENTITY_STILL_ALIVE.test(player)) {
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
index 92e5b781049122e3de3784ec4197557f2730b3b3..eecfbd4e835bfc3d98194365e360a827fb02bb38 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
@@ -2113,8 +2113,20 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
@Override
|
||||
public String getLocale() {
|
||||
return this.getHandle().locale;
|
||||
+
|
||||
+ }
|
||||
+
|
||||
+ // Paper start
|
||||
+ public void setAffectsSpawning(boolean affects) {
|
||||
+ this.getHandle().affectsSpawning = affects;
|
||||
}
|
||||
|
||||
+ @Override
|
||||
+ public boolean getAffectsSpawning() {
|
||||
+ return this.getHandle().affectsSpawning;
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
@Override
|
||||
public void updateCommands() {
|
||||
if (this.getHandle().connection == null) return;
|
|
@ -0,0 +1,213 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Tue, 1 Mar 2016 23:09:29 -0600
|
||||
Subject: [PATCH] Further improve server tick loop
|
||||
|
||||
Improves how the catchup buffer is handled, allowing it to roll both ways
|
||||
increasing the effeciency of the thread sleep so it only will sleep once.
|
||||
|
||||
Also increases the buffer of the catchup to ensure server stays at 20 TPS unless extreme conditions
|
||||
|
||||
Previous implementation did not calculate TPS correctly.
|
||||
Switch to a realistic rolling average and factor in std deviation as an extra reporting variable
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index e2e66fd4bd34e0ceaab350214a50ddbb1dc76184..ac81428f19e2d445f315000d34173c2d650a9aeb 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -281,7 +281,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
public org.bukkit.command.ConsoleCommandSender console;
|
||||
public org.bukkit.command.RemoteConsoleCommandSender remoteConsole;
|
||||
public ConsoleReader reader;
|
||||
- public static int currentTick = (int) (System.currentTimeMillis() / 50);
|
||||
+ public static int currentTick = 0; // Paper - Further improve tick loop
|
||||
public java.util.Queue<Runnable> processQueue = new java.util.concurrent.ConcurrentLinkedQueue<Runnable>();
|
||||
public int autosavePeriod;
|
||||
public Commands vanillaCommandDispatcher;
|
||||
@@ -290,7 +290,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
// Spigot start
|
||||
public static final int TPS = 20;
|
||||
public static final int TICK_TIME = 1000000000 / MinecraftServer.TPS;
|
||||
- private static final int SAMPLE_INTERVAL = 100;
|
||||
+ private static final int SAMPLE_INTERVAL = 20; // Paper
|
||||
public final double[] recentTps = new double[ 3 ];
|
||||
// Spigot end
|
||||
public final io.papermc.paper.configuration.PaperConfigurations paperConfigurations;
|
||||
@@ -953,6 +953,57 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
{
|
||||
return ( avg * exp ) + ( tps * ( 1 - exp ) );
|
||||
}
|
||||
+
|
||||
+ // Paper start - Further improve server tick loop
|
||||
+ private static final long SEC_IN_NANO = 1000000000;
|
||||
+ private static final long MAX_CATCHUP_BUFFER = TICK_TIME * TPS * 60L;
|
||||
+ private long lastTick = 0;
|
||||
+ private long catchupTime = 0;
|
||||
+ public final RollingAverage tps1 = new RollingAverage(60);
|
||||
+ public final RollingAverage tps5 = new RollingAverage(60 * 5);
|
||||
+ public final RollingAverage tps15 = new RollingAverage(60 * 15);
|
||||
+
|
||||
+ public static class RollingAverage {
|
||||
+ private final int size;
|
||||
+ private long time;
|
||||
+ private java.math.BigDecimal total;
|
||||
+ private int index = 0;
|
||||
+ private final java.math.BigDecimal[] samples;
|
||||
+ private final long[] times;
|
||||
+
|
||||
+ RollingAverage(int size) {
|
||||
+ this.size = size;
|
||||
+ this.time = size * SEC_IN_NANO;
|
||||
+ this.total = dec(TPS).multiply(dec(SEC_IN_NANO)).multiply(dec(size));
|
||||
+ this.samples = new java.math.BigDecimal[size];
|
||||
+ this.times = new long[size];
|
||||
+ for (int i = 0; i < size; i++) {
|
||||
+ this.samples[i] = dec(TPS);
|
||||
+ this.times[i] = SEC_IN_NANO;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private static java.math.BigDecimal dec(long t) {
|
||||
+ return new java.math.BigDecimal(t);
|
||||
+ }
|
||||
+ public void add(java.math.BigDecimal x, long t) {
|
||||
+ time -= times[index];
|
||||
+ total = total.subtract(samples[index].multiply(dec(times[index])));
|
||||
+ samples[index] = x;
|
||||
+ times[index] = t;
|
||||
+ time += t;
|
||||
+ total = total.add(x.multiply(dec(t)));
|
||||
+ if (++index == size) {
|
||||
+ index = 0;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public double getAverage() {
|
||||
+ return total.divide(dec(time), 30, java.math.RoundingMode.HALF_UP).doubleValue();
|
||||
+ }
|
||||
+ }
|
||||
+ private static final java.math.BigDecimal TPS_BASE = new java.math.BigDecimal(1E9).multiply(new java.math.BigDecimal(SAMPLE_INTERVAL));
|
||||
+ // Paper End
|
||||
// Spigot End
|
||||
|
||||
public static volatile RuntimeException chunkSystemCrash; // Paper - rewrite chunk system
|
||||
@@ -971,7 +1022,8 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
|
||||
// Spigot start
|
||||
Arrays.fill( recentTps, 20 );
|
||||
- long curTime, tickSection = Util.getMillis(), tickCount = 1;
|
||||
+ long start = System.nanoTime(), curTime, tickSection = start; // Paper - Further improve server tick loop
|
||||
+ lastTick = start - TICK_TIME; // Paper
|
||||
while (this.running) {
|
||||
// Paper start - rewrite chunk system
|
||||
// guarantee that nothing can stop the server from halting if it can at least still tick
|
||||
@@ -979,7 +1031,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
throw this.chunkSystemCrash;
|
||||
}
|
||||
// Paper end - rewrite chunk system
|
||||
- long i = (curTime = Util.getMillis()) - this.nextTickTime;
|
||||
+ long i = ((curTime = System.nanoTime()) / (1000L * 1000L)) - this.nextTickTime; // Paper
|
||||
|
||||
if (i > 5000L && this.nextTickTime - this.lastOverloadWarning >= 30000L) { // CraftBukkit
|
||||
long j = i / 50L;
|
||||
@@ -991,12 +1043,18 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
}
|
||||
|
||||
++MinecraftServer.currentTickLong; // Paper
|
||||
- if ( tickCount++ % MinecraftServer.SAMPLE_INTERVAL == 0 )
|
||||
+ if ( ++MinecraftServer.currentTick % MinecraftServer.SAMPLE_INTERVAL == 0 )
|
||||
{
|
||||
- double currentTps = 1E3 / ( curTime - tickSection ) * MinecraftServer.SAMPLE_INTERVAL;
|
||||
- this.recentTps[0] = MinecraftServer.calcTps( this.recentTps[0], 0.92, currentTps ); // 1/exp(5sec/1min)
|
||||
- this.recentTps[1] = MinecraftServer.calcTps( this.recentTps[1], 0.9835, currentTps ); // 1/exp(5sec/5min)
|
||||
- this.recentTps[2] = MinecraftServer.calcTps( this.recentTps[2], 0.9945, currentTps ); // 1/exp(5sec/15min)
|
||||
+ final long diff = curTime - tickSection;
|
||||
+ java.math.BigDecimal currentTps = TPS_BASE.divide(new java.math.BigDecimal(diff), 30, java.math.RoundingMode.HALF_UP);
|
||||
+ tps1.add(currentTps, diff);
|
||||
+ tps5.add(currentTps, diff);
|
||||
+ tps15.add(currentTps, diff);
|
||||
+ // Backwards compat with bad plugins
|
||||
+ this.recentTps[0] = tps1.getAverage();
|
||||
+ this.recentTps[1] = tps5.getAverage();
|
||||
+ this.recentTps[2] = tps15.getAverage();
|
||||
+ // Paper end
|
||||
tickSection = curTime;
|
||||
}
|
||||
// Spigot end
|
||||
@@ -1006,7 +1064,8 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
this.debugCommandProfiler = new MinecraftServer.TimeProfiler(Util.getNanos(), this.tickCount);
|
||||
}
|
||||
|
||||
- MinecraftServer.currentTick = (int) (System.currentTimeMillis() / 50); // CraftBukkit
|
||||
+ //MinecraftServer.currentTick = (int) (System.currentTimeMillis() / 50); // CraftBukkit // Paper - don't overwrite current tick time
|
||||
+ lastTick = curTime;
|
||||
this.nextTickTime += 50L;
|
||||
this.startMetricsRecordingTick();
|
||||
this.profiler.push("tick");
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index e5aa25abee4d4c5447920e64ad45acf9763dedf0..babde3ac7af9b5659bcc7e0298d1d77e7b2d60e2 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -2418,6 +2418,17 @@ public final class CraftServer implements Server {
|
||||
return CraftMagicNumbers.INSTANCE;
|
||||
}
|
||||
|
||||
+ // Paper - Add getTPS API - Further improve tick loop
|
||||
+ @Override
|
||||
+ public double[] getTPS() {
|
||||
+ return new double[] {
|
||||
+ net.minecraft.server.MinecraftServer.getServer().tps1.getAverage(),
|
||||
+ net.minecraft.server.MinecraftServer.getServer().tps5.getAverage(),
|
||||
+ net.minecraft.server.MinecraftServer.getServer().tps15.getAverage()
|
||||
+ };
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
// Spigot start
|
||||
private final org.bukkit.Server.Spigot spigot = new org.bukkit.Server.Spigot()
|
||||
{
|
||||
diff --git a/src/main/java/org/spigotmc/TicksPerSecondCommand.java b/src/main/java/org/spigotmc/TicksPerSecondCommand.java
|
||||
index 4ab81a99f906e3f28e026d0e50b5b943c1bdcfb5..9bede6a26c08ede063c7a38f1149c811df14b258 100644
|
||||
--- a/src/main/java/org/spigotmc/TicksPerSecondCommand.java
|
||||
+++ b/src/main/java/org/spigotmc/TicksPerSecondCommand.java
|
||||
@@ -24,22 +24,30 @@ public class TicksPerSecondCommand extends Command
|
||||
return true;
|
||||
}
|
||||
|
||||
- StringBuilder sb = new StringBuilder( ChatColor.GOLD + "TPS from last 1m, 5m, 15m: " );
|
||||
- for ( double tps : MinecraftServer.getServer().recentTps )
|
||||
- {
|
||||
- sb.append( this.format( tps ) );
|
||||
- sb.append( ", " );
|
||||
+ // Paper start - Further improve tick handling
|
||||
+ double[] tps = org.bukkit.Bukkit.getTPS();
|
||||
+ String[] tpsAvg = new String[tps.length];
|
||||
+
|
||||
+ for ( int i = 0; i < tps.length; i++) {
|
||||
+ tpsAvg[i] = TicksPerSecondCommand.format( tps[i] );
|
||||
+ }
|
||||
+ sender.sendMessage(ChatColor.GOLD + "TPS from last 1m, 5m, 15m: " + org.apache.commons.lang.StringUtils.join(tpsAvg, ", "));
|
||||
+ if (args.length > 0 && args[0].equals("mem") && sender.hasPermission("bukkit.command.tpsmemory")) {
|
||||
+ sender.sendMessage(ChatColor.GOLD + "Current Memory Usage: " + ChatColor.GREEN + ((Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / (1024 * 1024)) + "/" + (Runtime.getRuntime().totalMemory() / (1024 * 1024)) + " mb (Max: " + (Runtime.getRuntime().maxMemory() / (1024 * 1024)) + " mb)");
|
||||
+ if (!hasShownMemoryWarning) {
|
||||
+ sender.sendMessage(ChatColor.RED + "Warning: " + ChatColor.GOLD + " Memory usage on modern garbage collectors is not a stable value and it is perfectly normal to see it reach max. Please do not pay it much attention.");
|
||||
+ hasShownMemoryWarning = true;
|
||||
+ }
|
||||
}
|
||||
- sender.sendMessage( sb.substring( 0, sb.length() - 2 ) );
|
||||
- sender.sendMessage(ChatColor.GOLD + "Current Memory Usage: " + ChatColor.GREEN + ((Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / (1024 * 1024)) + "/" + (Runtime.getRuntime().totalMemory() / (1024 * 1024)) + " mb (Max: "
|
||||
- + (Runtime.getRuntime().maxMemory() / (1024 * 1024)) + " mb)");
|
||||
+ // Paper end
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
- private String format(double tps)
|
||||
+ private boolean hasShownMemoryWarning; // Paper
|
||||
+ private static String format(double tps) // Paper - Made static
|
||||
{
|
||||
return ( ( tps > 18.0 ) ? ChatColor.GREEN : ( tps > 16.0 ) ? ChatColor.YELLOW : ChatColor.RED ).toString()
|
||||
- + ( ( tps > 20.0 ) ? "*" : "" ) + Math.min( Math.round( tps * 100.0 ) / 100.0, 20.0 );
|
||||
+ + ( ( tps > 21.0 ) ? "*" : "" ) + Math.min( Math.round( tps * 100.0 ) / 100.0, 20.0 ); // Paper - only print * at 21, we commonly peak to 20.02 as the tick sleep is not accurate enough, stop the noise
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Zach Brown <zach.brown@destroystokyo.com>
|
||||
Date: Tue, 1 Mar 2016 23:12:03 -0600
|
||||
Subject: [PATCH] Only refresh abilities if needed
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
index eecfbd4e835bfc3d98194365e360a827fb02bb38..27f4387a3ac750114c99e41e855c8fb8081a507d 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
@@ -1782,12 +1782,13 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
|
||||
@Override
|
||||
public void setFlying(boolean value) {
|
||||
+ boolean needsUpdate = getHandle().getAbilities().flying != value; // Paper - Only refresh abilities if needed
|
||||
if (!this.getAllowFlight() && value) {
|
||||
throw new IllegalArgumentException("Cannot make player fly if getAllowFlight() is false");
|
||||
}
|
||||
|
||||
this.getHandle().getAbilities().flying = value;
|
||||
- this.getHandle().onUpdateAbilities();
|
||||
+ if (needsUpdate) this.getHandle().onUpdateAbilities(); // Paper - Only refresh abilities if needed
|
||||
}
|
||||
|
||||
@Override
|
158
patches/unapplied/server/0033-Entity-Origin-API.patch
Normal file
158
patches/unapplied/server/0033-Entity-Origin-API.patch
Normal file
|
@ -0,0 +1,158 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Byteflux <byte@byteflux.net>
|
||||
Date: Tue, 1 Mar 2016 23:45:08 -0600
|
||||
Subject: [PATCH] Entity Origin API
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
index 3fce997cc390136a16c941f0461b20d2bc046948..b1771e25c13b555d3316aca35f8a97ed4ce8f275 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -2215,6 +2215,15 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
|
||||
entity.updateDynamicGameEventListener(DynamicGameEventListener::add);
|
||||
entity.valid = true; // CraftBukkit
|
||||
+ // Paper start - Set origin location when the entity is being added to the world
|
||||
+ if (entity.getOriginVector() == null) {
|
||||
+ entity.setOrigin(entity.getBukkitEntity().getLocation());
|
||||
+ }
|
||||
+ // Default to current world if unknown, gross assumption but entities rarely change world
|
||||
+ if (entity.getOriginWorld() == null) {
|
||||
+ entity.setOrigin(entity.getOriginVector().toLocation(getWorld()));
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
||||
|
||||
public void onTrackingEnd(Entity entity) {
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index 0cd735648314872e98e310627247b9ad425ab64d..5cf04b209ae3fa6c52ad45e726343418d0de311f 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -304,7 +304,27 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
public long activatedTick = Integer.MIN_VALUE;
|
||||
public void inactiveTick() { }
|
||||
// Spigot end
|
||||
+ // Paper start
|
||||
+ @javax.annotation.Nullable
|
||||
+ private org.bukkit.util.Vector origin;
|
||||
+ @javax.annotation.Nullable
|
||||
+ private UUID originWorld;
|
||||
+
|
||||
+ public void setOrigin(@javax.annotation.Nonnull Location location) {
|
||||
+ this.origin = location.toVector();
|
||||
+ this.originWorld = location.getWorld().getUID();
|
||||
+ }
|
||||
|
||||
+ @javax.annotation.Nullable
|
||||
+ public org.bukkit.util.Vector getOriginVector() {
|
||||
+ return this.origin != null ? this.origin.clone() : null;
|
||||
+ }
|
||||
+
|
||||
+ @javax.annotation.Nullable
|
||||
+ public UUID getOriginWorld() {
|
||||
+ return this.originWorld;
|
||||
+ }
|
||||
+ // Paper end
|
||||
public float getBukkitYaw() {
|
||||
return this.yRot;
|
||||
}
|
||||
@@ -1928,6 +1948,15 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
this.bukkitEntity.storeBukkitValues(nbt);
|
||||
}
|
||||
// CraftBukkit end
|
||||
+ // Paper start - Save the entity's origin location
|
||||
+ if (this.origin != null) {
|
||||
+ UUID originWorld = this.originWorld != null ? this.originWorld : this.level != null ? this.level.getWorld().getUID() : null;
|
||||
+ if (originWorld != null) {
|
||||
+ nbt.putUUID("Paper.OriginWorld", originWorld);
|
||||
+ }
|
||||
+ nbt.put("Paper.Origin", this.newDoubleList(origin.getX(), origin.getY(), origin.getZ()));
|
||||
+ }
|
||||
+ // Paper end
|
||||
return nbt;
|
||||
} catch (Throwable throwable) {
|
||||
CrashReport crashreport = CrashReport.forThrowable(throwable, "Saving entity NBT");
|
||||
@@ -2054,6 +2083,20 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
}
|
||||
// CraftBukkit end
|
||||
|
||||
+ // Paper start - Restore the entity's origin location
|
||||
+ ListTag originTag = nbt.getList("Paper.Origin", 6);
|
||||
+ if (!originTag.isEmpty()) {
|
||||
+ UUID originWorld = null;
|
||||
+ if (nbt.contains("Paper.OriginWorld")) {
|
||||
+ originWorld = nbt.getUUID("Paper.OriginWorld");
|
||||
+ } else if (this.level != null) {
|
||||
+ originWorld = this.level.getWorld().getUID();
|
||||
+ }
|
||||
+ this.originWorld = originWorld;
|
||||
+ origin = new org.bukkit.util.Vector(originTag.getDouble(0), originTag.getDouble(1), originTag.getDouble(2));
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
} catch (Throwable throwable) {
|
||||
CrashReport crashreport = CrashReport.forThrowable(throwable, "Loading entity NBT");
|
||||
CrashReportCategory crashreportsystemdetails = crashreport.addCategory("Entity being loaded");
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
|
||||
index c125564cfca5c4a616e11b334a9ec7929ebea496..561b8d6fcf4d511fb026bcc2c02054e56589d0b7 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java
|
||||
@@ -339,6 +339,14 @@ public class FallingBlockEntity extends Entity {
|
||||
this.blockState = Blocks.SAND.defaultBlockState();
|
||||
}
|
||||
|
||||
+ // Paper start - Try and load origin location from the old NBT tags for backwards compatibility
|
||||
+ if (nbt.contains("SourceLoc_x")) {
|
||||
+ int srcX = nbt.getInt("SourceLoc_x");
|
||||
+ int srcY = nbt.getInt("SourceLoc_y");
|
||||
+ int srcZ = nbt.getInt("SourceLoc_z");
|
||||
+ this.setOrigin(new org.bukkit.Location(level.getWorld(), srcX, srcY, srcZ));
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
||||
|
||||
public void setHurtsEntities(float fallHurtAmount, int fallHurtMax) {
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
|
||||
index 43ec4bc45a3e553fbbf47aaf613f6e0aad2319cf..aa0dfd08aefbb9363ec96080432f0f75d71b0b95 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
|
||||
@@ -117,6 +117,14 @@ public class PrimedTnt extends Entity {
|
||||
@Override
|
||||
protected void readAdditionalSaveData(CompoundTag nbt) {
|
||||
this.setFuse(nbt.getShort("Fuse"));
|
||||
+ // Paper start - Try and load origin location from the old NBT tags for backwards compatibility
|
||||
+ if (nbt.contains("SourceLoc_x")) {
|
||||
+ int srcX = nbt.getInt("SourceLoc_x");
|
||||
+ int srcY = nbt.getInt("SourceLoc_y");
|
||||
+ int srcZ = nbt.getInt("SourceLoc_z");
|
||||
+ this.setOrigin(new org.bukkit.Location(level.getWorld(), srcX, srcY, srcZ));
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
||||
|
||||
@Nullable
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
||||
index 55bf95017d58bb61f9c6af27335c88421c74c4aa..62c2780b165a520e85f17fdf5c0d1c29b7579ebc 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
||||
@@ -1217,5 +1217,20 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
||||
|
||||
return ret;
|
||||
}
|
||||
+
|
||||
+ @Override
|
||||
+ public Location getOrigin() {
|
||||
+ Vector originVector = this.getHandle().getOriginVector();
|
||||
+ if (originVector == null) {
|
||||
+ return null;
|
||||
+ }
|
||||
+ World world = this.getWorld();
|
||||
+ if (this.getHandle().getOriginWorld() != null) {
|
||||
+ world = org.bukkit.Bukkit.getWorld(this.getHandle().getOriginWorld());
|
||||
+ }
|
||||
+
|
||||
+ //noinspection ConstantConditions
|
||||
+ return originVector.toLocation(world);
|
||||
+ }
|
||||
// Paper end
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Tue, 1 Mar 2016 23:52:34 -0600
|
||||
Subject: [PATCH] Prevent tile entity and entity crashes
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
||||
index 4b2aadae3a7595a5aee2bc71216adc34fa0f2cf9..e082e4a8c8fbce341bcf00115d1579b4bed4b2a4 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/Level.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
||||
@@ -729,11 +729,11 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
||||
try {
|
||||
tickConsumer.accept(entity);
|
||||
} catch (Throwable throwable) {
|
||||
- CrashReport crashreport = CrashReport.forThrowable(throwable, "Ticking entity");
|
||||
- CrashReportCategory crashreportsystemdetails = crashreport.addCategory("Entity being ticked");
|
||||
-
|
||||
- entity.fillCrashReportCategory(crashreportsystemdetails);
|
||||
- throw new ReportedException(crashreport);
|
||||
+ // Paper start - Prevent tile entity and entity crashes
|
||||
+ final String msg = String.format("Entity threw exception at %s:%s,%s,%s", entity.level.getWorld().getName(), entity.getX(), entity.getY(), entity.getZ());
|
||||
+ MinecraftServer.LOGGER.error(msg, throwable);
|
||||
+ entity.discard();
|
||||
+ // Paper end
|
||||
}
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java
|
||||
index b300d12e9e00519028b53aca9c3fb01f589eaa91..63acd109a79ed752a05df3d4f1b99309297c2055 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/BlockEntity.java
|
||||
@@ -213,7 +213,12 @@ public abstract class BlockEntity {
|
||||
return minecraftkey + " // " + this.getClass().getCanonicalName();
|
||||
});
|
||||
if (this.level != null) {
|
||||
- CrashReportCategory.populateBlockDetails(crashReportSection, this.level, this.worldPosition, this.getBlockState());
|
||||
+ // Paper start - Prevent TileEntity and Entity crashes
|
||||
+ BlockState block = this.getBlockState();
|
||||
+ if (block != null) {
|
||||
+ CrashReportCategory.populateBlockDetails(crashReportSection, this.level, this.worldPosition, block);
|
||||
+ }
|
||||
+ // Paper end
|
||||
CrashReportCategory.populateBlockDetails(crashReportSection, this.level, this.worldPosition, this.level.getBlockState(this.worldPosition));
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
|
||||
index 8c2b562e46a35369389da453012b7af570145380..f21ae1ae8af79c1c0c6f2feaa933638add0aa065 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
|
||||
@@ -1184,11 +1184,11 @@ public class LevelChunk extends ChunkAccess {
|
||||
|
||||
gameprofilerfiller.pop();
|
||||
} catch (Throwable throwable) {
|
||||
- CrashReport crashreport = CrashReport.forThrowable(throwable, "Ticking block entity");
|
||||
- CrashReportCategory crashreportsystemdetails = crashreport.addCategory("Block entity being ticked");
|
||||
-
|
||||
- this.blockEntity.fillCrashReportCategory(crashreportsystemdetails);
|
||||
- throw new ReportedException(crashreport);
|
||||
+ // Paper start - Prevent tile entity and entity crashes
|
||||
+ final String msg = String.format("BlockEntity threw exception at %s:%s,%s,%s", LevelChunk.this.getLevel().getWorld().getName(), this.getPos().getX(), this.getPos().getY(), this.getPos().getZ());
|
||||
+ net.minecraft.server.MinecraftServer.LOGGER.error(msg, throwable);
|
||||
+ LevelChunk.this.removeBlockEntity(this.getPos());
|
||||
+ // Paper end
|
||||
// Spigot start
|
||||
} finally {
|
||||
this.blockEntity.tickTimer.stopTiming();
|
|
@ -0,0 +1,49 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Zach Brown <zach.brown@destroystokyo.com>
|
||||
Date: Tue, 1 Mar 2016 23:58:50 -0600
|
||||
Subject: [PATCH] Configurable top of nether void damage
|
||||
|
||||
Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index 5cf04b209ae3fa6c52ad45e726343418d0de311f..128dd4749590905fdfa85907d33adc4e4dbe6c33 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -705,7 +705,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
}
|
||||
|
||||
public void checkOutOfWorld() {
|
||||
- if (this.getY() < (double) (this.level.getMinBuildHeight() - 64)) {
|
||||
+ // Paper start - Configurable nether ceiling damage
|
||||
+ if (this.getY() < (double) (this.level.getMinBuildHeight() - 64) || (this.level.getWorld().getEnvironment() == org.bukkit.World.Environment.NETHER
|
||||
+ && this.level.paperConfig().environment.netherCeilingVoidDamageHeight.test(v -> this.getY() >= v)
|
||||
+ && (!(this instanceof Player player) || !player.getAbilities().invulnerable))) {
|
||||
+ // Paper end
|
||||
this.outOfWorld();
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/portal/PortalForcer.java b/src/main/java/net/minecraft/world/level/portal/PortalForcer.java
|
||||
index 98cdf291a5d0248091891ad30104adef708eec55..ff57611088eabfb7e2db8fcf6344b1551b17b87b 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/portal/PortalForcer.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/portal/PortalForcer.java
|
||||
@@ -55,7 +55,7 @@ public class PortalForcer {
|
||||
Optional<PoiRecord> optional = villageplace.getInSquare((holder) -> {
|
||||
return holder.is(PoiTypes.NETHER_PORTAL);
|
||||
}, blockposition, i, PoiManager.Occupancy.ANY).filter((villageplacerecord) -> {
|
||||
- return worldborder.isWithinBounds(villageplacerecord.getPos());
|
||||
+ return worldborder.isWithinBounds(villageplacerecord.getPos()) && !this.level.paperConfig().environment.netherCeilingVoidDamageHeight.test(v -> villageplacerecord.getPos().getY() >= v); // Paper - don't teleport into void damage
|
||||
}).sorted(Comparator.comparingDouble((PoiRecord villageplacerecord) -> { // CraftBukkit - decompile error
|
||||
return villageplacerecord.getPos().distSqr(blockposition);
|
||||
}).thenComparingInt((villageplacerecord) -> {
|
||||
@@ -90,6 +90,11 @@ public class PortalForcer {
|
||||
BlockPos blockposition2 = null;
|
||||
WorldBorder worldborder = this.level.getWorldBorder();
|
||||
int i = Math.min(this.level.getMaxBuildHeight(), this.level.getMinBuildHeight() + this.level.getLogicalHeight()) - 1;
|
||||
+ // Paper start - if ceiling void damage is enabled, make sure the max height doesn't exceed the void damage height
|
||||
+ if (this.level.paperConfig().environment.netherCeilingVoidDamageHeight.enabled()) {
|
||||
+ i = Math.min(i, this.level.paperConfig().environment.netherCeilingVoidDamageHeight.intValue() - 1);
|
||||
+ }
|
||||
+ // Paper end
|
||||
BlockPos.MutableBlockPos blockposition_mutableblockposition = blockposition.mutable();
|
||||
Iterator iterator = BlockPos.spiralAround(blockposition, createRadius, Direction.EAST, Direction.SOUTH).iterator(); // CraftBukkit
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Zach Brown <zach.brown@destroystokyo.com>
|
||||
Date: Wed, 2 Mar 2016 00:03:55 -0600
|
||||
Subject: [PATCH] Check online mode before converting and renaming player data
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/storage/PlayerDataStorage.java b/src/main/java/net/minecraft/world/level/storage/PlayerDataStorage.java
|
||||
index bf4c895794c2bc2ad65faa128c6fa92cb0656841..6909b6be840e8d4feadcc8b0c5a44fc1b9c81a54 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/storage/PlayerDataStorage.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/storage/PlayerDataStorage.java
|
||||
@@ -56,7 +56,7 @@ public class PlayerDataStorage {
|
||||
File file = new File(this.playerDir, player.getStringUUID() + ".dat");
|
||||
// Spigot Start
|
||||
boolean usingWrongFile = false;
|
||||
- if ( !file.exists() )
|
||||
+ if ( org.bukkit.Bukkit.getOnlineMode() && !file.exists() ) // Paper - Check online mode first
|
||||
{
|
||||
file = new File( this.playerDir, java.util.UUID.nameUUIDFromBytes( ( "OfflinePlayer:" + player.getScoreboardName() ).getBytes( "UTF-8" ) ).toString() + ".dat");
|
||||
if ( file.exists() )
|
|
@ -0,0 +1,18 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Zach Brown <zach.brown@destroystokyo.com>
|
||||
Date: Wed, 2 Mar 2016 00:32:25 -0600
|
||||
Subject: [PATCH] Always tick falling blocks
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java
|
||||
index d3639643cda7d8ccf3c1208502605120590a2d30..e2dfc4d9a16a738dd0fe91838603e1d4370afa56 100644
|
||||
--- a/src/main/java/org/spigotmc/ActivationRange.java
|
||||
+++ b/src/main/java/org/spigotmc/ActivationRange.java
|
||||
@@ -89,6 +89,7 @@ public class ActivationRange
|
||||
|| entity instanceof AbstractHurtingProjectile
|
||||
|| entity instanceof LightningBolt
|
||||
|| entity instanceof PrimedTnt
|
||||
+ || entity instanceof net.minecraft.world.entity.item.FallingBlockEntity // Paper - Always tick falling blocks
|
||||
|| entity instanceof EndCrystal
|
||||
|| entity instanceof FireworkRocketEntity
|
||||
|| entity instanceof ThrownTrident )
|
18
patches/unapplied/server/0038-Configurable-end-credits.patch
Normal file
18
patches/unapplied/server/0038-Configurable-end-credits.patch
Normal file
|
@ -0,0 +1,18 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: DoctorDark <doctordark11@gmail.com>
|
||||
Date: Wed, 16 Mar 2016 02:21:39 -0500
|
||||
Subject: [PATCH] Configurable end credits
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
index 650d28ce34239d3ae9caa3852e1bac518790fd83..ecb57a664da6be49611b95bf6bde3d9c3f893e82 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -1011,6 +1011,7 @@ public class ServerPlayer extends Player {
|
||||
this.unRide();
|
||||
this.getLevel().removePlayerImmediately(this, Entity.RemovalReason.CHANGED_DIMENSION);
|
||||
if (!this.wonGame) {
|
||||
+ if (level.paperConfig().misc.disableEndCredits) this.seenCredits = true; // Paper - Toggle to always disable end credits
|
||||
this.wonGame = true;
|
||||
this.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.WIN_GAME, this.seenCredits ? 0.0F : 1.0F));
|
||||
this.seenCredits = true;
|
|
@ -0,0 +1,19 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Iceee <andrew@opticgaming.tv>
|
||||
Date: Wed, 2 Mar 2016 01:39:52 -0600
|
||||
Subject: [PATCH] Fix lag from explosions processing dead entities
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java
|
||||
index 5ab38db6305d885ab61ee2c25ccb5ee77bb31370..c5544f952be057bae9407725d885798f461081ea 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/Explosion.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/Explosion.java
|
||||
@@ -202,7 +202,7 @@ public class Explosion {
|
||||
int i1 = Mth.floor(this.y + (double) f2 + 1.0D);
|
||||
int j1 = Mth.floor(this.z - (double) f2 - 1.0D);
|
||||
int k1 = Mth.floor(this.z + (double) f2 + 1.0D);
|
||||
- List<Entity> list = this.level.getEntities(this.source, new AABB((double) i, (double) l, (double) j1, (double) j, (double) i1, (double) k1));
|
||||
+ List<Entity> list = this.level.getEntities(this.source, new AABB((double) i, (double) l, (double) j1, (double) j, (double) i1, (double) k1), (com.google.common.base.Predicate<Entity>) entity -> entity.isAlive() && !entity.isSpectator()); // Paper - Fix lag from explosions processing dead entities
|
||||
Vec3 vec3d = new Vec3(this.x, this.y, this.z);
|
||||
|
||||
for (int l1 = 0; l1 < list.size(); ++l1) {
|
133
patches/unapplied/server/0040-Optimize-explosions.patch
Normal file
133
patches/unapplied/server/0040-Optimize-explosions.patch
Normal file
|
@ -0,0 +1,133 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Byteflux <byte@byteflux.net>
|
||||
Date: Wed, 2 Mar 2016 11:59:48 -0600
|
||||
Subject: [PATCH] Optimize explosions
|
||||
|
||||
The process of determining an entity's exposure from explosions can be
|
||||
expensive when there are hundreds or more entities in range.
|
||||
|
||||
This patch adds a per-tick cache that is used for storing and retrieving
|
||||
an entity's exposure during an explosion.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index ac81428f19e2d445f315000d34173c2d650a9aeb..28d58f402f15ee37cc1bfa3114839db281fc5f57 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -1396,6 +1396,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
|
||||
this.profiler.pop();
|
||||
this.profiler.pop();
|
||||
+ worldserver.explosionDensityCache.clear(); // Paper - Optimize explosions
|
||||
}
|
||||
|
||||
this.profiler.popPush("connection");
|
||||
diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java
|
||||
index c5544f952be057bae9407725d885798f461081ea..b71cd16a63889d8a286b642158f9ab45af89b7c4 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/Explosion.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/Explosion.java
|
||||
@@ -221,7 +221,7 @@ public class Explosion {
|
||||
d8 /= d11;
|
||||
d9 /= d11;
|
||||
d10 /= d11;
|
||||
- double d12 = (double) Explosion.getSeenPercent(vec3d, entity);
|
||||
+ double d12 = this.getBlockDensity(vec3d, entity); // Paper - Optimize explosions
|
||||
double d13 = (1.0D - d7) * d12;
|
||||
|
||||
// CraftBukkit start
|
||||
@@ -494,4 +494,84 @@ public class Explosion {
|
||||
|
||||
private BlockInteraction() {}
|
||||
}
|
||||
+ // Paper start - Optimize explosions
|
||||
+ private float getBlockDensity(Vec3 vec3d, Entity entity) {
|
||||
+ if (!this.level.paperConfig().environment.optimizeExplosions) {
|
||||
+ return getSeenPercent(vec3d, entity);
|
||||
+ }
|
||||
+ CacheKey key = new CacheKey(this, entity.getBoundingBox());
|
||||
+ Float blockDensity = this.level.explosionDensityCache.get(key);
|
||||
+ if (blockDensity == null) {
|
||||
+ blockDensity = getSeenPercent(vec3d, entity);
|
||||
+ this.level.explosionDensityCache.put(key, blockDensity);
|
||||
+ }
|
||||
+
|
||||
+ return blockDensity;
|
||||
+ }
|
||||
+
|
||||
+ static class CacheKey {
|
||||
+ private final Level world;
|
||||
+ private final double posX, posY, posZ;
|
||||
+ private final double minX, minY, minZ;
|
||||
+ private final double maxX, maxY, maxZ;
|
||||
+
|
||||
+ public CacheKey(Explosion explosion, AABB aabb) {
|
||||
+ this.world = explosion.level;
|
||||
+ this.posX = explosion.x;
|
||||
+ this.posY = explosion.y;
|
||||
+ this.posZ = explosion.z;
|
||||
+ this.minX = aabb.minX;
|
||||
+ this.minY = aabb.minY;
|
||||
+ this.minZ = aabb.minZ;
|
||||
+ this.maxX = aabb.maxX;
|
||||
+ this.maxY = aabb.maxY;
|
||||
+ this.maxZ = aabb.maxZ;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean equals(Object o) {
|
||||
+ if (this == o) return true;
|
||||
+ if (o == null || getClass() != o.getClass()) return false;
|
||||
+
|
||||
+ CacheKey cacheKey = (CacheKey) o;
|
||||
+
|
||||
+ if (Double.compare(cacheKey.posX, posX) != 0) return false;
|
||||
+ if (Double.compare(cacheKey.posY, posY) != 0) return false;
|
||||
+ if (Double.compare(cacheKey.posZ, posZ) != 0) return false;
|
||||
+ if (Double.compare(cacheKey.minX, minX) != 0) return false;
|
||||
+ if (Double.compare(cacheKey.minY, minY) != 0) return false;
|
||||
+ if (Double.compare(cacheKey.minZ, minZ) != 0) return false;
|
||||
+ if (Double.compare(cacheKey.maxX, maxX) != 0) return false;
|
||||
+ if (Double.compare(cacheKey.maxY, maxY) != 0) return false;
|
||||
+ if (Double.compare(cacheKey.maxZ, maxZ) != 0) return false;
|
||||
+ return world.equals(cacheKey.world);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public int hashCode() {
|
||||
+ int result;
|
||||
+ long temp;
|
||||
+ result = world.hashCode();
|
||||
+ temp = Double.doubleToLongBits(posX);
|
||||
+ result = 31 * result + (int) (temp ^ (temp >>> 32));
|
||||
+ temp = Double.doubleToLongBits(posY);
|
||||
+ result = 31 * result + (int) (temp ^ (temp >>> 32));
|
||||
+ temp = Double.doubleToLongBits(posZ);
|
||||
+ result = 31 * result + (int) (temp ^ (temp >>> 32));
|
||||
+ temp = Double.doubleToLongBits(minX);
|
||||
+ result = 31 * result + (int) (temp ^ (temp >>> 32));
|
||||
+ temp = Double.doubleToLongBits(minY);
|
||||
+ result = 31 * result + (int) (temp ^ (temp >>> 32));
|
||||
+ temp = Double.doubleToLongBits(minZ);
|
||||
+ result = 31 * result + (int) (temp ^ (temp >>> 32));
|
||||
+ temp = Double.doubleToLongBits(maxX);
|
||||
+ result = 31 * result + (int) (temp ^ (temp >>> 32));
|
||||
+ temp = Double.doubleToLongBits(maxY);
|
||||
+ result = 31 * result + (int) (temp ^ (temp >>> 32));
|
||||
+ temp = Double.doubleToLongBits(maxZ);
|
||||
+ result = 31 * result + (int) (temp ^ (temp >>> 32));
|
||||
+ return result;
|
||||
+ }
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
||||
index e082e4a8c8fbce341bcf00115d1579b4bed4b2a4..746cab58dc67b47bb57889343c625e038dda4851 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/Level.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
||||
@@ -164,6 +164,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
||||
private org.spigotmc.TickLimiter entityLimiter;
|
||||
private org.spigotmc.TickLimiter tileLimiter;
|
||||
private int tileTickPosition;
|
||||
+ public final Map<Explosion.CacheKey, Float> explosionDensityCache = new HashMap<>(); // Paper - Optimize explosions
|
||||
|
||||
public CraftWorld getWorld() {
|
||||
return this.world;
|
|
@ -0,0 +1,55 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Sudzzy <originmc@outlook.com>
|
||||
Date: Wed, 2 Mar 2016 14:48:03 -0600
|
||||
Subject: [PATCH] Disable explosion knockback
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
index c6ce813f7ea6c4dcbd45e9d8c55f56c29dc3ea53..7e4f95e04a880ecb459228c90be462cbbec14620 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -1400,6 +1400,7 @@ public abstract class LivingEntity extends Entity {
|
||||
}
|
||||
}
|
||||
|
||||
+ boolean knockbackCancelled = level.paperConfig().environment.disableExplosionKnockback && source.isExplosion() && this instanceof net.minecraft.world.entity.player.Player; // Paper - Disable explosion knockback
|
||||
if (flag1) {
|
||||
if (flag) {
|
||||
this.level.broadcastEntityEvent(this, (byte) 29);
|
||||
@@ -1420,6 +1421,7 @@ public abstract class LivingEntity extends Entity {
|
||||
b0 = 2;
|
||||
}
|
||||
|
||||
+ if (!knockbackCancelled) // Paper - Disable explosion knockback
|
||||
this.level.broadcastEntityEvent(this, b0);
|
||||
}
|
||||
|
||||
@@ -1443,6 +1445,7 @@ public abstract class LivingEntity extends Entity {
|
||||
}
|
||||
}
|
||||
|
||||
+ if (knockbackCancelled) this.level.broadcastEntityEvent(this, (byte) 2); // Paper - Disable explosion knockback
|
||||
if (this.isDeadOrDying()) {
|
||||
if (!this.checkTotemDeathProtection(source)) {
|
||||
SoundEvent soundeffect = this.getDeathSound();
|
||||
diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java
|
||||
index b71cd16a63889d8a286b642158f9ab45af89b7c4..a9f45dbc2997c4deeba932d04a52e21f4dbfea95 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/Explosion.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/Explosion.java
|
||||
@@ -260,14 +260,14 @@ public class Explosion {
|
||||
double d14 = d13;
|
||||
|
||||
if (entity instanceof LivingEntity) {
|
||||
- d14 = ProtectionEnchantment.getExplosionKnockbackAfterDampener((LivingEntity) entity, d13);
|
||||
+ d14 = entity instanceof Player && level.paperConfig().environment.disableExplosionKnockback ? 0 : ProtectionEnchantment.getExplosionKnockbackAfterDampener((LivingEntity) entity, d13); // Paper - Disable explosion knockback
|
||||
}
|
||||
|
||||
entity.setDeltaMovement(entity.getDeltaMovement().add(d8 * d14, d9 * d14, d10 * d14));
|
||||
if (entity instanceof Player) {
|
||||
Player entityhuman = (Player) entity;
|
||||
|
||||
- if (!entityhuman.isSpectator() && (!entityhuman.isCreative() || !entityhuman.getAbilities().flying)) {
|
||||
+ if (!entityhuman.isSpectator() && (!entityhuman.isCreative() || !entityhuman.getAbilities().flying) && !level.paperConfig().environment.disableExplosionKnockback) { // Paper - Disable explosion knockback
|
||||
this.hitPlayers.put(entityhuman, new Vec3(d8 * d13, d9 * d13, d10 * d13));
|
||||
}
|
||||
}
|
19
patches/unapplied/server/0042-Disable-thunder.patch
Normal file
19
patches/unapplied/server/0042-Disable-thunder.patch
Normal file
|
@ -0,0 +1,19 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Sudzzy <originmc@outlook.com>
|
||||
Date: Wed, 2 Mar 2016 14:52:43 -0600
|
||||
Subject: [PATCH] Disable thunder
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
index b1771e25c13b555d3316aca35f8a97ed4ce8f275..f6b62d26e99d7bec49279a41475948a4fd4b92d9 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -692,7 +692,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
gameprofilerfiller.push("thunder");
|
||||
BlockPos blockposition;
|
||||
|
||||
- if (flag && this.isThundering() && this.spigotConfig.thunderChance > 0 && this.random.nextInt(this.spigotConfig.thunderChance) == 0) { // Spigot
|
||||
+ if (!this.paperConfig().environment.disableThunder && flag && this.isThundering() && this.spigotConfig.thunderChance > 0 && this.random.nextInt(this.spigotConfig.thunderChance) == 0) { // Spigot // Paper - disable thunder
|
||||
blockposition = this.findLightningTargetAround(this.getBlockRandomPos(j, 0, k, 15));
|
||||
if (this.isRainingAt(blockposition)) {
|
||||
DifficultyInstance difficultydamagescaler = this.getCurrentDifficultyAt(blockposition);
|
19
patches/unapplied/server/0043-Disable-ice-and-snow.patch
Normal file
19
patches/unapplied/server/0043-Disable-ice-and-snow.patch
Normal file
|
@ -0,0 +1,19 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Sudzzy <originmc@outlook.com>
|
||||
Date: Wed, 2 Mar 2016 14:57:24 -0600
|
||||
Subject: [PATCH] Disable ice and snow
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
index f6b62d26e99d7bec49279a41475948a4fd4b92d9..9c9c8178cd11e37aaef400e40092fb1095fa6c5f 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -722,7 +722,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
gameprofilerfiller.popPush("iceandsnow");
|
||||
int l;
|
||||
|
||||
- if (this.random.nextInt(16) == 0) {
|
||||
+ if (!this.paperConfig().environment.disableIceAndSnow && this.random.nextInt(16) == 0) { // Paper - Disable ice and snow
|
||||
blockposition = this.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING, this.getBlockRandomPos(j, 0, k, 15));
|
||||
BlockPos blockposition1 = blockposition.below();
|
||||
Biome biomebase = (Biome) this.getBiome(blockposition).value();
|
|
@ -0,0 +1,49 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Sudzzy <originmc@outlook.com>
|
||||
Date: Wed, 2 Mar 2016 15:03:53 -0600
|
||||
Subject: [PATCH] Configurable mob spawner tick rate
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/BaseSpawner.java b/src/main/java/net/minecraft/world/level/BaseSpawner.java
|
||||
index 3e83bff81a0656d5e1d079ad9e63c7d27561c8e3..b214a79efc4f5279d3dd29feb1f79efc45788a8d 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/BaseSpawner.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/BaseSpawner.java
|
||||
@@ -45,6 +45,7 @@ public abstract class BaseSpawner {
|
||||
public int maxNearbyEntities = 6;
|
||||
public int requiredPlayerRange = 16;
|
||||
public int spawnRange = 4;
|
||||
+ private int tickDelay = 0; // Paper
|
||||
|
||||
public BaseSpawner() {}
|
||||
|
||||
@@ -79,13 +80,18 @@ public abstract class BaseSpawner {
|
||||
}
|
||||
|
||||
public void serverTick(ServerLevel world, BlockPos pos) {
|
||||
+ // Paper start - Configurable mob spawner tick rate
|
||||
+ if (spawnDelay > 0 && --tickDelay > 0) return;
|
||||
+ tickDelay = world.paperConfig().tickRates.mobSpawner;
|
||||
+ if (tickDelay == -1) { return; } // If disabled
|
||||
+ // Paper end
|
||||
if (this.isNearPlayer(world, pos)) {
|
||||
- if (this.spawnDelay == -1) {
|
||||
+ if (this.spawnDelay < -tickDelay) {
|
||||
this.delay(world, pos);
|
||||
}
|
||||
|
||||
if (this.spawnDelay > 0) {
|
||||
- --this.spawnDelay;
|
||||
+ this.spawnDelay -= tickDelay; // Paper
|
||||
} else {
|
||||
boolean flag = false;
|
||||
RandomSource randomsource = world.getRandom();
|
||||
@@ -152,8 +158,7 @@ public abstract class BaseSpawner {
|
||||
((Mob) entity).finalizeSpawn(world, world.getCurrentDifficultyAt(entity.blockPosition()), MobSpawnType.SPAWNER, (SpawnGroupData) null, (CompoundTag) null);
|
||||
}
|
||||
// Spigot Start
|
||||
- if ( entityinsentient.level.spigotConfig.nerfSpawnerMobs )
|
||||
- {
|
||||
+ if (entityinsentient.level.spigotConfig.nerfSpawnerMobs) {
|
||||
entityinsentient.aware = false;
|
||||
}
|
||||
// Spigot End
|
|
@ -0,0 +1,48 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Isaac Moore <rmsy@me.com>
|
||||
Date: Tue, 19 Apr 2016 14:09:31 -0500
|
||||
Subject: [PATCH] Implement PlayerLocaleChangeEvent
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
index ecb57a664da6be49611b95bf6bde3d9c3f893e82..c0651c446bdcc4d96df36ad201b77f5ffffa5a7d 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -1787,7 +1787,7 @@ public class ServerPlayer extends Player {
|
||||
return s;
|
||||
}
|
||||
|
||||
- public String locale = "en_us"; // CraftBukkit - add, lowercase
|
||||
+ public String locale = null; // CraftBukkit - add, lowercase // Paper - default to null
|
||||
public java.util.Locale adventure$locale = java.util.Locale.US; // Paper
|
||||
public void updateOptions(ServerboundClientInformationPacket packet) {
|
||||
// CraftBukkit start
|
||||
@@ -1795,9 +1795,10 @@ public class ServerPlayer extends Player {
|
||||
PlayerChangedMainHandEvent event = new PlayerChangedMainHandEvent(this.getBukkitEntity(), getMainArm() == HumanoidArm.LEFT ? MainHand.LEFT : MainHand.RIGHT);
|
||||
this.server.server.getPluginManager().callEvent(event);
|
||||
}
|
||||
- if (!this.locale.equals(packet.language)) {
|
||||
+ if (this.locale == null || !this.locale.equals(packet.language)) { // Paper - check for null
|
||||
PlayerLocaleChangeEvent event = new PlayerLocaleChangeEvent(this.getBukkitEntity(), packet.language);
|
||||
this.server.server.getPluginManager().callEvent(event);
|
||||
+ this.server.server.getPluginManager().callEvent(new com.destroystokyo.paper.event.player.PlayerLocaleChangeEvent(this.getBukkitEntity(), this.locale, packet.language)); // Paper
|
||||
}
|
||||
this.locale = packet.language;
|
||||
// Paper start
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
index 27f4387a3ac750114c99e41e855c8fb8081a507d..31172053e26a8df53d0987e816b3e03a560332e6 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
@@ -2113,8 +2113,10 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
|
||||
@Override
|
||||
public String getLocale() {
|
||||
- return this.getHandle().locale;
|
||||
-
|
||||
+ // Paper start - Locale change event
|
||||
+ final String locale = this.getHandle().locale;
|
||||
+ return locale != null ? locale : "en_us";
|
||||
+ // Paper end
|
||||
}
|
||||
|
||||
// Paper start
|
62
patches/unapplied/server/0046-Add-BeaconEffectEvent.patch
Normal file
62
patches/unapplied/server/0046-Add-BeaconEffectEvent.patch
Normal file
|
@ -0,0 +1,62 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Byteflux <byte@byteflux.net>
|
||||
Date: Wed, 2 Mar 2016 23:30:53 -0600
|
||||
Subject: [PATCH] Add BeaconEffectEvent
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java
|
||||
index e1a720afaf9f3d843065ed1e8e4ce71019a0fea2..3a17c143de499d81109ae7d6e9fe18718139c5b7 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java
|
||||
@@ -41,6 +41,10 @@ import net.minecraft.world.phys.AABB;
|
||||
import org.bukkit.craftbukkit.potion.CraftPotionUtil;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
// CraftBukkit end
|
||||
+// Paper start
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import com.destroystokyo.paper.event.block.BeaconEffectEvent;
|
||||
+// Paper end
|
||||
|
||||
public class BeaconBlockEntity extends BlockEntity implements MenuProvider, Nameable {
|
||||
|
||||
@@ -280,15 +284,23 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider, Name
|
||||
}
|
||||
}
|
||||
|
||||
- private static void applyEffect(List list, MobEffect mobeffectlist, int j, int b0) {
|
||||
- {
|
||||
+ private static void applyEffect(List list, MobEffect effects, int i, int b0, boolean isPrimary, BlockPos worldPosition) { // Paper - BeaconEffectEvent
|
||||
+ if (!list.isEmpty()) { // Paper - BeaconEffectEvent
|
||||
Iterator iterator = list.iterator();
|
||||
|
||||
Player entityhuman;
|
||||
+ // Paper start - BeaconEffectEvent
|
||||
+ org.bukkit.block.Block block = ((Player) list.get(0)).level.getWorld().getBlockAt(worldPosition.getX(), worldPosition.getY(), worldPosition.getZ());
|
||||
+ PotionEffect effect = CraftPotionUtil.toBukkit(new MobEffectInstance(effects, i, b0, true, true));
|
||||
+ // Paper end
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
- entityhuman = (Player) iterator.next();
|
||||
- entityhuman.addEffect(new MobEffectInstance(mobeffectlist, j, b0, true, true), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.BEACON);
|
||||
+ // Paper start - BeaconEffectEvent
|
||||
+ entityhuman = (ServerPlayer) iterator.next();
|
||||
+ BeaconEffectEvent event = new BeaconEffectEvent(block, effect, (org.bukkit.entity.Player) entityhuman.getBukkitEntity(), isPrimary);
|
||||
+ if (CraftEventFactory.callEvent(event).isCancelled()) continue;
|
||||
+ entityhuman.addEffect(new MobEffectInstance(CraftPotionUtil.fromBukkit(event.getEffect())), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.BEACON);
|
||||
+ // Paper end
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -311,10 +323,10 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider, Name
|
||||
int j = BeaconBlockEntity.getLevel(beaconLevel);
|
||||
List list = BeaconBlockEntity.getHumansInRange(world, pos, beaconLevel);
|
||||
|
||||
- BeaconBlockEntity.applyEffect(list, primaryEffect, j, b0);
|
||||
+ BeaconBlockEntity.applyEffect(list, primaryEffect, j, b0, true, pos); // Paper - BeaconEffectEvent
|
||||
|
||||
if (BeaconBlockEntity.hasSecondaryEffect(beaconLevel, primaryEffect, secondaryEffect)) {
|
||||
- BeaconBlockEntity.applyEffect(list, secondaryEffect, j, 0);
|
||||
+ BeaconBlockEntity.applyEffect(list, secondaryEffect, j, 0, false, pos); // Paper - BeaconEffectEvent
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Sudzzy <originmc@outlook.com>
|
||||
Date: Wed, 2 Mar 2016 23:34:44 -0600
|
||||
Subject: [PATCH] Configurable container update tick rate
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
index c0651c446bdcc4d96df36ad201b77f5ffffa5a7d..cba9b5586048500d91081cc8ef2ad7ae2bb7a816 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -233,6 +233,7 @@ public class ServerPlayer extends Player {
|
||||
private int containerCounter;
|
||||
public int latency;
|
||||
public boolean wonGame;
|
||||
+ private int containerUpdateDelay; // Paper
|
||||
|
||||
// CraftBukkit start
|
||||
public String displayName;
|
||||
@@ -623,7 +624,12 @@ public class ServerPlayer extends Player {
|
||||
--this.invulnerableTime;
|
||||
}
|
||||
|
||||
- this.containerMenu.broadcastChanges();
|
||||
+ // Paper start - Configurable container update tick rate
|
||||
+ if (--containerUpdateDelay <= 0) {
|
||||
+ this.containerMenu.broadcastChanges();
|
||||
+ containerUpdateDelay = level.paperConfig().tickRates.containerUpdate;
|
||||
+ }
|
||||
+ // Paper end
|
||||
if (!this.level.isClientSide && !this.containerMenu.stillValid(this)) {
|
||||
this.closeContainer();
|
||||
this.containerMenu = this.inventoryMenu;
|
|
@ -0,0 +1,25 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Techcable <Techcable@outlook.com>
|
||||
Date: Wed, 2 Mar 2016 23:42:37 -0600
|
||||
Subject: [PATCH] Use UserCache for player heads
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java
|
||||
index 30865eece58ba2f3c991f9d373a128ada3385b4f..85b9baad074634a2f21c15adbb393ebc5924bdd8 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java
|
||||
@@ -208,7 +208,13 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta {
|
||||
if (name == null) {
|
||||
this.setProfile(null);
|
||||
} else {
|
||||
- this.setProfile(new GameProfile(null, name));
|
||||
+ // Paper start - Use Online Players Skull
|
||||
+ GameProfile newProfile = null;
|
||||
+ net.minecraft.server.level.ServerPlayer player = net.minecraft.server.MinecraftServer.getServer().getPlayerList().getPlayerByName(name);
|
||||
+ if (player != null) newProfile = player.getGameProfile();
|
||||
+ if (newProfile == null) newProfile = new GameProfile(null, name);
|
||||
+ this.setProfile(newProfile);
|
||||
+ // Paper end
|
||||
}
|
||||
|
||||
return true;
|
|
@ -0,0 +1,21 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Zach Brown <zach.brown@destroystokyo.com>
|
||||
Date: Wed, 2 Mar 2016 23:45:17 -0600
|
||||
Subject: [PATCH] Disable spigot tick limiters
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
||||
index 746cab58dc67b47bb57889343c625e038dda4851..6457384bded7b65f22547704eba74875a6b84ebb 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/Level.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
||||
@@ -695,9 +695,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
||||
// Spigot start
|
||||
// Iterator iterator = this.blockEntityTickers.iterator();
|
||||
int tilesThisCycle = 0;
|
||||
- for (this.tileLimiter.initTick();
|
||||
- tilesThisCycle < this.blockEntityTickers.size() && (tilesThisCycle % 10 != 0 || this.tileLimiter.shouldContinue());
|
||||
- this.tileTickPosition++, tilesThisCycle++) {
|
||||
+ for (tileTickPosition = 0; tileTickPosition < this.blockEntityTickers.size(); tileTickPosition++) { // Paper - Disable tick limiters
|
||||
this.tileTickPosition = (this.tileTickPosition < this.blockEntityTickers.size()) ? this.tileTickPosition : 0;
|
||||
TickingBlockEntity tickingblockentity = (TickingBlockEntity) this.blockEntityTickers.get(tileTickPosition);
|
||||
// Spigot start
|
|
@ -0,0 +1,38 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Steve Anton <anxuiz.nx@gmail.com>
|
||||
Date: Thu, 3 Mar 2016 00:09:38 -0600
|
||||
Subject: [PATCH] Add PlayerInitialSpawnEvent
|
||||
|
||||
For modifying a player's initial spawn location as they join the server
|
||||
|
||||
This is a duplicate API from spigot, so use our duplicate subclass and
|
||||
improve setPosition to use raw
|
||||
|
||||
== AT ==
|
||||
public net.minecraft.world.entity.Entity setRot(FF)V
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
index 8a75650f1e1b8a223723ece379beab0eb8f17ce9..ea766e18fb19dbb78e07357748bbf83095253275 100644
|
||||
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
@@ -229,7 +229,7 @@ public abstract class PlayerList {
|
||||
|
||||
// Spigot start - spawn location event
|
||||
Player spawnPlayer = player.getBukkitEntity();
|
||||
- org.spigotmc.event.player.PlayerSpawnLocationEvent ev = new org.spigotmc.event.player.PlayerSpawnLocationEvent(spawnPlayer, spawnPlayer.getLocation());
|
||||
+ org.spigotmc.event.player.PlayerSpawnLocationEvent ev = new com.destroystokyo.paper.event.player.PlayerInitialSpawnEvent(spawnPlayer, spawnPlayer.getLocation()); // Paper use our duplicate event
|
||||
this.cserver.getPluginManager().callEvent(ev);
|
||||
|
||||
Location loc = ev.getSpawnLocation();
|
||||
@@ -237,7 +237,10 @@ public abstract class PlayerList {
|
||||
|
||||
player.spawnIn(worldserver1);
|
||||
player.gameMode.setLevel((ServerLevel) player.level);
|
||||
- player.absMoveTo(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch());
|
||||
+ // Paper start - set raw so we aren't fully joined to the world (not added to chunk or world)
|
||||
+ player.setPosRaw(loc.getX(), loc.getY(), loc.getZ());
|
||||
+ player.setRot(loc.getYaw(), loc.getPitch());
|
||||
+ // Paper end
|
||||
// Spigot end
|
||||
|
||||
// CraftBukkit - Moved message to after join
|
|
@ -0,0 +1,23 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Thu, 3 Mar 2016 01:13:45 -0600
|
||||
Subject: [PATCH] Configurable Disabling Cat Chest Detection
|
||||
|
||||
Offers a gameplay feature to stop cats from blocking chests
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/ChestBlock.java b/src/main/java/net/minecraft/world/level/block/ChestBlock.java
|
||||
index ccde1bef18a7ffe338d71a6feb2dd88228004c34..c6b57d45383441aa35510e759ce3cb82bc98f305 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/ChestBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/ChestBlock.java
|
||||
@@ -361,6 +361,11 @@ public class ChestBlock extends AbstractChestBlock<ChestBlockEntity> implements
|
||||
}
|
||||
|
||||
private static boolean isCatSittingOnChest(LevelAccessor world, BlockPos pos) {
|
||||
+ // Paper start - Option to disable chest cat detection
|
||||
+ if (world.getMinecraftWorld().paperConfig().entities.behavior.disableChestCatDetection) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ // Paper end
|
||||
List<Cat> list = world.getEntitiesOfClass(Cat.class, new AABB((double) pos.getX(), (double) (pos.getY() + 1), (double) pos.getZ(), (double) (pos.getX() + 1), (double) (pos.getY() + 2), (double) (pos.getZ() + 1)));
|
||||
|
||||
if (!list.isEmpty()) {
|
|
@ -0,0 +1,170 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Thu, 3 Mar 2016 01:17:12 -0600
|
||||
Subject: [PATCH] Ensure commands are not ran async
|
||||
|
||||
Plugins calling Player.chat("/foo") or Server.dispatchCommand() could
|
||||
trigger the server to execute a command while on another thread.
|
||||
|
||||
These commands would then process EXPECTING to be on the main thread, leaving to
|
||||
very hard to trace concurrency issues.
|
||||
|
||||
This change will synchronize the command execution back to the main thread, causing a
|
||||
big slowdown in execution but throwing an exception at same time to raise awareness
|
||||
that it is happening so that plugin authors can fix their code to stop executing commands async.
|
||||
|
||||
This also properly splits up the chat and command handling to reflect the server now
|
||||
having separate packets for both, and the client always using the correct packet. Text
|
||||
from a chat packet should never be parsed into a command, even if it starts with the `/`
|
||||
character.
|
||||
|
||||
Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index fe315458cead06c3f01473e84b050dadb5ad2726..301d90618f51b90a4a7b0158deef7373fba9cca8 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -2040,7 +2040,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
return true;
|
||||
}
|
||||
|
||||
- private static boolean isChatMessageIllegal(String message) {
|
||||
+ public static boolean isChatMessageIllegal(String message) { // Paper - private -> public
|
||||
for (int i = 0; i < message.length(); ++i) {
|
||||
if (!SharedConstants.isAllowedChatCharacter(message.charAt(i))) {
|
||||
return true;
|
||||
@@ -2057,7 +2057,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
}
|
||||
OutgoingChatMessage outgoing = OutgoingChatMessage.create(original);
|
||||
|
||||
- if (!async && s.startsWith("/")) {
|
||||
+ if (false && !async && s.startsWith("/")) { // Paper - don't handle commands in chat logic
|
||||
this.handleCommand(s);
|
||||
} else if (this.player.getChatVisibility() == ChatVisiblity.SYSTEM) {
|
||||
// Do nothing, this is coming from a plugin
|
||||
@@ -2147,7 +2147,29 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
}
|
||||
}
|
||||
|
||||
- private void handleCommand(String s) {
|
||||
+ public void handleCommand(String s) { // Paper - private -> public
|
||||
+ // Paper Start
|
||||
+ if (!org.spigotmc.AsyncCatcher.shuttingDown && !org.bukkit.Bukkit.isPrimaryThread()) {
|
||||
+ LOGGER.error("Command Dispatched Async: " + s);
|
||||
+ LOGGER.error("Please notify author of plugin causing this execution to fix this bug! see: http://bit.ly/1oSiM6C", new Throwable());
|
||||
+ Waitable<Void> wait = new Waitable<>() {
|
||||
+ @Override
|
||||
+ protected Void evaluate() {
|
||||
+ ServerGamePacketListenerImpl.this.handleCommand(s);
|
||||
+ return null;
|
||||
+ }
|
||||
+ };
|
||||
+ server.processQueue.add(wait);
|
||||
+ try {
|
||||
+ wait.get();
|
||||
+ return;
|
||||
+ } catch (InterruptedException e) {
|
||||
+ Thread.currentThread().interrupt(); // This is proper habit for java. If we aren't handling it, pass it on!
|
||||
+ } catch (Exception e) {
|
||||
+ throw new RuntimeException("Exception processing chat command", e.getCause());
|
||||
+ }
|
||||
+ }
|
||||
+ // Paper End
|
||||
co.aikar.timings.MinecraftTimings.playerCommandTimer.startTiming(); // Paper
|
||||
if ( org.spigotmc.SpigotConfig.logCommands ) // Spigot
|
||||
this.LOGGER.info(this.player.getScoreboardName() + " issued server command: " + s);
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index babde3ac7af9b5659bcc7e0298d1d77e7b2d60e2..369657f5c54dae7b03b09aec1c672dc3f2cba090 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -857,6 +857,28 @@ public final class CraftServer implements Server {
|
||||
Validate.notNull(commandLine, "CommandLine cannot be null");
|
||||
org.spigotmc.AsyncCatcher.catchOp("command dispatch"); // Spigot
|
||||
|
||||
+ // Paper Start
|
||||
+ if (!org.spigotmc.AsyncCatcher.shuttingDown && !Bukkit.isPrimaryThread()) {
|
||||
+ final CommandSender fSender = sender;
|
||||
+ final String fCommandLine = commandLine;
|
||||
+ Bukkit.getLogger().log(Level.SEVERE, "Command Dispatched Async: " + commandLine);
|
||||
+ Bukkit.getLogger().log(Level.SEVERE, "Please notify author of plugin causing this execution to fix this bug! see: http://bit.ly/1oSiM6C", new Throwable());
|
||||
+ org.bukkit.craftbukkit.util.Waitable<Boolean> wait = new org.bukkit.craftbukkit.util.Waitable<Boolean>() {
|
||||
+ @Override
|
||||
+ protected Boolean evaluate() {
|
||||
+ return dispatchCommand(fSender, fCommandLine);
|
||||
+ }
|
||||
+ };
|
||||
+ net.minecraft.server.MinecraftServer.getServer().processQueue.add(wait);
|
||||
+ try {
|
||||
+ return wait.get();
|
||||
+ } catch (InterruptedException e) {
|
||||
+ Thread.currentThread().interrupt(); // This is proper habit for java. If we aren't handling it, pass it on!
|
||||
+ } catch (Exception e) {
|
||||
+ throw new RuntimeException("Exception processing dispatch command", e.getCause());
|
||||
+ }
|
||||
+ }
|
||||
+ // Paper End
|
||||
if (this.commandMap.dispatch(sender, commandLine)) {
|
||||
return true;
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
index 31172053e26a8df53d0987e816b3e03a560332e6..59e0a9b6f07342120ee5ca00434905b26faf04ca 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
@@ -504,7 +504,20 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
public void chat(String msg) {
|
||||
if (this.getHandle().connection == null) return;
|
||||
|
||||
- this.getHandle().connection.chat(msg, PlayerChatMessage.system(msg), false);
|
||||
+ // Paper start - improve chat handling
|
||||
+ if (ServerGamePacketListenerImpl.isChatMessageIllegal(msg)) {
|
||||
+ this.getHandle().connection.disconnect(Component.translatable("multiplayer.disconnect.illegal_characters"), org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_CHARACTERS);
|
||||
+ } else {
|
||||
+ if (msg.startsWith("/")) {
|
||||
+ this.getHandle().connection.handleCommand(msg);
|
||||
+ } else {
|
||||
+ final PlayerChatMessage playerChatMessage = PlayerChatMessage.system(msg).withResult(new net.minecraft.network.chat.ChatDecorator.ModernResult(Component.literal(msg), true, false));
|
||||
+ // TODO chat decorating
|
||||
+ // TODO text filtering
|
||||
+ this.getHandle().connection.chat(msg, playerChatMessage, false);
|
||||
+ }
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/util/ServerShutdownThread.java b/src/main/java/org/bukkit/craftbukkit/util/ServerShutdownThread.java
|
||||
index 19c44daaa407b7c1c7a7ffe56fef8c8814c6d5b2..6a073a9dc44d93eba296a0e18a9c7be8a7881725 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/util/ServerShutdownThread.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/util/ServerShutdownThread.java
|
||||
@@ -13,6 +13,7 @@ public class ServerShutdownThread extends Thread {
|
||||
public void run() {
|
||||
try {
|
||||
org.spigotmc.AsyncCatcher.enabled = false; // Spigot
|
||||
+ org.spigotmc.AsyncCatcher.shuttingDown = true; // Paper
|
||||
this.server.close();
|
||||
} finally {
|
||||
try {
|
||||
diff --git a/src/main/java/org/spigotmc/AsyncCatcher.java b/src/main/java/org/spigotmc/AsyncCatcher.java
|
||||
index 05e94702e42b8f5c35d2a112c486d57948a3acba..5409f230fdd53b70fc03c58177438534731ad4e6 100644
|
||||
--- a/src/main/java/org/spigotmc/AsyncCatcher.java
|
||||
+++ b/src/main/java/org/spigotmc/AsyncCatcher.java
|
||||
@@ -6,6 +6,7 @@ public class AsyncCatcher
|
||||
{
|
||||
|
||||
public static boolean enabled = true;
|
||||
+ public static boolean shuttingDown = false; // Paper
|
||||
|
||||
public static void catchOp(String reason)
|
||||
{
|
||||
diff --git a/src/main/java/org/spigotmc/RestartCommand.java b/src/main/java/org/spigotmc/RestartCommand.java
|
||||
index 882e93ad4471e3688f2fcfb1e6f16926786ee5e7..94d8ba376cd1f024b244654cac9bb62bb19e3060 100644
|
||||
--- a/src/main/java/org/spigotmc/RestartCommand.java
|
||||
+++ b/src/main/java/org/spigotmc/RestartCommand.java
|
||||
@@ -43,6 +43,7 @@ public class RestartCommand extends Command
|
||||
private static void restart(final String restartScript)
|
||||
{
|
||||
AsyncCatcher.enabled = false; // Disable async catcher incase it interferes with us
|
||||
+ org.spigotmc.AsyncCatcher.shuttingDown = true; // Paper
|
||||
try
|
||||
{
|
||||
String[] split = restartScript.split( " " );
|
|
@ -0,0 +1,32 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: vemacs <d@nkmem.es>
|
||||
Date: Thu, 3 Mar 2016 01:19:22 -0600
|
||||
Subject: [PATCH] All chunks are slime spawn chunks toggle
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/monster/Slime.java b/src/main/java/net/minecraft/world/entity/monster/Slime.java
|
||||
index 64c4b88f0a64436c126cf32d6e289b3876af8dfb..85abd62434cbe3beb63f61262504372b971d9684 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/monster/Slime.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/monster/Slime.java
|
||||
@@ -318,7 +318,7 @@ public class Slime extends Mob implements Enemy {
|
||||
}
|
||||
|
||||
ChunkPos chunkcoordintpair = new ChunkPos(pos);
|
||||
- boolean flag = WorldgenRandom.seedSlimeChunk(chunkcoordintpair.x, chunkcoordintpair.z, ((WorldGenLevel) world).getSeed(), world.getMinecraftWorld().spigotConfig.slimeSeed).nextInt(10) == 0; // Spigot
|
||||
+ boolean flag = world.getMinecraftWorld().paperConfig().entities.spawning.allChunksAreSlimeChunks || WorldgenRandom.seedSlimeChunk(chunkcoordintpair.x, chunkcoordintpair.z, ((WorldGenLevel) world).getSeed(), world.getMinecraftWorld().spigotConfig.slimeSeed).nextInt(10) == 0; // Spigot // Paper
|
||||
|
||||
if (random.nextInt(10) == 0 && flag && pos.getY() < 40) {
|
||||
return checkMobSpawnRules(type, world, spawnReason, pos, random);
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java
|
||||
index a895c81ea6af0822c8371ae93cfe4b72d419439d..e4a533ace96829414844607a013831dba7a1e73e 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java
|
||||
@@ -177,7 +177,7 @@ public class CraftChunk implements Chunk {
|
||||
@Override
|
||||
public boolean isSlimeChunk() {
|
||||
// 987234911L is deterimined in EntitySlime when seeing if a slime can spawn in a chunk
|
||||
- return WorldgenRandom.seedSlimeChunk(this.getX(), this.getZ(), this.getWorld().getSeed(), worldServer.spigotConfig.slimeSeed).nextInt(10) == 0;
|
||||
+ return this.worldServer.paperConfig().entities.spawning.allChunksAreSlimeChunks || WorldgenRandom.seedSlimeChunk(this.getX(), this.getZ(), this.getWorld().getSeed(), worldServer.spigotConfig.slimeSeed).nextInt(10) == 0; // Paper
|
||||
}
|
||||
|
||||
@Override
|
18
patches/unapplied/server/0054-Expose-server-CommandMap.patch
Normal file
18
patches/unapplied/server/0054-Expose-server-CommandMap.patch
Normal file
|
@ -0,0 +1,18 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: kashike <kashike@vq.lc>
|
||||
Date: Thu, 3 Mar 2016 02:15:57 -0600
|
||||
Subject: [PATCH] Expose server CommandMap
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index 369657f5c54dae7b03b09aec1c672dc3f2cba090..5d2ac8720d38b9c8485a3c3da906b0124bb99a03 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -1992,6 +1992,7 @@ public final class CraftServer implements Server {
|
||||
return this.helpMap;
|
||||
}
|
||||
|
||||
+ @Override // Paper - add override
|
||||
public SimpleCommandMap getCommandMap() {
|
||||
return this.commandMap;
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: kashike <kashike@vq.lc>
|
||||
Date: Thu, 3 Mar 2016 02:18:39 -0600
|
||||
Subject: [PATCH] Be a bit more informative in maxHealth exception
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
||||
index 489153b3d22b37f01a027b0effc091d4715e7f7b..c2407224e8bc5e872e153de14090d60e66bb07bc 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
||||
@@ -102,7 +102,10 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
||||
public void setHealth(double health) {
|
||||
health = (float) health;
|
||||
if ((health < 0) || (health > this.getMaxHealth())) {
|
||||
- throw new IllegalArgumentException("Health must be between 0 and " + this.getMaxHealth() + "(" + health + ")");
|
||||
+ // Paper - Be more informative
|
||||
+ throw new IllegalArgumentException("Health must be between 0 and " + getMaxHealth() + ", but was " + health
|
||||
+ + ". (attribute base value: " + this.getHandle().getAttribute(Attributes.MAX_HEALTH).getBaseValue()
|
||||
+ + (this instanceof CraftPlayer ? ", player: " + this.getName() + ')' : ')'));
|
||||
}
|
||||
|
||||
// during world generation, we don't want to run logic for dropping items and xp
|
|
@ -0,0 +1,176 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Techcable <Techcable@outlook.com>
|
||||
Date: Thu, 3 Mar 2016 02:32:10 -0600
|
||||
Subject: [PATCH] Player Tab List and Title APIs
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/network/FriendlyByteBuf.java b/src/main/java/net/minecraft/network/FriendlyByteBuf.java
|
||||
index e5ef4acbc74f3ef50ed8e162d3b2a7ae881a4b7a..76914b08c17a62a117319d458a6693070fc46348 100644
|
||||
--- a/src/main/java/net/minecraft/network/FriendlyByteBuf.java
|
||||
+++ b/src/main/java/net/minecraft/network/FriendlyByteBuf.java
|
||||
@@ -501,6 +501,11 @@ public class FriendlyByteBuf extends ByteBuf {
|
||||
public FriendlyByteBuf writeComponent(final net.kyori.adventure.text.Component component) {
|
||||
return this.writeUtf(PaperAdventure.asJsonString(component, this.adventure$locale), 262144);
|
||||
}
|
||||
+
|
||||
+ @Deprecated
|
||||
+ public FriendlyByteBuf writeComponent(final net.md_5.bungee.api.chat.BaseComponent[] component) {
|
||||
+ return this.writeUtf(net.md_5.bungee.chat.ComponentSerializer.toString(component), 262144);
|
||||
+ }
|
||||
// Paper end
|
||||
|
||||
public FriendlyByteBuf writeComponent(Component text) {
|
||||
diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundSetSubtitleTextPacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundSetSubtitleTextPacket.java
|
||||
index c44a276d201fdfa5144d45d319d7761583c60639..f68a1a6dc6add9496e25cb52c318e086e356e2bb 100644
|
||||
--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundSetSubtitleTextPacket.java
|
||||
+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundSetSubtitleTextPacket.java
|
||||
@@ -7,6 +7,7 @@ import net.minecraft.network.protocol.Packet;
|
||||
public class ClientboundSetSubtitleTextPacket implements Packet<ClientGamePacketListener> {
|
||||
private final Component text;
|
||||
public net.kyori.adventure.text.Component adventure$text; // Paper
|
||||
+ public net.md_5.bungee.api.chat.BaseComponent[] components; // Paper
|
||||
|
||||
public ClientboundSetSubtitleTextPacket(Component subtitle) {
|
||||
this.text = subtitle;
|
||||
@@ -21,6 +22,8 @@ public class ClientboundSetSubtitleTextPacket implements Packet<ClientGamePacket
|
||||
// Paper start
|
||||
if (this.adventure$text != null) {
|
||||
buf.writeComponent(this.adventure$text);
|
||||
+ } else if (this.components != null) {
|
||||
+ buf.writeComponent(this.components);
|
||||
} else
|
||||
// Paper end
|
||||
buf.writeComponent(this.text);
|
||||
diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundSetTitleTextPacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundSetTitleTextPacket.java
|
||||
index bd808eb312ade7122973a47f4b96505829511da5..bf0f9cab7c66c089f35b851e799ba4a43420b437 100644
|
||||
--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundSetTitleTextPacket.java
|
||||
+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundSetTitleTextPacket.java
|
||||
@@ -7,6 +7,7 @@ import net.minecraft.network.protocol.Packet;
|
||||
public class ClientboundSetTitleTextPacket implements Packet<ClientGamePacketListener> {
|
||||
private final Component text;
|
||||
public net.kyori.adventure.text.Component adventure$text; // Paper
|
||||
+ public net.md_5.bungee.api.chat.BaseComponent[] components; // Paper
|
||||
|
||||
public ClientboundSetTitleTextPacket(Component title) {
|
||||
this.text = title;
|
||||
@@ -21,6 +22,8 @@ public class ClientboundSetTitleTextPacket implements Packet<ClientGamePacketLis
|
||||
// Paper start
|
||||
if (this.adventure$text != null) {
|
||||
buf.writeComponent(this.adventure$text);
|
||||
+ } else if (this.components != null) {
|
||||
+ buf.writeComponent(this.components);
|
||||
} else
|
||||
// Paper end
|
||||
buf.writeComponent(this.text);
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
index 59e0a9b6f07342120ee5ca00434905b26faf04ca..0a92f895922f5eacb87fc6cf4cd9e3783703cdf9 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
+import com.destroystokyo.paper.Title;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.io.BaseEncoding;
|
||||
@@ -350,6 +351,100 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
}
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ @Override
|
||||
+ public void setPlayerListHeaderFooter(BaseComponent[] header, BaseComponent[] footer) {
|
||||
+ if (header != null) {
|
||||
+ String headerJson = net.md_5.bungee.chat.ComponentSerializer.toString(header);
|
||||
+ playerListHeader = net.kyori.adventure.text.serializer.gson.GsonComponentSerializer.gson().deserialize(headerJson);
|
||||
+ } else {
|
||||
+ playerListHeader = null;
|
||||
+ }
|
||||
+
|
||||
+ if (footer != null) {
|
||||
+ String footerJson = net.md_5.bungee.chat.ComponentSerializer.toString(footer);
|
||||
+ playerListFooter = net.kyori.adventure.text.serializer.gson.GsonComponentSerializer.gson().deserialize(footerJson);
|
||||
+ } else {
|
||||
+ playerListFooter = null;
|
||||
+ }
|
||||
+
|
||||
+ updatePlayerListHeaderFooter();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setPlayerListHeaderFooter(BaseComponent header, BaseComponent footer) {
|
||||
+ this.setPlayerListHeaderFooter(header == null ? null : new BaseComponent[]{header},
|
||||
+ footer == null ? null : new BaseComponent[]{footer});
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ @Override
|
||||
+ public void setTitleTimes(int fadeInTicks, int stayTicks, int fadeOutTicks) {
|
||||
+ getHandle().connection.send(new ClientboundSetTitlesAnimationPacket(fadeInTicks, stayTicks, fadeOutTicks));
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setSubtitle(BaseComponent[] subtitle) {
|
||||
+ final ClientboundSetSubtitleTextPacket packet = new ClientboundSetSubtitleTextPacket((net.minecraft.network.chat.Component) null);
|
||||
+ packet.components = subtitle;
|
||||
+ getHandle().connection.send(packet);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setSubtitle(BaseComponent subtitle) {
|
||||
+ setSubtitle(new BaseComponent[]{subtitle});
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void showTitle(BaseComponent[] title) {
|
||||
+ final ClientboundSetTitleTextPacket packet = new ClientboundSetTitleTextPacket((net.minecraft.network.chat.Component) null);
|
||||
+ packet.components = title;
|
||||
+ getHandle().connection.send(packet);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void showTitle(BaseComponent title) {
|
||||
+ showTitle(new BaseComponent[]{title});
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void showTitle(BaseComponent[] title, BaseComponent[] subtitle, int fadeInTicks, int stayTicks, int fadeOutTicks) {
|
||||
+ setTitleTimes(fadeInTicks, stayTicks, fadeOutTicks);
|
||||
+ setSubtitle(subtitle);
|
||||
+ showTitle(title);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void showTitle(BaseComponent title, BaseComponent subtitle, int fadeInTicks, int stayTicks, int fadeOutTicks) {
|
||||
+ setTitleTimes(fadeInTicks, stayTicks, fadeOutTicks);
|
||||
+ setSubtitle(subtitle);
|
||||
+ showTitle(title);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void sendTitle(Title title) {
|
||||
+ Preconditions.checkNotNull(title, "Title is null");
|
||||
+ setTitleTimes(title.getFadeIn(), title.getStay(), title.getFadeOut());
|
||||
+ setSubtitle(title.getSubtitle() == null ? new BaseComponent[0] : title.getSubtitle());
|
||||
+ showTitle(title.getTitle());
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void updateTitle(Title title) {
|
||||
+ Preconditions.checkNotNull(title, "Title is null");
|
||||
+ setTitleTimes(title.getFadeIn(), title.getStay(), title.getFadeOut());
|
||||
+ if (title.getSubtitle() != null) {
|
||||
+ setSubtitle(title.getSubtitle());
|
||||
+ }
|
||||
+ showTitle(title.getTitle());
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void hideTitle() {
|
||||
+ getHandle().connection.send(new ClientboundClearTitlesPacket(false));
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
if(true) return io.papermc.paper.adventure.DisplayNames.getLegacy(this); // Paper
|
|
@ -0,0 +1,38 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Joseph Hirschfeld <joe@ibj.io>
|
||||
Date: Thu, 3 Mar 2016 02:46:17 -0600
|
||||
Subject: [PATCH] Add configurable portal search radius
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index 128dd4749590905fdfa85907d33adc4e4dbe6c33..575ce3bb03c7eef215e71d238a46aa1cc8510f89 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -3029,7 +3029,13 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
double d0 = DimensionType.getTeleportationScale(this.level.dimensionType(), destination.dimensionType());
|
||||
BlockPos blockposition = worldborder.clampToBounds(this.getX() * d0, this.getY(), this.getZ() * d0);
|
||||
// CraftBukkit start
|
||||
- CraftPortalEvent event = this.callPortalEvent(this, destination, new PositionImpl(blockposition.getX(), blockposition.getY(), blockposition.getZ()), PlayerTeleportEvent.TeleportCause.NETHER_PORTAL, flag2 ? 16 : 128, 16);
|
||||
+ // Paper start
|
||||
+ int portalSearchRadius = destination.paperConfig().environment.portalSearchRadius;
|
||||
+ if (level.paperConfig().environment.portalSearchVanillaDimensionScaling && flag2) { // == THE_NETHER
|
||||
+ portalSearchRadius = (int) (portalSearchRadius / destination.dimensionType().coordinateScale());
|
||||
+ }
|
||||
+ // Paper end
|
||||
+ CraftPortalEvent event = this.callPortalEvent(this, destination, new PositionImpl(blockposition.getX(), blockposition.getY(), blockposition.getZ()), PlayerTeleportEvent.TeleportCause.NETHER_PORTAL, portalSearchRadius, destination.paperConfig().environment.portalCreateRadius); // Paper start - configurable portal radius
|
||||
if (event == null) {
|
||||
return null;
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/level/portal/PortalForcer.java b/src/main/java/net/minecraft/world/level/portal/PortalForcer.java
|
||||
index ff57611088eabfb7e2db8fcf6344b1551b17b87b..d1c7eba29c64a6dbf55d3062ced9769eecb548ed 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/portal/PortalForcer.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/portal/PortalForcer.java
|
||||
@@ -43,7 +43,7 @@ public class PortalForcer {
|
||||
|
||||
public Optional<BlockUtil.FoundRectangle> findPortalAround(BlockPos pos, boolean destIsNether, WorldBorder worldBorder) {
|
||||
// CraftBukkit start
|
||||
- return this.findPortalAround(pos, worldBorder, destIsNether ? 16 : 128); // Search Radius
|
||||
+ return this.findPortalAround(pos, worldBorder, destIsNether ? level.paperConfig().environment.portalCreateRadius : level.paperConfig().environment.portalSearchRadius); // Search Radius // Paper - search Radius
|
||||
}
|
||||
|
||||
public Optional<BlockUtil.FoundRectangle> findPortalAround(BlockPos blockposition, WorldBorder worldborder, int i) {
|
88
patches/unapplied/server/0058-Add-velocity-warnings.patch
Normal file
88
patches/unapplied/server/0058-Add-velocity-warnings.patch
Normal file
|
@ -0,0 +1,88 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Joseph Hirschfeld <joe@ibj.io>
|
||||
Date: Thu, 3 Mar 2016 02:48:12 -0600
|
||||
Subject: [PATCH] Add velocity warnings
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index 5d2ac8720d38b9c8485a3c3da906b0124bb99a03..7f32015fbcbd94ed514a5749484527c2b1657036 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -294,6 +294,7 @@ public final class CraftServer implements Server {
|
||||
public boolean ignoreVanillaPermissions = false;
|
||||
private final List<CraftPlayer> playerView;
|
||||
public int reloadCount;
|
||||
+ public static Exception excessiveVelEx; // Paper - Velocity warnings
|
||||
|
||||
static {
|
||||
ConfigurationSerialization.registerClass(CraftOfflinePlayer.class);
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
||||
index 62c2780b165a520e85f17fdf5c0d1c29b7579ebc..91c0354f554edbf2fc68748a8fbf182cd8d93de5 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
|
||||
@@ -454,10 +454,40 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
||||
public void setVelocity(Vector velocity) {
|
||||
Preconditions.checkArgument(velocity != null, "velocity");
|
||||
velocity.checkFinite();
|
||||
+ // Paper start - Warn server owners when plugins try to set super high velocities
|
||||
+ if (!(this instanceof org.bukkit.entity.Projectile || this instanceof org.bukkit.entity.Minecart) && isUnsafeVelocity(velocity)) {
|
||||
+ CraftServer.excessiveVelEx = new Exception("Excessive velocity set detected: tried to set velocity of entity " + entity.getScoreboardName() + " id #" + getEntityId() + " to (" + velocity.getX() + "," + velocity.getY() + "," + velocity.getZ() + ").");
|
||||
+ }
|
||||
+ // Paper end
|
||||
this.entity.setDeltaMovement(CraftVector.toNMS(velocity));
|
||||
entity.hurtMarked = true;
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ /**
|
||||
+ * Checks if the given velocity is not necessarily safe in all situations.
|
||||
+ * This function returning true does not mean the velocity is dangerous or to be avoided, only that it may be
|
||||
+ * a detriment to performance on the server.
|
||||
+ *
|
||||
+ * It is not to be used as a hard rule of any sort.
|
||||
+ * Paper only uses it to warn server owners in watchdog crashes.
|
||||
+ *
|
||||
+ * @param vel incoming velocity to check
|
||||
+ * @return if the velocity has the potential to be a performance detriment
|
||||
+ */
|
||||
+ private static boolean isUnsafeVelocity(Vector vel) {
|
||||
+ final double x = vel.getX();
|
||||
+ final double y = vel.getY();
|
||||
+ final double z = vel.getZ();
|
||||
+
|
||||
+ if (x > 4 || x < -4 || y > 4 || y < -4 || z > 4 || z < -4) {
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ return false;
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
@Override
|
||||
public double getHeight() {
|
||||
return this.getHandle().getBbHeight();
|
||||
diff --git a/src/main/java/org/spigotmc/WatchdogThread.java b/src/main/java/org/spigotmc/WatchdogThread.java
|
||||
index 11d7ede26b46d0bf9cced65e8c3bcc41c8b66dbf..3ad14bf0697e682a2e777baa8faeb323d127fb13 100644
|
||||
--- a/src/main/java/org/spigotmc/WatchdogThread.java
|
||||
+++ b/src/main/java/org/spigotmc/WatchdogThread.java
|
||||
@@ -80,7 +80,19 @@ public final class WatchdogThread extends io.papermc.paper.util.TickThread // Pa
|
||||
log.log( Level.SEVERE, "During the run of the server, a physics stackoverflow was supressed" );
|
||||
log.log( Level.SEVERE, "near " + net.minecraft.world.level.Level.lastPhysicsProblem );
|
||||
}
|
||||
- //
|
||||
+ // Paper start - Warn in watchdog if an excessive velocity was ever set
|
||||
+ if ( org.bukkit.craftbukkit.CraftServer.excessiveVelEx != null )
|
||||
+ {
|
||||
+ log.log( Level.SEVERE, "------------------------------" );
|
||||
+ log.log( Level.SEVERE, "During the run of the server, a plugin set an excessive velocity on an entity" );
|
||||
+ log.log( Level.SEVERE, "This may be the cause of the issue, or it may be entirely unrelated" );
|
||||
+ log.log( Level.SEVERE, org.bukkit.craftbukkit.CraftServer.excessiveVelEx.getMessage());
|
||||
+ for ( StackTraceElement stack : org.bukkit.craftbukkit.CraftServer.excessiveVelEx.getStackTrace() )
|
||||
+ {
|
||||
+ log.log( Level.SEVERE, "\t\t" + stack );
|
||||
+ }
|
||||
+ }
|
||||
+ // Paper end
|
||||
log.log( Level.SEVERE, "------------------------------" );
|
||||
log.log( Level.SEVERE, "Server thread dump (Look for plugins here before reporting to Paper!):" ); // Paper
|
||||
io.papermc.paper.chunk.system.scheduling.ChunkTaskScheduler.dumpAllChunkLoadInfo(isLongTimeout); // Paper // Paper - rewrite chunk system
|
|
@ -0,0 +1,30 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Sudzzy <originmc@outlook.com>
|
||||
Date: Thu, 3 Mar 2016 02:50:31 -0600
|
||||
Subject: [PATCH] Configurable inter-world teleportation safety
|
||||
|
||||
People are able to abuse the way Bukkit handles teleportation across worlds since it provides a built in teleportation
|
||||
safety check.
|
||||
|
||||
To abuse the safety check, players are required to get into a location deemed unsafe by Bukkit e.g. be within a chest
|
||||
or door block. While they are in this block, they accept a teleport request from a player within a different world. Once
|
||||
the player teleports, Minecraft will recursively search upwards for a safe location, this could eventually land within a
|
||||
player's skybase.
|
||||
|
||||
Example setup to perform the glitch: http://puu.sh/ng3PC/cf072dcbdb.png
|
||||
The wanted destination was on top of the emerald block however the player ended on top of the diamond block.
|
||||
This only is the case if the player is teleporting between worlds.
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
index 0a92f895922f5eacb87fc6cf4cd9e3783703cdf9..8b97cf87bff848b60f506ae0cde14e369e4afca8 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
@@ -1155,7 +1155,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
if (fromWorld == toWorld) {
|
||||
entity.connection.teleport(to);
|
||||
} else {
|
||||
- server.getHandle().respawn(entity, toWorld, true, to, true);
|
||||
+ server.getHandle().respawn(entity, toWorld, true, to, !toWorld.paperConfig().environment.disableTeleportationSuffocationCheck); // Paper
|
||||
}
|
||||
return true;
|
||||
}
|
|
@ -0,0 +1,225 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Joseph Hirschfeld <joe@ibj.io>
|
||||
Date: Thu, 3 Mar 2016 03:15:41 -0600
|
||||
Subject: [PATCH] Add exception reporting event
|
||||
|
||||
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/ServerSchedulerReportingWrapper.java b/src/main/java/com/destroystokyo/paper/ServerSchedulerReportingWrapper.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..f699ce18ca044f813e194ef2786b7ea853ea86e7
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/com/destroystokyo/paper/ServerSchedulerReportingWrapper.java
|
||||
@@ -0,0 +1,38 @@
|
||||
+package com.destroystokyo.paper;
|
||||
+
|
||||
+import com.google.common.base.Preconditions;
|
||||
+import org.bukkit.craftbukkit.scheduler.CraftTask;
|
||||
+import com.destroystokyo.paper.event.server.ServerExceptionEvent;
|
||||
+import com.destroystokyo.paper.exception.ServerSchedulerException;
|
||||
+
|
||||
+/**
|
||||
+ * Reporting wrapper to catch exceptions not natively
|
||||
+ */
|
||||
+public class ServerSchedulerReportingWrapper implements Runnable {
|
||||
+
|
||||
+ private final CraftTask internalTask;
|
||||
+
|
||||
+ public ServerSchedulerReportingWrapper(CraftTask internalTask) {
|
||||
+ this.internalTask = Preconditions.checkNotNull(internalTask, "internalTask");
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void run() {
|
||||
+ try {
|
||||
+ internalTask.run();
|
||||
+ } catch (RuntimeException e) {
|
||||
+ internalTask.getOwner().getServer().getPluginManager().callEvent(
|
||||
+ new ServerExceptionEvent(new ServerSchedulerException(e, internalTask))
|
||||
+ );
|
||||
+ throw e;
|
||||
+ } catch (Throwable t) {
|
||||
+ internalTask.getOwner().getServer().getPluginManager().callEvent(
|
||||
+ new ServerExceptionEvent(new ServerSchedulerException(t, internalTask))
|
||||
+ ); //Do not rethrow, since it is not permitted with Runnable#run
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public CraftTask getInternalTask() {
|
||||
+ return internalTask;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/server/players/OldUsersConverter.java b/src/main/java/net/minecraft/server/players/OldUsersConverter.java
|
||||
index 439ff01be1521c283d60cacb110fcb4993933057..da98f074ccd5a40c635824112c97fd174c393cb1 100644
|
||||
--- a/src/main/java/net/minecraft/server/players/OldUsersConverter.java
|
||||
+++ b/src/main/java/net/minecraft/server/players/OldUsersConverter.java
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.minecraft.server.players;
|
||||
|
||||
+import com.destroystokyo.paper.exception.ServerInternalException;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.io.Files;
|
||||
@@ -363,6 +364,7 @@ public class OldUsersConverter {
|
||||
root = NbtIo.readCompressed(new java.io.FileInputStream(file5));
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
+ ServerInternalException.reportInternalException(exception); // Paper
|
||||
}
|
||||
|
||||
if (root != null) {
|
||||
@@ -376,6 +378,7 @@ public class OldUsersConverter {
|
||||
NbtIo.writeCompressed(root, new java.io.FileOutputStream(file2));
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
+ ServerInternalException.reportInternalException(exception); // Paper
|
||||
}
|
||||
}
|
||||
// CraftBukkit end
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/village/VillageSiege.java b/src/main/java/net/minecraft/world/entity/ai/village/VillageSiege.java
|
||||
index c6fb4c33d7ea52b88d8fc0d90748cbab7387c565..fed09b886f4fa0006d160e5f2abb00dfee45434d 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/village/VillageSiege.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/village/VillageSiege.java
|
||||
@@ -118,6 +118,7 @@ public class VillageSiege implements CustomSpawner {
|
||||
entityzombie.finalizeSpawn(world, world.getCurrentDifficultyAt(entityzombie.blockPosition()), MobSpawnType.EVENT, (SpawnGroupData) null, (CompoundTag) null);
|
||||
} catch (Exception exception) {
|
||||
VillageSiege.LOGGER.warn("Failed to create zombie for village siege at {}", vec3d, exception);
|
||||
+ com.destroystokyo.paper.exception.ServerInternalException.reportInternalException(exception); // Paper
|
||||
return;
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
||||
index 6457384bded7b65f22547704eba74875a6b84ebb..383bf9fe7263bc6153a2e1cbc21657215a3bdb79 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/Level.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
||||
@@ -1,5 +1,10 @@
|
||||
package net.minecraft.world.level;
|
||||
|
||||
+import co.aikar.timings.Timing;
|
||||
+import co.aikar.timings.Timings;
|
||||
+import com.destroystokyo.paper.event.server.ServerExceptionEvent;
|
||||
+import com.destroystokyo.paper.exception.ServerInternalException;
|
||||
+import com.google.common.base.MoreObjects;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.mojang.serialization.Codec;
|
||||
import java.io.IOException;
|
||||
@@ -731,6 +736,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
||||
// Paper start - Prevent tile entity and entity crashes
|
||||
final String msg = String.format("Entity threw exception at %s:%s,%s,%s", entity.level.getWorld().getName(), entity.getX(), entity.getY(), entity.getZ());
|
||||
MinecraftServer.LOGGER.error(msg, throwable);
|
||||
+ getCraftServer().getPluginManager().callEvent(new ServerExceptionEvent(new ServerInternalException(msg, throwable)));
|
||||
entity.discard();
|
||||
// Paper end
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/level/NaturalSpawner.java b/src/main/java/net/minecraft/world/level/NaturalSpawner.java
|
||||
index 0e4f6893a2fce69782c4246c52e03926fe2df26f..5c58031279c0b74d2061c802e60b7bed50f27156 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/NaturalSpawner.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/NaturalSpawner.java
|
||||
@@ -291,6 +291,7 @@ public final class NaturalSpawner {
|
||||
NaturalSpawner.LOGGER.warn("Can't spawn entity of type: {}", BuiltInRegistries.ENTITY_TYPE.getKey(type));
|
||||
} catch (Exception exception) {
|
||||
NaturalSpawner.LOGGER.warn("Failed to create mob", exception);
|
||||
+ com.destroystokyo.paper.exception.ServerInternalException.reportInternalException(exception); // Paper
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -404,6 +405,7 @@ public final class NaturalSpawner {
|
||||
entity = biomesettingsmobs_c.type.create(world.getLevel());
|
||||
} catch (Exception exception) {
|
||||
NaturalSpawner.LOGGER.warn("Failed to create mob", exception);
|
||||
+ com.destroystokyo.paper.exception.ServerInternalException.reportInternalException(exception); // Paper
|
||||
continue;
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
|
||||
index f21ae1ae8af79c1c0c6f2feaa933638add0aa065..ba24e32f96797ed8c8bd82391d1903f6ad2a9813 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
|
||||
@@ -1,6 +1,7 @@
|
||||
package net.minecraft.world.level.chunk;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
+import com.destroystokyo.paper.exception.ServerInternalException;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.UnmodifiableIterator;
|
||||
import com.mojang.logging.LogUtils;
|
||||
@@ -605,10 +606,16 @@ public class LevelChunk extends ChunkAccess {
|
||||
|
||||
// CraftBukkit start
|
||||
} else {
|
||||
- System.out.println("Attempted to place a tile entity (" + blockEntity + ") at " + blockEntity.getBlockPos().getX() + "," + blockEntity.getBlockPos().getY() + "," + blockEntity.getBlockPos().getZ()
|
||||
- + " (" + this.getBlockState(blockposition) + ") where there was no entity tile!");
|
||||
- System.out.println("Chunk coordinates: " + (this.chunkPos.x * 16) + "," + (this.chunkPos.z * 16));
|
||||
- new Exception().printStackTrace();
|
||||
+ // Paper start
|
||||
+ ServerInternalException e = new ServerInternalException(
|
||||
+ "Attempted to place a tile entity (" + blockEntity + ") at " + blockEntity.getBlockPos().getX() + ","
|
||||
+ + blockEntity.getBlockPos().getY() + "," + blockEntity.getBlockPos().getZ()
|
||||
+ + " (" + getBlockState(blockposition) + ") where there was no entity tile!\n" +
|
||||
+ "Chunk coordinates: " + (this.chunkPos.x * 16) + "," + (this.chunkPos.z * 16) +
|
||||
+ "\nWorld: " + level.getLevel().dimension().location());
|
||||
+ e.printStackTrace();
|
||||
+ ServerInternalException.reportInternalException(e);
|
||||
+ // Paper end
|
||||
// CraftBukkit end
|
||||
}
|
||||
}
|
||||
@@ -1187,6 +1194,7 @@ public class LevelChunk extends ChunkAccess {
|
||||
// Paper start - Prevent tile entity and entity crashes
|
||||
final String msg = String.format("BlockEntity threw exception at %s:%s,%s,%s", LevelChunk.this.getLevel().getWorld().getName(), this.getPos().getX(), this.getPos().getY(), this.getPos().getZ());
|
||||
net.minecraft.server.MinecraftServer.LOGGER.error(msg, throwable);
|
||||
+ net.minecraft.world.level.chunk.LevelChunk.this.level.getCraftServer().getPluginManager().callEvent(new com.destroystokyo.paper.event.server.ServerExceptionEvent(new ServerInternalException(msg, throwable)));
|
||||
LevelChunk.this.removeBlockEntity(this.getPos());
|
||||
// Paper end
|
||||
// Spigot start
|
||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java
|
||||
index e68205fe7169c7c5b7c6fdada2ee97d86107ca97..aa8972fd1a1fade05d60ab69efb8ff24f344508a 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java
|
||||
@@ -275,6 +275,7 @@ public class RegionFile implements AutoCloseable {
|
||||
return true;
|
||||
}
|
||||
} catch (IOException ioexception) {
|
||||
+ com.destroystokyo.paper.exception.ServerInternalException.reportInternalException(ioexception); // Paper
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -356,6 +357,7 @@ public class RegionFile implements AutoCloseable {
|
||||
((java.nio.Buffer) buf).position(5); // CraftBukkit - decompile error
|
||||
filechannel.write(buf);
|
||||
} catch (Throwable throwable) {
|
||||
+ com.destroystokyo.paper.exception.ServerInternalException.reportInternalException(throwable); // Paper
|
||||
if (filechannel != null) {
|
||||
try {
|
||||
filechannel.close();
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
|
||||
index 07c4d9cd5081378e1b903518f7174fca959cd9e3..dfc2789009fcaa08baa8054bdac915590b8701d6 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
|
||||
@@ -17,6 +17,9 @@ import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.IntUnaryOperator;
|
||||
import java.util.logging.Level;
|
||||
+import com.destroystokyo.paper.ServerSchedulerReportingWrapper;
|
||||
+import com.destroystokyo.paper.event.server.ServerExceptionEvent;
|
||||
+import com.destroystokyo.paper.exception.ServerSchedulerException;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.plugin.IllegalPluginAccessException;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
@@ -434,6 +437,8 @@ public class CraftScheduler implements BukkitScheduler {
|
||||
msg,
|
||||
throwable);
|
||||
}
|
||||
+ org.bukkit.Bukkit.getServer().getPluginManager().callEvent(
|
||||
+ new ServerExceptionEvent(new ServerSchedulerException(msg, throwable, task)));
|
||||
// Paper end
|
||||
} finally {
|
||||
this.currentTask = null;
|
||||
@@ -441,7 +446,7 @@ public class CraftScheduler implements BukkitScheduler {
|
||||
this.parsePending();
|
||||
} else {
|
||||
this.debugTail = this.debugTail.setNext(new CraftAsyncDebugger(currentTick + CraftScheduler.RECENT_TICKS, task.getOwner(), task.getTaskClass()));
|
||||
- this.executor.execute(task);
|
||||
+ this.executor.execute(new ServerSchedulerReportingWrapper(task)); // Paper
|
||||
// We don't need to parse pending
|
||||
// (async tasks must live with race-conditions if they attempt to cancel between these few lines of code)
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: kashike <kashike@vq.lc>
|
||||
Date: Tue, 8 Mar 2016 18:28:43 -0800
|
||||
Subject: [PATCH] Don't nest if we don't need to when cerealising text
|
||||
components
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundSystemChatPacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundSystemChatPacket.java
|
||||
index 55e21c7b13826f60e3c656f76e1507e0242e0af3..1387e3597c43fd652f2fc82ca6fc2e83039604e2 100644
|
||||
--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundSystemChatPacket.java
|
||||
+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundSystemChatPacket.java
|
||||
@@ -14,7 +14,7 @@ public record ClientboundSystemChatPacket(@javax.annotation.Nullable net.kyori.a
|
||||
}
|
||||
|
||||
public ClientboundSystemChatPacket(net.md_5.bungee.api.chat.BaseComponent[] content, boolean overlay) {
|
||||
- this(null, net.md_5.bungee.chat.ComponentSerializer.toString(content), overlay); // Paper - Adventure
|
||||
+ this(null, improveBungeeComponentSerialization(content), overlay); // Paper - Adventure
|
||||
}
|
||||
// Spigot end
|
||||
// Paper start
|
||||
@@ -25,6 +25,14 @@ public record ClientboundSystemChatPacket(@javax.annotation.Nullable net.kyori.a
|
||||
public ClientboundSystemChatPacket(net.kyori.adventure.text.Component content, boolean overlay) {
|
||||
this(content, null, overlay);
|
||||
}
|
||||
+
|
||||
+ private static String improveBungeeComponentSerialization(net.md_5.bungee.api.chat.BaseComponent[] content) {
|
||||
+ if (content.length == 1) {
|
||||
+ return net.md_5.bungee.chat.ComponentSerializer.toString(content[0]);
|
||||
+ } else {
|
||||
+ return net.md_5.bungee.chat.ComponentSerializer.toString(content);
|
||||
+ }
|
||||
+ }
|
||||
// Paper end
|
||||
|
||||
public ClientboundSystemChatPacket(FriendlyByteBuf buf) {
|
|
@ -0,0 +1,36 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Tue, 8 Mar 2016 23:25:45 -0500
|
||||
Subject: [PATCH] Disable Scoreboards for non players by default
|
||||
|
||||
Entities collision is checking for scoreboards setting.
|
||||
This is very heavy to do map lookups for every collision to check
|
||||
this setting.
|
||||
|
||||
So avoid looking up scoreboards and short circuit to the "not on a team"
|
||||
logic which is most likely to be true.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index 575ce3bb03c7eef215e71d238a46aa1cc8510f89..98067f625b49d93fdd91af5114790848a2228ac0 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -2660,6 +2660,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
|
||||
@Nullable
|
||||
public Team getTeam() {
|
||||
+ if (!this.level.paperConfig().scoreboards.allowNonPlayerEntitiesOnScoreboards && !(this instanceof Player)) { return null; } // Paper
|
||||
return this.level.getScoreboard().getPlayersTeam(this.getScoreboardName());
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
index 7e4f95e04a880ecb459228c90be462cbbec14620..eec1467eaaadaa66febc06e51372c5f602216fb5 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -822,6 +822,7 @@ public abstract class LivingEntity extends Entity {
|
||||
if (nbt.contains("Team", 8)) {
|
||||
String s = nbt.getString("Team");
|
||||
PlayerTeam scoreboardteam = this.level.getScoreboard().getPlayerTeam(s);
|
||||
+ if (!level.paperConfig().scoreboards.allowNonPlayerEntitiesOnScoreboards && !(this instanceof net.minecraft.world.entity.player.Player)) { scoreboardteam = null; } // Paper
|
||||
boolean flag = scoreboardteam != null && this.level.getScoreboard().addPlayerToTeam(this.getStringUUID(), scoreboardteam);
|
||||
|
||||
if (!flag) {
|
|
@ -0,0 +1,46 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: mrapple <tony@oc.tc>
|
||||
Date: Sun, 25 Nov 2012 13:43:39 -0600
|
||||
Subject: [PATCH] Add methods for working with arrows stuck in living entities
|
||||
|
||||
Upstream added methods for this, original methods are now
|
||||
deprecated
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
||||
index c2407224e8bc5e872e153de14090d60e66bb07bc..3fae28c52f2aac63ac6a4e8eb6af2d7226e6bec6 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java
|
||||
@@ -266,9 +266,15 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
||||
}
|
||||
|
||||
@Override
|
||||
- public void setArrowsInBody(int count) {
|
||||
+ public void setArrowsInBody(final int count, final boolean fireEvent) { // Paper
|
||||
Preconditions.checkArgument(count >= 0, "New arrow amount must be >= 0");
|
||||
+ if (!fireEvent) { // Paper
|
||||
this.getHandle().getEntityData().set(net.minecraft.world.entity.LivingEntity.DATA_ARROW_COUNT_ID, count);
|
||||
+ // Paper start
|
||||
+ } else {
|
||||
+ this.getHandle().setArrowCount(count);
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -764,4 +770,16 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
||||
this.getHandle().persistentInvisibility = invisible;
|
||||
this.getHandle().setSharedFlag(5, invisible);
|
||||
}
|
||||
+
|
||||
+ // Paper start
|
||||
+ @Override
|
||||
+ public int getArrowsStuck() {
|
||||
+ return this.getHandle().getArrowCount();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setArrowsStuck(final int arrows) {
|
||||
+ this.getHandle().setArrowCount(arrows);
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
51
patches/unapplied/server/0064-Chunk-Save-Reattempt.patch
Normal file
51
patches/unapplied/server/0064-Chunk-Save-Reattempt.patch
Normal file
|
@ -0,0 +1,51 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Mon, 4 Mar 2013 23:46:10 -0500
|
||||
Subject: [PATCH] Chunk Save Reattempt
|
||||
|
||||
We commonly have "Stream Closed" errors on chunk saving, so this code should re-try to save the chunk in the event of failure and hopefully prevent rollbacks.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java
|
||||
index aa8972fd1a1fade05d60ab69efb8ff24f344508a..ddcc212ba83d9365adb842b3d3ced64e3d7dd155 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java
|
||||
@@ -275,7 +275,7 @@ public class RegionFile implements AutoCloseable {
|
||||
return true;
|
||||
}
|
||||
} catch (IOException ioexception) {
|
||||
- com.destroystokyo.paper.exception.ServerInternalException.reportInternalException(ioexception); // Paper
|
||||
+ com.destroystokyo.paper.util.SneakyThrow.sneaky(ioexception); // Paper - we want the upper try/catch to retry this
|
||||
return false;
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
|
||||
index 18ef7025f7f4dc2a4aff85ca65ff5a2d35a1ef06..64e957650dafc9fc30fa997e7f7d3fd47cf60089 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
|
||||
@@ -167,6 +167,7 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
}
|
||||
// Paper end - rewrite chunk system
|
||||
try { // Paper
|
||||
+ int attempts = 0; Exception laste = null; while (attempts++ < 5) { try { // Paper
|
||||
|
||||
if (nbt == null) {
|
||||
regionfile.clear(pos);
|
||||
@@ -191,7 +192,18 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
dataoutputstream.close();
|
||||
}
|
||||
}
|
||||
+ // Paper start
|
||||
+ return;
|
||||
+ } catch (Exception ex) {
|
||||
+ laste = ex;
|
||||
+ }
|
||||
+ }
|
||||
|
||||
+ if (laste != null) {
|
||||
+ com.destroystokyo.paper.exception.ServerInternalException.reportInternalException(laste);
|
||||
+ net.minecraft.server.MinecraftServer.LOGGER.error("Failed to save chunk " + pos, laste);
|
||||
+ }
|
||||
+ // Paper end
|
||||
} finally { // Paper start
|
||||
regionfile.fileLock.unlock();
|
||||
} // Paper end
|
|
@ -0,0 +1,93 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jedediah Smith <jedediah@silencegreys.com>
|
||||
Date: Sat, 4 Apr 2015 23:17:52 -0400
|
||||
Subject: [PATCH] Complete resource pack API
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index 301d90618f51b90a4a7b0158deef7373fba9cca8..eaf0e468d7ebf54290ae9e2df9f4a2c252142f65 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -1764,8 +1764,11 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
ServerGamePacketListenerImpl.LOGGER.info("Disconnecting {} due to resource pack rejection", this.player.getName());
|
||||
this.disconnect(Component.translatable("multiplayer.requiredTexturePrompt.disconnect"));
|
||||
}
|
||||
- this.cserver.getPluginManager().callEvent(new PlayerResourcePackStatusEvent(this.getCraftPlayer(), PlayerResourcePackStatusEvent.Status.values()[packet.action.ordinal()])); // CraftBukkit
|
||||
-
|
||||
+ // Paper start
|
||||
+ PlayerResourcePackStatusEvent.Status packStatus = PlayerResourcePackStatusEvent.Status.values()[packet.action.ordinal()];
|
||||
+ player.getBukkitEntity().setResourcePackStatus(packStatus);
|
||||
+ this.cserver.getPluginManager().callEvent(new PlayerResourcePackStatusEvent(this.getCraftPlayer(), packStatus)); // CraftBukkit
|
||||
+ // Paper end
|
||||
}
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
index 8b97cf87bff848b60f506ae0cde14e369e4afca8..673e4dc85e5c3ae43170564108f6b74187720d07 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
@@ -152,6 +152,7 @@ import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.messaging.StandardMessenger;
|
||||
import org.bukkit.profile.PlayerProfile;
|
||||
import org.bukkit.scoreboard.Scoreboard;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import net.md_5.bungee.api.chat.BaseComponent; // Spigot
|
||||
|
||||
@@ -170,6 +171,10 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
private double healthScale = 20;
|
||||
private CraftWorldBorder clientWorldBorder = null;
|
||||
private BorderChangeListener clientWorldBorderListener = this.createWorldBorderListener();
|
||||
+ // Paper start
|
||||
+ private org.bukkit.event.player.PlayerResourcePackStatusEvent.Status resourcePackStatus;
|
||||
+ private String resourcePackHash;
|
||||
+ // Paper end
|
||||
|
||||
public CraftPlayer(CraftServer server, ServerPlayer entity) {
|
||||
super(server, entity);
|
||||
@@ -2236,6 +2241,45 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
public boolean getAffectsSpawning() {
|
||||
return this.getHandle().affectsSpawning;
|
||||
}
|
||||
+
|
||||
+ @Override
|
||||
+ public void setResourcePack(@NotNull String url, @NotNull String hash) {
|
||||
+ this.setResourcePack(url, hash, false, null);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setResourcePack(@NotNull String url, @NotNull String hash, boolean required) {
|
||||
+ this.setResourcePack(url, hash, required, null);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setResourcePack(@NotNull String url, @NotNull String hash, boolean required, net.kyori.adventure.text.Component resourcePackPrompt) {
|
||||
+ Validate.notNull(url, "Resource pack URL cannot be null");
|
||||
+ Validate.notNull(hash, "Hash cannot be null");
|
||||
+ net.minecraft.network.chat.Component promptComponent = resourcePackPrompt != null ?
|
||||
+ io.papermc.paper.adventure.PaperAdventure.asVanilla(resourcePackPrompt) :
|
||||
+ null;
|
||||
+ this.getHandle().sendTexturePack(url, hash, required, promptComponent);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public org.bukkit.event.player.PlayerResourcePackStatusEvent.Status getResourcePackStatus() {
|
||||
+ return this.resourcePackStatus;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getResourcePackHash() {
|
||||
+ return this.resourcePackHash;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean hasResourcePack() {
|
||||
+ return this.resourcePackStatus == org.bukkit.event.player.PlayerResourcePackStatusEvent.Status.SUCCESSFULLY_LOADED;
|
||||
+ }
|
||||
+
|
||||
+ public void setResourcePackStatus(org.bukkit.event.player.PlayerResourcePackStatusEvent.Status status) {
|
||||
+ this.resourcePackStatus = status;
|
||||
+ }
|
||||
// Paper end
|
||||
|
||||
@Override
|
|
@ -0,0 +1,38 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Fri, 18 Mar 2016 13:17:38 -0400
|
||||
Subject: [PATCH] Default loading permissions.yml before plugins
|
||||
|
||||
Under previous behavior, plugins were not able to check if a player had a permission
|
||||
if it was defined in permissions.yml. there is no clean way for a plugin to fix that either.
|
||||
|
||||
This will change the order so that by default, permissions.yml loads BEFORE plugins instead of after.
|
||||
|
||||
This gives plugins expected permission checks.
|
||||
|
||||
It also helps improve the expected logic, as servers should set the initial defaults, and then let plugins
|
||||
modify that. Under the previous logic, plugins were unable (cleanly) override permissions.yml.
|
||||
|
||||
A config option has been added for those who depend on the previous behavior, but I don't expect that.
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index 7f32015fbcbd94ed514a5749484527c2b1657036..6c7b1fe353a4d9bd9e307e7984f9348dd5914ff1 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -454,6 +454,7 @@ public final class CraftServer implements Server {
|
||||
if (type == PluginLoadOrder.STARTUP) {
|
||||
this.helpMap.clear();
|
||||
this.helpMap.initializeGeneralTopics();
|
||||
+ if (io.papermc.paper.configuration.GlobalConfiguration.get().misc.loadPermissionsYmlBeforePlugins) loadCustomPermissions(); // Paper
|
||||
}
|
||||
|
||||
Plugin[] plugins = this.pluginManager.getPlugins();
|
||||
@@ -473,7 +474,7 @@ public final class CraftServer implements Server {
|
||||
this.commandMap.registerServerAliases();
|
||||
DefaultPermissions.registerCorePermissions();
|
||||
CraftDefaultPermissions.registerCorePermissions();
|
||||
- this.loadCustomPermissions();
|
||||
+ if (!io.papermc.paper.configuration.GlobalConfiguration.get().misc.loadPermissionsYmlBeforePlugins) this.loadCustomPermissions(); // Paper
|
||||
this.helpMap.initializeCommands();
|
||||
this.syncCommands();
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: William <admin@domnian.com>
|
||||
Date: Fri, 18 Mar 2016 03:30:17 -0400
|
||||
Subject: [PATCH] Allow Reloading of Custom Permissions
|
||||
|
||||
https://github.com/PaperMC/Paper/issues/49
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index 6c7b1fe353a4d9bd9e307e7984f9348dd5914ff1..318b3e22cad28ef3a49ff005808c5e3525ccbcf4 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -2546,5 +2546,23 @@ public final class CraftServer implements Server {
|
||||
}
|
||||
return this.adventure$audiences;
|
||||
}
|
||||
+
|
||||
+ @Override
|
||||
+ public void reloadPermissions() {
|
||||
+ pluginManager.clearPermissions();
|
||||
+ if (io.papermc.paper.configuration.GlobalConfiguration.get().misc.loadPermissionsYmlBeforePlugins) loadCustomPermissions();
|
||||
+ for (Plugin plugin : pluginManager.getPlugins()) {
|
||||
+ for (Permission perm : plugin.getDescription().getPermissions()) {
|
||||
+ try {
|
||||
+ pluginManager.addPermission(perm);
|
||||
+ } catch (IllegalArgumentException ex) {
|
||||
+ getLogger().log(Level.WARNING, "Plugin " + plugin.getDescription().getFullName() + " tried to register permission '" + perm.getName() + "' but it's already registered", ex);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ if (!io.papermc.paper.configuration.GlobalConfiguration.get().misc.loadPermissionsYmlBeforePlugins) loadCustomPermissions();
|
||||
+ DefaultPermissions.registerCorePermissions();
|
||||
+ CraftDefaultPermissions.registerCorePermissions();
|
||||
+ }
|
||||
// Paper end
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Fri, 18 Mar 2016 13:50:14 -0400
|
||||
Subject: [PATCH] Remove Metadata on reload
|
||||
|
||||
Metadata is not meant to persist reload as things break badly with non primitive types
|
||||
This will remove metadata on reload so it does not crash everything if a plugin uses it.
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index 318b3e22cad28ef3a49ff005808c5e3525ccbcf4..3a046d3eb6bca6f45f8018a3844c58ac8cba43ac 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -944,8 +944,16 @@ public final class CraftServer implements Server {
|
||||
world.spigotConfig.init(); // Spigot
|
||||
}
|
||||
|
||||
+ Plugin[] pluginClone = pluginManager.getPlugins().clone(); // Paper
|
||||
this.pluginManager.clearPlugins();
|
||||
this.commandMap.clearCommands();
|
||||
+ // Paper start
|
||||
+ for (Plugin plugin : pluginClone) {
|
||||
+ entityMetadata.removeAll(plugin);
|
||||
+ worldMetadata.removeAll(plugin);
|
||||
+ playerMetadata.removeAll(plugin);
|
||||
+ }
|
||||
+ // Paper end
|
||||
this.reloadData();
|
||||
org.spigotmc.SpigotConfig.registerCommands(); // Spigot
|
||||
io.papermc.paper.command.PaperCommands.registerCommands(this.console); // Paper
|
|
@ -0,0 +1,321 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Thu, 28 May 2015 23:00:19 -0400
|
||||
Subject: [PATCH] Handle Item Meta Inconsistencies
|
||||
|
||||
First, Enchantment order would blow away seeing 2 items as the same,
|
||||
however the Client forces enchantment list in a certain order, as well
|
||||
as does the /enchant command. Anvils can insert it into forced order,
|
||||
causing 2 same items to be considered different.
|
||||
|
||||
This change makes unhandled NBT Tags and Enchantments use a sorted tree map,
|
||||
so they will always be in a consistent order.
|
||||
|
||||
Additionally, the old enchantment API was never updated when ItemMeta
|
||||
was added, resulting in 2 different ways to modify an items enchantments.
|
||||
|
||||
For consistency, the old API methods now forward to use the
|
||||
ItemMeta API equivalents, and should deprecate the old API's.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java
|
||||
index cf810a1d645dd63595702a5f07456cd48393ee79..87031aa69148118d9f5bf16cb8a55cf72f9d0a1d 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/ItemStack.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/ItemStack.java
|
||||
@@ -155,6 +155,23 @@ public final class ItemStack {
|
||||
return this.getItem().getTooltipImage(this);
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ private static final java.util.Comparator<? super CompoundTag> enchantSorter = java.util.Comparator.comparing(o -> o.getString("id"));
|
||||
+ private void processEnchantOrder(@Nullable CompoundTag tag) {
|
||||
+ if (tag == null || !tag.contains("Enchantments", 9)) {
|
||||
+ return;
|
||||
+ }
|
||||
+ ListTag list = tag.getList("Enchantments", 10);
|
||||
+ if (list.size() < 2) {
|
||||
+ return;
|
||||
+ }
|
||||
+ try {
|
||||
+ //noinspection unchecked
|
||||
+ list.sort((java.util.Comparator<? super net.minecraft.nbt.Tag>) enchantSorter); // Paper
|
||||
+ } catch (Exception ignored) {}
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
public ItemStack(ItemLike item) {
|
||||
this(item, 1);
|
||||
}
|
||||
@@ -206,6 +223,7 @@ public final class ItemStack {
|
||||
// CraftBukkit start - make defensive copy as this data may be coming from the save thread
|
||||
this.tag = nbttagcompound.getCompound("tag").copy();
|
||||
// CraftBukkit end
|
||||
+ this.processEnchantOrder(this.tag); // Paper
|
||||
this.getItem().verifyTagAfterLoad(this.tag);
|
||||
}
|
||||
|
||||
@@ -780,6 +798,7 @@ public final class ItemStack {
|
||||
|
||||
public void setTag(@Nullable CompoundTag nbt) {
|
||||
this.tag = nbt;
|
||||
+ this.processEnchantOrder(this.tag); // Paper
|
||||
if (this.getItem().canBeDepleted()) {
|
||||
this.setDamageValue(this.getDamageValue());
|
||||
}
|
||||
@@ -1073,6 +1092,7 @@ public final class ItemStack {
|
||||
ListTag nbttaglist = this.tag.getList("Enchantments", 10);
|
||||
|
||||
nbttaglist.add(EnchantmentHelper.storeEnchantment(EnchantmentHelper.getEnchantmentId(enchantment), (byte) level));
|
||||
+ processEnchantOrder(this.tag); // Paper
|
||||
}
|
||||
|
||||
public boolean isEnchanted() {
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
|
||||
index 781a1e5e4220d2198467c0fd3956f5e0387a7aff..3c3f5a4b7109ec8b47b550f9e766556f8d1546ec 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
|
||||
@@ -6,7 +6,6 @@ import java.util.Map;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.world.item.Item;
|
||||
-import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
@@ -178,28 +177,11 @@ public final class CraftItemStack extends ItemStack {
|
||||
public void addUnsafeEnchantment(Enchantment ench, int level) {
|
||||
Validate.notNull(ench, "Cannot add null enchantment");
|
||||
|
||||
- if (!CraftItemStack.makeTag(this.handle)) {
|
||||
- return;
|
||||
- }
|
||||
- ListTag list = CraftItemStack.getEnchantmentList(this.handle);
|
||||
- if (list == null) {
|
||||
- list = new ListTag();
|
||||
- this.handle.getTag().put(ENCHANTMENTS.NBT, list);
|
||||
- }
|
||||
- int size = list.size();
|
||||
-
|
||||
- for (int i = 0; i < size; i++) {
|
||||
- CompoundTag tag = (CompoundTag) list.get(i);
|
||||
- String id = tag.getString(ENCHANTMENTS_ID.NBT);
|
||||
- if (ench.getKey().equals(NamespacedKey.fromString(id))) {
|
||||
- tag.putShort(ENCHANTMENTS_LVL.NBT, (short) level);
|
||||
- return;
|
||||
- }
|
||||
- }
|
||||
- CompoundTag tag = new CompoundTag();
|
||||
- tag.putString(ENCHANTMENTS_ID.NBT, ench.getKey().toString());
|
||||
- tag.putShort(ENCHANTMENTS_LVL.NBT, (short) level);
|
||||
- list.add(tag);
|
||||
+ // Paper start - Replace whole method
|
||||
+ final ItemMeta itemMeta = this.getItemMeta();
|
||||
+ itemMeta.addEnchant(ench, level, true);
|
||||
+ this.setItemMeta(itemMeta);
|
||||
+ // Paper end
|
||||
}
|
||||
|
||||
static boolean makeTag(net.minecraft.world.item.ItemStack item) {
|
||||
@@ -225,57 +207,29 @@ public final class CraftItemStack extends ItemStack {
|
||||
if (this.handle == null) {
|
||||
return 0;
|
||||
}
|
||||
- return EnchantmentHelper.getItemEnchantmentLevel(CraftEnchantment.getRaw(ench), handle);
|
||||
+ return net.minecraft.world.item.enchantment.EnchantmentHelper.getItemEnchantmentLevel(CraftEnchantment.getRaw(ench), handle); // Paper
|
||||
}
|
||||
|
||||
@Override
|
||||
public int removeEnchantment(Enchantment ench) {
|
||||
Validate.notNull(ench, "Cannot remove null enchantment");
|
||||
|
||||
- ListTag list = CraftItemStack.getEnchantmentList(this.handle), listCopy;
|
||||
- if (list == null) {
|
||||
- return 0;
|
||||
- }
|
||||
- int index = Integer.MIN_VALUE;
|
||||
- int level = Integer.MIN_VALUE;
|
||||
- int size = list.size();
|
||||
-
|
||||
- for (int i = 0; i < size; i++) {
|
||||
- CompoundTag enchantment = (CompoundTag) list.get(i);
|
||||
- String id = enchantment.getString(ENCHANTMENTS_ID.NBT);
|
||||
- if (ench.getKey().equals(NamespacedKey.fromString(id))) {
|
||||
- index = i;
|
||||
- level = 0xffff & enchantment.getShort(ENCHANTMENTS_LVL.NBT);
|
||||
- break;
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- if (index == Integer.MIN_VALUE) {
|
||||
- return 0;
|
||||
- }
|
||||
- if (size == 1) {
|
||||
- this.handle.getTag().remove(ENCHANTMENTS.NBT);
|
||||
- if (this.handle.getTag().isEmpty()) {
|
||||
- this.handle.setTag(null);
|
||||
- }
|
||||
- return level;
|
||||
- }
|
||||
-
|
||||
- // This is workaround for not having an index removal
|
||||
- listCopy = new ListTag();
|
||||
- for (int i = 0; i < size; i++) {
|
||||
- if (i != index) {
|
||||
- listCopy.add(list.get(i));
|
||||
- }
|
||||
+ // Paper start - replace entire method
|
||||
+ int level = getEnchantmentLevel(ench);
|
||||
+ if (level > 0) {
|
||||
+ final ItemMeta itemMeta = this.getItemMeta();
|
||||
+ if (itemMeta == null) return 0;
|
||||
+ itemMeta.removeEnchant(ench);
|
||||
+ this.setItemMeta(itemMeta);
|
||||
}
|
||||
- this.handle.getTag().put(ENCHANTMENTS.NBT, listCopy);
|
||||
+ // Paper end
|
||||
|
||||
return level;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Enchantment, Integer> getEnchantments() {
|
||||
- return CraftItemStack.getEnchantments(this.handle);
|
||||
+ return this.hasItemMeta() ? this.getItemMeta().getEnchants() : ImmutableMap.<Enchantment, Integer>of(); // Paper - use Item Meta
|
||||
}
|
||||
|
||||
static Map<Enchantment, Integer> getEnchantments(net.minecraft.world.item.ItemStack item) {
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
||||
index 78029398774f1060e3522e4613259be894d68c22..9823ddae9edb40be805332ca1ef4325f9c1df14b 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
||||
@@ -6,6 +6,7 @@ import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableMultimap;
|
||||
import com.google.common.collect.LinkedHashMultimap;
|
||||
+import com.google.common.collect.ImmutableSortedMap; // Paper
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.google.common.collect.SetMultimap;
|
||||
@@ -23,6 +24,7 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Base64;
|
||||
import java.util.Collection;
|
||||
+import java.util.Comparator; // Paper
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
@@ -33,6 +35,7 @@ import java.util.Map;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
+import java.util.TreeMap; // Paper
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javax.annotation.Nonnull;
|
||||
@@ -273,7 +276,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
||||
private List<String> lore; // null and empty are two different states internally
|
||||
private Integer customModelData;
|
||||
private CompoundTag blockData;
|
||||
- private Map<Enchantment, Integer> enchantments;
|
||||
+ private EnchantmentMap enchantments; // Paper
|
||||
private Multimap<Attribute, AttributeModifier> attributeModifiers;
|
||||
private int repairCost;
|
||||
private int hideFlag;
|
||||
@@ -284,7 +287,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
||||
private static final CraftPersistentDataTypeRegistry DATA_TYPE_REGISTRY = new CraftPersistentDataTypeRegistry();
|
||||
|
||||
private CompoundTag internalTag;
|
||||
- final Map<String, Tag> unhandledTags = new HashMap<String, Tag>(); // Visible for testing only
|
||||
+ final Map<String, Tag> unhandledTags = new TreeMap<String, Tag>(); // Visible for testing only // Paper
|
||||
private CraftPersistentDataContainer persistentDataContainer = new CraftPersistentDataContainer(CraftMetaItem.DATA_TYPE_REGISTRY);
|
||||
|
||||
private int version = CraftMagicNumbers.INSTANCE.getDataVersion(); // Internal use only
|
||||
@@ -305,7 +308,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
||||
this.blockData = meta.blockData;
|
||||
|
||||
if (meta.enchantments != null) { // Spigot
|
||||
- this.enchantments = new LinkedHashMap<Enchantment, Integer>(meta.enchantments);
|
||||
+ this.enchantments = new EnchantmentMap(meta.enchantments); // Paper
|
||||
}
|
||||
|
||||
if (meta.hasAttributeModifiers()) {
|
||||
@@ -388,13 +391,13 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
||||
}
|
||||
}
|
||||
|
||||
- static Map<Enchantment, Integer> buildEnchantments(CompoundTag tag, ItemMetaKey key) {
|
||||
+ static EnchantmentMap buildEnchantments(CompoundTag tag, ItemMetaKey key) { // Paper
|
||||
if (!tag.contains(key.NBT)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ListTag ench = tag.getList(key.NBT, CraftMagicNumbers.NBT.TAG_COMPOUND);
|
||||
- Map<Enchantment, Integer> enchantments = new LinkedHashMap<Enchantment, Integer>(ench.size());
|
||||
+ EnchantmentMap enchantments = new EnchantmentMap(); // Paper
|
||||
|
||||
for (int i = 0; i < ench.size(); i++) {
|
||||
String id = ((CompoundTag) ench.get(i)).getString(ENCHANTMENTS_ID.NBT);
|
||||
@@ -547,13 +550,13 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
||||
}
|
||||
}
|
||||
|
||||
- static Map<Enchantment, Integer> buildEnchantments(Map<String, Object> map, ItemMetaKey key) {
|
||||
+ static EnchantmentMap buildEnchantments(Map<String, Object> map, ItemMetaKey key) { // Paper
|
||||
Map<?, ?> ench = SerializableMeta.getObject(Map.class, map, key.BUKKIT, true);
|
||||
if (ench == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
- Map<Enchantment, Integer> enchantments = new LinkedHashMap<Enchantment, Integer>(ench.size());
|
||||
+ EnchantmentMap enchantments = new EnchantmentMap(); // Paper
|
||||
for (Map.Entry<?, ?> entry : ench.entrySet()) {
|
||||
// Doctor older enchants
|
||||
String enchantKey = entry.getKey().toString();
|
||||
@@ -829,14 +832,14 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
||||
|
||||
@Override
|
||||
public Map<Enchantment, Integer> getEnchants() {
|
||||
- return this.hasEnchants() ? ImmutableMap.copyOf(enchantments) : ImmutableMap.<Enchantment, Integer>of();
|
||||
+ return this.hasEnchants() ? ImmutableSortedMap.copyOfSorted(this.enchantments) : ImmutableMap.<Enchantment, Integer>of(); // Paper
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addEnchant(Enchantment ench, int level, boolean ignoreRestrictions) {
|
||||
Validate.notNull(ench, "Enchantment cannot be null");
|
||||
if (this.enchantments == null) {
|
||||
- this.enchantments = new LinkedHashMap<Enchantment, Integer>(4);
|
||||
+ this.enchantments = new EnchantmentMap(); // Paper
|
||||
}
|
||||
|
||||
if (ignoreRestrictions || level >= ench.getStartLevel() && level <= ench.getMaxLevel()) {
|
||||
@@ -1224,7 +1227,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
||||
clone.customModelData = this.customModelData;
|
||||
clone.blockData = this.blockData;
|
||||
if (this.enchantments != null) {
|
||||
- clone.enchantments = new LinkedHashMap<Enchantment, Integer>(this.enchantments);
|
||||
+ clone.enchantments = new EnchantmentMap(this.enchantments); // Paper
|
||||
}
|
||||
if (this.hasAttributeModifiers()) {
|
||||
clone.attributeModifiers = LinkedHashMultimap.create(this.attributeModifiers);
|
||||
@@ -1460,4 +1463,22 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
|
||||
return CraftMetaItem.HANDLED_TAGS;
|
||||
}
|
||||
}
|
||||
+
|
||||
+ // Paper start
|
||||
+ private static class EnchantmentMap extends TreeMap<Enchantment, Integer> {
|
||||
+ private EnchantmentMap(Map<Enchantment, Integer> enchantments) {
|
||||
+ this();
|
||||
+ putAll(enchantments);
|
||||
+ }
|
||||
+
|
||||
+ private EnchantmentMap() {
|
||||
+ super(Comparator.comparing(o -> o.getKey().toString()));
|
||||
+ }
|
||||
+
|
||||
+ public EnchantmentMap clone() {
|
||||
+ return (EnchantmentMap) super.clone();
|
||||
+ }
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Fri, 18 Mar 2016 15:12:22 -0400
|
||||
Subject: [PATCH] Configurable Non Player Arrow Despawn Rate
|
||||
|
||||
Can set a much shorter despawn rate for arrows that players can not pick up.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
|
||||
index 3e1f5fcf589ad7916adb44b53490ccac947a8799..d4b8364fd860ee2cc632d8c752435b9b311c7ece 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
|
||||
@@ -312,7 +312,7 @@ public abstract class AbstractArrow extends Projectile {
|
||||
|
||||
protected void tickDespawn() {
|
||||
++this.life;
|
||||
- if (this.life >= ((this instanceof ThrownTrident) ? level.spigotConfig.tridentDespawnRate : level.spigotConfig.arrowDespawnRate)) { // Spigot
|
||||
+ if (this.life >= (pickup == Pickup.CREATIVE_ONLY ? level.paperConfig().entities.spawning.creativeArrowDespawnRate.value() : (pickup == Pickup.DISALLOWED ? level.paperConfig().entities.spawning.nonPlayerArrowDespawnRate.value() : ((this instanceof ThrownTrident) ? level.spigotConfig.tridentDespawnRate : level.spigotConfig.arrowDespawnRate)))) { // Spigot // Paper - TODO: Extract this to init?
|
||||
this.discard();
|
||||
}
|
||||
|
47
patches/unapplied/server/0071-Add-World-Util-Methods.patch
Normal file
47
patches/unapplied/server/0071-Add-World-Util-Methods.patch
Normal file
|
@ -0,0 +1,47 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Fri, 18 Mar 2016 20:16:03 -0400
|
||||
Subject: [PATCH] Add World Util Methods
|
||||
|
||||
Methods that can be used for other patches to help improve logic.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
index 9c9c8178cd11e37aaef400e40092fb1095fa6c5f..d4b101d0f1835b57f34f68653d728df2bb78faa1 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -219,7 +219,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
public final LevelStorageSource.LevelStorageAccess convertable;
|
||||
public final UUID uuid;
|
||||
|
||||
- public LevelChunk getChunkIfLoaded(int x, int z) {
|
||||
+ @Override public LevelChunk getChunkIfLoaded(int x, int z) { // Paper - this was added in world too but keeping here for NMS ABI
|
||||
return this.chunkSource.getChunk(x, z, false);
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
||||
index 383bf9fe7263bc6153a2e1cbc21657215a3bdb79..47d24d64d16f00e481d4773487163bc1e46ae4a8 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/Level.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
||||
@@ -337,6 +337,22 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
||||
return chunk == null ? null : chunk.getFluidState(blockposition);
|
||||
}
|
||||
|
||||
+ public final boolean isLoadedAndInBounds(BlockPos blockposition) { // Paper - final for inline
|
||||
+ return getWorldBorder().isWithinBounds(blockposition) && getChunkIfLoadedImmediately(blockposition.getX() >> 4, blockposition.getZ() >> 4) != null;
|
||||
+ }
|
||||
+
|
||||
+ public @Nullable LevelChunk getChunkIfLoaded(int x, int z) { // Overridden in WorldServer for ABI compat which has final
|
||||
+ return ((ServerLevel) this).getChunkSource().getChunkAtIfLoadedImmediately(x, z);
|
||||
+ }
|
||||
+ public final @Nullable LevelChunk getChunkIfLoaded(BlockPos blockposition) {
|
||||
+ return ((ServerLevel) this).getChunkSource().getChunkAtIfLoadedImmediately(blockposition.getX() >> 4, blockposition.getZ() >> 4);
|
||||
+ }
|
||||
+
|
||||
+ // reduces need to do isLoaded before getType
|
||||
+ public final @Nullable BlockState getBlockStateIfLoadedAndInBounds(BlockPos blockposition) {
|
||||
+ return getWorldBorder().isWithinBounds(blockposition) ? getBlockStateIfLoaded(blockposition) : null;
|
||||
+ }
|
||||
+
|
||||
@Override
|
||||
public final ChunkAccess getChunk(int chunkX, int chunkZ, ChunkStatus leastStatus, boolean create) { // Paper - final for inline
|
||||
// Paper end
|
|
@ -0,0 +1,49 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jedediah Smith <jedediah@silencegreys.com>
|
||||
Date: Sun, 21 Jun 2015 15:07:20 -0400
|
||||
Subject: [PATCH] Custom replacement for eaten items
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
index eec1467eaaadaa66febc06e51372c5f602216fb5..29495ff2d2c31f6b6ef6e2817662d143e538f926 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -3639,10 +3639,11 @@ public abstract class LivingEntity extends Entity {
|
||||
this.triggerItemUseEffects(this.useItem, 16);
|
||||
// CraftBukkit start - fire PlayerItemConsumeEvent
|
||||
ItemStack itemstack;
|
||||
+ PlayerItemConsumeEvent event = null; // Paper
|
||||
if (this instanceof ServerPlayer) {
|
||||
org.bukkit.inventory.ItemStack craftItem = CraftItemStack.asBukkitCopy(this.useItem);
|
||||
org.bukkit.inventory.EquipmentSlot hand = org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(enumhand);
|
||||
- PlayerItemConsumeEvent event = new PlayerItemConsumeEvent((Player) this.getBukkitEntity(), craftItem, hand);
|
||||
+ event = new PlayerItemConsumeEvent((Player) this.getBukkitEntity(), craftItem, hand); // Paper
|
||||
level.getCraftServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
@@ -3656,6 +3657,13 @@ public abstract class LivingEntity extends Entity {
|
||||
} else {
|
||||
itemstack = this.useItem.finishUsingItem(this.level, this);
|
||||
}
|
||||
+
|
||||
+ // Paper start - save the default replacement item and change it if necessary
|
||||
+ final ItemStack defaultReplacement = itemstack;
|
||||
+ if (event != null && event.getReplacement() != null) {
|
||||
+ itemstack = CraftItemStack.asNMSCopy(event.getReplacement());
|
||||
+ }
|
||||
+ // Paper end
|
||||
// CraftBukkit end
|
||||
|
||||
if (itemstack != this.useItem) {
|
||||
@@ -3663,6 +3671,11 @@ public abstract class LivingEntity extends Entity {
|
||||
}
|
||||
|
||||
this.stopUsingItem();
|
||||
+ // Paper start - if the replacement is anything but the default, update the client inventory
|
||||
+ if (this instanceof ServerPlayer && !com.google.common.base.Objects.equal(defaultReplacement, itemstack)) {
|
||||
+ ((ServerPlayer) this).getBukkitEntity().updateInventory();
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Sun, 27 Sep 2015 01:18:02 -0400
|
||||
Subject: [PATCH] handle NaN health/absorb values and repair bad data
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
index 29495ff2d2c31f6b6ef6e2817662d143e538f926..b2871726eb4dd7f16d161097cbf0f287839e10ba 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -783,7 +783,13 @@ public abstract class LivingEntity extends Entity {
|
||||
|
||||
@Override
|
||||
public void readAdditionalSaveData(CompoundTag nbt) {
|
||||
- this.setAbsorptionAmount(nbt.getFloat("AbsorptionAmount"));
|
||||
+ // Paper start - jvm keeps optimizing the setter
|
||||
+ float absorptionAmount = nbt.getFloat("AbsorptionAmount");
|
||||
+ if (Float.isNaN(absorptionAmount)) {
|
||||
+ absorptionAmount = 0;
|
||||
+ }
|
||||
+ this.setAbsorptionAmount(absorptionAmount);
|
||||
+ // Paper end
|
||||
if (nbt.contains("Attributes", 9) && this.level != null && !this.level.isClientSide) {
|
||||
this.getAttributes().load(nbt.getList("Attributes", 10));
|
||||
}
|
||||
@@ -1270,6 +1276,10 @@ public abstract class LivingEntity extends Entity {
|
||||
}
|
||||
|
||||
public void setHealth(float health) {
|
||||
+ // Paper start
|
||||
+ if (Float.isNaN(health)) { health = getMaxHealth(); if (this.valid) {
|
||||
+ System.err.println("[NAN-HEALTH] " + getScoreboardName() + " had NaN health set");
|
||||
+ } } // Paper end
|
||||
// CraftBukkit start - Handle scaled health
|
||||
if (this instanceof ServerPlayer) {
|
||||
org.bukkit.craftbukkit.entity.CraftPlayer player = ((ServerPlayer) this).getBukkitEntity();
|
||||
@@ -3472,7 +3482,7 @@ public abstract class LivingEntity extends Entity {
|
||||
}
|
||||
|
||||
public void setAbsorptionAmount(float amount) {
|
||||
- if (amount < 0.0F) {
|
||||
+ if (amount < 0.0F || Float.isNaN(amount)) { // Paper
|
||||
amount = 0.0F;
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
index 673e4dc85e5c3ae43170564108f6b74187720d07..b08b72f8c029faae9b9d425e8ce77a1ff23addd7 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
@@ -2041,6 +2041,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
}
|
||||
|
||||
public void setRealHealth(double health) {
|
||||
+ if (Double.isNaN(health)) {return;} // Paper
|
||||
this.health = health;
|
||||
}
|
||||
|
|
@ -0,0 +1,113 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Tue, 22 Mar 2016 00:33:47 -0400
|
||||
Subject: [PATCH] Use a Shared Random for Entities
|
||||
|
||||
Reduces memory usage and provides ensures more randomness, Especially since a lot of garbage entity objects get created.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index 98067f625b49d93fdd91af5114790848a2228ac0..c070fd1b224aeeaa9ebb054105a0f73285956da1 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -159,6 +159,79 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
return tag.contains("Bukkit.updateLevel") && tag.getInt("Bukkit.updateLevel") >= level;
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ public static RandomSource SHARED_RANDOM = new RandomRandomSource();
|
||||
+ private static final class RandomRandomSource extends java.util.Random implements net.minecraft.world.level.levelgen.BitRandomSource {
|
||||
+ private boolean locked = false;
|
||||
+
|
||||
+ @Override
|
||||
+ public synchronized void setSeed(long seed) {
|
||||
+ if (locked) {
|
||||
+ LOGGER.error("Ignoring setSeed on Entity.SHARED_RANDOM", new Throwable());
|
||||
+ } else {
|
||||
+ super.setSeed(seed);
|
||||
+ locked = true;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public RandomSource fork() {
|
||||
+ return new net.minecraft.world.level.levelgen.LegacyRandomSource(this.nextLong());
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public net.minecraft.world.level.levelgen.PositionalRandomFactory forkPositional() {
|
||||
+ return new net.minecraft.world.level.levelgen.LegacyRandomSource.LegacyPositionalRandomFactory(this.nextLong());
|
||||
+ }
|
||||
+
|
||||
+ // these below are added to fix reobf issues that I don't wanna deal with right now
|
||||
+ @Override
|
||||
+ public int next(int bits) {
|
||||
+ return super.next(bits);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public int nextInt(int origin, int bound) {
|
||||
+ return net.minecraft.world.level.levelgen.BitRandomSource.super.nextInt(origin, bound);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public long nextLong() {
|
||||
+ return net.minecraft.world.level.levelgen.BitRandomSource.super.nextLong();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public int nextInt() {
|
||||
+ return net.minecraft.world.level.levelgen.BitRandomSource.super.nextInt();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public int nextInt(int bound) {
|
||||
+ return net.minecraft.world.level.levelgen.BitRandomSource.super.nextInt(bound);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean nextBoolean() {
|
||||
+ return net.minecraft.world.level.levelgen.BitRandomSource.super.nextBoolean();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public float nextFloat() {
|
||||
+ return net.minecraft.world.level.levelgen.BitRandomSource.super.nextFloat();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public double nextDouble() {
|
||||
+ return net.minecraft.world.level.levelgen.BitRandomSource.super.nextDouble();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public double nextGaussian() {
|
||||
+ return super.nextGaussian();
|
||||
+ }
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
private CraftEntity bukkitEntity;
|
||||
|
||||
public CraftEntity getBukkitEntity() {
|
||||
@@ -398,7 +471,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
this.bb = Entity.INITIAL_AABB;
|
||||
this.stuckSpeedMultiplier = Vec3.ZERO;
|
||||
this.nextStep = 1.0F;
|
||||
- this.random = RandomSource.create();
|
||||
+ this.random = SHARED_RANDOM; // Paper
|
||||
this.remainingFireTicks = -this.getFireImmuneTicks();
|
||||
this.fluidHeight = new Object2DoubleArrayMap(2);
|
||||
this.fluidOnEyes = new HashSet();
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/animal/Squid.java b/src/main/java/net/minecraft/world/entity/animal/Squid.java
|
||||
index 8e63ab510e4c2e458da726ca67be4d3b5274e7b7..a51424d29ac353cf1bec4d1484db0acb63bebba5 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/animal/Squid.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/animal/Squid.java
|
||||
@@ -46,7 +46,7 @@ public class Squid extends WaterAnimal {
|
||||
|
||||
public Squid(EntityType<? extends Squid> type, Level world) {
|
||||
super(type, world);
|
||||
- this.random.setSeed((long) this.getId());
|
||||
+ //this.random.setSeed((long) this.getId()); // Paper - we set the random to shared, do not clobber the seed
|
||||
this.tentacleSpeed = 1.0F / (this.random.nextFloat() + 1.0F) * 0.2F;
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Zach Brown <zach.brown@destroystokyo.com>
|
||||
Date: Tue, 22 Mar 2016 12:04:28 -0500
|
||||
Subject: [PATCH] Configurable spawn chances for skeleton horses
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
index d4b101d0f1835b57f34f68653d728df2bb78faa1..87a81cdd00b19ba020f6506eedd8ac4bf20d32ef 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -696,7 +696,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
blockposition = this.findLightningTargetAround(this.getBlockRandomPos(j, 0, k, 15));
|
||||
if (this.isRainingAt(blockposition)) {
|
||||
DifficultyInstance difficultydamagescaler = this.getCurrentDifficultyAt(blockposition);
|
||||
- boolean flag1 = this.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) && this.random.nextDouble() < (double) difficultydamagescaler.getEffectiveDifficulty() * 0.01D && !this.getBlockState(blockposition.below()).is(Blocks.LIGHTNING_ROD);
|
||||
+ boolean flag1 = this.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) && this.random.nextDouble() < (double) difficultydamagescaler.getEffectiveDifficulty() * this.paperConfig().entities.spawning.skeletonHorseThunderSpawnChance.or(0.01D) && !this.getBlockState(blockposition.below()).is(Blocks.LIGHTNING_ROD); // Paper
|
||||
|
||||
if (flag1) {
|
||||
SkeletonHorse entityhorseskeleton = (SkeletonHorse) EntityType.SKELETON_HORSE.create(this);
|
|
@ -0,0 +1,166 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Thu, 3 Mar 2016 02:07:55 -0600
|
||||
Subject: [PATCH] Optimize isInWorldBounds and getBlockState for inlining
|
||||
|
||||
Hot methods, so reduce # of instructions for the method.
|
||||
|
||||
Move is valid location test to the BlockPosition class so that it can access local variables.
|
||||
|
||||
Replace all calls to the new place to the unnecessary forward.
|
||||
|
||||
Optimize getType and getBlockData to manually inline and optimize the calls
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/core/Vec3i.java b/src/main/java/net/minecraft/core/Vec3i.java
|
||||
index 3b254a89484ac8a9dba399c7eb081328ff69a7b2..a6a6aaf226655d0e44bc229288112882a9c04e3b 100644
|
||||
--- a/src/main/java/net/minecraft/core/Vec3i.java
|
||||
+++ b/src/main/java/net/minecraft/core/Vec3i.java
|
||||
@@ -33,6 +33,12 @@ public class Vec3i implements Comparable<Vec3i> {
|
||||
return CODEC.flatXmap(checkOffsetAxes(maxAbsValue), checkOffsetAxes(maxAbsValue));
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ public final boolean isInsideBuildHeightAndWorldBoundsHorizontal(net.minecraft.world.level.LevelHeightAccessor levelHeightAccessor) {
|
||||
+ return getX() >= -30000000 && getZ() >= -30000000 && getX() < 30000000 && getZ() < 30000000 && !levelHeightAccessor.isOutsideBuildHeight(getY());
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
public Vec3i(int x, int y, int z) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
||||
index 47d24d64d16f00e481d4773487163bc1e46ae4a8..4d2a64a38a94cc82767030dbdf219b5ee1002a7d 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/Level.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
||||
@@ -279,7 +279,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
||||
}
|
||||
|
||||
public boolean isInWorldBounds(BlockPos pos) {
|
||||
- return !this.isOutsideBuildHeight(pos) && Level.isInWorldBoundsHorizontal(pos);
|
||||
+ return pos.isInsideBuildHeightAndWorldBoundsHorizontal(this); // Paper - use better/optimized check
|
||||
}
|
||||
|
||||
public static boolean isInSpawnableBounds(BlockPos pos) {
|
||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java b/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java
|
||||
index 1b7496cec0ba5a95615a069e3168bd46308d0b40..508c2fff8d8e0c6f37b6c4e3b72ba772c2ab2ee5 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/chunk/ChunkAccess.java
|
||||
@@ -160,6 +160,7 @@ public abstract class ChunkAccess implements BlockGetter, BiomeManager.NoiseBiom
|
||||
return GameEventListenerRegistry.NOOP;
|
||||
}
|
||||
|
||||
+ public abstract BlockState getBlockState(final int x, final int y, final int z); // Paper
|
||||
@Nullable
|
||||
public abstract BlockState setBlockState(BlockPos pos, BlockState state, boolean moved);
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/EmptyLevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/EmptyLevelChunk.java
|
||||
index 2eb92dde607d7c8968cb07c6f3c24e1c45e9990f..908f71721daf4305692f424d7712cbfdddddae83 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/chunk/EmptyLevelChunk.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/chunk/EmptyLevelChunk.java
|
||||
@@ -55,6 +55,12 @@ public class EmptyLevelChunk extends LevelChunk {
|
||||
public void setBlockEmptinessMap(final boolean[] emptinessMap) {}
|
||||
// Paper end - starlight
|
||||
|
||||
+ // Paper start
|
||||
+ @Override
|
||||
+ public BlockState getBlockState(int x, int y, int z) {
|
||||
+ return Blocks.VOID_AIR.defaultBlockState();
|
||||
+ }
|
||||
+ // Paper end
|
||||
@Override
|
||||
public BlockState getBlockState(BlockPos pos) {
|
||||
return Blocks.VOID_AIR.defaultBlockState();
|
||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/ImposterProtoChunk.java b/src/main/java/net/minecraft/world/level/chunk/ImposterProtoChunk.java
|
||||
index 8033c8741a0f73919a357893652592b317bfb417..9a1cffd51aaf97f759a9057aefbf50bd6f5ed028 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/chunk/ImposterProtoChunk.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/chunk/ImposterProtoChunk.java
|
||||
@@ -89,6 +89,12 @@ public class ImposterProtoChunk extends ProtoChunk {
|
||||
public BlockState getBlockState(BlockPos pos) {
|
||||
return this.wrapped.getBlockState(pos);
|
||||
}
|
||||
+ // Paper start
|
||||
+ @Override
|
||||
+ public final BlockState getBlockState(final int x, final int y, final int z) {
|
||||
+ return this.wrapped.getBlockStateFinal(x, y, z);
|
||||
+ }
|
||||
+ // Paper end
|
||||
|
||||
@Override
|
||||
public FluidState getFluidState(BlockPos pos) {
|
||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
|
||||
index ba24e32f96797ed8c8bd82391d1903f6ad2a9813..2efeccb33d1d5fb148a12f71eae870fbdcb6e0fd 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
|
||||
@@ -342,12 +342,29 @@ public class LevelChunk extends ChunkAccess {
|
||||
}
|
||||
}
|
||||
|
||||
+ // Paper start - Optimize getBlockData to reduce instructions
|
||||
@Override
|
||||
public BlockState getBlockState(BlockPos pos) {
|
||||
- int i = pos.getX();
|
||||
- int j = pos.getY();
|
||||
- int k = pos.getZ();
|
||||
+ return this.getBlockStateFinal(pos.getX(), pos.getY(), pos.getZ());
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public BlockState getBlockState(final int x, final int y, final int z) {
|
||||
+ return this.getBlockStateFinal(x, y, z);
|
||||
+ }
|
||||
+ public final BlockState getBlockStateFinal(final int x, final int y, final int z) {
|
||||
+ // Method body / logic copied from below
|
||||
+ final int i = this.getSectionIndex(y);
|
||||
+ if (i < 0 || i >= this.sections.length || this.sections[i].nonEmptyBlockCount == 0 || this.sections[i].hasOnlyAir()) {
|
||||
+ return Blocks.AIR.defaultBlockState();
|
||||
+ }
|
||||
+ // Inlined ChunkSection.getType() and DataPaletteBlock.a(int,int,int)
|
||||
+ return this.sections[i].states.get((y & 15) << 8 | (z & 15) << 4 | x & 15);
|
||||
|
||||
+ }
|
||||
+
|
||||
+ public BlockState getBlockState_unused(int i, int j, int k) {
|
||||
+ // Paper end
|
||||
if (this.level.isDebug()) {
|
||||
BlockState iblockdata = null;
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java
|
||||
index dddae1e226d8f58cdcfc597e25d4228cd3245cb4..ae37e97e52557b48f129cc02eeea395378a48444 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java
|
||||
@@ -21,7 +21,7 @@ public class LevelChunkSection {
|
||||
public static final int SECTION_SIZE = 4096;
|
||||
public static final int BIOME_CONTAINER_BITS = 2;
|
||||
private final int bottomBlockY;
|
||||
- private short nonEmptyBlockCount;
|
||||
+ short nonEmptyBlockCount; // Paper - package-private
|
||||
private short tickingBlockCount;
|
||||
private short tickingFluidCount;
|
||||
public final PalettedContainer<BlockState> states;
|
||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/ProtoChunk.java b/src/main/java/net/minecraft/world/level/chunk/ProtoChunk.java
|
||||
index 0b67858f8d6689b34816f9556f3424af512a7401..c24b4c6a560aab2df07783b3481981deb8571a50 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/chunk/ProtoChunk.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/chunk/ProtoChunk.java
|
||||
@@ -94,14 +94,18 @@ public class ProtoChunk extends ChunkAccess {
|
||||
|
||||
@Override
|
||||
public BlockState getBlockState(BlockPos pos) {
|
||||
- int i = pos.getY();
|
||||
- if (this.isOutsideBuildHeight(i)) {
|
||||
+ // Paper start
|
||||
+ return getBlockState(pos.getX(), pos.getY(), pos.getZ());
|
||||
+ }
|
||||
+ public BlockState getBlockState(final int x, final int y, final int z) {
|
||||
+ if (this.isOutsideBuildHeight(y)) {
|
||||
return Blocks.VOID_AIR.defaultBlockState();
|
||||
} else {
|
||||
- LevelChunkSection levelChunkSection = this.getSection(this.getSectionIndex(i));
|
||||
- return levelChunkSection.hasOnlyAir() ? Blocks.AIR.defaultBlockState() : levelChunkSection.getBlockState(pos.getX() & 15, i & 15, pos.getZ() & 15);
|
||||
+ LevelChunkSection levelChunkSection = this.getSections()[this.getSectionIndex(y)];
|
||||
+ return levelChunkSection.hasOnlyAir() ? Blocks.AIR.defaultBlockState() : levelChunkSection.getBlockState(x & 15, y & 15, z & 15);
|
||||
}
|
||||
}
|
||||
+ // Paper end
|
||||
|
||||
@Override
|
||||
public FluidState getFluidState(BlockPos pos) {
|
|
@ -0,0 +1,70 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Mon, 28 Mar 2016 19:55:45 -0400
|
||||
Subject: [PATCH] Only process BlockPhysicsEvent if a plugin has a listener
|
||||
|
||||
Saves on some object allocation and processing when no plugin listens to this
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index 28d58f402f15ee37cc1bfa3114839db281fc5f57..e62aa86afb05d8f00d8dd2b676407bfa7d0ed9fb 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -1357,6 +1357,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
ServerLevel worldserver = (ServerLevel) iterator.next();
|
||||
+ worldserver.hasPhysicsEvent = org.bukkit.event.block.BlockPhysicsEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper
|
||||
|
||||
this.profiler.push(() -> {
|
||||
return worldserver + " " + worldserver.dimension().location();
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
index 87a81cdd00b19ba020f6506eedd8ac4bf20d32ef..a487331d9df8fa0d58cfb0859c25a8fffe376ac2 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -218,6 +218,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
// CraftBukkit start
|
||||
public final LevelStorageSource.LevelStorageAccess convertable;
|
||||
public final UUID uuid;
|
||||
+ public boolean hasPhysicsEvent = true; // Paper
|
||||
|
||||
@Override public LevelChunk getChunkIfLoaded(int x, int z) { // Paper - this was added in world too but keeping here for NMS ABI
|
||||
return this.chunkSource.getChunk(x, z, false);
|
||||
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
||||
index 4d2a64a38a94cc82767030dbdf219b5ee1002a7d..00911231201f84b781048d052495b60a47fb5277 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/Level.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
||||
@@ -497,7 +497,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
||||
// CraftBukkit start
|
||||
iblockdata1.updateIndirectNeighbourShapes(this, blockposition, k, j - 1); // Don't call an event for the old block to limit event spam
|
||||
CraftWorld world = ((ServerLevel) this).getWorld();
|
||||
- if (world != null) {
|
||||
+ if (world != null && ((ServerLevel)this).hasPhysicsEvent) { // Paper
|
||||
BlockPhysicsEvent event = new BlockPhysicsEvent(world.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), CraftBlockData.fromData(iblockdata));
|
||||
this.getCraftServer().getPluginManager().callEvent(event);
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/BushBlock.java b/src/main/java/net/minecraft/world/level/block/BushBlock.java
|
||||
index d40e791529911ca81398ac267a819415da91502a..03fde6e47c4a347c62fe9b4a3351769aedf874f6 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/BushBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/BushBlock.java
|
||||
@@ -24,7 +24,7 @@ public class BushBlock extends Block {
|
||||
public BlockState updateShape(BlockState state, Direction direction, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) {
|
||||
// CraftBukkit start
|
||||
if (!state.canSurvive(world, pos)) {
|
||||
- if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPhysicsEvent(world, pos).isCancelled()) {
|
||||
+ if (!(world instanceof net.minecraft.server.level.ServerLevel && ((net.minecraft.server.level.ServerLevel) world).hasPhysicsEvent) || !org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPhysicsEvent(world, pos).isCancelled()) { // Paper
|
||||
return Blocks.AIR.defaultBlockState();
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/DoublePlantBlock.java b/src/main/java/net/minecraft/world/level/block/DoublePlantBlock.java
|
||||
index 12bf4125bc697092a038600955318f8436bdb5d7..e234ae13fe9793db237adb6f6216fa32638cfc4f 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/DoublePlantBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/DoublePlantBlock.java
|
||||
@@ -95,7 +95,7 @@ public class DoublePlantBlock extends BushBlock {
|
||||
|
||||
protected static void preventCreativeDropFromBottomPart(Level world, BlockPos pos, BlockState state, Player player) {
|
||||
// CraftBukkit start
|
||||
- if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPhysicsEvent(world, pos).isCancelled()) {
|
||||
+ if (((net.minecraft.server.level.ServerLevel)world).hasPhysicsEvent && org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPhysicsEvent(world, pos).isCancelled()) { // Paper
|
||||
return;
|
||||
}
|
||||
// CraftBukkit end
|
|
@ -0,0 +1,26 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Mon, 28 Mar 2016 20:32:58 -0400
|
||||
Subject: [PATCH] Entity AddTo/RemoveFrom World Events
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
index a487331d9df8fa0d58cfb0859c25a8fffe376ac2..e7d07d1f86af49b8729f6ac66b398ee6aae5ab4a 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -2225,6 +2225,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
entity.setOrigin(entity.getOriginVector().toLocation(getWorld()));
|
||||
}
|
||||
// Paper end
|
||||
+ new com.destroystokyo.paper.event.entity.EntityAddToWorldEvent(entity.getBukkitEntity()).callEvent(); // Paper - fire while valid
|
||||
}
|
||||
|
||||
public void onTrackingEnd(Entity entity) {
|
||||
@@ -2300,6 +2301,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
}
|
||||
}
|
||||
// CraftBukkit end
|
||||
+ new com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent(entity.getBukkitEntity()).callEvent(); // Paper - fire while valid
|
||||
}
|
||||
|
||||
public void onSectionChange(Entity entity) {
|
|
@ -0,0 +1,30 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Mon, 28 Mar 2016 20:46:14 -0400
|
||||
Subject: [PATCH] Configurable Chunk Inhabited Time
|
||||
|
||||
Vanilla stores how long a chunk has been active on a server, and dynamically scales some
|
||||
aspects of vanilla gameplay to this factor.
|
||||
|
||||
For people who want all chunks to be treated equally, you can chose a fixed value.
|
||||
|
||||
This allows to fine-tune vanilla gameplay.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
|
||||
index 2efeccb33d1d5fb148a12f71eae870fbdcb6e0fd..b4c76e53eef8dc0efec98848352a243931ffc1f3 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
|
||||
@@ -327,6 +327,13 @@ public class LevelChunk extends ChunkAccess {
|
||||
return new ChunkAccess.TicksToSave(this.blockTicks, this.fluidTicks);
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ @Override
|
||||
+ public long getInhabitedTime() {
|
||||
+ return this.level.paperConfig().chunks.fixedChunkInhabitedTime < 0 ? super.getInhabitedTime() : this.level.paperConfig().chunks.fixedChunkInhabitedTime;
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
@Override
|
||||
public GameEventListenerRegistry getListenerRegistry(int ySectionCoord) {
|
||||
Level world = this.level;
|
149
patches/unapplied/server/0080-EntityPathfindEvent.patch
Normal file
149
patches/unapplied/server/0080-EntityPathfindEvent.patch
Normal file
|
@ -0,0 +1,149 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Mon, 28 Mar 2016 21:22:26 -0400
|
||||
Subject: [PATCH] EntityPathfindEvent
|
||||
|
||||
Fires when an Entity decides to start moving to a location.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/navigation/FlyingPathNavigation.java b/src/main/java/net/minecraft/world/entity/ai/navigation/FlyingPathNavigation.java
|
||||
index a8f69e48937b3ebd2f57a4da747e6762c4a77934..acd0b946cab86eb173e713535194d3a9347c7d48 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/navigation/FlyingPathNavigation.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/navigation/FlyingPathNavigation.java
|
||||
@@ -40,7 +40,7 @@ public class FlyingPathNavigation extends PathNavigation {
|
||||
|
||||
@Override
|
||||
public Path createPath(Entity entity, int distance) {
|
||||
- return this.createPath(entity.blockPosition(), distance);
|
||||
+ return this.createPath(entity.blockPosition(), entity, distance); // Paper - Forward target entity
|
||||
}
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/navigation/GroundPathNavigation.java b/src/main/java/net/minecraft/world/entity/ai/navigation/GroundPathNavigation.java
|
||||
index 6b24f94f1762570547c0fc484b3939de73fbd309..80b3fd4150d749af7d584f95ee3d0b8ed664ead9 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/navigation/GroundPathNavigation.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/navigation/GroundPathNavigation.java
|
||||
@@ -39,14 +39,14 @@ public class GroundPathNavigation extends PathNavigation {
|
||||
}
|
||||
|
||||
@Override
|
||||
- public Path createPath(BlockPos target, int distance) {
|
||||
+ public Path createPath(BlockPos target, @javax.annotation.Nullable Entity entity, int distance) { // Paper
|
||||
if (this.level.getBlockState(target).isAir()) {
|
||||
BlockPos blockPos;
|
||||
for(blockPos = target.below(); blockPos.getY() > this.level.getMinBuildHeight() && this.level.getBlockState(blockPos).isAir(); blockPos = blockPos.below()) {
|
||||
}
|
||||
|
||||
if (blockPos.getY() > this.level.getMinBuildHeight()) {
|
||||
- return super.createPath(blockPos.above(), distance);
|
||||
+ return super.createPath(blockPos.above(), entity, distance); // Paper
|
||||
}
|
||||
|
||||
while(blockPos.getY() < this.level.getMaxBuildHeight() && this.level.getBlockState(blockPos).isAir()) {
|
||||
@@ -57,19 +57,19 @@ public class GroundPathNavigation extends PathNavigation {
|
||||
}
|
||||
|
||||
if (!this.level.getBlockState(target).getMaterial().isSolid()) {
|
||||
- return super.createPath(target, distance);
|
||||
+ return super.createPath(target, entity, distance); // Paper
|
||||
} else {
|
||||
BlockPos blockPos2;
|
||||
for(blockPos2 = target.above(); blockPos2.getY() < this.level.getMaxBuildHeight() && this.level.getBlockState(blockPos2).getMaterial().isSolid(); blockPos2 = blockPos2.above()) {
|
||||
}
|
||||
|
||||
- return super.createPath(blockPos2, distance);
|
||||
+ return super.createPath(blockPos2, entity, distance); // Paper
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path createPath(Entity entity, int distance) {
|
||||
- return this.createPath(entity.blockPosition(), distance);
|
||||
+ return this.createPath(entity.blockPosition(), entity, distance); // Paper - Forward target entity
|
||||
}
|
||||
|
||||
private int getSurfaceY() {
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java b/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java
|
||||
index ec1bd2fff121aa00b50b0d65c0e53e4146c3deb9..bd782c8935db6e0aa3489725d3c4ee401f9bf242 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java
|
||||
@@ -109,7 +109,13 @@ public abstract class PathNavigation {
|
||||
|
||||
@Nullable
|
||||
public Path createPath(BlockPos target, int distance) {
|
||||
- return this.createPath(ImmutableSet.of(target), 8, false, distance);
|
||||
+ // Paper start - add target entity parameter
|
||||
+ return this.createPath(target, null, distance);
|
||||
+ }
|
||||
+ @Nullable
|
||||
+ public Path createPath(BlockPos target, @Nullable Entity entity, int distance) {
|
||||
+ return this.createPath(ImmutableSet.of(target), entity, 8, false, distance);
|
||||
+ // Paper end
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -119,7 +125,7 @@ public abstract class PathNavigation {
|
||||
|
||||
@Nullable
|
||||
public Path createPath(Entity entity, int distance) {
|
||||
- return this.createPath(ImmutableSet.of(entity.blockPosition()), 16, true, distance);
|
||||
+ return this.createPath(ImmutableSet.of(entity.blockPosition()), entity, 16, true, distance); // Paper
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -129,6 +135,16 @@ public abstract class PathNavigation {
|
||||
|
||||
@Nullable
|
||||
protected Path createPath(Set<BlockPos> positions, int range, boolean useHeadPos, int distance, float followRange) {
|
||||
+ return this.createPath(positions, null, range, useHeadPos, distance, followRange);
|
||||
+ }
|
||||
+
|
||||
+ @Nullable
|
||||
+ protected Path createPath(Set<BlockPos> positions, @Nullable Entity target, int range, boolean useHeadPos, int distance) {
|
||||
+ return this.createPath(positions, target, range, useHeadPos, distance, (float) this.mob.getAttributeValue(Attributes.FOLLOW_RANGE));
|
||||
+ }
|
||||
+
|
||||
+ @Nullable protected Path createPath(Set<BlockPos> positions, @Nullable Entity target, int range, boolean useHeadPos, int distance, float followRange) {
|
||||
+ // Paper end
|
||||
if (positions.isEmpty()) {
|
||||
return null;
|
||||
} else if (this.mob.getY() < (double)this.level.getMinBuildHeight()) {
|
||||
@@ -138,6 +154,23 @@ public abstract class PathNavigation {
|
||||
} else if (this.path != null && !this.path.isDone() && positions.contains(this.targetPos)) {
|
||||
return this.path;
|
||||
} else {
|
||||
+ // Paper start - Pathfind event
|
||||
+ boolean copiedSet = false;
|
||||
+ for (BlockPos possibleTarget : positions) {
|
||||
+ if (!new com.destroystokyo.paper.event.entity.EntityPathfindEvent(this.mob.getBukkitEntity(),
|
||||
+ io.papermc.paper.util.MCUtil.toLocation(this.mob.level, possibleTarget), target == null ? null : target.getBukkitEntity()).callEvent()) {
|
||||
+ if (!copiedSet) {
|
||||
+ copiedSet = true;
|
||||
+ positions = new java.util.HashSet<>(positions);
|
||||
+ }
|
||||
+ // note: since we copy the set this remove call is safe, since we're iterating over the old copy
|
||||
+ positions.remove(possibleTarget);
|
||||
+ if (positions.isEmpty()) {
|
||||
+ return null;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ // Paper end
|
||||
this.level.getProfiler().push("pathfind");
|
||||
BlockPos blockPos = useHeadPos ? this.mob.blockPosition().above() : this.mob.blockPosition();
|
||||
int i = (int)(followRange + (float)range);
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/navigation/WallClimberNavigation.java b/src/main/java/net/minecraft/world/entity/ai/navigation/WallClimberNavigation.java
|
||||
index d11e9f4f7ae5f2666d67878309b4a1359ef90e39..de1f178fa18ae3ff3c73bc59b10eb39857800bf9 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/navigation/WallClimberNavigation.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/navigation/WallClimberNavigation.java
|
||||
@@ -16,9 +16,9 @@ public class WallClimberNavigation extends GroundPathNavigation {
|
||||
}
|
||||
|
||||
@Override
|
||||
- public Path createPath(BlockPos target, int distance) {
|
||||
+ public Path createPath(BlockPos target, @Nullable Entity entity, int distance) { // Paper
|
||||
this.pathToPosition = target;
|
||||
- return super.createPath(target, distance);
|
||||
+ return super.createPath(target, entity, distance); // Paper
|
||||
}
|
||||
|
||||
@Override
|
|
@ -0,0 +1,25 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Antony Riley <antony@cyberiantiger.org>
|
||||
Date: Tue, 29 Mar 2016 08:22:55 +0300
|
||||
Subject: [PATCH] Sanitise RegionFileCache and make configurable.
|
||||
|
||||
RegionFileCache prior to this patch would close every single open region
|
||||
file upon reaching a size of 256.
|
||||
This patch modifies that behaviour so it closes the the least recently
|
||||
used RegionFile.
|
||||
The implementation uses a LinkedHashMap as an LRU cache (modified from HashMap).
|
||||
The maximum size of the RegionFileCache is also made configurable.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
|
||||
index 64e957650dafc9fc30fa997e7f7d3fd47cf60089..1a1ade7538263f4c1a91eb122086a150af3d86ba 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
|
||||
@@ -57,7 +57,7 @@ public class RegionFileStorage implements AutoCloseable {
|
||||
// Paper end
|
||||
return regionfile;
|
||||
} else {
|
||||
- if (this.regionCache.size() >= 256) {
|
||||
+ if (this.regionCache.size() >= io.papermc.paper.configuration.GlobalConfiguration.get().misc.regionFileCacheSize) { // Paper - configurable
|
||||
((RegionFile) this.regionCache.removeLast()).close();
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Thu, 31 Mar 2016 19:17:58 -0400
|
||||
Subject: [PATCH] Do not load chunks for Pathfinding
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java b/src/main/java/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java
|
||||
index 243740ee9debe3ca0a988b0a448af09a5845b96d..04406fdb2961a85d8e6bffbb8e233e8c4dcf4390 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java
|
||||
@@ -465,7 +465,12 @@ public class WalkNodeEvaluator extends NodeEvaluator {
|
||||
for(int n = -1; n <= 1; ++n) {
|
||||
if (l != 0 || n != 0) {
|
||||
pos.set(i + l, j + m, k + n);
|
||||
- BlockState blockState = world.getBlockState(pos);
|
||||
+ // Paper start
|
||||
+ BlockState blockState = world.getBlockStateIfLoaded(pos);
|
||||
+ if (blockState == null) {
|
||||
+ return BlockPathTypes.BLOCKED;
|
||||
+ } else {
|
||||
+ // Paper end
|
||||
if (blockState.is(Blocks.CACTUS)) {
|
||||
return BlockPathTypes.DANGER_CACTUS;
|
||||
}
|
||||
@@ -481,6 +486,7 @@ public class WalkNodeEvaluator extends NodeEvaluator {
|
||||
if (world.getFluidState(pos).is(FluidTags.WATER)) {
|
||||
return BlockPathTypes.WATER_BORDER;
|
||||
}
|
||||
+ } // Paper
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -490,7 +496,8 @@ public class WalkNodeEvaluator extends NodeEvaluator {
|
||||
}
|
||||
|
||||
protected static BlockPathTypes getBlockPathTypeRaw(BlockGetter world, BlockPos pos) {
|
||||
- BlockState blockState = world.getBlockState(pos);
|
||||
+ BlockState blockState = world.getBlockStateIfLoaded(pos); // Paper
|
||||
+ if (blockState == null) return BlockPathTypes.BLOCKED; // Paper
|
||||
Block block = blockState.getBlock();
|
||||
Material material = blockState.getMaterial();
|
||||
if (blockState.isAir()) {
|
|
@ -0,0 +1,65 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jedediah Smith <jedediah@silencegreys.com>
|
||||
Date: Sat, 2 Apr 2016 05:09:16 -0400
|
||||
Subject: [PATCH] Add PlayerUseUnknownEntityEvent
|
||||
|
||||
== AT ==
|
||||
public net.minecraft.network.protocol.game.ServerboundInteractPacket$ActionType
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/network/protocol/game/ServerboundInteractPacket.java b/src/main/java/net/minecraft/network/protocol/game/ServerboundInteractPacket.java
|
||||
index a5d57cc862036012d83b090bb1b3ccf4115a88b3..21068f766b75c414d5818073b7dca083d8ff4409 100644
|
||||
--- a/src/main/java/net/minecraft/network/protocol/game/ServerboundInteractPacket.java
|
||||
+++ b/src/main/java/net/minecraft/network/protocol/game/ServerboundInteractPacket.java
|
||||
@@ -10,8 +10,8 @@ import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
public class ServerboundInteractPacket implements Packet<ServerGamePacketListener> {
|
||||
- private final int entityId;
|
||||
- private final ServerboundInteractPacket.Action action;
|
||||
+ private final int entityId; public final int getEntityId() { return this.entityId; } // Paper - add accessor
|
||||
+ private final ServerboundInteractPacket.Action action; public final ServerboundInteractPacket.ActionType getActionType() { return this.action.getType(); } // Paper - add accessor
|
||||
private final boolean usingSecondaryAction;
|
||||
static final ServerboundInteractPacket.Action ATTACK_ACTION = new ServerboundInteractPacket.Action() {
|
||||
@Override
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index eaf0e468d7ebf54290ae9e2df9f4a2c252142f65..050e8f545f5cc86985d3dbbe3192f632b64af66f 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -2525,8 +2525,37 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
});
|
||||
}
|
||||
}
|
||||
+ // Paper start - fire event
|
||||
+ else {
|
||||
+ packet.dispatch(new net.minecraft.network.protocol.game.ServerboundInteractPacket.Handler() {
|
||||
+ @Override
|
||||
+ public void onInteraction(net.minecraft.world.InteractionHand hand) {
|
||||
+ ServerGamePacketListenerImpl.this.callPlayerUseUnknownEntityEvent(packet, hand);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void onInteraction(net.minecraft.world.InteractionHand hand, net.minecraft.world.phys.Vec3 pos) {
|
||||
+ ServerGamePacketListenerImpl.this.callPlayerUseUnknownEntityEvent(packet, hand);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void onAttack() {
|
||||
+ ServerGamePacketListenerImpl.this.callPlayerUseUnknownEntityEvent(packet, net.minecraft.world.InteractionHand.MAIN_HAND);
|
||||
+ }
|
||||
+ });
|
||||
+ }
|
||||
+
|
||||
+ }
|
||||
|
||||
+ private void callPlayerUseUnknownEntityEvent(ServerboundInteractPacket packet, InteractionHand hand) {
|
||||
+ this.cserver.getPluginManager().callEvent(new com.destroystokyo.paper.event.player.PlayerUseUnknownEntityEvent(
|
||||
+ this.getCraftPlayer(),
|
||||
+ packet.getEntityId(),
|
||||
+ packet.getActionType() == ServerboundInteractPacket.ActionType.ATTACK,
|
||||
+ hand == InteractionHand.MAIN_HAND ? EquipmentSlot.HAND : EquipmentSlot.OFF_HAND
|
||||
+ ));
|
||||
}
|
||||
+ // Paper end
|
||||
|
||||
@Override
|
||||
public void handleClientCommand(ServerboundClientCommandPacket packet) {
|
|
@ -0,0 +1,26 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Sun, 3 Apr 2016 16:28:17 -0400
|
||||
Subject: [PATCH] Configurable Grass Spread Tick Rate
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/SpreadingSnowyDirtBlock.java b/src/main/java/net/minecraft/world/level/block/SpreadingSnowyDirtBlock.java
|
||||
index bd5a45765b53bf4f2f9aaea4769c71ffb008741d..61783f17b655cbb6430d22fb3a81931ab3ea130c 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/SpreadingSnowyDirtBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/SpreadingSnowyDirtBlock.java
|
||||
@@ -2,6 +2,7 @@ package net.minecraft.world.level.block;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
+import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.tags.FluidTags;
|
||||
import net.minecraft.util.RandomSource;
|
||||
@@ -39,6 +40,7 @@ public abstract class SpreadingSnowyDirtBlock extends SnowyDirtBlock {
|
||||
|
||||
@Override
|
||||
public void randomTick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) {
|
||||
+ if (this instanceof GrassBlock && world.paperConfig().tickRates.grassSpread != 1 && (world.paperConfig().tickRates.grassSpread < 1 || (MinecraftServer.currentTick + pos.hashCode()) % world.paperConfig().tickRates.grassSpread != 0)) { return; } // Paper
|
||||
if (!SpreadingSnowyDirtBlock.canBeGrass(state, world, pos)) {
|
||||
// CraftBukkit start
|
||||
if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(world, pos, Blocks.DIRT.defaultBlockState()).isCancelled()) {
|
|
@ -0,0 +1,18 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Sun, 3 Apr 2016 17:48:50 -0400
|
||||
Subject: [PATCH] Fix Cancelling BlockPlaceEvent triggering physics
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
index e7d07d1f86af49b8729f6ac66b398ee6aae5ab4a..0d08690aade0e3334c583b62e0abf7bbab9a0c59 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -1458,6 +1458,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
|
||||
@Override
|
||||
public void updateNeighborsAt(BlockPos pos, Block sourceBlock) {
|
||||
+ if (captureBlockStates) { return; } // Paper - Cancel all physics during placement
|
||||
this.neighborUpdater.updateNeighborsAtExceptFromFacing(pos, sourceBlock, (Direction) null);
|
||||
}
|
||||
|
118
patches/unapplied/server/0086-Optimize-DataBits.patch
Normal file
118
patches/unapplied/server/0086-Optimize-DataBits.patch
Normal file
|
@ -0,0 +1,118 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Tue, 5 Apr 2016 21:38:58 -0400
|
||||
Subject: [PATCH] Optimize DataBits
|
||||
|
||||
Remove Debug checks as these are super hot and causing noticeable hits
|
||||
|
||||
Before: http://i.imgur.com/nQsMzAE.png
|
||||
After: http://i.imgur.com/nJ46crB.png
|
||||
|
||||
Optimize redundant converting of static fields into an unsigned long each call by precomputing it in ctor
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/util/SimpleBitStorage.java b/src/main/java/net/minecraft/util/SimpleBitStorage.java
|
||||
index c8ae9d25eedb7cb2d9f95b799a507727b655f11f..9b81ce9d85cba07e9752c29fb5a842c4b00aa873 100644
|
||||
--- a/src/main/java/net/minecraft/util/SimpleBitStorage.java
|
||||
+++ b/src/main/java/net/minecraft/util/SimpleBitStorage.java
|
||||
@@ -11,8 +11,8 @@ public class SimpleBitStorage implements BitStorage {
|
||||
private final long mask;
|
||||
private final int size;
|
||||
private final int valuesPerLong;
|
||||
- private final int divideMul;
|
||||
- private final int divideAdd;
|
||||
+ private final int divideMul; private final long divideMulUnsigned; // Paper - referenced in b(int) with 2 Integer.toUnsignedLong calls
|
||||
+ private final int divideAdd; private final long divideAddUnsigned; // Paper
|
||||
private final int divideShift;
|
||||
|
||||
public SimpleBitStorage(int elementBits, int size, int[] data) {
|
||||
@@ -56,8 +56,8 @@ public class SimpleBitStorage implements BitStorage {
|
||||
this.mask = (1L << elementBits) - 1L;
|
||||
this.valuesPerLong = (char)(64 / elementBits);
|
||||
int i = 3 * (this.valuesPerLong - 1);
|
||||
- this.divideMul = MAGIC[i + 0];
|
||||
- this.divideAdd = MAGIC[i + 1];
|
||||
+ this.divideMul = MAGIC[i + 0]; this.divideMulUnsigned = Integer.toUnsignedLong(this.divideMul); // Paper
|
||||
+ this.divideAdd = MAGIC[i + 1]; this.divideAddUnsigned = Integer.toUnsignedLong(this.divideAdd); // Paper
|
||||
this.divideShift = MAGIC[i + 2];
|
||||
int j = (size + this.valuesPerLong - 1) / this.valuesPerLong;
|
||||
if (data != null) {
|
||||
@@ -73,15 +73,15 @@ public class SimpleBitStorage implements BitStorage {
|
||||
}
|
||||
|
||||
private int cellIndex(int index) {
|
||||
- long l = Integer.toUnsignedLong(this.divideMul);
|
||||
- long m = Integer.toUnsignedLong(this.divideAdd);
|
||||
- return (int)((long)index * l + m >> 32 >> this.divideShift);
|
||||
+ //long l = Integer.toUnsignedLong(this.divideMul); // Paper
|
||||
+ //long m = Integer.toUnsignedLong(this.divideAdd); // Paper
|
||||
+ return (int) ((long) index * this.divideMulUnsigned + this.divideAddUnsigned >> 32 >> this.divideShift); // Paper
|
||||
}
|
||||
|
||||
@Override
|
||||
- public int getAndSet(int index, int value) {
|
||||
- Validate.inclusiveBetween(0L, (long)(this.size - 1), (long)index);
|
||||
- Validate.inclusiveBetween(0L, this.mask, (long)value);
|
||||
+ public final int getAndSet(int index, int value) { // Paper - make final for inline
|
||||
+ //Validate.inclusiveBetween(0L, (long)(this.size - 1), (long)index); // Paper
|
||||
+ //Validate.inclusiveBetween(0L, this.mask, (long)value); // Paper
|
||||
int i = this.cellIndex(index);
|
||||
long l = this.data[i];
|
||||
int j = (index - i * this.valuesPerLong) * this.bits;
|
||||
@@ -91,9 +91,9 @@ public class SimpleBitStorage implements BitStorage {
|
||||
}
|
||||
|
||||
@Override
|
||||
- public void set(int index, int value) {
|
||||
- Validate.inclusiveBetween(0L, (long)(this.size - 1), (long)index);
|
||||
- Validate.inclusiveBetween(0L, this.mask, (long)value);
|
||||
+ public final void set(int index, int value) { // Paper - make final for inline
|
||||
+ //Validate.inclusiveBetween(0L, (long)(this.size - 1), (long)index); // Paper
|
||||
+ //Validate.inclusiveBetween(0L, this.mask, (long)value); // Paper
|
||||
int i = this.cellIndex(index);
|
||||
long l = this.data[i];
|
||||
int j = (index - i * this.valuesPerLong) * this.bits;
|
||||
@@ -101,8 +101,8 @@ public class SimpleBitStorage implements BitStorage {
|
||||
}
|
||||
|
||||
@Override
|
||||
- public int get(int index) {
|
||||
- Validate.inclusiveBetween(0L, (long)(this.size - 1), (long)index);
|
||||
+ public final int get(int index) { // Paper - make final for inline
|
||||
+ //Validate.inclusiveBetween(0L, (long)(this.size - 1), (long)index);
|
||||
int i = this.cellIndex(index);
|
||||
long l = this.data[i];
|
||||
int j = (index - i * this.valuesPerLong) * this.bits;
|
||||
diff --git a/src/main/java/net/minecraft/util/ZeroBitStorage.java b/src/main/java/net/minecraft/util/ZeroBitStorage.java
|
||||
index 172e7a0761724cc802387e613258830a0defb04a..9686ce7536c9924b1b2aced4f013f46759cbc72e 100644
|
||||
--- a/src/main/java/net/minecraft/util/ZeroBitStorage.java
|
||||
+++ b/src/main/java/net/minecraft/util/ZeroBitStorage.java
|
||||
@@ -13,21 +13,21 @@ public class ZeroBitStorage implements BitStorage {
|
||||
}
|
||||
|
||||
@Override
|
||||
- public int getAndSet(int index, int value) {
|
||||
- Validate.inclusiveBetween(0L, (long)(this.size - 1), (long)index);
|
||||
- Validate.inclusiveBetween(0L, 0L, (long)value);
|
||||
+ public final int getAndSet(int index, int value) { // Paper - make final for inline
|
||||
+ //Validate.inclusiveBetween(0L, (long)(this.size - 1), (long)index); // Paper
|
||||
+ //Validate.inclusiveBetween(0L, 0L, (long)value); // Paper
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
- public void set(int index, int value) {
|
||||
- Validate.inclusiveBetween(0L, (long)(this.size - 1), (long)index);
|
||||
- Validate.inclusiveBetween(0L, 0L, (long)value);
|
||||
+ public final void set(int index, int value) { // Paper - make final for inline
|
||||
+ //Validate.inclusiveBetween(0L, (long)(this.size - 1), (long)index); // Paper
|
||||
+ //Validate.inclusiveBetween(0L, 0L, (long)value); // Paper
|
||||
}
|
||||
|
||||
@Override
|
||||
- public int get(int index) {
|
||||
- Validate.inclusiveBetween(0L, (long)(this.size - 1), (long)index);
|
||||
+ public final int get(int index) { // Paper - make final for inline
|
||||
+ //Validate.inclusiveBetween(0L, (long)(this.size - 1), (long)index); // Paper
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Zach Brown <zach.brown@destroystokyo.com>
|
||||
Date: Wed, 6 Apr 2016 01:04:23 -0500
|
||||
Subject: [PATCH] Option to use vanilla per-world scoreboard coloring on names
|
||||
|
||||
This change is basically a bandaid to fix CB's complete and utter lack
|
||||
of support for vanilla scoreboard name modifications.
|
||||
|
||||
In the future, finding a way to merge the vanilla expectations in with
|
||||
bukkit's concept of a display name would be preferable. There was a PR
|
||||
for this on CB at one point but I can't find it. We may need to do this
|
||||
ourselves at some point in the future.
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/adventure/ChatProcessor.java b/src/main/java/io/papermc/paper/adventure/ChatProcessor.java
|
||||
index e7bcc08e3d3fe0ecb97e65cb2c32582750e22c28..309fe1162db195c7c3c94d785d6aa2700e42b08a 100644
|
||||
--- a/src/main/java/io/papermc/paper/adventure/ChatProcessor.java
|
||||
+++ b/src/main/java/io/papermc/paper/adventure/ChatProcessor.java
|
||||
@@ -28,7 +28,9 @@ import net.minecraft.network.chat.PlayerChatMessage;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
+import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
+import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.util.LazyPlayerSet;
|
||||
import org.bukkit.craftbukkit.util.Waitable;
|
||||
@@ -364,10 +366,16 @@ public final class ChatProcessor {
|
||||
}
|
||||
|
||||
static String legacyDisplayName(final CraftPlayer player) {
|
||||
+ if (((org.bukkit.craftbukkit.CraftWorld) player.getWorld()).getHandle().paperConfig().scoreboards.useVanillaWorldScoreboardNameColoring) {
|
||||
+ return legacySection().serialize(player.teamDisplayName()) + ChatColor.RESET;
|
||||
+ }
|
||||
return player.getDisplayName();
|
||||
}
|
||||
|
||||
static Component displayName(final CraftPlayer player) {
|
||||
+ if (((CraftWorld) player.getWorld()).getHandle().paperConfig().scoreboards.useVanillaWorldScoreboardNameColoring) {
|
||||
+ return player.teamDisplayName();
|
||||
+ }
|
||||
return player.displayName();
|
||||
}
|
||||
|
|
@ -0,0 +1,109 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Wed, 13 Apr 2016 02:10:49 -0400
|
||||
Subject: [PATCH] Configurable Player Collision
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundSetPlayerTeamPacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundSetPlayerTeamPacket.java
|
||||
index 1294b38262505b0d54089e428df9b363219de1f0..ee37ec0de1ca969144824427ae42b0c81434a1b4 100644
|
||||
--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundSetPlayerTeamPacket.java
|
||||
+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundSetPlayerTeamPacket.java
|
||||
@@ -193,7 +193,7 @@ public class ClientboundSetPlayerTeamPacket implements Packet<ClientGamePacketLi
|
||||
buf.writeComponent(this.displayName);
|
||||
buf.writeByte(this.options);
|
||||
buf.writeUtf(this.nametagVisibility);
|
||||
- buf.writeUtf(this.collisionRule);
|
||||
+ buf.writeUtf(!io.papermc.paper.configuration.GlobalConfiguration.get().collisions.enablePlayerCollisions ? "never" : this.collisionRule); // Paper
|
||||
buf.writeEnum(this.color);
|
||||
buf.writeComponent(this.playerPrefix);
|
||||
buf.writeComponent(this.playerSuffix);
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index e62aa86afb05d8f00d8dd2b676407bfa7d0ed9fb..aab7ea2bbc9066b206b15cceb4db49aa230ebafd 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -586,6 +586,20 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
this.server.getPluginManager().callEvent(new org.bukkit.event.world.WorldLoadEvent(worldserver.getWorld()));
|
||||
}
|
||||
|
||||
+ // Paper start - Handle collideRule team for player collision toggle
|
||||
+ final ServerScoreboard scoreboard = this.getScoreboard();
|
||||
+ final java.util.Collection<String> toRemove = scoreboard.getPlayerTeams().stream().filter(team -> team.getName().startsWith("collideRule_")).map(net.minecraft.world.scores.PlayerTeam::getName).collect(java.util.stream.Collectors.toList());
|
||||
+ for (String teamName : toRemove) {
|
||||
+ scoreboard.removePlayerTeam(scoreboard.getPlayerTeam(teamName)); // Clean up after ourselves
|
||||
+ }
|
||||
+
|
||||
+ if (!io.papermc.paper.configuration.GlobalConfiguration.get().collisions.enablePlayerCollisions) {
|
||||
+ this.getPlayerList().collideRuleTeamName = org.apache.commons.lang3.StringUtils.left("collideRule_" + java.util.concurrent.ThreadLocalRandom.current().nextInt(), 16);
|
||||
+ net.minecraft.world.scores.PlayerTeam collideTeam = scoreboard.addPlayerTeam(this.getPlayerList().collideRuleTeamName);
|
||||
+ collideTeam.setSeeFriendlyInvisibles(false); // Because we want to mimic them not being on a team at all
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
this.server.enablePlugins(org.bukkit.plugin.PluginLoadOrder.POSTWORLD);
|
||||
this.server.getPluginManager().callEvent(new ServerLoadEvent(ServerLoadEvent.LoadType.STARTUP));
|
||||
this.connection.acceptConnections();
|
||||
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
index ea766e18fb19dbb78e07357748bbf83095253275..e39619717f089162e2e3bf12cd00eb390a59c4bf 100644
|
||||
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
@@ -98,6 +98,7 @@ import net.minecraft.world.level.storage.PlayerDataStorage;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraft.world.scores.Objective;
|
||||
import net.minecraft.world.scores.PlayerTeam;
|
||||
+import net.minecraft.world.scores.Scoreboard; // Paper
|
||||
import net.minecraft.world.scores.Team;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
@@ -160,6 +161,7 @@ public abstract class PlayerList {
|
||||
// CraftBukkit start
|
||||
private CraftServer cserver;
|
||||
private final Map<String,ServerPlayer> playersByName = new java.util.HashMap<>();
|
||||
+ public @Nullable String collideRuleTeamName; // Paper - Team name used for collideRule
|
||||
|
||||
public PlayerList(MinecraftServer server, LayeredRegistryAccess<RegistryLayer> registryManager, PlayerDataStorage saveHandler, int maxPlayers) {
|
||||
this.cserver = server.server = new CraftServer((DedicatedServer) server, this);
|
||||
@@ -399,6 +401,13 @@ public abstract class PlayerList {
|
||||
|
||||
player.initInventoryMenu();
|
||||
// CraftBukkit - Moved from above, added world
|
||||
+ // Paper start - Add to collideRule team if needed
|
||||
+ final Scoreboard scoreboard = this.getServer().getLevel(Level.OVERWORLD).getScoreboard();
|
||||
+ final PlayerTeam collideRuleTeam = scoreboard.getPlayerTeam(this.collideRuleTeamName);
|
||||
+ if (this.collideRuleTeamName != null && collideRuleTeam != null && player.getTeam() == null) {
|
||||
+ scoreboard.addPlayerToTeam(player.getScoreboardName(), collideRuleTeam);
|
||||
+ }
|
||||
+ // Paper end
|
||||
PlayerList.LOGGER.info("{}[{}] logged in with entity id {} at ([{}]{}, {}, {})", player.getName().getString(), s1, player.getId(), worldserver1.serverLevelData.getLevelName(), player.getX(), player.getY(), player.getZ());
|
||||
}
|
||||
|
||||
@@ -518,6 +527,16 @@ public abstract class PlayerList {
|
||||
entityplayer.doTick(); // SPIGOT-924
|
||||
// CraftBukkit end
|
||||
|
||||
+ // Paper start - Remove from collideRule team if needed
|
||||
+ if (this.collideRuleTeamName != null) {
|
||||
+ final Scoreboard scoreBoard = this.server.getLevel(Level.OVERWORLD).getScoreboard();
|
||||
+ final PlayerTeam team = scoreBoard.getPlayersTeam(this.collideRuleTeamName);
|
||||
+ if (entityplayer.getTeam() == team && team != null) {
|
||||
+ scoreBoard.removePlayerFromTeam(entityplayer.getScoreboardName(), team);
|
||||
+ }
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
this.save(entityplayer);
|
||||
if (entityplayer.isPassenger()) {
|
||||
Entity entity = entityplayer.getRootVehicle();
|
||||
@@ -1149,6 +1168,13 @@ public abstract class PlayerList {
|
||||
}
|
||||
// CraftBukkit end
|
||||
|
||||
+ // Paper start - Remove collideRule team if it exists
|
||||
+ if (this.collideRuleTeamName != null) {
|
||||
+ final Scoreboard scoreboard = this.getServer().getLevel(Level.OVERWORLD).getScoreboard();
|
||||
+ final PlayerTeam team = scoreboard.getPlayersTeam(this.collideRuleTeamName);
|
||||
+ if (team != null) scoreboard.removePlayerTeam(team);
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
||||
|
||||
// CraftBukkit start
|
|
@ -0,0 +1,49 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: kashike <kashike@vq.lc>
|
||||
Date: Wed, 13 Apr 2016 20:21:38 -0700
|
||||
Subject: [PATCH] Add handshake event to allow plugins to handle client
|
||||
handshaking logic themselves
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java
|
||||
index 5948138f3697c0cce9638524a0f481eb368da911..8284d49c8e30645d00be952c847bab7ce5753d78 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java
|
||||
@@ -88,9 +88,36 @@ public class ServerHandshakePacketListenerImpl implements ServerHandshakePacketL
|
||||
this.connection.disconnect(ichatmutablecomponent);
|
||||
} else {
|
||||
this.connection.setListener(new ServerLoginPacketListenerImpl(this.server, this.connection));
|
||||
+ // Paper start - handshake event
|
||||
+ boolean proxyLogicEnabled = org.spigotmc.SpigotConfig.bungee;
|
||||
+ boolean handledByEvent = false;
|
||||
+ // Try and handle the handshake through the event
|
||||
+ if (com.destroystokyo.paper.event.player.PlayerHandshakeEvent.getHandlerList().getRegisteredListeners().length != 0) { // Hello? Can you hear me?
|
||||
+ java.net.SocketAddress socketAddress = this.connection.address;
|
||||
+ String hostnameOfRemote = socketAddress instanceof java.net.InetSocketAddress ? ((java.net.InetSocketAddress) socketAddress).getHostString() : InetAddress.getLoopbackAddress().getHostAddress();
|
||||
+ com.destroystokyo.paper.event.player.PlayerHandshakeEvent event = new com.destroystokyo.paper.event.player.PlayerHandshakeEvent(packet.hostName, hostnameOfRemote, !proxyLogicEnabled);
|
||||
+ if (event.callEvent()) {
|
||||
+ // If we've failed somehow, let the client know so and go no further.
|
||||
+ if (event.isFailed()) {
|
||||
+ Component component = io.papermc.paper.adventure.PaperAdventure.asVanilla(event.failMessage());
|
||||
+ this.connection.send(new ClientboundLoginDisconnectPacket(component));
|
||||
+ this.connection.disconnect(component);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ if (event.getServerHostname() != null) packet.hostName = event.getServerHostname();
|
||||
+ if (event.getSocketAddressHostname() != null) this.connection.address = new java.net.InetSocketAddress(event.getSocketAddressHostname(), socketAddress instanceof java.net.InetSocketAddress ? ((java.net.InetSocketAddress) socketAddress).getPort() : 0);
|
||||
+ this.connection.spoofedUUID = event.getUniqueId();
|
||||
+ this.connection.spoofedProfile = gson.fromJson(event.getPropertiesJson(), com.mojang.authlib.properties.Property[].class);
|
||||
+ handledByEvent = true; // Hooray, we did it!
|
||||
+ }
|
||||
+ }
|
||||
// Spigot Start
|
||||
String[] split = packet.hostName.split("\00");
|
||||
- if (org.spigotmc.SpigotConfig.bungee) {
|
||||
+ // Don't try and handle default logic if it's been handled by the event.
|
||||
+ if (!handledByEvent && proxyLogicEnabled) {
|
||||
+ // Paper end
|
||||
+ // if (org.spigotmc.SpigotConfig.bungee) { // Paper - comment out, we check above!
|
||||
if ( ( split.length == 3 || split.length == 4 ) && ( ServerHandshakePacketListenerImpl.HOST_PATTERN.matcher( split[1] ).matches() ) ) {
|
||||
packet.hostName = split[0];
|
||||
connection.address = new java.net.InetSocketAddress(split[1], ((java.net.InetSocketAddress) this.connection.getRemoteAddress()).getPort());
|
|
@ -0,0 +1,47 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Sat, 16 Apr 2016 00:39:33 -0400
|
||||
Subject: [PATCH] Configurable RCON IP address
|
||||
|
||||
For servers with multiple IP's, ability to bind to a specific interface.
|
||||
|
||||
== AT ==
|
||||
public net.minecraft.server.dedicated.Settings getStringRaw(Ljava/lang/String;)Ljava/lang/String;
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java
|
||||
index 666dc4b22569e1ae26ff988c7d4ac1113acd32f3..e72fb5c548a9baef09ae547863c4bdc439ce28b2 100644
|
||||
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java
|
||||
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java
|
||||
@@ -108,6 +108,8 @@ public class DedicatedServerProperties extends Settings<DedicatedServerPropertie
|
||||
private final DedicatedServerProperties.WorldDimensionData worldDimensionData;
|
||||
public final WorldOptions worldOptions;
|
||||
|
||||
+ public final String rconIp; // Paper - Add rcon ip
|
||||
+
|
||||
// CraftBukkit start
|
||||
public DedicatedServerProperties(Properties properties, OptionSet optionset) {
|
||||
super(properties, optionset);
|
||||
@@ -165,6 +167,10 @@ public class DedicatedServerProperties extends Settings<DedicatedServerPropertie
|
||||
}, WorldPresets.NORMAL.location().toString()));
|
||||
this.serverResourcePackInfo = DedicatedServerProperties.getServerPackInfo(this.get("resource-pack", ""), this.get("resource-pack-sha1", ""), this.getLegacyString("resource-pack-hash"), this.get("require-resource-pack", false), this.get("resource-pack-prompt", ""));
|
||||
this.initialDataPackConfiguration = DedicatedServerProperties.getDatapackConfig(this.get("initial-enabled-packs", String.join(",", WorldDataConfiguration.DEFAULT.dataPacks().getEnabled())), this.get("initial-disabled-packs", String.join(",", WorldDataConfiguration.DEFAULT.dataPacks().getDisabled())));
|
||||
+ // Paper start - Configurable rcon ip
|
||||
+ final String rconIp = this.getStringRaw("rcon.ip");
|
||||
+ this.rconIp = rconIp == null ? this.serverIp : rconIp;
|
||||
+ // Paper end
|
||||
}
|
||||
|
||||
// CraftBukkit start
|
||||
diff --git a/src/main/java/net/minecraft/server/rcon/thread/RconThread.java b/src/main/java/net/minecraft/server/rcon/thread/RconThread.java
|
||||
index cb61eaf8447c8340c4b4e1079c0a6aecd41a6116..3bf60f640aa9fa4cabd2b3e5d3931e8467b9df24 100644
|
||||
--- a/src/main/java/net/minecraft/server/rcon/thread/RconThread.java
|
||||
+++ b/src/main/java/net/minecraft/server/rcon/thread/RconThread.java
|
||||
@@ -60,7 +60,7 @@ public class RconThread extends GenericThread {
|
||||
@Nullable
|
||||
public static RconThread create(ServerInterface server) {
|
||||
DedicatedServerProperties dedicatedServerProperties = server.getProperties();
|
||||
- String string = server.getServerIp();
|
||||
+ String string = dedicatedServerProperties.rconIp; // Paper - Configurable rcon ip
|
||||
if (string.isEmpty()) {
|
||||
string = "0.0.0.0";
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Zach Brown <zach.brown@destroystokyo.com>
|
||||
Date: Fri, 22 Apr 2016 01:43:11 -0500
|
||||
Subject: [PATCH] EntityRegainHealthEvent isFastRegen API
|
||||
|
||||
Don't even get me started
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
index b2871726eb4dd7f16d161097cbf0f287839e10ba..16ec3763e6d13a2dd3e1cc8cd898c6d783ac070c 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -1249,10 +1249,16 @@ public abstract class LivingEntity extends Entity {
|
||||
}
|
||||
|
||||
public void heal(float f, EntityRegainHealthEvent.RegainReason regainReason) {
|
||||
+ // Paper start - Forward
|
||||
+ heal(f, regainReason, false);
|
||||
+ }
|
||||
+
|
||||
+ public void heal(float f, EntityRegainHealthEvent.RegainReason regainReason, boolean isFastRegen) {
|
||||
+ // Paper end
|
||||
float f1 = this.getHealth();
|
||||
|
||||
if (f1 > 0.0F) {
|
||||
- EntityRegainHealthEvent event = new EntityRegainHealthEvent(this.getBukkitEntity(), f, regainReason);
|
||||
+ EntityRegainHealthEvent event = new EntityRegainHealthEvent(this.getBukkitEntity(), f, regainReason, isFastRegen); // Paper
|
||||
// Suppress during worldgen
|
||||
if (this.valid) {
|
||||
this.level.getCraftServer().getPluginManager().callEvent(event);
|
||||
diff --git a/src/main/java/net/minecraft/world/food/FoodData.java b/src/main/java/net/minecraft/world/food/FoodData.java
|
||||
index ae323c786b5a0d61d9292469baa50a3ad8e4ccff..2934b6de1f1fb914a532ee20184df99d1acd8e65 100644
|
||||
--- a/src/main/java/net/minecraft/world/food/FoodData.java
|
||||
+++ b/src/main/java/net/minecraft/world/food/FoodData.java
|
||||
@@ -84,7 +84,7 @@ public class FoodData {
|
||||
if (this.tickTimer >= this.saturatedRegenRate) { // CraftBukkit
|
||||
float f = Math.min(this.saturationLevel, 6.0F);
|
||||
|
||||
- player.heal(f / 6.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.SATIATED); // CraftBukkit - added RegainReason
|
||||
+ player.heal(f / 6.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.SATIATED, true); // CraftBukkit - added RegainReason // Paper - This is fast regen
|
||||
// this.addExhaustion(f); CraftBukkit - EntityExhaustionEvent
|
||||
player.causeFoodExhaustion(f, org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.REGEN); // CraftBukkit - EntityExhaustionEvent
|
||||
this.tickTimer = 0;
|
|
@ -0,0 +1,33 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: kashike <kashike@vq.lc>
|
||||
Date: Thu, 21 Apr 2016 23:51:55 -0700
|
||||
Subject: [PATCH] Add ability to configure frosted_ice properties
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/FrostedIceBlock.java b/src/main/java/net/minecraft/world/level/block/FrostedIceBlock.java
|
||||
index e1916fe8a7aa736d9266efde954bbfbda38a3a65..331b642c36af97f7f05bd63f96d42d1af443e5a3 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/FrostedIceBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/FrostedIceBlock.java
|
||||
@@ -32,6 +32,7 @@ public class FrostedIceBlock extends IceBlock {
|
||||
|
||||
@Override
|
||||
public void tick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) {
|
||||
+ if (!world.paperConfig().environment.frostedIce.enabled) return; // Paper - add ability to disable frosted ice
|
||||
if ((random.nextInt(3) == 0 || this.fewerNeigboursThan(world, pos, 4)) && world.getMaxLocalRawBrightness(pos) > 11 - state.getValue(AGE) - state.getLightBlock(world, pos) && this.slightlyMelt(state, world, pos)) {
|
||||
BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos();
|
||||
|
||||
@@ -39,12 +40,12 @@ public class FrostedIceBlock extends IceBlock {
|
||||
mutableBlockPos.setWithOffset(pos, direction);
|
||||
BlockState blockState = world.getBlockState(mutableBlockPos);
|
||||
if (blockState.is(this) && !this.slightlyMelt(blockState, world, mutableBlockPos)) {
|
||||
- world.scheduleTick(mutableBlockPos, this, Mth.nextInt(random, 20, 40));
|
||||
+ world.scheduleTick(mutableBlockPos, this, Mth.nextInt(random, world.paperConfig().environment.frostedIce.delay.min, world.paperConfig().environment.frostedIce.delay.max)); // Paper - use configurable min/max delay
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
- world.scheduleTick(pos, this, Mth.nextInt(random, 20, 40));
|
||||
+ world.scheduleTick(pos, this, Mth.nextInt(random, world.paperConfig().environment.frostedIce.delay.min, world.paperConfig().environment.frostedIce.delay.max)); // Paper - use configurable min/max delay
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Thu, 28 Apr 2016 00:57:27 -0400
|
||||
Subject: [PATCH] remove null possibility for getServer singleton
|
||||
|
||||
to stop IDE complaining about potential NPE
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index aab7ea2bbc9066b206b15cceb4db49aa230ebafd..3ed50490121f34ab5b247565b9a4555bf6a46dff 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -193,6 +193,7 @@ import co.aikar.timings.MinecraftTimings; // Paper
|
||||
|
||||
public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTask> implements CommandSource, AutoCloseable {
|
||||
|
||||
+ private static MinecraftServer SERVER; // Paper
|
||||
public static final Logger LOGGER = LogUtils.getLogger();
|
||||
public static final String VANILLA_BRAND = "vanilla";
|
||||
private static final float AVERAGE_TICK_TIME_SMOOTHING = 0.8F;
|
||||
@@ -318,6 +319,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
|
||||
public MinecraftServer(OptionSet options, WorldLoader.DataLoadContext worldLoader, Thread thread, LevelStorageSource.LevelStorageAccess convertable_conversionsession, PackRepository resourcepackrepository, WorldStem worldstem, Proxy proxy, DataFixer datafixer, Services services, ChunkProgressListenerFactory worldloadlistenerfactory) {
|
||||
super("Server");
|
||||
+ SERVER = this; // Paper - better singleton
|
||||
this.metricsRecorder = InactiveMetricsRecorder.INSTANCE;
|
||||
this.profiler = this.metricsRecorder.getProfiler();
|
||||
this.onMetricsRecordingStopped = (methodprofilerresults) -> {
|
||||
@@ -2304,9 +2306,8 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
return false;
|
||||
}
|
||||
|
||||
- @Deprecated
|
||||
public static MinecraftServer getServer() {
|
||||
- return (Bukkit.getServer() instanceof CraftServer) ? ((CraftServer) Bukkit.getServer()).getServer() : null;
|
||||
+ return SERVER; // Paper
|
||||
}
|
||||
// CraftBukkit end
|
||||
|
|
@ -0,0 +1,128 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Fri, 29 Apr 2016 20:02:00 -0400
|
||||
Subject: [PATCH] Improve Maps (in item frames) performance and bug fixes
|
||||
|
||||
Maps used a modified version of rendering to support plugin controlled
|
||||
imaging on maps. The Craft Map Renderer is much slower than Vanilla,
|
||||
causing maps in item frames to cause a noticeable hit on server performance.
|
||||
|
||||
This updates the map system to not use the Craft system if we detect that no
|
||||
custom renderers are in use, defaulting to the much simpler Vanilla system.
|
||||
|
||||
Additionally, numerous issues to player position tracking on maps has been fixed.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
index 0d08690aade0e3334c583b62e0abf7bbab9a0c59..349a9f4596cd1411ec3a69cd7d6f5414971b74ef 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -2246,6 +2246,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
{
|
||||
if ( iter.next().player == entity )
|
||||
{
|
||||
+ map.decorations.remove(entity.getName().getString()); // Paper
|
||||
iter.remove();
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java
|
||||
index 60fb74537fdc96005cbf6aa1670e773c0faa2f26..7322c15921e05aaf0dafed89e1d90f2748efb2a9 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/player/Player.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java
|
||||
@@ -758,6 +758,14 @@ public abstract class Player extends LivingEntity {
|
||||
return null;
|
||||
}
|
||||
// CraftBukkit end
|
||||
+ // Paper start - remove player from map on drop
|
||||
+ if (itemstack.getItem() == Items.FILLED_MAP) {
|
||||
+ net.minecraft.world.level.saveddata.maps.MapItemSavedData worldmap = net.minecraft.world.item.MapItem.getSavedData(itemstack, this.level);
|
||||
+ if (worldmap != null) {
|
||||
+ worldmap.tickCarriedBy(this, itemstack);
|
||||
+ }
|
||||
+ }
|
||||
+ // Paper end
|
||||
|
||||
return entityitem;
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java b/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java
|
||||
index 1fd305ccedfd311dc5238810003889b2c1897089..984da6264cdaf57a49a15861b9ce834a9efac1a7 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java
|
||||
@@ -63,6 +63,7 @@ public class MapItemSavedData extends SavedData {
|
||||
public final Map<String, MapDecoration> decorations = Maps.newLinkedHashMap();
|
||||
private final Map<String, MapFrame> frameMarkers = Maps.newHashMap();
|
||||
private int trackedDecorationCount;
|
||||
+ private org.bukkit.craftbukkit.map.RenderData vanillaRender = new org.bukkit.craftbukkit.map.RenderData(); // Paper
|
||||
|
||||
// CraftBukkit start
|
||||
public final CraftMapView mapView;
|
||||
@@ -83,6 +84,7 @@ public class MapItemSavedData extends SavedData {
|
||||
// CraftBukkit start
|
||||
this.mapView = new CraftMapView(this);
|
||||
this.server = (CraftServer) org.bukkit.Bukkit.getServer();
|
||||
+ this.vanillaRender.buffer = colors; // Paper
|
||||
// CraftBukkit end
|
||||
}
|
||||
|
||||
@@ -138,6 +140,7 @@ public class MapItemSavedData extends SavedData {
|
||||
if (abyte.length == 16384) {
|
||||
worldmap.colors = abyte;
|
||||
}
|
||||
+ worldmap.vanillaRender.buffer = abyte; // Paper
|
||||
|
||||
ListTag nbttaglist = nbt.getList("banners", 10);
|
||||
|
||||
@@ -548,6 +551,21 @@ public class MapItemSavedData extends SavedData {
|
||||
|
||||
public class HoldingPlayer {
|
||||
|
||||
+ // Paper start
|
||||
+ private void addSeenPlayers(java.util.Collection<MapDecoration> icons) {
|
||||
+ org.bukkit.entity.Player player = (org.bukkit.entity.Player) this.player.getBukkitEntity();
|
||||
+ MapItemSavedData.this.decorations.forEach((name, mapIcon) -> {
|
||||
+ // If this cursor is for a player check visibility with vanish system
|
||||
+ org.bukkit.entity.Player other = org.bukkit.Bukkit.getPlayerExact(name); // Spigot
|
||||
+ if (other == null || player.canSee(other)) {
|
||||
+ icons.add(mapIcon);
|
||||
+ }
|
||||
+ });
|
||||
+ }
|
||||
+ private boolean shouldUseVanillaMap() {
|
||||
+ return mapView.getRenderers().size() == 1 && mapView.getRenderers().get(0).getClass() == org.bukkit.craftbukkit.map.CraftMapRenderer.class;
|
||||
+ }
|
||||
+ // Paper end
|
||||
public final Player player;
|
||||
private boolean dirtyData = true;
|
||||
private int minDirtyX;
|
||||
@@ -581,7 +599,9 @@ public class MapItemSavedData extends SavedData {
|
||||
@Nullable
|
||||
Packet<?> nextUpdatePacket(int mapId) {
|
||||
MapItemSavedData.MapPatch worldmap_b;
|
||||
- org.bukkit.craftbukkit.map.RenderData render = MapItemSavedData.this.mapView.render((org.bukkit.craftbukkit.entity.CraftPlayer) this.player.getBukkitEntity()); // CraftBukkit
|
||||
+ if (!this.dirtyData && this.tick % 5 != 0) { this.tick++; return null; } // Paper - this won't end up sending, so don't render it!
|
||||
+ boolean vanillaMaps = shouldUseVanillaMap(); // Paper
|
||||
+ org.bukkit.craftbukkit.map.RenderData render = !vanillaMaps ? MapItemSavedData.this.mapView.render((org.bukkit.craftbukkit.entity.CraftPlayer) this.player.getBukkitEntity()) : MapItemSavedData.this.vanillaRender; // CraftBukkit // Paper
|
||||
|
||||
if (this.dirtyData) {
|
||||
this.dirtyData = false;
|
||||
@@ -597,6 +617,8 @@ public class MapItemSavedData extends SavedData {
|
||||
// CraftBukkit start
|
||||
java.util.Collection<MapDecoration> icons = new java.util.ArrayList<MapDecoration>();
|
||||
|
||||
+ if (vanillaMaps) addSeenPlayers(icons); // Paper
|
||||
+
|
||||
for (org.bukkit.map.MapCursor cursor : render.cursors) {
|
||||
if (cursor.isVisible()) {
|
||||
icons.add(new MapDecoration(MapDecoration.Type.byIcon(cursor.getRawType()), cursor.getX(), cursor.getY(), cursor.getDirection(), PaperAdventure.asVanilla(cursor.caption()))); // Paper - Adventure
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/map/RenderData.java b/src/main/java/org/bukkit/craftbukkit/map/RenderData.java
|
||||
index 256a131781721c86dd6cdbc329335964570cbe8c..5768cd512ec166f1e8d1f4a28792015347297c3f 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/map/RenderData.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/map/RenderData.java
|
||||
@@ -5,7 +5,7 @@ import org.bukkit.map.MapCursor;
|
||||
|
||||
public class RenderData {
|
||||
|
||||
- public final byte[] buffer;
|
||||
+ public byte[] buffer; // Paper
|
||||
public final ArrayList<MapCursor> cursors;
|
||||
|
||||
public RenderData() {
|
|
@ -0,0 +1,770 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Sun, 1 May 2016 21:19:14 -0400
|
||||
Subject: [PATCH] LootTable API & Replenishable Lootables Feature
|
||||
|
||||
Provides an API to control the loot table for an object.
|
||||
Also provides a feature that any Lootable Inventory (Chests in Structures)
|
||||
can automatically replenish after a given time.
|
||||
|
||||
This feature is good for long term worlds so that newer players
|
||||
do not suffer with "Every chest has been looted"
|
||||
|
||||
== AT ==
|
||||
public org.bukkit.craftbukkit.block.CraftBlockEntityState getTileEntity()Lnet/minecraft/world/level/block/entity/BlockEntity;
|
||||
public org.bukkit.craftbukkit.block.CraftLootable setLootTable(Lorg/bukkit/loot/LootTable;J)V
|
||||
public org.bukkit.craftbukkit.entity.CraftMinecartContainer setLootTable(Lorg/bukkit/loot/LootTable;J)V
|
||||
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/loottable/PaperContainerEntityLootableInventory.java b/src/main/java/com/destroystokyo/paper/loottable/PaperContainerEntityLootableInventory.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..88e32ed64f90bfd277dac84ba4bd84f0d943f5f8
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/com/destroystokyo/paper/loottable/PaperContainerEntityLootableInventory.java
|
||||
@@ -0,0 +1,63 @@
|
||||
+package com.destroystokyo.paper.loottable;
|
||||
+
|
||||
+import net.minecraft.world.entity.Entity;
|
||||
+import net.minecraft.world.entity.vehicle.AbstractMinecartContainer;
|
||||
+import net.minecraft.world.entity.vehicle.ContainerEntity;
|
||||
+import net.minecraft.world.level.Level;
|
||||
+import org.bukkit.Bukkit;
|
||||
+import org.bukkit.craftbukkit.util.CraftNamespacedKey;
|
||||
+
|
||||
+public class PaperContainerEntityLootableInventory implements PaperLootableEntityInventory {
|
||||
+
|
||||
+ private final ContainerEntity entity;
|
||||
+
|
||||
+ public PaperContainerEntityLootableInventory(ContainerEntity entity) {
|
||||
+ this.entity = entity;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public org.bukkit.loot.LootTable getLootTable() {
|
||||
+ return entity.getLootTable() != null ? Bukkit.getLootTable(CraftNamespacedKey.fromMinecraft(entity.getLootTable())) : null;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setLootTable(org.bukkit.loot.LootTable table, long seed) {
|
||||
+ setLootTable(table);
|
||||
+ setSeed(seed);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setSeed(long seed) {
|
||||
+ entity.setLootTableSeed(seed);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public long getSeed() {
|
||||
+ return entity.getLootTableSeed();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setLootTable(org.bukkit.loot.LootTable table) {
|
||||
+ entity.setLootTable((table == null) ? null : CraftNamespacedKey.toMinecraft(table.getKey()));
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public PaperLootableInventoryData getLootableData() {
|
||||
+ return entity.getLootableData();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public Entity getHandle() {
|
||||
+ return entity.getEntity();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public LootableInventory getAPILootableInventory() {
|
||||
+ return (LootableInventory) entity.getEntity().getBukkitEntity();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public Level getNMSWorld() {
|
||||
+ return entity.getLevel();
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/loottable/PaperLootableBlockInventory.java b/src/main/java/com/destroystokyo/paper/loottable/PaperLootableBlockInventory.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..70ca5625ff5d13a8e9cd64953066a7e1547ff223
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/com/destroystokyo/paper/loottable/PaperLootableBlockInventory.java
|
||||
@@ -0,0 +1,33 @@
|
||||
+package com.destroystokyo.paper.loottable;
|
||||
+
|
||||
+import net.minecraft.core.BlockPos;
|
||||
+import net.minecraft.world.level.Level;
|
||||
+import net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity;
|
||||
+import org.bukkit.Chunk;
|
||||
+import org.bukkit.block.Block;
|
||||
+
|
||||
+public interface PaperLootableBlockInventory extends LootableBlockInventory, PaperLootableInventory {
|
||||
+
|
||||
+ RandomizableContainerBlockEntity getTileEntity();
|
||||
+
|
||||
+ @Override
|
||||
+ default LootableInventory getAPILootableInventory() {
|
||||
+ return this;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ default Level getNMSWorld() {
|
||||
+ return getTileEntity().getLevel();
|
||||
+ }
|
||||
+
|
||||
+ default Block getBlock() {
|
||||
+ final BlockPos position = getTileEntity().getBlockPos();
|
||||
+ final Chunk bukkitChunk = getTileEntity().getLevel().getChunkAt(position).bukkitChunk;
|
||||
+ return bukkitChunk.getBlock(position.getX(), position.getY(), position.getZ());
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ default PaperLootableInventoryData getLootableData() {
|
||||
+ return getTileEntity().lootableData;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/loottable/PaperLootableEntityInventory.java b/src/main/java/com/destroystokyo/paper/loottable/PaperLootableEntityInventory.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..2fba5bc0f982e143ad5f5bda55d768edc5f847df
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/com/destroystokyo/paper/loottable/PaperLootableEntityInventory.java
|
||||
@@ -0,0 +1,28 @@
|
||||
+package com.destroystokyo.paper.loottable;
|
||||
+
|
||||
+import net.minecraft.world.level.Level;
|
||||
+import org.bukkit.entity.Entity;
|
||||
+
|
||||
+public interface PaperLootableEntityInventory extends LootableEntityInventory, PaperLootableInventory {
|
||||
+
|
||||
+ net.minecraft.world.entity.Entity getHandle();
|
||||
+
|
||||
+ @Override
|
||||
+ default LootableInventory getAPILootableInventory() {
|
||||
+ return this;
|
||||
+ }
|
||||
+
|
||||
+ default Entity getEntity() {
|
||||
+ return getHandle().getBukkitEntity();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ default Level getNMSWorld() {
|
||||
+ return getHandle().getCommandSenderWorld();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ default PaperLootableInventoryData getLootableData() {
|
||||
+ return getHandle().lootableData;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/loottable/PaperLootableInventory.java b/src/main/java/com/destroystokyo/paper/loottable/PaperLootableInventory.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..ce135d990c785b02df468391ea622aa236290f07
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/com/destroystokyo/paper/loottable/PaperLootableInventory.java
|
||||
@@ -0,0 +1,70 @@
|
||||
+package com.destroystokyo.paper.loottable;
|
||||
+
|
||||
+import org.bukkit.loot.Lootable;
|
||||
+import java.util.UUID;
|
||||
+import net.minecraft.world.level.Level;
|
||||
+
|
||||
+public interface PaperLootableInventory extends LootableInventory, Lootable {
|
||||
+
|
||||
+ PaperLootableInventoryData getLootableData();
|
||||
+ LootableInventory getAPILootableInventory();
|
||||
+
|
||||
+ Level getNMSWorld();
|
||||
+
|
||||
+ default org.bukkit.World getBukkitWorld() {
|
||||
+ return getNMSWorld().getWorld();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ default boolean isRefillEnabled() {
|
||||
+ return getNMSWorld().paperConfig().lootables.autoReplenish;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ default boolean hasBeenFilled() {
|
||||
+ return getLastFilled() != -1;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ default boolean hasPlayerLooted(UUID player) {
|
||||
+ return getLootableData().hasPlayerLooted(player);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ default Long getLastLooted(UUID player) {
|
||||
+ return getLootableData().getLastLooted(player);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ default boolean setHasPlayerLooted(UUID player, boolean looted) {
|
||||
+ final boolean hasLooted = hasPlayerLooted(player);
|
||||
+ if (hasLooted != looted) {
|
||||
+ getLootableData().setPlayerLootedState(player, looted);
|
||||
+ }
|
||||
+ return hasLooted;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ default boolean hasPendingRefill() {
|
||||
+ long nextRefill = getLootableData().getNextRefill();
|
||||
+ return nextRefill != -1 && nextRefill > getLootableData().getLastFill();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ default long getLastFilled() {
|
||||
+ return getLootableData().getLastFill();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ default long getNextRefill() {
|
||||
+ return getLootableData().getNextRefill();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ default long setNextRefill(long refillAt) {
|
||||
+ if (refillAt < -1) {
|
||||
+ refillAt = -1;
|
||||
+ }
|
||||
+ return getLootableData().setNextRefill(refillAt);
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/loottable/PaperLootableInventoryData.java b/src/main/java/com/destroystokyo/paper/loottable/PaperLootableInventoryData.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..e5ea9f27a1936ed9e329e74317c91c5df89b9fbd
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/com/destroystokyo/paper/loottable/PaperLootableInventoryData.java
|
||||
@@ -0,0 +1,179 @@
|
||||
+package com.destroystokyo.paper.loottable;
|
||||
+
|
||||
+import io.papermc.paper.configuration.WorldConfiguration;
|
||||
+import org.bukkit.entity.Player;
|
||||
+import org.bukkit.loot.LootTable;
|
||||
+import javax.annotation.Nullable;
|
||||
+import net.minecraft.nbt.CompoundTag;
|
||||
+import net.minecraft.nbt.ListTag;
|
||||
+import java.util.HashMap;
|
||||
+import java.util.Map;
|
||||
+import java.util.Random;
|
||||
+import java.util.UUID;
|
||||
+
|
||||
+public class PaperLootableInventoryData {
|
||||
+
|
||||
+ private static final Random RANDOM = new Random();
|
||||
+
|
||||
+ private long lastFill = -1;
|
||||
+ private long nextRefill = -1;
|
||||
+ private int numRefills = 0;
|
||||
+ private Map<UUID, Long> lootedPlayers;
|
||||
+ private final PaperLootableInventory lootable;
|
||||
+
|
||||
+ public PaperLootableInventoryData(PaperLootableInventory lootable) {
|
||||
+ this.lootable = lootable;
|
||||
+ }
|
||||
+
|
||||
+ long getLastFill() {
|
||||
+ return this.lastFill;
|
||||
+ }
|
||||
+
|
||||
+ long getNextRefill() {
|
||||
+ return this.nextRefill;
|
||||
+ }
|
||||
+
|
||||
+ long setNextRefill(long nextRefill) {
|
||||
+ long prev = this.nextRefill;
|
||||
+ this.nextRefill = nextRefill;
|
||||
+ return prev;
|
||||
+ }
|
||||
+
|
||||
+ public boolean shouldReplenish(@Nullable net.minecraft.world.entity.player.Player player) {
|
||||
+ LootTable table = this.lootable.getLootTable();
|
||||
+
|
||||
+ // No Loot Table associated
|
||||
+ if (table == null) {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ // ALWAYS process the first fill or if the feature is disabled
|
||||
+ if (this.lastFill == -1 || !this.lootable.getNMSWorld().paperConfig().lootables.autoReplenish) {
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ // Only process refills when a player is set
|
||||
+ if (player == null) {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ // Chest is not scheduled for refill
|
||||
+ if (this.nextRefill == -1) {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ final WorldConfiguration paperConfig = this.lootable.getNMSWorld().paperConfig();
|
||||
+
|
||||
+ // Check if max refills has been hit
|
||||
+ if (paperConfig.lootables.maxRefills != -1 && this.numRefills >= paperConfig.lootables.maxRefills) {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ // Refill has not been reached
|
||||
+ if (this.nextRefill > System.currentTimeMillis()) {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ final Player bukkitPlayer = (Player) player.getBukkitEntity();
|
||||
+ LootableInventoryReplenishEvent event = new LootableInventoryReplenishEvent(bukkitPlayer, lootable.getAPILootableInventory());
|
||||
+ if (paperConfig.lootables.restrictPlayerReloot && hasPlayerLooted(player.getUUID())) {
|
||||
+ event.setCancelled(true);
|
||||
+ }
|
||||
+ return event.callEvent();
|
||||
+ }
|
||||
+ public void processRefill(@Nullable net.minecraft.world.entity.player.Player player) {
|
||||
+ this.lastFill = System.currentTimeMillis();
|
||||
+ final WorldConfiguration paperConfig = this.lootable.getNMSWorld().paperConfig();
|
||||
+ if (paperConfig.lootables.autoReplenish) {
|
||||
+ long min = paperConfig.lootables.refreshMin.seconds();
|
||||
+ long max = paperConfig.lootables.refreshMax.seconds();
|
||||
+ this.nextRefill = this.lastFill + (min + RANDOM.nextLong(max - min + 1)) * 1000L;
|
||||
+ this.numRefills++;
|
||||
+ if (paperConfig.lootables.resetSeedOnFill) {
|
||||
+ this.lootable.setSeed(0);
|
||||
+ }
|
||||
+ if (player != null) { // This means that numRefills can be incremented without a player being in the lootedPlayers list - Seems to be EntityMinecartChest specific
|
||||
+ this.setPlayerLootedState(player.getUUID(), true);
|
||||
+ }
|
||||
+ } else {
|
||||
+ this.lootable.clearLootTable();
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ public void loadNbt(CompoundTag base) {
|
||||
+ if (!base.contains("Paper.LootableData", 10)) { // 10 = compound
|
||||
+ return;
|
||||
+ }
|
||||
+ CompoundTag comp = base.getCompound("Paper.LootableData");
|
||||
+ if (comp.contains("lastFill")) {
|
||||
+ this.lastFill = comp.getLong("lastFill");
|
||||
+ }
|
||||
+ if (comp.contains("nextRefill")) {
|
||||
+ this.nextRefill = comp.getLong("nextRefill");
|
||||
+ }
|
||||
+
|
||||
+ if (comp.contains("numRefills")) {
|
||||
+ this.numRefills = comp.getInt("numRefills");
|
||||
+ }
|
||||
+ if (comp.contains("lootedPlayers", 9)) { // 9 = list
|
||||
+ ListTag list = comp.getList("lootedPlayers", 10); // 10 = compound
|
||||
+ final int size = list.size();
|
||||
+ if (size > 0) {
|
||||
+ this.lootedPlayers = new HashMap<>(list.size());
|
||||
+ }
|
||||
+ for (int i = 0; i < size; i++) {
|
||||
+ final CompoundTag cmp = list.getCompound(i);
|
||||
+ lootedPlayers.put(cmp.getUUID("UUID"), cmp.getLong("Time"));
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ public void saveNbt(CompoundTag base) {
|
||||
+ CompoundTag comp = new CompoundTag();
|
||||
+ if (this.nextRefill != -1) {
|
||||
+ comp.putLong("nextRefill", this.nextRefill);
|
||||
+ }
|
||||
+ if (this.lastFill != -1) {
|
||||
+ comp.putLong("lastFill", this.lastFill);
|
||||
+ }
|
||||
+ if (this.numRefills != 0) {
|
||||
+ comp.putInt("numRefills", this.numRefills);
|
||||
+ }
|
||||
+ if (this.lootedPlayers != null && !this.lootedPlayers.isEmpty()) {
|
||||
+ ListTag list = new ListTag();
|
||||
+ for (Map.Entry<UUID, Long> entry : this.lootedPlayers.entrySet()) {
|
||||
+ CompoundTag cmp = new CompoundTag();
|
||||
+ cmp.putUUID("UUID", entry.getKey());
|
||||
+ cmp.putLong("Time", entry.getValue());
|
||||
+ list.add(cmp);
|
||||
+ }
|
||||
+ comp.put("lootedPlayers", list);
|
||||
+ }
|
||||
+
|
||||
+ if (!comp.isEmpty()) {
|
||||
+ base.put("Paper.LootableData", comp);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ void setPlayerLootedState(UUID player, boolean looted) {
|
||||
+ if (looted && this.lootedPlayers == null) {
|
||||
+ this.lootedPlayers = new HashMap<>();
|
||||
+ }
|
||||
+ if (looted) {
|
||||
+ if (!this.lootedPlayers.containsKey(player)) {
|
||||
+ this.lootedPlayers.put(player, System.currentTimeMillis());
|
||||
+ }
|
||||
+ } else if (this.lootedPlayers != null) {
|
||||
+ this.lootedPlayers.remove(player);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ boolean hasPlayerLooted(UUID player) {
|
||||
+ return this.lootedPlayers != null && this.lootedPlayers.containsKey(player);
|
||||
+ }
|
||||
+
|
||||
+ Long getLastLooted(UUID player) {
|
||||
+ return lootedPlayers != null ? lootedPlayers.get(player) : null;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/loottable/PaperTileEntityLootableInventory.java b/src/main/java/com/destroystokyo/paper/loottable/PaperTileEntityLootableInventory.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..9cfa5d36a6991067a3866e0d437749fafcc0158e
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/com/destroystokyo/paper/loottable/PaperTileEntityLootableInventory.java
|
||||
@@ -0,0 +1,65 @@
|
||||
+package com.destroystokyo.paper.loottable;
|
||||
+
|
||||
+import io.papermc.paper.util.MCUtil;
|
||||
+import net.minecraft.world.level.Level;
|
||||
+import net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity;
|
||||
+import org.bukkit.Bukkit;
|
||||
+import org.bukkit.craftbukkit.util.CraftNamespacedKey;
|
||||
+
|
||||
+public class PaperTileEntityLootableInventory implements PaperLootableBlockInventory {
|
||||
+ private RandomizableContainerBlockEntity tileEntityLootable;
|
||||
+
|
||||
+ public PaperTileEntityLootableInventory(RandomizableContainerBlockEntity tileEntityLootable) {
|
||||
+ this.tileEntityLootable = tileEntityLootable;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public org.bukkit.loot.LootTable getLootTable() {
|
||||
+ return tileEntityLootable.lootTable != null ? Bukkit.getLootTable(CraftNamespacedKey.fromMinecraft(tileEntityLootable.lootTable)) : null;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setLootTable(org.bukkit.loot.LootTable table, long seed) {
|
||||
+ setLootTable(table);
|
||||
+ setSeed(seed);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setLootTable(org.bukkit.loot.LootTable table) {
|
||||
+ tileEntityLootable.lootTable = (table == null) ? null : CraftNamespacedKey.toMinecraft(table.getKey());
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setSeed(long seed) {
|
||||
+ tileEntityLootable.lootTableSeed = seed;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public long getSeed() {
|
||||
+ return tileEntityLootable.lootTableSeed;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public PaperLootableInventoryData getLootableData() {
|
||||
+ return tileEntityLootable.lootableData;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public RandomizableContainerBlockEntity getTileEntity() {
|
||||
+ return tileEntityLootable;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public LootableInventory getAPILootableInventory() {
|
||||
+ Level world = tileEntityLootable.getLevel();
|
||||
+ if (world == null) {
|
||||
+ return null;
|
||||
+ }
|
||||
+ return (LootableInventory) getBukkitWorld().getBlockAt(MCUtil.toLocation(world, tileEntityLootable.getBlockPos())).getState();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public Level getNMSWorld() {
|
||||
+ return tileEntityLootable.getLevel();
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index c070fd1b224aeeaa9ebb054105a0f73285956da1..0c0060cdc35e0d8d3098a0ade8080f91dbc81a2b 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -232,6 +232,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
}
|
||||
// Paper end
|
||||
|
||||
+ public com.destroystokyo.paper.loottable.PaperLootableInventoryData lootableData; // Paper
|
||||
private CraftEntity bukkitEntity;
|
||||
|
||||
public CraftEntity getBukkitEntity() {
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java
|
||||
index 9347faecdaa3ef8c375fe8b0a89fc3385b6823bd..cc74eeb45913fab03e85969957215d2811252a83 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java
|
||||
@@ -32,6 +32,20 @@ public abstract class AbstractMinecartContainer extends AbstractMinecart impleme
|
||||
public ResourceLocation lootTable;
|
||||
public long lootTableSeed;
|
||||
|
||||
+ // Paper start
|
||||
+ {
|
||||
+ this.lootableData = new com.destroystokyo.paper.loottable.PaperLootableInventoryData(new com.destroystokyo.paper.loottable.PaperContainerEntityLootableInventory(this));
|
||||
+ }
|
||||
+ @Override
|
||||
+ public Entity getEntity() {
|
||||
+ return this;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public com.destroystokyo.paper.loottable.PaperLootableInventoryData getLootableData() {
|
||||
+ return this.lootableData;
|
||||
+ }
|
||||
+ // Paper end
|
||||
// CraftBukkit start
|
||||
public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
|
||||
private int maxStack = MAX_STACK;
|
||||
@@ -134,12 +148,14 @@ public abstract class AbstractMinecartContainer extends AbstractMinecart impleme
|
||||
@Override
|
||||
protected void addAdditionalSaveData(CompoundTag nbt) {
|
||||
super.addAdditionalSaveData(nbt);
|
||||
+ this.lootableData.saveNbt(nbt); // Paper
|
||||
this.addChestVehicleSaveData(nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readAdditionalSaveData(CompoundTag nbt) {
|
||||
super.readAdditionalSaveData(nbt);
|
||||
+ this.lootableData.loadNbt(nbt); // Paper
|
||||
this.readChestVehicleSaveData(nbt);
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/vehicle/ChestBoat.java b/src/main/java/net/minecraft/world/entity/vehicle/ChestBoat.java
|
||||
index e1c4289ff790c691fdae8f7653414a60eb196dc2..a99e2586962952332dd9904ef5bb50a0d3083266 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/vehicle/ChestBoat.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/vehicle/ChestBoat.java
|
||||
@@ -65,12 +65,14 @@ public class ChestBoat extends Boat implements HasCustomInventoryScreen, Contain
|
||||
@Override
|
||||
protected void addAdditionalSaveData(CompoundTag nbt) {
|
||||
super.addAdditionalSaveData(nbt);
|
||||
+ this.lootableData.saveNbt(nbt); // Paper
|
||||
this.addChestVehicleSaveData(nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void readAdditionalSaveData(CompoundTag nbt) {
|
||||
super.readAdditionalSaveData(nbt);
|
||||
+ this.lootableData.loadNbt(nbt); // Paper
|
||||
this.readChestVehicleSaveData(nbt);
|
||||
}
|
||||
|
||||
@@ -226,6 +228,20 @@ public class ChestBoat extends Boat implements HasCustomInventoryScreen, Contain
|
||||
this.itemStacks = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ {
|
||||
+ this.lootableData = new com.destroystokyo.paper.loottable.PaperLootableInventoryData(new com.destroystokyo.paper.loottable.PaperContainerEntityLootableInventory(this));
|
||||
+ }
|
||||
+ @Override
|
||||
+ public Entity getEntity() {
|
||||
+ return this;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public com.destroystokyo.paper.loottable.PaperLootableInventoryData getLootableData() {
|
||||
+ return this.lootableData;
|
||||
+ }
|
||||
+ // Paper end
|
||||
// CraftBukkit start
|
||||
public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
|
||||
private int maxStack = MAX_STACK;
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/vehicle/ContainerEntity.java b/src/main/java/net/minecraft/world/entity/vehicle/ContainerEntity.java
|
||||
index e2a9782e0ae60eb5557dce0831084c5722687df6..6ae9cccb28b2354ee47e6682082f92f3ecd56a67 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/vehicle/ContainerEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/vehicle/ContainerEntity.java
|
||||
@@ -61,7 +61,7 @@ public interface ContainerEntity extends Container, MenuProvider {
|
||||
if (this.getLootTableSeed() != 0L) {
|
||||
nbt.putLong("LootTableSeed", this.getLootTableSeed());
|
||||
}
|
||||
- } else {
|
||||
+ } else if (true) { // Paper - always load the items, table may still remain
|
||||
ContainerHelper.saveAllItems(nbt, this.getItemStacks());
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ public interface ContainerEntity extends Container, MenuProvider {
|
||||
if (nbt.contains("LootTable", 8)) {
|
||||
this.setLootTable(new ResourceLocation(nbt.getString("LootTable")));
|
||||
this.setLootTableSeed(nbt.getLong("LootTableSeed"));
|
||||
- } else {
|
||||
+ } else if (true) { // Paper - always load the items, table may still remain
|
||||
ContainerHelper.loadAllItems(nbt, this.getItemStacks());
|
||||
}
|
||||
|
||||
@@ -104,13 +104,15 @@ public interface ContainerEntity extends Container, MenuProvider {
|
||||
|
||||
default void unpackChestVehicleLootTable(@Nullable Player player) {
|
||||
MinecraftServer minecraftServer = this.getLevel().getServer();
|
||||
- if (this.getLootTable() != null && minecraftServer != null) {
|
||||
+ if (this.getLootableData().shouldReplenish(player) && minecraftServer != null) { // Paper
|
||||
LootTable lootTable = minecraftServer.getLootTables().get(this.getLootTable());
|
||||
if (player != null) {
|
||||
CriteriaTriggers.GENERATE_LOOT.trigger((ServerPlayer)player, this.getLootTable());
|
||||
}
|
||||
|
||||
- this.setLootTable((ResourceLocation)null);
|
||||
+ // this.setLootTable((ResourceLocation)null); // Paper
|
||||
+ this.getLootableData().processRefill(player); // Paper
|
||||
+
|
||||
LootContext.Builder builder = (new LootContext.Builder((ServerLevel)this.getLevel())).withParameter(LootContextParams.ORIGIN, this.position()).withOptionalRandomSeed(this.getLootTableSeed());
|
||||
if (player != null) {
|
||||
builder.withLuck(player.getLuck()).withParameter(LootContextParams.THIS_ENTITY, player);
|
||||
@@ -184,4 +186,13 @@ public interface ContainerEntity extends Container, MenuProvider {
|
||||
default boolean isChestVehicleStillValid(Player player) {
|
||||
return !this.isRemoved() && this.position().closerThan(player.position(), 8.0D);
|
||||
}
|
||||
+ // Paper start
|
||||
+ default Entity getEntity() {
|
||||
+ throw new UnsupportedOperationException();
|
||||
+ }
|
||||
+
|
||||
+ default com.destroystokyo.paper.loottable.PaperLootableInventoryData getLootableData() {
|
||||
+ throw new UnsupportedOperationException();
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java
|
||||
index 216fc20326d71121098430dc1b9f7477265a91b7..e3bee2df77d87630e96621470e940d9d9e152e7f 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java
|
||||
@@ -28,6 +28,7 @@ public abstract class RandomizableContainerBlockEntity extends BaseContainerBloc
|
||||
@Nullable
|
||||
public ResourceLocation lootTable;
|
||||
public long lootTableSeed;
|
||||
+ public final com.destroystokyo.paper.loottable.PaperLootableInventoryData lootableData = new com.destroystokyo.paper.loottable.PaperLootableInventoryData(new com.destroystokyo.paper.loottable.PaperTileEntityLootableInventory(this)); // Paper
|
||||
|
||||
protected RandomizableContainerBlockEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
|
||||
super(type, pos, state);
|
||||
@@ -42,16 +43,19 @@ public abstract class RandomizableContainerBlockEntity extends BaseContainerBloc
|
||||
}
|
||||
|
||||
protected boolean tryLoadLootTable(CompoundTag nbt) {
|
||||
+ this.lootableData.loadNbt(nbt); // Paper
|
||||
if (nbt.contains("LootTable", 8)) {
|
||||
this.lootTable = new ResourceLocation(nbt.getString("LootTable"));
|
||||
+ try { org.bukkit.craftbukkit.util.CraftNamespacedKey.fromMinecraft(this.lootTable); } catch (IllegalArgumentException ex) { this.lootTable = null; } // Paper - validate
|
||||
this.lootTableSeed = nbt.getLong("LootTableSeed");
|
||||
- return true;
|
||||
+ return false; // Paper - always load the items, table may still remain
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean trySaveLootTable(CompoundTag nbt) {
|
||||
+ this.lootableData.saveNbt(nbt); // Paper
|
||||
if (this.lootTable == null) {
|
||||
return false;
|
||||
} else {
|
||||
@@ -60,18 +64,19 @@ public abstract class RandomizableContainerBlockEntity extends BaseContainerBloc
|
||||
nbt.putLong("LootTableSeed", this.lootTableSeed);
|
||||
}
|
||||
|
||||
- return true;
|
||||
+ return false; // Paper - always save the items, table may still remain
|
||||
}
|
||||
}
|
||||
|
||||
public void unpackLootTable(@Nullable Player player) {
|
||||
- if (this.lootTable != null && this.level.getServer() != null) {
|
||||
+ if (this.lootableData.shouldReplenish(player) && this.level.getServer() != null) { // Paper
|
||||
LootTable lootTable = this.level.getServer().getLootTables().get(this.lootTable);
|
||||
if (player instanceof ServerPlayer) {
|
||||
CriteriaTriggers.GENERATE_LOOT.trigger((ServerPlayer)player, this.lootTable);
|
||||
}
|
||||
|
||||
- this.lootTable = null;
|
||||
+ //this.lootTable = null; // Paper
|
||||
+ this.lootableData.processRefill(player); // Paper
|
||||
LootContext.Builder builder = (new LootContext.Builder((ServerLevel)this.level)).withParameter(LootContextParams.ORIGIN, Vec3.atCenterOf(this.worldPosition)).withOptionalRandomSeed(this.lootTableSeed);
|
||||
if (player != null) {
|
||||
builder.withLuck(player.getLuck()).withParameter(LootContextParams.THIS_ENTITY, player);
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftChest.java b/src/main/java/org/bukkit/craftbukkit/block/CraftChest.java
|
||||
index b31fa63019822bc172d85427b3f3f2c154d7e179..82b3f3b3aced73ce136b6b94fe212972ac6090ef 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftChest.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftChest.java
|
||||
@@ -12,8 +12,9 @@ import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.craftbukkit.inventory.CraftInventory;
|
||||
import org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
+import com.destroystokyo.paper.loottable.PaperLootableBlockInventory; // Paper
|
||||
|
||||
-public class CraftChest extends CraftLootable<ChestBlockEntity> implements Chest {
|
||||
+public class CraftChest extends CraftLootable<ChestBlockEntity> implements Chest, PaperLootableBlockInventory { // Paper
|
||||
|
||||
public CraftChest(World world, ChestBlockEntity tileEntity) {
|
||||
super(world, tileEntity);
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftLootable.java b/src/main/java/org/bukkit/craftbukkit/block/CraftLootable.java
|
||||
index 982adacb361b0590799dc68f9b7c13c7195627fd..e49eece9bff3a53469673d03a7bbf8f9cf8776b8 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftLootable.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftLootable.java
|
||||
@@ -9,7 +9,7 @@ import org.bukkit.craftbukkit.util.CraftNamespacedKey;
|
||||
import org.bukkit.loot.LootTable;
|
||||
import org.bukkit.loot.Lootable;
|
||||
|
||||
-public abstract class CraftLootable<T extends RandomizableContainerBlockEntity> extends CraftContainer<T> implements Nameable, Lootable {
|
||||
+public abstract class CraftLootable<T extends RandomizableContainerBlockEntity> extends CraftContainer<T> implements Nameable, Lootable, com.destroystokyo.paper.loottable.PaperLootableBlockInventory { // Paper
|
||||
|
||||
public CraftLootable(World world, T tileEntity) {
|
||||
super(world, tileEntity);
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftChestBoat.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftChestBoat.java
|
||||
index ae07db69b11b993b50782c94aa5c45b97d949612..06a96f027f90fd5bf05de72c8722ff5a81608b66 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftChestBoat.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftChestBoat.java
|
||||
@@ -11,8 +11,7 @@ import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.loot.LootTable;
|
||||
|
||||
-public class CraftChestBoat extends CraftBoat implements org.bukkit.entity.ChestBoat {
|
||||
-
|
||||
+public class CraftChestBoat extends CraftBoat implements org.bukkit.entity.ChestBoat, com.destroystokyo.paper.loottable.PaperLootableEntityInventory { // Paper
|
||||
private final Inventory inventory;
|
||||
|
||||
public CraftChestBoat(CraftServer server, ChestBoat entity) {
|
||||
@@ -66,7 +65,7 @@ public class CraftChestBoat extends CraftBoat implements org.bukkit.entity.Chest
|
||||
return this.getHandle().getLootTableSeed();
|
||||
}
|
||||
|
||||
- private void setLootTable(LootTable table, long seed) {
|
||||
+ public void setLootTable(LootTable table, long seed) { // Paper - change visibility since it overrides a public method
|
||||
ResourceLocation newKey = (table == null) ? null : CraftNamespacedKey.toMinecraft(table.getKey());
|
||||
this.getHandle().setLootTable(newKey);
|
||||
this.getHandle().setLootTableSeed(seed);
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartChest.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartChest.java
|
||||
index eb21b8457774d5ac765fa9008157cb29d9b72509..abf58bef2042a9efba5a78fd7f97339deceaa780 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartChest.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartChest.java
|
||||
@@ -8,7 +8,7 @@ import org.bukkit.entity.minecart.StorageMinecart;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
-public class CraftMinecartChest extends CraftMinecartContainer implements StorageMinecart {
|
||||
+public class CraftMinecartChest extends CraftMinecartContainer implements StorageMinecart, com.destroystokyo.paper.loottable.PaperLootableEntityInventory { // Paper
|
||||
private final CraftInventory inventory;
|
||||
|
||||
public CraftMinecartChest(CraftServer server, MinecartChest entity) {
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartHopper.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartHopper.java
|
||||
index 34b8f103625f087bb725bed595dd9c30f4a6f70c..ee9648739fb39c5842063d7442df6eb5c9336d7f 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartHopper.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartHopper.java
|
||||
@@ -7,7 +7,7 @@ import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.minecart.HopperMinecart;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
|
||||
-public final class CraftMinecartHopper extends CraftMinecartContainer implements HopperMinecart {
|
||||
+public final class CraftMinecartHopper extends CraftMinecartContainer implements HopperMinecart, com.destroystokyo.paper.loottable.PaperLootableEntityInventory { // Paper
|
||||
private final CraftInventory inventory;
|
||||
|
||||
public CraftMinecartHopper(CraftServer server, MinecartHopper entity) {
|
|
@ -0,0 +1,18 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Sat, 7 May 2016 23:33:08 -0400
|
||||
Subject: [PATCH] Don't save empty scoreboard teams to scoreboard.dat
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/scores/ScoreboardSaveData.java b/src/main/java/net/minecraft/world/scores/ScoreboardSaveData.java
|
||||
index b837b6616a2384b253cca8ed62c9488b639f6298..2be7a697f08045b974579e6942b38571e744efac 100644
|
||||
--- a/src/main/java/net/minecraft/world/scores/ScoreboardSaveData.java
|
||||
+++ b/src/main/java/net/minecraft/world/scores/ScoreboardSaveData.java
|
||||
@@ -136,6 +136,7 @@ public class ScoreboardSaveData extends SavedData {
|
||||
ListTag listTag = new ListTag();
|
||||
|
||||
for(PlayerTeam playerTeam : this.scoreboard.getPlayerTeams()) {
|
||||
+ if (!io.papermc.paper.configuration.GlobalConfiguration.get().scoreboards.saveEmptyScoreboardTeams && playerTeam.getPlayers().isEmpty()) continue; // Paper
|
||||
CompoundTag compoundTag = new CompoundTag();
|
||||
compoundTag.putString("Name", playerTeam.getName());
|
||||
compoundTag.putString("DisplayName", Component.Serializer.toJson(playerTeam.getDisplayName()));
|
|
@ -0,0 +1,19 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Zach Brown <zach.brown@destroystokyo.com>
|
||||
Date: Thu, 12 May 2016 23:02:58 -0500
|
||||
Subject: [PATCH] System property for disabling watchdoge
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/spigotmc/WatchdogThread.java b/src/main/java/org/spigotmc/WatchdogThread.java
|
||||
index 3ad14bf0697e682a2e777baa8faeb323d127fb13..a9897c494b3dc56d900356d74030359832febbaa 100644
|
||||
--- a/src/main/java/org/spigotmc/WatchdogThread.java
|
||||
+++ b/src/main/java/org/spigotmc/WatchdogThread.java
|
||||
@@ -61,7 +61,7 @@ public final class WatchdogThread extends io.papermc.paper.util.TickThread // Pa
|
||||
while ( !this.stopping )
|
||||
{
|
||||
//
|
||||
- if ( this.lastTick != 0 && this.timeoutTime > 0 && WatchdogThread.monotonicMillis() > this.lastTick + this.timeoutTime )
|
||||
+ if ( this.lastTick != 0 && this.timeoutTime > 0 && WatchdogThread.monotonicMillis() > this.lastTick + this.timeoutTime && !Boolean.getBoolean("disable.watchdog")) // Paper - Add property to disable
|
||||
{
|
||||
Logger log = Bukkit.getServer().getLogger();
|
||||
log.log( Level.SEVERE, "------------------------------" );
|
|
@ -0,0 +1,86 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Mon, 16 May 2016 20:47:41 -0400
|
||||
Subject: [PATCH] Async GameProfileCache saving
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index 3ed50490121f34ab5b247565b9a4555bf6a46dff..0a419ec121bbddffa0424147c642f79d4e5eb817 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -934,7 +934,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
} catch (java.lang.InterruptedException ignored) {} // Paper
|
||||
if (org.spigotmc.SpigotConfig.saveUserCacheOnStopOnly) {
|
||||
MinecraftServer.LOGGER.info("Saving usercache.json");
|
||||
- this.getProfileCache().save();
|
||||
+ this.getProfileCache().save(false); // Paper
|
||||
}
|
||||
// Spigot end
|
||||
io.papermc.paper.chunk.system.io.RegionFileIOThread.close(true); // Paper // Paper - rewrite chunk system
|
||||
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
index 18f7d73fd8a780753e2249a9fec6bb335ebfdeed..35904c69e14c4c0addda204d5e3788518c2e16c4 100644
|
||||
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
@@ -242,7 +242,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||
}
|
||||
|
||||
if (this.convertOldUsers()) {
|
||||
- this.getProfileCache().save();
|
||||
+ this.getProfileCache().save(false); // Paper
|
||||
}
|
||||
|
||||
if (!OldUsersConverter.serverReadyAfterUserconversion(this)) {
|
||||
diff --git a/src/main/java/net/minecraft/server/players/GameProfileCache.java b/src/main/java/net/minecraft/server/players/GameProfileCache.java
|
||||
index d246563021c32127e570809f4d849b6a156f4dc6..225e15d686675e21969c4210fa38fef58d920355 100644
|
||||
--- a/src/main/java/net/minecraft/server/players/GameProfileCache.java
|
||||
+++ b/src/main/java/net/minecraft/server/players/GameProfileCache.java
|
||||
@@ -127,7 +127,7 @@ public class GameProfileCache {
|
||||
GameProfileCache.GameProfileInfo usercache_usercacheentry = new GameProfileCache.GameProfileInfo(profile, date);
|
||||
|
||||
this.safeAdd(usercache_usercacheentry);
|
||||
- if( !org.spigotmc.SpigotConfig.saveUserCacheOnStopOnly ) this.save(); // Spigot - skip saving if disabled
|
||||
+ if( !org.spigotmc.SpigotConfig.saveUserCacheOnStopOnly ) this.save(true); // Spigot - skip saving if disabled // Paper - async
|
||||
}
|
||||
|
||||
private long getNextOperation() {
|
||||
@@ -160,7 +160,7 @@ public class GameProfileCache {
|
||||
}
|
||||
|
||||
if (flag && !org.spigotmc.SpigotConfig.saveUserCacheOnStopOnly) { // Spigot - skip saving if disabled
|
||||
- this.save();
|
||||
+ this.save(true); // Paper
|
||||
}
|
||||
|
||||
return optional;
|
||||
@@ -274,7 +274,7 @@ public class GameProfileCache {
|
||||
return arraylist;
|
||||
}
|
||||
|
||||
- public void save() {
|
||||
+ public void save(boolean asyncSave) { // Paper
|
||||
JsonArray jsonarray = new JsonArray();
|
||||
DateFormat dateformat = GameProfileCache.createDateFormat();
|
||||
|
||||
@@ -282,6 +282,7 @@ public class GameProfileCache {
|
||||
jsonarray.add(GameProfileCache.writeGameProfile(usercache_usercacheentry, dateformat));
|
||||
});
|
||||
String s = this.gson.toJson(jsonarray);
|
||||
+ Runnable save = () -> { // Paper
|
||||
|
||||
try {
|
||||
BufferedWriter bufferedwriter = Files.newWriter(this.file, StandardCharsets.UTF_8);
|
||||
@@ -306,6 +307,14 @@ public class GameProfileCache {
|
||||
} catch (IOException ioexception) {
|
||||
;
|
||||
}
|
||||
+ // Paper start
|
||||
+ };
|
||||
+ if (asyncSave) {
|
||||
+ io.papermc.paper.util.MCUtil.scheduleAsyncTask(save);
|
||||
+ } else {
|
||||
+ save.run();
|
||||
+ }
|
||||
+ // Paper end
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Zach Brown <zach.brown@destroystokyo.com>
|
||||
Date: Sun, 22 May 2016 20:20:55 -0500
|
||||
Subject: [PATCH] Optional TNT doesn't move in water
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java
|
||||
index 6b372ac843e992820ac0a8ebb9c3c5d9795cc6b0..841bb7741ae6b0e9cb98120ee1649b93ef4c3dab 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerEntity.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerEntity.java
|
||||
@@ -69,7 +69,7 @@ public class ServerEntity {
|
||||
@Nullable
|
||||
private List<SynchedEntityData.DataValue<?>> trackedDataValues;
|
||||
// CraftBukkit start
|
||||
- private final Set<ServerPlayerConnection> trackedPlayers;
|
||||
+ final Set<ServerPlayerConnection> trackedPlayers; // Paper - private -> package
|
||||
|
||||
public ServerEntity(ServerLevel worldserver, Entity entity, int i, boolean flag, Consumer<Packet<?>> consumer, Set<ServerPlayerConnection> trackedPlayers) {
|
||||
this.trackedPlayers = trackedPlayers;
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
|
||||
index aa0dfd08aefbb9363ec96080432f0f75d71b0b95..4b81d62d3250b99cbcb4eb2468ef81c149bf177e 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
|
||||
@@ -94,6 +94,27 @@ public class PrimedTnt extends Entity {
|
||||
}
|
||||
}
|
||||
|
||||
+ // Paper start - Optional prevent TNT from moving in water
|
||||
+ if (!this.isRemoved() && this.wasTouchingWater && this.level.paperConfig().fixes.preventTntFromMovingInWater) {
|
||||
+ /*
|
||||
+ * Author: Jedediah Smith <jedediah@silencegreys.com>
|
||||
+ */
|
||||
+ // Send position and velocity updates to nearby players on every tick while the TNT is in water.
|
||||
+ // This does pretty well at keeping their clients in sync with the server.
|
||||
+ net.minecraft.server.level.ChunkMap.TrackedEntity ete = ((net.minecraft.server.level.ServerLevel)this.level).getChunkSource().chunkMap.entityMap.get(this.getId());
|
||||
+ if (ete != null) {
|
||||
+ net.minecraft.network.protocol.game.ClientboundSetEntityMotionPacket velocityPacket = new net.minecraft.network.protocol.game.ClientboundSetEntityMotionPacket(this);
|
||||
+ net.minecraft.network.protocol.game.ClientboundTeleportEntityPacket positionPacket = new net.minecraft.network.protocol.game.ClientboundTeleportEntityPacket(this);
|
||||
+
|
||||
+ ete.seenBy.stream()
|
||||
+ .filter(viewer -> (viewer.getPlayer().getX() - this.getX()) * (viewer.getPlayer().getY() - this.getY()) * (viewer.getPlayer().getZ() - this.getZ()) < 16 * 16)
|
||||
+ .forEach(viewer -> {
|
||||
+ viewer.send(velocityPacket);
|
||||
+ viewer.send(positionPacket);
|
||||
+ });
|
||||
+ }
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
||||
|
||||
private void explode() {
|
||||
@@ -144,4 +165,11 @@ public class PrimedTnt extends Entity {
|
||||
public int getFuse() {
|
||||
return (Integer) this.entityData.get(PrimedTnt.DATA_FUSE_ID);
|
||||
}
|
||||
+
|
||||
+ // Paper start - Optional prevent TNT from moving in water
|
||||
+ @Override
|
||||
+ public boolean isPushedByFluid() {
|
||||
+ return !level.paperConfig().fixes.preventTntFromMovingInWater && super.isPushedByFluid();
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Martin Panzer <postremus1996@googlemail.com>
|
||||
Date: Mon, 23 May 2016 12:12:37 +0200
|
||||
Subject: [PATCH] Faster redstone torch rapid clock removal
|
||||
|
||||
Only resize the the redstone torch list once, since resizing arrays / lists is costly
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
||||
index 00911231201f84b781048d052495b60a47fb5277..c834428e04eab9639cfa9d07513d695dcb3bfce9 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/Level.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
||||
@@ -170,6 +170,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
||||
private org.spigotmc.TickLimiter tileLimiter;
|
||||
private int tileTickPosition;
|
||||
public final Map<Explosion.CacheKey, Float> explosionDensityCache = new HashMap<>(); // Paper - Optimize explosions
|
||||
+ public java.util.ArrayDeque<net.minecraft.world.level.block.RedstoneTorchBlock.Toggle> redstoneUpdateInfos; // Paper - Move from Map in BlockRedstoneTorch to here
|
||||
|
||||
public CraftWorld getWorld() {
|
||||
return this.world;
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/RedstoneTorchBlock.java b/src/main/java/net/minecraft/world/level/block/RedstoneTorchBlock.java
|
||||
index 9b6f8508d16bcecd9dc148f75598655e3585f175..da07fce0cf7c9fbdb57d2c59e431b59bf583bf50 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/RedstoneTorchBlock.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/RedstoneTorchBlock.java
|
||||
@@ -21,7 +21,7 @@ import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
|
||||
public class RedstoneTorchBlock extends TorchBlock {
|
||||
|
||||
public static final BooleanProperty LIT = BlockStateProperties.LIT;
|
||||
- private static final Map<BlockGetter, List<RedstoneTorchBlock.Toggle>> RECENT_TOGGLES = new WeakHashMap();
|
||||
+ // Paper - Move the mapped list to World
|
||||
public static final int RECENT_TOGGLE_TIMER = 60;
|
||||
public static final int MAX_RECENT_TOGGLES = 8;
|
||||
public static final int RESTART_DELAY = 160;
|
||||
@@ -72,11 +72,15 @@ public class RedstoneTorchBlock extends TorchBlock {
|
||||
@Override
|
||||
public void tick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) {
|
||||
boolean flag = this.hasNeighborSignal(world, pos, state);
|
||||
- List list = (List) RedstoneTorchBlock.RECENT_TOGGLES.get(world);
|
||||
-
|
||||
- while (list != null && !list.isEmpty() && world.getGameTime() - ((RedstoneTorchBlock.Toggle) list.get(0)).when > 60L) {
|
||||
- list.remove(0);
|
||||
+ // Paper start
|
||||
+ java.util.ArrayDeque<RedstoneTorchBlock.Toggle> redstoneUpdateInfos = world.redstoneUpdateInfos;
|
||||
+ if (redstoneUpdateInfos != null) {
|
||||
+ RedstoneTorchBlock.Toggle curr;
|
||||
+ while ((curr = redstoneUpdateInfos.peek()) != null && world.getGameTime() - curr.when > 60L) {
|
||||
+ redstoneUpdateInfos.poll();
|
||||
+ }
|
||||
}
|
||||
+ // Paper end
|
||||
|
||||
// CraftBukkit start
|
||||
org.bukkit.plugin.PluginManager manager = world.getCraftServer().getPluginManager();
|
||||
@@ -152,9 +156,12 @@ public class RedstoneTorchBlock extends TorchBlock {
|
||||
}
|
||||
|
||||
private static boolean isToggledTooFrequently(Level world, BlockPos pos, boolean addNew) {
|
||||
- List<RedstoneTorchBlock.Toggle> list = (List) RedstoneTorchBlock.RECENT_TOGGLES.computeIfAbsent(world, (iblockaccess) -> {
|
||||
- return Lists.newArrayList();
|
||||
- });
|
||||
+ // Paper start
|
||||
+ java.util.ArrayDeque<RedstoneTorchBlock.Toggle> list = world.redstoneUpdateInfos;
|
||||
+ if (list == null) {
|
||||
+ list = world.redstoneUpdateInfos = new java.util.ArrayDeque<>();
|
||||
+ }
|
||||
+
|
||||
|
||||
if (addNew) {
|
||||
list.add(new RedstoneTorchBlock.Toggle(pos.immutable(), world.getGameTime()));
|
||||
@@ -162,9 +169,9 @@ public class RedstoneTorchBlock extends TorchBlock {
|
||||
|
||||
int i = 0;
|
||||
|
||||
- for (int j = 0; j < list.size(); ++j) {
|
||||
- RedstoneTorchBlock.Toggle blockredstonetorch_redstoneupdateinfo = (RedstoneTorchBlock.Toggle) list.get(j);
|
||||
-
|
||||
+ for (java.util.Iterator<RedstoneTorchBlock.Toggle> iterator = list.iterator(); iterator.hasNext();) {
|
||||
+ RedstoneTorchBlock.Toggle blockredstonetorch_redstoneupdateinfo = iterator.next();
|
||||
+ // Paper end
|
||||
if (blockredstonetorch_redstoneupdateinfo.pos.equals(pos)) {
|
||||
++i;
|
||||
if (i >= 8) {
|
|
@ -0,0 +1,25 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Martin Panzer <postremus1996@googlemail.com>
|
||||
Date: Sat, 28 May 2016 16:54:03 +0200
|
||||
Subject: [PATCH] Add server-name parameter
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||
index 49f6d20706e8fb94c41834f5addcd015d18acd7e..ef46dc1ed538b783213651f624326b2d49c786e0 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||
@@ -156,6 +156,14 @@ public class Main {
|
||||
.defaultsTo(new File[] {})
|
||||
.describedAs("Jar file");
|
||||
// Paper end
|
||||
+
|
||||
+ // Paper start
|
||||
+ acceptsAll(asList("server-name"), "Name of the server")
|
||||
+ .withRequiredArg()
|
||||
+ .ofType(String.class)
|
||||
+ .defaultsTo("Unknown Server")
|
||||
+ .describedAs("Name");
|
||||
+ // Paper end
|
||||
}
|
||||
};
|
||||
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue