do some work
This commit is contained in:
parent
abc49bf069
commit
f2c45ed1d3
7 changed files with 223 additions and 264 deletions
359
patches/server/0004-Test-changes.patch
Normal file
359
patches/server/0004-Test-changes.patch
Normal file
|
@ -0,0 +1,359 @@
|
|||
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 2905c7273ed4d62a7f1bc7eab9ae919ee6c012de..e5f1c91937af872109e478b99a6037332994e717 100644
|
||||
--- a/build.gradle.kts
|
||||
+++ b/build.gradle.kts
|
||||
@@ -23,6 +23,7 @@ dependencies {
|
||||
testImplementation("org.hamcrest:hamcrest:2.2")
|
||||
testImplementation("org.mockito:mockito-core:5.11.0")
|
||||
testImplementation("org.ow2.asm:asm-tree:9.7")
|
||||
+ testImplementation("org.junit-pioneer:junit-pioneer:2.2.0") // Paper - CartesianTest
|
||||
}
|
||||
|
||||
val craftbukkitPackageVersion = "1_20_R4" // Paper
|
||||
@@ -53,6 +54,12 @@ tasks.jar {
|
||||
}
|
||||
}
|
||||
|
||||
+// Paper start - compile tests with -parameters for better junit parameterized test names
|
||||
+tasks.compileTestJava {
|
||||
+ options.compilerArgs.add("-parameters")
|
||||
+}
|
||||
+// Paper end
|
||||
+
|
||||
publishing {
|
||||
publications.create<MavenPublication>("maven") {
|
||||
artifact(tasks.shadowJar)
|
||||
diff --git a/src/test/java/io/papermc/paper/registry/RegistryKeyTest.java b/src/test/java/io/papermc/paper/registry/RegistryKeyTest.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..e070aa1bb69859224493d958621389ee757f8752
|
||||
--- /dev/null
|
||||
+++ b/src/test/java/io/papermc/paper/registry/RegistryKeyTest.java
|
||||
@@ -0,0 +1,33 @@
|
||||
+package io.papermc.paper.registry;
|
||||
+
|
||||
+import java.util.Optional;
|
||||
+import java.util.stream.Stream;
|
||||
+import net.minecraft.core.Registry;
|
||||
+import net.minecraft.resources.ResourceKey;
|
||||
+import net.minecraft.resources.ResourceLocation;
|
||||
+import org.bukkit.support.AbstractTestingBase;
|
||||
+import org.junit.jupiter.api.BeforeAll;
|
||||
+import org.junit.jupiter.params.ParameterizedTest;
|
||||
+import org.junit.jupiter.params.provider.MethodSource;
|
||||
+
|
||||
+import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
+
|
||||
+class RegistryKeyTest extends AbstractTestingBase {
|
||||
+
|
||||
+ @BeforeAll
|
||||
+ static void before() throws ClassNotFoundException {
|
||||
+ Class.forName(RegistryKey.class.getName()); // load all keys so they are found for the test
|
||||
+ }
|
||||
+
|
||||
+ static Stream<RegistryKey<?>> data() {
|
||||
+ return RegistryKeyImpl.REGISTRY_KEYS.stream();
|
||||
+ }
|
||||
+
|
||||
+ @ParameterizedTest
|
||||
+ @MethodSource("data")
|
||||
+ void testApiRegistryKeysExist(final RegistryKey<?> key) {
|
||||
+ final Optional<Registry<Object>> registry = AbstractTestingBase.REGISTRY_CUSTOM.registry(ResourceKey.createRegistryKey(new ResourceLocation(key.key().asString())));
|
||||
+ assertTrue(registry.isPresent(), "Missing vanilla registry for " + key.key().asString());
|
||||
+
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/test/java/io/papermc/paper/util/EmptyTag.java b/src/test/java/io/papermc/paper/util/EmptyTag.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..6eb95a5e2534974c0e52e2b78b04e7c2b2f28525
|
||||
--- /dev/null
|
||||
+++ b/src/test/java/io/papermc/paper/util/EmptyTag.java
|
||||
@@ -0,0 +1,31 @@
|
||||
+package io.papermc.paper.util;
|
||||
+
|
||||
+import java.util.Collections;
|
||||
+import java.util.Set;
|
||||
+import org.bukkit.Keyed;
|
||||
+import org.bukkit.NamespacedKey;
|
||||
+import org.bukkit.Tag;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+public record EmptyTag(NamespacedKey key) implements Tag<Keyed> {
|
||||
+
|
||||
+ @SuppressWarnings("deprecation")
|
||||
+ public EmptyTag() {
|
||||
+ this(NamespacedKey.randomKey());
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public @NotNull NamespacedKey getKey() {
|
||||
+ return this.key;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isTagged(@NotNull final Keyed item) {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public @NotNull Set<Keyed> getValues() {
|
||||
+ return Collections.emptySet();
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/test/java/io/papermc/paper/util/MethodParameterProvider.java b/src/test/java/io/papermc/paper/util/MethodParameterProvider.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..3f58ef36df34cd15fcb72189eeff057654adf0c6
|
||||
--- /dev/null
|
||||
+++ b/src/test/java/io/papermc/paper/util/MethodParameterProvider.java
|
||||
@@ -0,0 +1,206 @@
|
||||
+/*
|
||||
+ * Copyright 2015-2023 the original author or authors of https://github.com/junit-team/junit5/blob/6593317c15fb556febbde11914fa7afe00abf8cd/junit-jupiter-params/src/main/java/org/junit/jupiter/params/provider/MethodArgumentsProvider.java
|
||||
+ *
|
||||
+ * All rights reserved. This program and the accompanying materials are
|
||||
+ * made available under the terms of the Eclipse Public License v2.0 which
|
||||
+ * accompanies this distribution and is available at
|
||||
+ *
|
||||
+ * https://www.eclipse.org/legal/epl-v20.html
|
||||
+ */
|
||||
+
|
||||
+package io.papermc.paper.util;
|
||||
+
|
||||
+import java.lang.reflect.Method;
|
||||
+import java.lang.reflect.Parameter;
|
||||
+import java.util.List;
|
||||
+import java.util.function.Predicate;
|
||||
+import java.util.stream.Stream;
|
||||
+import org.junit.jupiter.api.Test;
|
||||
+import org.junit.jupiter.api.TestFactory;
|
||||
+import org.junit.jupiter.api.TestTemplate;
|
||||
+import org.junit.jupiter.api.extension.ExtensionContext;
|
||||
+import org.junit.jupiter.params.support.AnnotationConsumer;
|
||||
+import org.junit.platform.commons.JUnitException;
|
||||
+import org.junit.platform.commons.PreconditionViolationException;
|
||||
+import org.junit.platform.commons.util.ClassLoaderUtils;
|
||||
+import org.junit.platform.commons.util.CollectionUtils;
|
||||
+import org.junit.platform.commons.util.Preconditions;
|
||||
+import org.junit.platform.commons.util.ReflectionUtils;
|
||||
+import org.junit.platform.commons.util.StringUtils;
|
||||
+import org.junitpioneer.jupiter.cartesian.CartesianParameterArgumentsProvider;
|
||||
+
|
||||
+import static java.lang.String.format;
|
||||
+import static java.util.Arrays.stream;
|
||||
+import static java.util.stream.Collectors.toList;
|
||||
+import static org.junit.platform.commons.util.AnnotationUtils.isAnnotated;
|
||||
+import static org.junit.platform.commons.util.CollectionUtils.isConvertibleToStream;
|
||||
+
|
||||
+public class MethodParameterProvider implements CartesianParameterArgumentsProvider<Object>, AnnotationConsumer<MethodParameterSource> {
|
||||
+ private MethodParameterSource source;
|
||||
+
|
||||
+ MethodParameterProvider() {
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void accept(final MethodParameterSource source) {
|
||||
+ this.source = source;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public Stream<Object> provideArguments(ExtensionContext context, Parameter parameter) {
|
||||
+ return this.provideArguments(context, this.source);
|
||||
+ }
|
||||
+
|
||||
+ // Below is mostly copied from MethodArgumentsProvider
|
||||
+
|
||||
+ private static final Predicate<Method> isFactoryMethod = //
|
||||
+ method -> isConvertibleToStream(method.getReturnType()) && !isTestMethod(method);
|
||||
+
|
||||
+ protected Stream<Object> provideArguments(ExtensionContext context, MethodParameterSource methodSource) {
|
||||
+ Class<?> testClass = context.getRequiredTestClass();
|
||||
+ Method testMethod = context.getRequiredTestMethod();
|
||||
+ Object testInstance = context.getTestInstance().orElse(null);
|
||||
+ String[] methodNames = methodSource.value();
|
||||
+ // @formatter:off
|
||||
+ return stream(methodNames)
|
||||
+ .map(factoryMethodName -> findFactoryMethod(testClass, testMethod, factoryMethodName))
|
||||
+ .map(factoryMethod -> validateFactoryMethod(factoryMethod, testInstance))
|
||||
+ .map(factoryMethod -> context.getExecutableInvoker().invoke(factoryMethod, testInstance))
|
||||
+ .flatMap(CollectionUtils::toStream);
|
||||
+ // @formatter:on
|
||||
+ }
|
||||
+
|
||||
+ private static Method findFactoryMethod(Class<?> testClass, Method testMethod, String factoryMethodName) {
|
||||
+ String originalFactoryMethodName = factoryMethodName;
|
||||
+
|
||||
+ // If the user did not provide a factory method name, find a "default" local
|
||||
+ // factory method with the same name as the parameterized test method.
|
||||
+ if (StringUtils.isBlank(factoryMethodName)) {
|
||||
+ factoryMethodName = testMethod.getName();
|
||||
+ return findFactoryMethodBySimpleName(testClass, testMethod, factoryMethodName);
|
||||
+ }
|
||||
+
|
||||
+ // Convert local factory method name to fully-qualified method name.
|
||||
+ if (!looksLikeAFullyQualifiedMethodName(factoryMethodName)) {
|
||||
+ factoryMethodName = testClass.getName() + "#" + factoryMethodName;
|
||||
+ }
|
||||
+
|
||||
+ // Find factory method using fully-qualified name.
|
||||
+ Method factoryMethod = findFactoryMethodByFullyQualifiedName(testClass, testMethod, factoryMethodName);
|
||||
+
|
||||
+ // Ensure factory method has a valid return type and is not a test method.
|
||||
+ Preconditions.condition(isFactoryMethod.test(factoryMethod), () -> format(
|
||||
+ "Could not find valid factory method [%s] for test class [%s] but found the following invalid candidate: %s",
|
||||
+ originalFactoryMethodName, testClass.getName(), factoryMethod));
|
||||
+
|
||||
+ return factoryMethod;
|
||||
+ }
|
||||
+
|
||||
+ private static boolean looksLikeAFullyQualifiedMethodName(String factoryMethodName) {
|
||||
+ if (factoryMethodName.contains("#")) {
|
||||
+ return true;
|
||||
+ }
|
||||
+ int indexOfFirstDot = factoryMethodName.indexOf('.');
|
||||
+ if (indexOfFirstDot == -1) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ int indexOfLastOpeningParenthesis = factoryMethodName.lastIndexOf('(');
|
||||
+ if (indexOfLastOpeningParenthesis > 0) {
|
||||
+ // Exclude simple/local method names with parameters
|
||||
+ return indexOfFirstDot < indexOfLastOpeningParenthesis;
|
||||
+ }
|
||||
+ // If we get this far, we conclude the supplied factory method name "looks"
|
||||
+ // like it was intended to be a fully-qualified method name, even if the
|
||||
+ // syntax is invalid. We do this in order to provide better diagnostics for
|
||||
+ // the user when a fully-qualified method name is in fact invalid.
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ // package-private for testing
|
||||
+ static Method findFactoryMethodByFullyQualifiedName(
|
||||
+ Class<?> testClass, Method testMethod,
|
||||
+ String fullyQualifiedMethodName
|
||||
+ ) {
|
||||
+ String[] methodParts = ReflectionUtils.parseFullyQualifiedMethodName(fullyQualifiedMethodName);
|
||||
+ String className = methodParts[0];
|
||||
+ String methodName = methodParts[1];
|
||||
+ String methodParameters = methodParts[2];
|
||||
+ ClassLoader classLoader = ClassLoaderUtils.getClassLoader(testClass);
|
||||
+ Class<?> clazz = loadRequiredClass(className, classLoader);
|
||||
+
|
||||
+ // Attempt to find an exact match first.
|
||||
+ Method factoryMethod = ReflectionUtils.findMethod(clazz, methodName, methodParameters).orElse(null);
|
||||
+ if (factoryMethod != null) {
|
||||
+ return factoryMethod;
|
||||
+ }
|
||||
+
|
||||
+ boolean explicitParameterListSpecified = //
|
||||
+ StringUtils.isNotBlank(methodParameters) || fullyQualifiedMethodName.endsWith("()");
|
||||
+
|
||||
+ // If we didn't find an exact match but an explicit parameter list was specified,
|
||||
+ // that's a user configuration error.
|
||||
+ Preconditions.condition(!explicitParameterListSpecified,
|
||||
+ () -> format("Could not find factory method [%s(%s)] in class [%s]", methodName, methodParameters,
|
||||
+ className));
|
||||
+
|
||||
+ // Otherwise, fall back to the same lenient search semantics that are used
|
||||
+ // to locate a "default" local factory method.
|
||||
+ return findFactoryMethodBySimpleName(clazz, testMethod, methodName);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Find the factory method by searching for all methods in the given {@code clazz}
|
||||
+ * with the desired {@code factoryMethodName} which have return types that can be
|
||||
+ * converted to a {@link Stream}, ignoring the {@code testMethod} itself as well
|
||||
+ * as any {@code @Test}, {@code @TestTemplate}, or {@code @TestFactory} methods
|
||||
+ * with the same name.
|
||||
+ *
|
||||
+ * @return the single factory method matching the search criteria
|
||||
+ * @throws PreconditionViolationException if the factory method was not found or
|
||||
+ * multiple competing factory methods with the same name were found
|
||||
+ */
|
||||
+ private static Method findFactoryMethodBySimpleName(Class<?> clazz, Method testMethod, String factoryMethodName) {
|
||||
+ Predicate<Method> isCandidate = candidate -> factoryMethodName.equals(candidate.getName())
|
||||
+ && !testMethod.equals(candidate);
|
||||
+ List<Method> candidates = ReflectionUtils.findMethods(clazz, isCandidate);
|
||||
+
|
||||
+ List<Method> factoryMethods = candidates.stream().filter(isFactoryMethod).collect(toList());
|
||||
+
|
||||
+ Preconditions.condition(factoryMethods.size() > 0, () -> {
|
||||
+ // If we didn't find the factory method using the isFactoryMethod Predicate, perhaps
|
||||
+ // the specified factory method has an invalid return type or is a test method.
|
||||
+ // In that case, we report the invalid candidates that were found.
|
||||
+ if (candidates.size() > 0) {
|
||||
+ return format(
|
||||
+ "Could not find valid factory method [%s] in class [%s] but found the following invalid candidates: %s",
|
||||
+ factoryMethodName, clazz.getName(), candidates);
|
||||
+ }
|
||||
+ // Otherwise, report that we didn't find anything.
|
||||
+ return format("Could not find factory method [%s] in class [%s]", factoryMethodName, clazz.getName());
|
||||
+ });
|
||||
+ Preconditions.condition(factoryMethods.size() == 1,
|
||||
+ () -> format("%d factory methods named [%s] were found in class [%s]: %s", factoryMethods.size(),
|
||||
+ factoryMethodName, clazz.getName(), factoryMethods));
|
||||
+ return factoryMethods.get(0);
|
||||
+ }
|
||||
+
|
||||
+ private static boolean isTestMethod(Method candidate) {
|
||||
+ return isAnnotated(candidate, Test.class) || isAnnotated(candidate, TestTemplate.class)
|
||||
+ || isAnnotated(candidate, TestFactory.class);
|
||||
+ }
|
||||
+
|
||||
+ private static Class<?> loadRequiredClass(String className, ClassLoader classLoader) {
|
||||
+ return ReflectionUtils.tryToLoadClass(className, classLoader).getOrThrow(
|
||||
+ cause -> new JUnitException(format("Could not load class [%s]", className), cause));
|
||||
+ }
|
||||
+
|
||||
+ private static Method validateFactoryMethod(Method factoryMethod, Object testInstance) {
|
||||
+ Preconditions.condition(
|
||||
+ factoryMethod.getDeclaringClass().isInstance(testInstance) || ReflectionUtils.isStatic(factoryMethod),
|
||||
+ () -> format("Method '%s' must be static: local factory methods must be static "
|
||||
+ + "unless the PER_CLASS @TestInstance lifecycle mode is used; "
|
||||
+ + "external factory methods must always be static.",
|
||||
+ factoryMethod.toGenericString()));
|
||||
+ return factoryMethod;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/test/java/io/papermc/paper/util/MethodParameterSource.java b/src/test/java/io/papermc/paper/util/MethodParameterSource.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..6cbf11c898439834cffb99ef84e5df1494356809
|
||||
--- /dev/null
|
||||
+++ b/src/test/java/io/papermc/paper/util/MethodParameterSource.java
|
||||
@@ -0,0 +1,14 @@
|
||||
+package io.papermc.paper.util;
|
||||
+
|
||||
+import java.lang.annotation.ElementType;
|
||||
+import java.lang.annotation.Retention;
|
||||
+import java.lang.annotation.RetentionPolicy;
|
||||
+import java.lang.annotation.Target;
|
||||
+import org.junitpioneer.jupiter.cartesian.CartesianArgumentsSource;
|
||||
+
|
||||
+@Retention(RetentionPolicy.RUNTIME)
|
||||
+@Target({ElementType.PARAMETER, ElementType.ANNOTATION_TYPE})
|
||||
+@CartesianArgumentsSource(MethodParameterProvider.class)
|
||||
+public @interface MethodParameterSource {
|
||||
+ String[] value() default {};
|
||||
+}
|
||||
diff --git a/src/test/java/org/bukkit/support/DummyServer.java b/src/test/java/org/bukkit/support/DummyServer.java
|
||||
index ee0cff84379bc0539b2c611a4904aff9f5843814..02a8e6b45bf304b6e0f88043a25188aa16b3d6bf 100644
|
||||
--- a/src/test/java/org/bukkit/support/DummyServer.java
|
||||
+++ b/src/test/java/org/bukkit/support/DummyServer.java
|
||||
@@ -50,6 +50,15 @@ public final class DummyServer {
|
||||
return registers.computeIfAbsent(aClass, key -> CraftRegistry.createRegistry(aClass, AbstractTestingBase.REGISTRY_CUSTOM));
|
||||
});
|
||||
|
||||
+ // Paper start - testing additions
|
||||
+ final Thread currentThread = Thread.currentThread();
|
||||
+ when(instance.isPrimaryThread()).thenAnswer(ignored -> Thread.currentThread().equals(currentThread));
|
||||
+
|
||||
+ final org.bukkit.plugin.PluginManager pluginManager = new org.bukkit.plugin.SimplePluginManager(instance, new org.bukkit.command.SimpleCommandMap(instance));
|
||||
+ when(instance.getPluginManager()).thenReturn(pluginManager);
|
||||
+ when(instance.getTag(anyString(), any(org.bukkit.NamespacedKey.class), any())).thenAnswer(ignored -> new io.papermc.paper.util.EmptyTag());
|
||||
+ // paper end - testing additions
|
||||
+
|
||||
Bukkit.setServer(instance);
|
||||
} catch (Throwable t) {
|
||||
throw new Error(t);
|
5085
patches/server/0005-Paper-config-files.patch
Normal file
5085
patches/server/0005-Paper-config-files.patch
Normal file
File diff suppressed because it is too large
Load diff
86
patches/server/0006-MC-Dev-fixes.patch
Normal file
86
patches/server/0006-MC-Dev-fixes.patch
Normal file
|
@ -0,0 +1,86 @@
|
|||
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/core/BlockPos.java b/src/main/java/net/minecraft/core/BlockPos.java
|
||||
index 478d2114fbd5c499a8adbf8b6cefcc8335e830dc..2074d4327f0c356c220f3a6a9761439e76a15fc3 100644
|
||||
--- a/src/main/java/net/minecraft/core/BlockPos.java
|
||||
+++ b/src/main/java/net/minecraft/core/BlockPos.java
|
||||
@@ -427,12 +427,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 433b6673ea62d466c466c1ff3732041a8fcbb6b5..bc91370654f5da33cbfe7d42431568915c1159d6 100644
|
||||
--- a/src/main/java/net/minecraft/core/registries/BuiltInRegistries.java
|
||||
+++ b/src/main/java/net/minecraft/core/registries/BuiltInRegistries.java
|
||||
@@ -299,7 +299,7 @@ public class BuiltInRegistries {
|
||||
Bootstrap.checkBootstrapCalled(() -> "registry " + key);
|
||||
ResourceLocation resourceLocation = key.location();
|
||||
LOADERS.put(resourceLocation, () -> initializer.run(registry));
|
||||
- WRITABLE_REGISTRY.register((ResourceKey<WritableRegistry<?>>)key, registry, RegistrationInfo.BUILT_IN);
|
||||
+ WRITABLE_REGISTRY.register((ResourceKey)key, registry, RegistrationInfo.BUILT_IN); // Paper - decompile fix
|
||||
return registry;
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/nbt/TagParser.java b/src/main/java/net/minecraft/nbt/TagParser.java
|
||||
index a614e960fcd5958ad17b679eee8a8e6926f58e62..da101bca71f4710812621b98f0a0d8cab180346a 100644
|
||||
--- a/src/main/java/net/minecraft/nbt/TagParser.java
|
||||
+++ b/src/main/java/net/minecraft/nbt/TagParser.java
|
||||
@@ -253,11 +253,11 @@ public class TagParser {
|
||||
}
|
||||
|
||||
if (typeReader == ByteTag.TYPE) {
|
||||
- list.add((T)((NumericTag)tag).getAsByte());
|
||||
+ list.add((T)(Byte)((NumericTag)tag).getAsByte()); // Paper - decompile fix
|
||||
} else if (typeReader == LongTag.TYPE) {
|
||||
- list.add((T)((NumericTag)tag).getAsLong());
|
||||
+ list.add((T)(Long)((NumericTag)tag).getAsLong()); // Paper - decompile fix
|
||||
} else {
|
||||
- list.add((T)((NumericTag)tag).getAsInt());
|
||||
+ list.add((T)(Integer)((NumericTag)tag).getAsInt()); // Paper - decompile fix
|
||||
}
|
||||
|
||||
if (!this.hasElementSeparator()) {
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index 254e362cd54359512285bab632dbae3cec0f03e0..a3d44867e6243f30640df91a0285ed735a9f1f34 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -1924,7 +1924,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/util/SortedArraySet.java b/src/main/java/net/minecraft/util/SortedArraySet.java
|
||||
index 661a6274a800ca9b91bdb809d026972d23c3b263..ea72dcb064a35bc6245bc5c94d592efedd8faf41 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) {
|
7018
patches/server/0007-ConcurrentUtil.patch
Normal file
7018
patches/server/0007-ConcurrentUtil.patch
Normal file
File diff suppressed because it is too large
Load diff
155
patches/server/0008-CB-fixes.patch
Normal file
155
patches/server/0008-CB-fixes.patch
Normal file
|
@ -0,0 +1,155 @@
|
|||
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 cc5e1076bdf7b4794ee79934fb70234ba61efe15..b3caf69f9627ba2114dc9d06551ccf182debfb04 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -302,7 +302,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/animal/camel/Camel.java b/src/main/java/net/minecraft/world/entity/animal/camel/Camel.java
|
||||
index 85e0a68d85fe62df19ad9809b1869a3eee6d5465..09aa76ec6f89163c1221721008ccb541eaf420ca 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
|
||||
@@ -451,15 +451,9 @@ public class Camel extends AbstractHorse implements PlayerRideableJumping, Saddl
|
||||
}
|
||||
|
||||
@Override
|
||||
- // CraftBukkit start - void -> boolean
|
||||
- public boolean actuallyHurt(DamageSource damagesource, float f) {
|
||||
- boolean hurt = super.actuallyHurt(damagesource, f);
|
||||
- if (!hurt) {
|
||||
- return hurt;
|
||||
- }
|
||||
- // CraftBukkit end
|
||||
+ public boolean actuallyHurt(DamageSource damagesource, float f) { // Paper - change return type to boolean
|
||||
this.standUpInstantly();
|
||||
- return hurt; // CraftBukkit
|
||||
+ return super.actuallyHurt(damagesource, f); // Paper - change return type to boolean
|
||||
}
|
||||
|
||||
@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 0dc7f88877020bddd5a84db51d349f52b673048e..aae73586265593ee7830fb8dd5c2e3d7560057f0 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
|
||||
@@ -40,7 +40,7 @@ public class StructureCheck {
|
||||
private final ChunkScanAccess storageAccess;
|
||||
private final RegistryAccess registryAccess;
|
||||
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 {
|
||||
ChunkScanAccess chunkIoWorker,
|
||||
RegistryAccess registryManager,
|
||||
StructureTemplateManager structureTemplateManager,
|
||||
- ResourceKey<Level> worldKey,
|
||||
+ ResourceKey<net.minecraft.world.level.dimension.LevelStem> worldKey, // Paper - fix missing CB diff
|
||||
ChunkGenerator chunkGenerator,
|
||||
RandomState noiseConfig,
|
||||
LevelHeightAccessor world,
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftLootTable.java b/src/main/java/org/bukkit/craftbukkit/CraftLootTable.java
|
||||
index 9b90649f71849b3830ca9b6a3c5a722c66b02f1f..209c6b64e79c29ea3bb84ddbe89a8bff66f81d0f 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftLootTable.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftLootTable.java
|
||||
@@ -197,4 +197,11 @@ public class CraftLootTable implements org.bukkit.loot.LootTable {
|
||||
org.bukkit.loot.LootTable table = (org.bukkit.loot.LootTable) obj;
|
||||
return table.getKey().equals(this.getKey());
|
||||
}
|
||||
+
|
||||
+ // Paper start - satisfy equals/hashCode contract
|
||||
+ @Override
|
||||
+ public int hashCode() {
|
||||
+ return java.util.Objects.hash(key);
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index 02ddd4e200a86d720297dbec508480fc0cd270d1..080c0cf84d959e1acdde088f367bd005ea9c3bbd 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -2482,7 +2482,13 @@ public final class CraftServer implements Server {
|
||||
Preconditions.checkArgument(key != null, "NamespacedKey key cannot be null");
|
||||
|
||||
ReloadableServerRegistries.Holder registry = this.getServer().reloadableRegistries();
|
||||
- return new CraftLootTable(key, registry.getLootTable(CraftLootTable.bukkitKeyToMinecraft(key)));
|
||||
+ // Paper start - honor method contract
|
||||
+ final ResourceKey<net.minecraft.world.level.storage.loot.LootTable> lootTableKey = CraftLootTable.bukkitKeyToMinecraft(key);
|
||||
+ final Optional<net.minecraft.world.level.storage.loot.LootTable> table = registry.get().lookup(Registries.LOOT_TABLE)
|
||||
+ .flatMap(registryEntryLookup -> registryEntryLookup.get(lootTableKey))
|
||||
+ .map(net.minecraft.core.Holder::value);
|
||||
+ return table.map(lootTable -> new CraftLootTable(key, lootTable)).orElse(null);
|
||||
+ // Paper end
|
||||
}
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||
index 1e3ca7ca98abfd5be233a7eeb6dad201776d2d6a..9ec50bbb262b25fea157ae48e8395f5cd38f8906 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||
@@ -123,6 +123,7 @@ public class Main {
|
||||
this.acceptsAll(Main.asList("forceUpgrade"), "Whether to force a world upgrade");
|
||||
this.acceptsAll(Main.asList("eraseCache"), "Whether to force cache erase during world upgrade");
|
||||
this.acceptsAll(Main.asList("recreateRegionFiles"), "Whether to recreate region files during world upgrade");
|
||||
+ this.accepts("safeMode", "Loads level with vanilla datapack only"); // Paper
|
||||
this.acceptsAll(Main.asList("nogui"), "Disables the graphical console");
|
||||
|
||||
this.acceptsAll(Main.asList("nojline"), "Disables jline and emulates the vanilla console");
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
|
||||
index 905adf97c0d1f0d1c774a6835a5dffcfea884e58..c017ce2ca1bc535795c958a2e509af2adf88efa9 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
|
||||
@@ -26,6 +26,7 @@ import org.bukkit.scheduler.BukkitWorker;
|
||||
|
||||
/**
|
||||
* The fundamental concepts for this implementation:
|
||||
+ * <ul>
|
||||
* <li>Main thread owns {@link #head} and {@link #currentTick}, but it may be read from any thread</li>
|
||||
* <li>Main thread exclusively controls {@link #temp} and {@link #pending}.
|
||||
* They are never to be accessed outside of the main thread; alternatives exist to prevent locking.</li>
|
||||
@@ -41,6 +42,7 @@ import org.bukkit.scheduler.BukkitWorker;
|
||||
* <li>Sync tasks are only to be removed from runners on the main thread when coupled with a removal from pending and temp.</li>
|
||||
* <li>Most of the design in this scheduler relies on queuing special tasks to perform any data changes on the main thread.
|
||||
* When executed from inside a synchronous method, the scheduler will be updated before next execution by virtue of the frequent {@link #parsePending()} calls.</li>
|
||||
+ * </ul>
|
||||
*/
|
||||
public class CraftScheduler implements BukkitScheduler {
|
||||
|
||||
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 5ac25dab93fd4c9e9533c80d1ca3d93446d7a365..245ad120a36b6defca7e6889faae1ca5fc33d0c7 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();
|
||||
}
|
8302
patches/server/0009-MC-Utils.patch
Normal file
8302
patches/server/0009-MC-Utils.patch
Normal file
File diff suppressed because it is too large
Load diff
5935
patches/server/0010-Adventure.patch
Normal file
5935
patches/server/0010-Adventure.patch
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue