mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
apply all api patches
This commit is contained in:
527
patches/api/0001-Pufferfish-API-Changes.patch
Normal file
527
patches/api/0001-Pufferfish-API-Changes.patch
Normal file
@@ -0,0 +1,527 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Kevin Raneri <kevin.raneri@gmail.com>
|
||||
Date: Tue, 9 Nov 2021 14:01:56 -0500
|
||||
Subject: [PATCH] Pufferfish API Changes
|
||||
|
||||
Pufferfish
|
||||
Copyright (C) 2022 Pufferfish Studios LLC
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
diff --git a/build.gradle.kts b/build.gradle.kts
|
||||
index 254fd96d3950b4494c7e43547b00b5175ee53c93..c1a6edfcfb363454b4ae5e5f9a63e75903a3d8bb 100644
|
||||
--- a/build.gradle.kts
|
||||
+++ b/build.gradle.kts
|
||||
@@ -52,6 +52,7 @@ dependencies {
|
||||
apiAndDocs("net.kyori:adventure-text-logger-slf4j")
|
||||
api("org.apache.logging.log4j:log4j-api:$log4jVersion")
|
||||
api("org.slf4j:slf4j-api:$slf4jVersion")
|
||||
+ api("io.sentry:sentry:5.4.0") // Pufferfish
|
||||
|
||||
implementation("org.ow2.asm:asm:9.7.1")
|
||||
implementation("org.ow2.asm:asm-commons:9.7.1")
|
||||
@@ -135,6 +136,13 @@ val generateApiVersioningFile by tasks.registering {
|
||||
}
|
||||
}
|
||||
|
||||
+// Pufferfish Start
|
||||
+tasks.withType<JavaCompile> {
|
||||
+ val compilerArgs = options.compilerArgs
|
||||
+ compilerArgs.add("--add-modules=jdk.incubator.vector")
|
||||
+}
|
||||
+// Pufferfish End
|
||||
+
|
||||
tasks.jar {
|
||||
from(generateApiVersioningFile.map { it.outputs.files.singleFile }) {
|
||||
into("META-INF/maven/${project.group}/${project.name}")
|
||||
diff --git a/src/main/java/gg/pufferfish/pufferfish/sentry/SentryContext.java b/src/main/java/gg/pufferfish/pufferfish/sentry/SentryContext.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..10310fdd53de28efb8a8250f6d3b0c8eb08fb68a
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/gg/pufferfish/pufferfish/sentry/SentryContext.java
|
||||
@@ -0,0 +1,161 @@
|
||||
+package gg.pufferfish.pufferfish.sentry;
|
||||
+
|
||||
+import com.google.gson.Gson;
|
||||
+import java.lang.reflect.Field;
|
||||
+import java.lang.reflect.Modifier;
|
||||
+import java.util.Map;
|
||||
+import java.util.TreeMap;
|
||||
+import org.apache.logging.log4j.ThreadContext;
|
||||
+import org.bukkit.command.Command;
|
||||
+import org.bukkit.command.CommandSender;
|
||||
+import org.bukkit.entity.Player;
|
||||
+import org.bukkit.event.Event;
|
||||
+import org.bukkit.event.player.PlayerEvent;
|
||||
+import org.bukkit.plugin.Plugin;
|
||||
+import org.bukkit.plugin.RegisteredListener;
|
||||
+import org.jetbrains.annotations.Nullable;
|
||||
+
|
||||
+public class SentryContext {
|
||||
+
|
||||
+ private static final Gson GSON = new Gson();
|
||||
+
|
||||
+ public static void setPluginContext(@Nullable Plugin plugin) {
|
||||
+ if (plugin != null) {
|
||||
+ ThreadContext.put("pufferfishsentry_pluginname", plugin.getName());
|
||||
+ ThreadContext.put("pufferfishsentry_pluginversion", plugin.getDescription().getVersion());
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public static void removePluginContext() {
|
||||
+ ThreadContext.remove("pufferfishsentry_pluginname");
|
||||
+ ThreadContext.remove("pufferfishsentry_pluginversion");
|
||||
+ }
|
||||
+
|
||||
+ public static void setSenderContext(@Nullable CommandSender sender) {
|
||||
+ if (sender != null) {
|
||||
+ ThreadContext.put("pufferfishsentry_playername", sender.getName());
|
||||
+ if (sender instanceof Player player) {
|
||||
+ ThreadContext.put("pufferfishsentry_playerid", player.getUniqueId().toString());
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public static void removeSenderContext() {
|
||||
+ ThreadContext.remove("pufferfishsentry_playername");
|
||||
+ ThreadContext.remove("pufferfishsentry_playerid");
|
||||
+ }
|
||||
+
|
||||
+ public static void setEventContext(Event event, RegisteredListener registration) {
|
||||
+ setPluginContext(registration.getPlugin());
|
||||
+
|
||||
+ try {
|
||||
+ // Find the player that was involved with this event
|
||||
+ Player player = null;
|
||||
+ if (event instanceof PlayerEvent) {
|
||||
+ player = ((PlayerEvent) event).getPlayer();
|
||||
+ } else {
|
||||
+ Class<? extends Event> eventClass = event.getClass();
|
||||
+
|
||||
+ Field playerField = null;
|
||||
+
|
||||
+ for (Field field : eventClass.getDeclaredFields()) {
|
||||
+ if (field.getType().equals(Player.class)) {
|
||||
+ playerField = field;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (playerField != null) {
|
||||
+ playerField.setAccessible(true);
|
||||
+ player = (Player) playerField.get(event);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (player != null) {
|
||||
+ setSenderContext(player);
|
||||
+ }
|
||||
+ } catch (Exception e) {} // We can't really safely log exceptions.
|
||||
+
|
||||
+ ThreadContext.put("pufferfishsentry_eventdata", GSON.toJson(serializeFields(event)));
|
||||
+ }
|
||||
+
|
||||
+ public static void removeEventContext() {
|
||||
+ removePluginContext();
|
||||
+ removeSenderContext();
|
||||
+ ThreadContext.remove("pufferfishsentry_eventdata");
|
||||
+ }
|
||||
+
|
||||
+ private static Map<String, String> serializeFields(Object object) {
|
||||
+ Map<String, String> fields = new TreeMap<>();
|
||||
+ fields.put("_class", object.getClass().getName());
|
||||
+ for (Field declaredField : object.getClass().getDeclaredFields()) {
|
||||
+ try {
|
||||
+ if (Modifier.isStatic(declaredField.getModifiers())) {
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ String fieldName = declaredField.getName();
|
||||
+ if (fieldName.equals("handlers")) {
|
||||
+ continue;
|
||||
+ }
|
||||
+ declaredField.setAccessible(true);
|
||||
+ Object value = declaredField.get(object);
|
||||
+ if (value != null) {
|
||||
+ fields.put(fieldName, value.toString());
|
||||
+ } else {
|
||||
+ fields.put(fieldName, "<null>");
|
||||
+ }
|
||||
+ } catch (Exception e) {} // We can't really safely log exceptions.
|
||||
+ }
|
||||
+ return fields;
|
||||
+ }
|
||||
+
|
||||
+ public static class State {
|
||||
+
|
||||
+ private Plugin plugin;
|
||||
+ private Command command;
|
||||
+ private String commandLine;
|
||||
+ private Event event;
|
||||
+ private RegisteredListener registeredListener;
|
||||
+
|
||||
+ public Plugin getPlugin() {
|
||||
+ return plugin;
|
||||
+ }
|
||||
+
|
||||
+ public void setPlugin(Plugin plugin) {
|
||||
+ this.plugin = plugin;
|
||||
+ }
|
||||
+
|
||||
+ public Command getCommand() {
|
||||
+ return command;
|
||||
+ }
|
||||
+
|
||||
+ public void setCommand(Command command) {
|
||||
+ this.command = command;
|
||||
+ }
|
||||
+
|
||||
+ public String getCommandLine() {
|
||||
+ return commandLine;
|
||||
+ }
|
||||
+
|
||||
+ public void setCommandLine(String commandLine) {
|
||||
+ this.commandLine = commandLine;
|
||||
+ }
|
||||
+
|
||||
+ public Event getEvent() {
|
||||
+ return event;
|
||||
+ }
|
||||
+
|
||||
+ public void setEvent(Event event) {
|
||||
+ this.event = event;
|
||||
+ }
|
||||
+
|
||||
+ public RegisteredListener getRegisteredListener() {
|
||||
+ return registeredListener;
|
||||
+ }
|
||||
+
|
||||
+ public void setRegisteredListener(RegisteredListener registeredListener) {
|
||||
+ this.registeredListener = registeredListener;
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/gg/pufferfish/pufferfish/simd/SIMDChecker.java b/src/main/java/gg/pufferfish/pufferfish/simd/SIMDChecker.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..3441cdad70da1bd523c5933b1a914688718c2657
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/gg/pufferfish/pufferfish/simd/SIMDChecker.java
|
||||
@@ -0,0 +1,40 @@
|
||||
+package gg.pufferfish.pufferfish.simd;
|
||||
+
|
||||
+import java.util.logging.Level;
|
||||
+import java.util.logging.Logger;
|
||||
+import jdk.incubator.vector.FloatVector;
|
||||
+import jdk.incubator.vector.IntVector;
|
||||
+import jdk.incubator.vector.VectorSpecies;
|
||||
+
|
||||
+/**
|
||||
+ * Basically, java is annoying and we have to push this out to its own class.
|
||||
+ */
|
||||
+@Deprecated
|
||||
+public class SIMDChecker {
|
||||
+
|
||||
+ @Deprecated
|
||||
+ public static boolean canEnable(Logger logger) {
|
||||
+ try {
|
||||
+ if (SIMDDetection.getJavaVersion() < 17 || SIMDDetection.getJavaVersion() > 21) {
|
||||
+ return false;
|
||||
+ } else {
|
||||
+ SIMDDetection.testRun = true;
|
||||
+
|
||||
+ VectorSpecies<Integer> ISPEC = IntVector.SPECIES_PREFERRED;
|
||||
+ VectorSpecies<Float> FSPEC = FloatVector.SPECIES_PREFERRED;
|
||||
+
|
||||
+ logger.log(Level.INFO, "Max SIMD vector size on this system is " + ISPEC.vectorBitSize() + " bits (int)");
|
||||
+ logger.log(Level.INFO, "Max SIMD vector size on this system is " + FSPEC.vectorBitSize() + " bits (float)");
|
||||
+
|
||||
+ if (ISPEC.elementSize() < 2 || FSPEC.elementSize() < 2) {
|
||||
+ logger.log(Level.WARNING, "SIMD is not properly supported on this system!");
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ return true;
|
||||
+ }
|
||||
+ } catch (NoClassDefFoundError | Exception ignored) {} // Basically, we don't do anything. This lets us detect if it's not functional and disable it.
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+}
|
||||
diff --git a/src/main/java/gg/pufferfish/pufferfish/simd/SIMDDetection.java b/src/main/java/gg/pufferfish/pufferfish/simd/SIMDDetection.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..a84889d3e9cfc4d7ab5f867820a6484c6070711b
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/gg/pufferfish/pufferfish/simd/SIMDDetection.java
|
||||
@@ -0,0 +1,35 @@
|
||||
+package gg.pufferfish.pufferfish.simd;
|
||||
+
|
||||
+import java.util.logging.Logger;
|
||||
+
|
||||
+@Deprecated
|
||||
+public class SIMDDetection {
|
||||
+
|
||||
+ public static boolean isEnabled = false;
|
||||
+ public static boolean versionLimited = false;
|
||||
+ public static boolean testRun = false;
|
||||
+
|
||||
+ @Deprecated
|
||||
+ public static boolean canEnable(Logger logger) {
|
||||
+ try {
|
||||
+ return SIMDChecker.canEnable(logger);
|
||||
+ } catch (NoClassDefFoundError | Exception ignored) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @Deprecated
|
||||
+ public static int getJavaVersion() {
|
||||
+ // https://stackoverflow.com/a/2591122
|
||||
+ String version = System.getProperty("java.version");
|
||||
+ if(version.startsWith("1.")) {
|
||||
+ version = version.substring(2, 3);
|
||||
+ } else {
|
||||
+ int dot = version.indexOf(".");
|
||||
+ if(dot != -1) { version = version.substring(0, dot); }
|
||||
+ }
|
||||
+ version = version.split("-")[0]; // Azul is stupid
|
||||
+ return Integer.parseInt(version);
|
||||
+ }
|
||||
+
|
||||
+}
|
||||
diff --git a/src/main/java/gg/pufferfish/pufferfish/simd/VectorMapPalette.java b/src/main/java/gg/pufferfish/pufferfish/simd/VectorMapPalette.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..ae2464920c9412ac90b819a540ee58be0741465f
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/gg/pufferfish/pufferfish/simd/VectorMapPalette.java
|
||||
@@ -0,0 +1,83 @@
|
||||
+package gg.pufferfish.pufferfish.simd;
|
||||
+
|
||||
+import java.awt.Color;
|
||||
+import jdk.incubator.vector.FloatVector;
|
||||
+import jdk.incubator.vector.IntVector;
|
||||
+import jdk.incubator.vector.VectorMask;
|
||||
+import jdk.incubator.vector.VectorSpecies;
|
||||
+import org.bukkit.map.MapPalette;
|
||||
+
|
||||
+@Deprecated
|
||||
+public class VectorMapPalette {
|
||||
+
|
||||
+ private static final VectorSpecies<Integer> I_SPEC = IntVector.SPECIES_PREFERRED;
|
||||
+ private static final VectorSpecies<Float> F_SPEC = FloatVector.SPECIES_PREFERRED;
|
||||
+
|
||||
+ @Deprecated
|
||||
+ public static void matchColorVectorized(int[] in, byte[] out) {
|
||||
+ int speciesLength = I_SPEC.length();
|
||||
+ int i;
|
||||
+ for (i = 0; i < in.length - speciesLength; i += speciesLength) {
|
||||
+ float[] redsArr = new float[speciesLength];
|
||||
+ float[] bluesArr = new float[speciesLength];
|
||||
+ float[] greensArr = new float[speciesLength];
|
||||
+ int[] alphasArr = new int[speciesLength];
|
||||
+
|
||||
+ for (int j = 0; j < speciesLength; j++) {
|
||||
+ alphasArr[j] = (in[i + j] >> 24) & 0xFF;
|
||||
+ redsArr[j] = (in[i + j] >> 16) & 0xFF;
|
||||
+ greensArr[j] = (in[i + j] >> 8) & 0xFF;
|
||||
+ bluesArr[j] = (in[i + j] >> 0) & 0xFF;
|
||||
+ }
|
||||
+
|
||||
+ IntVector alphas = IntVector.fromArray(I_SPEC, alphasArr, 0);
|
||||
+ FloatVector reds = FloatVector.fromArray(F_SPEC, redsArr, 0);
|
||||
+ FloatVector greens = FloatVector.fromArray(F_SPEC, greensArr, 0);
|
||||
+ FloatVector blues = FloatVector.fromArray(F_SPEC, bluesArr, 0);
|
||||
+ IntVector resultIndex = IntVector.zero(I_SPEC);
|
||||
+ VectorMask<Integer> modificationMask = VectorMask.fromLong(I_SPEC, 0xffffffff);
|
||||
+
|
||||
+ modificationMask = modificationMask.and(alphas.lt(128).not());
|
||||
+ FloatVector bestDistances = FloatVector.broadcast(F_SPEC, Float.MAX_VALUE);
|
||||
+
|
||||
+ for (int c = 4; c < MapPalette.colors.length; c++) {
|
||||
+ // We're using 32-bit floats here because it's 2x faster and nobody will know the difference.
|
||||
+ // For correctness, the original algorithm uses 64-bit floats instead. Completely unnecessary.
|
||||
+ FloatVector compReds = FloatVector.broadcast(F_SPEC, MapPalette.colors[c].getRed());
|
||||
+ FloatVector compGreens = FloatVector.broadcast(F_SPEC, MapPalette.colors[c].getGreen());
|
||||
+ FloatVector compBlues = FloatVector.broadcast(F_SPEC, MapPalette.colors[c].getBlue());
|
||||
+
|
||||
+ FloatVector rMean = reds.add(compReds).div(2.0f);
|
||||
+ FloatVector rDiff = reds.sub(compReds);
|
||||
+ FloatVector gDiff = greens.sub(compGreens);
|
||||
+ FloatVector bDiff = blues.sub(compBlues);
|
||||
+
|
||||
+ FloatVector weightR = rMean.div(256.0f).add(2);
|
||||
+ FloatVector weightG = FloatVector.broadcast(F_SPEC, 4.0f);
|
||||
+ FloatVector weightB = FloatVector.broadcast(F_SPEC, 255.0f).sub(rMean).div(256.0f).add(2.0f);
|
||||
+
|
||||
+ FloatVector distance = weightR.mul(rDiff).mul(rDiff).add(weightG.mul(gDiff).mul(gDiff)).add(weightB.mul(bDiff).mul(bDiff));
|
||||
+
|
||||
+ // Now we compare to the best distance we've found.
|
||||
+ // This mask contains a "1" if better, and a "0" otherwise.
|
||||
+ VectorMask<Float> bestDistanceMask = distance.lt(bestDistances);
|
||||
+ bestDistances = bestDistances.blend(distance, bestDistanceMask); // Update the best distances
|
||||
+
|
||||
+ // Update the result array
|
||||
+ // We also AND with the modification mask because we don't want to interfere if the alpha value isn't large enough.
|
||||
+ resultIndex = resultIndex.blend(c, bestDistanceMask.cast(I_SPEC).and(modificationMask)); // Update the results
|
||||
+ }
|
||||
+
|
||||
+ for (int j = 0; j < speciesLength; j++) {
|
||||
+ int index = resultIndex.lane(j);
|
||||
+ out[i + j] = (byte) (index < 128 ? index : -129 + (index - 127));
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ // For the final ones, fall back to the regular method
|
||||
+ for (; i < in.length; i++) {
|
||||
+ out[i] = MapPalette.matchColor(new Color(in[i], true));
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+}
|
||||
diff --git a/src/main/java/org/bukkit/map/MapPalette.java b/src/main/java/org/bukkit/map/MapPalette.java
|
||||
index c80faa079eca1564847070f0338fc98024639829..e632d51d3487eb4807243b6705999ad124466bf5 100644
|
||||
--- a/src/main/java/org/bukkit/map/MapPalette.java
|
||||
+++ b/src/main/java/org/bukkit/map/MapPalette.java
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.bukkit.map;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
+import gg.pufferfish.pufferfish.simd.SIMDDetection; // Pufferfish
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Image;
|
||||
@@ -40,7 +41,7 @@ public final class MapPalette {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
- static final Color[] colors = {
|
||||
+ public static final Color[] colors = { // Pufferfish - public access
|
||||
c(0, 0, 0, 0), c(0, 0, 0, 0), c(0, 0, 0, 0), c(0, 0, 0, 0),
|
||||
c(89, 125, 39), c(109, 153, 48), c(127, 178, 56), c(67, 94, 29),
|
||||
c(174, 164, 115), c(213, 201, 140), c(247, 233, 163), c(130, 123, 86),
|
||||
@@ -211,9 +212,15 @@ public final class MapPalette {
|
||||
temp.getRGB(0, 0, temp.getWidth(), temp.getHeight(), pixels, 0, temp.getWidth());
|
||||
|
||||
byte[] result = new byte[temp.getWidth() * temp.getHeight()];
|
||||
+ // Pufferfish start
|
||||
+ if (!SIMDDetection.isEnabled) {
|
||||
for (int i = 0; i < pixels.length; i++) {
|
||||
result[i] = matchColor(new Color(pixels[i], true));
|
||||
}
|
||||
+ } else {
|
||||
+ gg.pufferfish.pufferfish.simd.VectorMapPalette.matchColorVectorized(pixels, result);
|
||||
+ }
|
||||
+ // Pufferfish end
|
||||
return result;
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/plugin/SimplePluginManager.java b/src/main/java/org/bukkit/plugin/SimplePluginManager.java
|
||||
index 003bece642b682985625db93cad93026352bfc66..e8ba4f1108f2548a487877027e37d81fc150e042 100644
|
||||
--- a/src/main/java/org/bukkit/plugin/SimplePluginManager.java
|
||||
+++ b/src/main/java/org/bukkit/plugin/SimplePluginManager.java
|
||||
@@ -597,7 +597,9 @@ public final class SimplePluginManager implements PluginManager {
|
||||
|
||||
// Paper start
|
||||
private void handlePluginException(String msg, Throwable ex, Plugin plugin) {
|
||||
+ gg.pufferfish.pufferfish.sentry.SentryContext.setPluginContext(plugin); // Pufferfish
|
||||
server.getLogger().log(Level.SEVERE, msg, ex);
|
||||
+ gg.pufferfish.pufferfish.sentry.SentryContext.removePluginContext(); // Pufferfish
|
||||
callEvent(new com.destroystokyo.paper.event.server.ServerExceptionEvent(new com.destroystokyo.paper.exception.ServerPluginEnableDisableException(msg, ex, plugin)));
|
||||
}
|
||||
// Paper end
|
||||
@@ -667,9 +669,11 @@ public final class SimplePluginManager implements PluginManager {
|
||||
));
|
||||
}
|
||||
} catch (Throwable ex) {
|
||||
+ gg.pufferfish.pufferfish.sentry.SentryContext.setEventContext(event, registration); // Pufferfish
|
||||
// Paper start - error reporting
|
||||
String msg = "Could not pass event " + event.getEventName() + " to " + registration.getPlugin().getDescription().getFullName();
|
||||
server.getLogger().log(Level.SEVERE, msg, ex);
|
||||
+ gg.pufferfish.pufferfish.sentry.SentryContext.removeEventContext(); // Pufferfish
|
||||
if (!(event instanceof com.destroystokyo.paper.event.server.ServerExceptionEvent)) { // We don't want to cause an endless event loop
|
||||
callEvent(new com.destroystokyo.paper.event.server.ServerExceptionEvent(new com.destroystokyo.paper.exception.ServerEventException(msg, ex, registration.getPlugin(), registration.getListener(), event)));
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
|
||||
index eaefbb00e9993d54906cc8cf35cf753c0d6c7707..301e82369603f3dd6e6c1bd380da4bacacd7ef6c 100644
|
||||
--- a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
|
||||
+++ b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
|
||||
@@ -336,7 +336,13 @@ public final class JavaPluginLoader implements PluginLoader {
|
||||
try {
|
||||
jPlugin.setEnabled(true);
|
||||
} catch (Throwable ex) {
|
||||
+ gg.pufferfish.pufferfish.sentry.SentryContext.setPluginContext(plugin); // Pufferfish
|
||||
server.getLogger().log(Level.SEVERE, "Error occurred while enabling " + plugin.getDescription().getFullName() + " (Is it up to date?)", ex);
|
||||
+ gg.pufferfish.pufferfish.sentry.SentryContext.removePluginContext(); // Pufferfish
|
||||
+ // Paper start - Disable plugins that fail to load
|
||||
+ this.server.getPluginManager().disablePlugin(jPlugin);
|
||||
+ return;
|
||||
+ // Paper end
|
||||
}
|
||||
|
||||
// Perhaps abort here, rather than continue going, but as it stands,
|
||||
@@ -361,7 +367,9 @@ public final class JavaPluginLoader implements PluginLoader {
|
||||
try {
|
||||
jPlugin.setEnabled(false);
|
||||
} catch (Throwable ex) {
|
||||
+ gg.pufferfish.pufferfish.sentry.SentryContext.setPluginContext(plugin); // Pufferfish
|
||||
server.getLogger().log(Level.SEVERE, "Error occurred while disabling " + plugin.getDescription().getFullName() + " (Is it up to date?)", ex);
|
||||
+ gg.pufferfish.pufferfish.sentry.SentryContext.removePluginContext(); // Pufferfish
|
||||
}
|
||||
|
||||
if (cloader instanceof PluginClassLoader) {
|
||||
diff --git a/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java b/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
|
||||
index 7e4f7cb2afbc145e532285c793573ad107bc3033..12449e18180d604e9cbbc744da74a8b222a18e1f 100644
|
||||
--- a/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
|
||||
+++ b/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java
|
||||
@@ -50,6 +50,8 @@ public final class PluginClassLoader extends URLClassLoader implements io.paperm
|
||||
private io.papermc.paper.plugin.provider.classloader.PluginClassLoaderGroup classLoaderGroup; // Paper
|
||||
public io.papermc.paper.plugin.provider.entrypoint.DependencyContext dependencyContext; // Paper
|
||||
|
||||
+ private boolean closed = false; // Pufferfish
|
||||
+
|
||||
static {
|
||||
ClassLoader.registerAsParallelCapable();
|
||||
}
|
||||
@@ -197,6 +199,7 @@ public final class PluginClassLoader extends URLClassLoader implements io.paperm
|
||||
throw new ClassNotFoundException(name);
|
||||
}
|
||||
|
||||
+ public boolean _airplane_hasClass(@NotNull String name) { return this.classes.containsKey(name); } // Pufferfish
|
||||
@Override
|
||||
protected Class<?> findClass(String name) throws ClassNotFoundException {
|
||||
if (name.startsWith("org.bukkit.") || name.startsWith("net.minecraft.")) {
|
||||
@@ -204,7 +207,7 @@ public final class PluginClassLoader extends URLClassLoader implements io.paperm
|
||||
}
|
||||
Class<?> result = classes.get(name);
|
||||
|
||||
- if (result == null) {
|
||||
+ if (result == null && !this.closed) { // Pufferfish
|
||||
String path = name.replace('.', '/').concat(".class");
|
||||
JarEntry entry = jar.getJarEntry(path);
|
||||
|
||||
@@ -251,6 +254,7 @@ public final class PluginClassLoader extends URLClassLoader implements io.paperm
|
||||
this.setClass(name, result); // Paper
|
||||
}
|
||||
|
||||
+ if (result == null) throw new ClassNotFoundException(name); // Pufferfish
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -265,6 +269,7 @@ public final class PluginClassLoader extends URLClassLoader implements io.paperm
|
||||
// Paper end
|
||||
super.close();
|
||||
} finally {
|
||||
+ this.closed = true; // Pufferfish
|
||||
jar.close();
|
||||
}
|
||||
}
|
||||
39
patches/api/0002-Fix-pufferfish-issues.patch
Normal file
39
patches/api/0002-Fix-pufferfish-issues.patch
Normal file
@@ -0,0 +1,39 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: BillyGalbreath <Blake.Galbreath@Gmail.com>
|
||||
Date: Tue, 4 Jan 2022 23:05:41 -0600
|
||||
Subject: [PATCH] Fix pufferfish issues
|
||||
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/ServerBuildInfo.java b/src/main/java/io/papermc/paper/ServerBuildInfo.java
|
||||
index 652ff54e7c50412503725d628bfe72ed03059790..a7c0936a1ee80618f9a504087c88814f738f4693 100644
|
||||
--- a/src/main/java/io/papermc/paper/ServerBuildInfo.java
|
||||
+++ b/src/main/java/io/papermc/paper/ServerBuildInfo.java
|
||||
@@ -19,6 +19,13 @@ public interface ServerBuildInfo {
|
||||
*/
|
||||
Key BRAND_PAPER_ID = Key.key("papermc", "paper");
|
||||
|
||||
+ // Purpur start
|
||||
+ /**
|
||||
+ * The brand id for Pufferfish.
|
||||
+ */
|
||||
+ Key BRAND_PUFFERFISH_ID = Key.key("pufferfish", "pufferfish");
|
||||
+ // Purpur end
|
||||
+
|
||||
/**
|
||||
* Gets the {@code ServerBuildInfo}.
|
||||
*
|
||||
diff --git a/src/test/java/org/bukkit/AnnotationTest.java b/src/test/java/org/bukkit/AnnotationTest.java
|
||||
index f9e4b16a21d6cc6c9cbbe06d20c8af25e72e3ddb..4028b230e7fe1c78520f227a377a2a61e8381ecc 100644
|
||||
--- a/src/test/java/org/bukkit/AnnotationTest.java
|
||||
+++ b/src/test/java/org/bukkit/AnnotationTest.java
|
||||
@@ -47,6 +47,10 @@ public class AnnotationTest {
|
||||
"org/bukkit/plugin/java/PluginClassLoader",
|
||||
// Generic functional interface
|
||||
"org/bukkit/util/Consumer",
|
||||
+ // Purpur start
|
||||
+ "gg/pufferfish/pufferfish/sentry/SentryContext",
|
||||
+ "gg/pufferfish/pufferfish/sentry/SentryContext$State",
|
||||
+ // Purpur end
|
||||
// Paper start
|
||||
"io/papermc/paper/util/TransformingRandomAccessList",
|
||||
"io/papermc/paper/util/TransformingRandomAccessList$TransformedListIterator",
|
||||
24
patches/api/0003-Rebrand.patch
Normal file
24
patches/api/0003-Rebrand.patch
Normal file
@@ -0,0 +1,24 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: granny <granny@purpurmc.org>
|
||||
Date: Thu, 16 May 2024 19:11:29 -0700
|
||||
Subject: [PATCH] Rebrand
|
||||
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/ServerBuildInfo.java b/src/main/java/io/papermc/paper/ServerBuildInfo.java
|
||||
index a7c0936a1ee80618f9a504087c88814f738f4693..7196594e07af19a14c320d77df893978525fe386 100644
|
||||
--- a/src/main/java/io/papermc/paper/ServerBuildInfo.java
|
||||
+++ b/src/main/java/io/papermc/paper/ServerBuildInfo.java
|
||||
@@ -26,6 +26,13 @@ public interface ServerBuildInfo {
|
||||
Key BRAND_PUFFERFISH_ID = Key.key("pufferfish", "pufferfish");
|
||||
// Purpur end
|
||||
|
||||
+ // Purpur start
|
||||
+ /**
|
||||
+ * The brand id for Purpur.
|
||||
+ */
|
||||
+ Key BRAND_PURPUR_ID = Key.key("purpurmc", "purpur");
|
||||
+ // Purpur end
|
||||
+
|
||||
/**
|
||||
* Gets the {@code ServerBuildInfo}.
|
||||
*
|
||||
29
patches/api/0004-Purpur-config-files.patch
Normal file
29
patches/api/0004-Purpur-config-files.patch
Normal file
@@ -0,0 +1,29 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
|
||||
Date: Tue, 18 Feb 2020 20:30:03 -0600
|
||||
Subject: [PATCH] Purpur config files
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
|
||||
index 20750c09d819d62f32491db8672936b929e1098e..959d6ec728ac6cb4d0b8e31056ab3a417c684a92 100644
|
||||
--- a/src/main/java/org/bukkit/Server.java
|
||||
+++ b/src/main/java/org/bukkit/Server.java
|
||||
@@ -2214,6 +2214,18 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
|
||||
}
|
||||
// Paper end
|
||||
|
||||
+ // Purpur start
|
||||
+ @NotNull
|
||||
+ public org.bukkit.configuration.file.YamlConfiguration getPurpurConfig() {
|
||||
+ throw new UnsupportedOperationException("Not supported yet.");
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ public java.util.Properties getServerProperties() {
|
||||
+ throw new UnsupportedOperationException("Not supported yet.");
|
||||
+ }
|
||||
+ // Purpur end
|
||||
+
|
||||
/**
|
||||
* Sends the component to the player
|
||||
*
|
||||
19
patches/api/0005-Build-System-Changes.patch
Normal file
19
patches/api/0005-Build-System-Changes.patch
Normal file
@@ -0,0 +1,19 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Ben Kerllenevich <ben@omega24.dev>
|
||||
Date: Sat, 12 Jun 2021 12:35:38 -0400
|
||||
Subject: [PATCH] Build System Changes
|
||||
|
||||
|
||||
diff --git a/build.gradle.kts b/build.gradle.kts
|
||||
index c1a6edfcfb363454b4ae5e5f9a63e75903a3d8bb..628ec6699d34c1877c02001de95096bc7b44120e 100644
|
||||
--- a/build.gradle.kts
|
||||
+++ b/build.gradle.kts
|
||||
@@ -155,6 +155,8 @@ tasks.jar {
|
||||
}
|
||||
|
||||
tasks.withType<Javadoc> {
|
||||
+ (options as StandardJavadocDocletOptions).addStringOption("-add-modules", "jdk.incubator.vector") // Purpur - our javadocs need this for pufferfish's SIMD patch
|
||||
+ (options as StandardJavadocDocletOptions).addStringOption("Xdoclint:none", "-quiet") // Purpur - silence Paper's bajillion javadoc warnings
|
||||
val options = options as StandardJavadocDocletOptions
|
||||
options.overview = "src/main/javadoc/overview.html"
|
||||
options.use()
|
||||
24
patches/api/0006-Purpur-client-support.patch
Normal file
24
patches/api/0006-Purpur-client-support.patch
Normal file
@@ -0,0 +1,24 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Fredthedoggy <45927799+fredthedoggy@users.noreply.github.com>
|
||||
Date: Thu, 19 Aug 2021 20:04:18 -0400
|
||||
Subject: [PATCH] Purpur client support
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java
|
||||
index 95f0b3186e313c7fbd5c8531d52b82a69e525f94..76fd6c5377bb5b4d1c1f508456931bf27ad49e3e 100644
|
||||
--- a/src/main/java/org/bukkit/entity/Player.java
|
||||
+++ b/src/main/java/org/bukkit/entity/Player.java
|
||||
@@ -3911,4 +3911,13 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
|
||||
*/
|
||||
void sendEntityEffect(org.bukkit.@NotNull EntityEffect effect, @NotNull Entity target);
|
||||
// Paper end - entity effect API
|
||||
+
|
||||
+ // Purpur start
|
||||
+ /**
|
||||
+ * Allows you to get if player uses Purpur Client
|
||||
+ *
|
||||
+ * @return True if Player uses Purpur Client
|
||||
+ */
|
||||
+ public boolean usesPurpurClient();
|
||||
+ // Purpur end
|
||||
}
|
||||
124
patches/api/0007-Default-permissions.patch
Normal file
124
patches/api/0007-Default-permissions.patch
Normal file
@@ -0,0 +1,124 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
|
||||
Date: Fri, 5 Jun 2020 23:32:38 -0500
|
||||
Subject: [PATCH] Default permissions
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/util/permissions/CommandPermissions.java b/src/main/java/org/bukkit/util/permissions/CommandPermissions.java
|
||||
index 7763d6101ac61900db1e2310966b99584539fd0e..d5a42707d365ffd72532bbb1a59a1ca7145f9918 100644
|
||||
--- a/src/main/java/org/bukkit/util/permissions/CommandPermissions.java
|
||||
+++ b/src/main/java/org/bukkit/util/permissions/CommandPermissions.java
|
||||
@@ -18,6 +18,7 @@ public final class CommandPermissions {
|
||||
DefaultPermissions.registerPermission(PREFIX + "plugins", "Allows the user to view the list of plugins running on this server", PermissionDefault.TRUE, commands);
|
||||
DefaultPermissions.registerPermission(PREFIX + "reload", "Allows the user to reload the server settings", PermissionDefault.OP, commands);
|
||||
DefaultPermissions.registerPermission(PREFIX + "version", "Allows the user to view the version of the server", PermissionDefault.TRUE, commands);
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "purpur", "Allows the user to use the purpur command", PermissionDefault.OP, commands); // Purpur
|
||||
|
||||
commands.recalculatePermissibles();
|
||||
return commands;
|
||||
diff --git a/src/main/java/org/bukkit/util/permissions/DefaultPermissions.java b/src/main/java/org/bukkit/util/permissions/DefaultPermissions.java
|
||||
index e1a4ddf2c07cdd242fa8054a0152522fe4039e85..8e481e3815f5645ee92f0d229e5ff25c8fc9a6c2 100644
|
||||
--- a/src/main/java/org/bukkit/util/permissions/DefaultPermissions.java
|
||||
+++ b/src/main/java/org/bukkit/util/permissions/DefaultPermissions.java
|
||||
@@ -89,6 +89,8 @@ public final class DefaultPermissions {
|
||||
CommandPermissions.registerPermissions(parent);
|
||||
BroadcastPermissions.registerPermissions(parent);
|
||||
|
||||
+ PurpurPermissions.registerPermissions(); // Purpur
|
||||
+
|
||||
parent.recalculatePermissibles();
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/util/permissions/PurpurPermissions.java b/src/main/java/org/bukkit/util/permissions/PurpurPermissions.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..baec4c87d7ea4d54934ca22fd1eb7b46dd69061b
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/bukkit/util/permissions/PurpurPermissions.java
|
||||
@@ -0,0 +1,87 @@
|
||||
+package org.bukkit.util.permissions;
|
||||
+
|
||||
+import org.bukkit.entity.Entity;
|
||||
+import org.bukkit.entity.EntityType;
|
||||
+import org.bukkit.entity.Mob;
|
||||
+import org.bukkit.permissions.Permission;
|
||||
+import org.bukkit.permissions.PermissionDefault;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+import java.util.HashSet;
|
||||
+import java.util.Set;
|
||||
+
|
||||
+public final class PurpurPermissions {
|
||||
+ private static final String ROOT = "purpur";
|
||||
+ private static final String PREFIX = ROOT + ".";
|
||||
+ private static final Set<String> mobs = new HashSet<>();
|
||||
+
|
||||
+ static {
|
||||
+ for (EntityType mob : EntityType.values()) {
|
||||
+ Class<? extends Entity> clazz = mob.getEntityClass();
|
||||
+ if (clazz != null && Mob.class.isAssignableFrom(clazz)) {
|
||||
+ mobs.add(mob.getName());
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ public static Permission registerPermissions() {
|
||||
+ Permission purpur = DefaultPermissions.registerPermission(ROOT, "Gives the user the ability to use all Purpur utilities and commands", PermissionDefault.FALSE);
|
||||
+
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "enderchest.rows.six", "Gives the user six rows of enderchest space", PermissionDefault.FALSE, purpur);
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "enderchest.rows.five", "Gives the user five rows of enderchest space", PermissionDefault.FALSE, purpur);
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "enderchest.rows.four", "Gives the user four rows of enderchest space", PermissionDefault.FALSE, purpur);
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "enderchest.rows.three", "Gives the user three rows of enderchest space", PermissionDefault.FALSE, purpur);
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "enderchest.rows.two", "Gives the user two rows of enderchest space", PermissionDefault.FALSE, purpur);
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "enderchest.rows.one", "Gives the user one row of enderchest space", PermissionDefault.FALSE, purpur);
|
||||
+
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "debug.f3n", "Allows the user to use F3+N keybind to swap gamemodes", PermissionDefault.FALSE, purpur);
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "joinfullserver", "Allows the user to join a full server", PermissionDefault.OP, purpur);
|
||||
+
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "drop.spawners", "Allows the user to drop spawner cage when broken with diamond pickaxe with silk touch", PermissionDefault.FALSE, purpur);
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "place.spawners", "Allows the user to place spawner cage in the world", PermissionDefault.FALSE, purpur);
|
||||
+
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "mending_shift_click", "Allows the user to use shift-right-click to mend items", PermissionDefault.FALSE, purpur);
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "inventory_totem", "Uses a totem from anywhere in the user's inventory on death", PermissionDefault.FALSE, purpur);
|
||||
+
|
||||
+ Permission anvil = DefaultPermissions.registerPermission(PREFIX + "anvil", "Allows the user to use all anvil color and format abilities", PermissionDefault.FALSE, purpur);
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "anvil.color", "Allows the user to use color codes in an anvil", PermissionDefault.FALSE, anvil);
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "anvil.minimessage", "Allows the user to use minimessage tags in an anvil", PermissionDefault.FALSE, anvil);
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "anvil.remove_italics", "Allows the user to remove italics in an anvil", PermissionDefault.FALSE, anvil);
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "anvil.format", "Allows the user to use format codes in an anvil", PermissionDefault.FALSE, anvil);
|
||||
+ anvil.recalculatePermissibles();
|
||||
+
|
||||
+ Permission book = DefaultPermissions.registerPermission(PREFIX + "book", "Allows the user to use color codes on books", PermissionDefault.FALSE, purpur);
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "book.color.edit", "Allows the user to use color codes on books when editing", PermissionDefault.FALSE, book);
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "book.color.sign", "Allows the user to use color codes on books when signing", PermissionDefault.FALSE, book);
|
||||
+ book.recalculatePermissibles();
|
||||
+
|
||||
+ Permission sign = DefaultPermissions.registerPermission(PREFIX + "sign", "Allows the user to use all sign abilities", PermissionDefault.FALSE, purpur);
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "sign.edit", "Allows the user to click signs to open sign editor", PermissionDefault.FALSE, sign);
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "sign.color", "Allows the user to use color codes on signs", PermissionDefault.FALSE, sign);
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "sign.style", "Allows the user to use style codes on signs", PermissionDefault.FALSE, sign);
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "sign.magic", "Allows the user to use magic/obfuscate code on signs", PermissionDefault.FALSE, sign);
|
||||
+ sign.recalculatePermissibles();
|
||||
+
|
||||
+ Permission ride = DefaultPermissions.registerPermission("allow.ride", "Allows the user to ride all mobs", PermissionDefault.FALSE, purpur);
|
||||
+ for (String mob : mobs) {
|
||||
+ DefaultPermissions.registerPermission("allow.ride." + mob, "Allows the user to ride " + mob, PermissionDefault.FALSE, ride);
|
||||
+ }
|
||||
+ ride.recalculatePermissibles();
|
||||
+
|
||||
+ Permission special = DefaultPermissions.registerPermission("allow.special", "Allows the user to use all mobs special abilities", PermissionDefault.FALSE, purpur);
|
||||
+ for (String mob : mobs) {
|
||||
+ DefaultPermissions.registerPermission("allow.special." + mob, "Allows the user to use " + mob + " special ability", PermissionDefault.FALSE, special);
|
||||
+ }
|
||||
+ special.recalculatePermissibles();
|
||||
+
|
||||
+ Permission powered = DefaultPermissions.registerPermission("allow.powered", "Allows the user to toggle all mobs powered state", PermissionDefault.FALSE, purpur);
|
||||
+ DefaultPermissions.registerPermission("allow.powered.creeper", "Allows the user to toggle creeper powered state", PermissionDefault.FALSE, powered);
|
||||
+ powered.recalculatePermissibles();
|
||||
+
|
||||
+ DefaultPermissions.registerPermission(PREFIX + "portal.instant", "Allows the user to bypass portal wait time", PermissionDefault.FALSE, purpur);
|
||||
+
|
||||
+ purpur.recalculatePermissibles();
|
||||
+ return purpur;
|
||||
+ }
|
||||
+}
|
||||
196
patches/api/0008-Ridables.patch
Normal file
196
patches/api/0008-Ridables.patch
Normal file
@@ -0,0 +1,196 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: William Blake Galbreath <blake.galbreath@gmail.com>
|
||||
Date: Sat, 4 May 2019 00:57:16 -0500
|
||||
Subject: [PATCH] Ridables
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/entity/Entity.java b/src/main/java/org/bukkit/entity/Entity.java
|
||||
index d0ae8a94db20281d3664d74718c65234eb2e5f83..bf6d13cc6b0566f4076383c8f170dc8c9589e416 100644
|
||||
--- a/src/main/java/org/bukkit/entity/Entity.java
|
||||
+++ b/src/main/java/org/bukkit/entity/Entity.java
|
||||
@@ -1172,4 +1172,35 @@ public interface Entity extends Metadatable, CommandSender, Nameable, Persistent
|
||||
*/
|
||||
void broadcastHurtAnimation(@NotNull java.util.Collection<Player> players);
|
||||
// Paper end - broadcast hurt animation
|
||||
+
|
||||
+ // Purpur start
|
||||
+ /**
|
||||
+ * Get the riding player
|
||||
+ *
|
||||
+ * @return Riding player
|
||||
+ */
|
||||
+ @Nullable
|
||||
+ Player getRider();
|
||||
+
|
||||
+ /**
|
||||
+ * Check if entity is being ridden
|
||||
+ *
|
||||
+ * @return True if being ridden
|
||||
+ */
|
||||
+ boolean hasRider();
|
||||
+
|
||||
+ /**
|
||||
+ * Check if entity is ridable
|
||||
+ *
|
||||
+ * @return True if ridable
|
||||
+ */
|
||||
+ boolean isRidable();
|
||||
+
|
||||
+ /**
|
||||
+ * Check if entity is ridable in water
|
||||
+ *
|
||||
+ * @return True if ridable in water
|
||||
+ */
|
||||
+ boolean isRidableInWater();
|
||||
+ // Purpur end
|
||||
}
|
||||
diff --git a/src/main/java/org/purpurmc/purpur/event/entity/RidableMoveEvent.java b/src/main/java/org/purpurmc/purpur/event/entity/RidableMoveEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..c31a656daa3df1ab87302d8f14110a828c920102
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/purpurmc/purpur/event/entity/RidableMoveEvent.java
|
||||
@@ -0,0 +1,100 @@
|
||||
+package org.purpurmc.purpur.event.entity;
|
||||
+
|
||||
+import com.google.common.base.Preconditions;
|
||||
+import org.bukkit.Location;
|
||||
+import org.bukkit.entity.Mob;
|
||||
+import org.bukkit.entity.Player;
|
||||
+import org.bukkit.event.Cancellable;
|
||||
+import org.bukkit.event.HandlerList;
|
||||
+import org.bukkit.event.entity.EntityEvent;
|
||||
+import org.jetbrains.annotations.ApiStatus;
|
||||
+import org.jspecify.annotations.NullMarked;
|
||||
+
|
||||
+/**
|
||||
+ * Triggered when a ridable mob moves with a rider
|
||||
+ */
|
||||
+@NullMarked
|
||||
+public class RidableMoveEvent extends EntityEvent implements Cancellable {
|
||||
+ private static final HandlerList handlers = new HandlerList();
|
||||
+ private boolean canceled;
|
||||
+ private final Player rider;
|
||||
+ private Location from;
|
||||
+ private Location to;
|
||||
+
|
||||
+ @ApiStatus.Internal
|
||||
+ public RidableMoveEvent(Mob entity, Player rider, Location from, Location to) {
|
||||
+ super(entity);
|
||||
+ this.rider = rider;
|
||||
+ this.from = from;
|
||||
+ this.to = to;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public Mob getEntity() {
|
||||
+ return (Mob) entity;
|
||||
+ }
|
||||
+
|
||||
+ public Player getRider() {
|
||||
+ return rider;
|
||||
+ }
|
||||
+
|
||||
+ public boolean isCancelled() {
|
||||
+ return canceled;
|
||||
+ }
|
||||
+
|
||||
+ public void setCancelled(boolean cancel) {
|
||||
+ canceled = cancel;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the location this entity moved from
|
||||
+ *
|
||||
+ * @return Location the entity moved from
|
||||
+ */
|
||||
+ public Location getFrom() {
|
||||
+ return from;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the location to mark as where the entity moved from
|
||||
+ *
|
||||
+ * @param from New location to mark as the entity's previous location
|
||||
+ */
|
||||
+ public void setFrom(Location from) {
|
||||
+ validateLocation(from);
|
||||
+ this.from = from;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the location this entity moved to
|
||||
+ *
|
||||
+ * @return Location the entity moved to
|
||||
+ */
|
||||
+ public Location getTo() {
|
||||
+ return to;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the location that this entity will move to
|
||||
+ *
|
||||
+ * @param to New Location this entity will move to
|
||||
+ */
|
||||
+ public void setTo(Location to) {
|
||||
+ validateLocation(to);
|
||||
+ this.to = to;
|
||||
+ }
|
||||
+
|
||||
+ private void validateLocation(Location loc) {
|
||||
+ Preconditions.checkArgument(loc != null, "Cannot use null location!");
|
||||
+ Preconditions.checkArgument(loc.getWorld() != null, "Cannot use null location with null world!");
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public HandlerList getHandlers() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+
|
||||
+ public static HandlerList getHandlerList() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/org/purpurmc/purpur/event/entity/RidableSpacebarEvent.java b/src/main/java/org/purpurmc/purpur/event/entity/RidableSpacebarEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..02de629f066ef7d4898b3053efa957edeea16a3f
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/purpurmc/purpur/event/entity/RidableSpacebarEvent.java
|
||||
@@ -0,0 +1,38 @@
|
||||
+package org.purpurmc.purpur.event.entity;
|
||||
+
|
||||
+import org.bukkit.entity.Entity;
|
||||
+import org.bukkit.event.Cancellable;
|
||||
+import org.bukkit.event.HandlerList;
|
||||
+import org.bukkit.event.entity.EntityEvent;
|
||||
+import org.jetbrains.annotations.ApiStatus;
|
||||
+import org.jspecify.annotations.NullMarked;
|
||||
+
|
||||
+@NullMarked
|
||||
+public class RidableSpacebarEvent extends EntityEvent implements Cancellable {
|
||||
+ private static final HandlerList handlers = new HandlerList();
|
||||
+ private boolean cancelled;
|
||||
+
|
||||
+ @ApiStatus.Internal
|
||||
+ public RidableSpacebarEvent(Entity entity) {
|
||||
+ super(entity);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isCancelled() {
|
||||
+ return cancelled;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setCancelled(boolean cancel) {
|
||||
+ cancelled = cancel;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public HandlerList getHandlers() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+
|
||||
+ public static HandlerList getHandlerList() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+}
|
||||
19
patches/api/0009-Allow-inventory-resizing.patch
Normal file
19
patches/api/0009-Allow-inventory-resizing.patch
Normal file
@@ -0,0 +1,19 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: William Blake Galbreath <blake.galbreath@gmail.com>
|
||||
Date: Tue, 23 Jul 2019 06:50:55 -0500
|
||||
Subject: [PATCH] Allow inventory resizing
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/event/inventory/InventoryType.java b/src/main/java/org/bukkit/event/inventory/InventoryType.java
|
||||
index 7184f80899206bedeac387e9f8a35482801efd4b..e4197c89c04b91732ce96981f8df0a0bdaee24ce 100644
|
||||
--- a/src/main/java/org/bukkit/event/inventory/InventoryType.java
|
||||
+++ b/src/main/java/org/bukkit/event/inventory/InventoryType.java
|
||||
@@ -164,7 +164,7 @@ public enum InventoryType {
|
||||
SMITHING_NEW(4, "Upgrade Gear", MenuType.SMITHING),
|
||||
;
|
||||
|
||||
- private final int size;
|
||||
+ private int size; public void setDefaultSize(int size) { this.size = size; } // Purpur - remove final and add setter
|
||||
private final String title;
|
||||
private final MenuType menuType;
|
||||
private final boolean isCreatable;
|
||||
137
patches/api/0010-Llama-API.patch
Normal file
137
patches/api/0010-Llama-API.patch
Normal file
@@ -0,0 +1,137 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: William Blake Galbreath <blake.galbreath@gmail.com>
|
||||
Date: Fri, 18 Oct 2019 22:50:05 -0500
|
||||
Subject: [PATCH] Llama API
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/entity/Llama.java b/src/main/java/org/bukkit/entity/Llama.java
|
||||
index bc84b892cae5fe7019a3ad481e9da79956efa1fe..48eb5b00c460cccde29d327cef1d63fc04d6a829 100644
|
||||
--- a/src/main/java/org/bukkit/entity/Llama.java
|
||||
+++ b/src/main/java/org/bukkit/entity/Llama.java
|
||||
@@ -119,4 +119,20 @@ public interface Llama extends ChestedHorse, RangedEntity { // Paper
|
||||
@org.jetbrains.annotations.Nullable
|
||||
Llama getCaravanTail();
|
||||
// Paper end
|
||||
+
|
||||
+ // Purpur start
|
||||
+ /**
|
||||
+ * Check if this Llama should attempt to join a caravan
|
||||
+ *
|
||||
+ * @return True if Llama is allowed to join a caravan
|
||||
+ */
|
||||
+ boolean shouldJoinCaravan();
|
||||
+
|
||||
+ /**
|
||||
+ * Set if this Llama should attempt to join a caravan
|
||||
+ *
|
||||
+ * @param shouldJoinCaravan True to allow joining a caravan
|
||||
+ */
|
||||
+ void setShouldJoinCaravan(boolean shouldJoinCaravan);
|
||||
+ // Purpur end
|
||||
}
|
||||
diff --git a/src/main/java/org/purpurmc/purpur/event/entity/LlamaJoinCaravanEvent.java b/src/main/java/org/purpurmc/purpur/event/entity/LlamaJoinCaravanEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..e34c37579dc8a5a108c03b9eff6bb916a910d867
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/purpurmc/purpur/event/entity/LlamaJoinCaravanEvent.java
|
||||
@@ -0,0 +1,60 @@
|
||||
+package org.purpurmc.purpur.event.entity;
|
||||
+
|
||||
+import org.bukkit.entity.Llama;
|
||||
+import org.bukkit.event.Cancellable;
|
||||
+import org.bukkit.event.HandlerList;
|
||||
+import org.bukkit.event.entity.EntityEvent;
|
||||
+import org.jetbrains.annotations.ApiStatus;
|
||||
+import org.jspecify.annotations.NullMarked;
|
||||
+
|
||||
+/**
|
||||
+ * Called when a Llama tries to join a caravan.
|
||||
+ * <p>
|
||||
+ * Cancelling the event will not let the Llama join. To prevent future attempts
|
||||
+ * at joining a caravan use {@link Llama#setShouldJoinCaravan(boolean)}.
|
||||
+ */
|
||||
+@NullMarked
|
||||
+public class LlamaJoinCaravanEvent extends EntityEvent implements Cancellable {
|
||||
+ private static final HandlerList handlers = new HandlerList();
|
||||
+ private boolean canceled;
|
||||
+ private final Llama head;
|
||||
+
|
||||
+ @ApiStatus.Internal
|
||||
+ public LlamaJoinCaravanEvent(Llama llama, Llama head) {
|
||||
+ super(llama);
|
||||
+ this.head = head;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public Llama getEntity() {
|
||||
+ return (Llama) entity;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Get the Llama that this Llama is about to follow
|
||||
+ *
|
||||
+ * @return Llama about to be followed
|
||||
+ */
|
||||
+ public Llama getHead() {
|
||||
+ return head;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isCancelled() {
|
||||
+ return canceled;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setCancelled(boolean cancel) {
|
||||
+ canceled = cancel;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public HandlerList getHandlers() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+
|
||||
+ public static HandlerList getHandlerList() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/org/purpurmc/purpur/event/entity/LlamaLeaveCaravanEvent.java b/src/main/java/org/purpurmc/purpur/event/entity/LlamaLeaveCaravanEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..23ea41ff5dc43a915a263aeb1a246705de8bf9e1
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/purpurmc/purpur/event/entity/LlamaLeaveCaravanEvent.java
|
||||
@@ -0,0 +1,34 @@
|
||||
+package org.purpurmc.purpur.event.entity;
|
||||
+
|
||||
+import org.bukkit.entity.Llama;
|
||||
+import org.bukkit.event.HandlerList;
|
||||
+import org.bukkit.event.entity.EntityEvent;
|
||||
+import org.jetbrains.annotations.ApiStatus;
|
||||
+import org.jspecify.annotations.NullMarked;
|
||||
+
|
||||
+/**
|
||||
+ * Called when a Llama leaves a caravan
|
||||
+ */
|
||||
+@NullMarked
|
||||
+public class LlamaLeaveCaravanEvent extends EntityEvent {
|
||||
+ private static final HandlerList handlers = new HandlerList();
|
||||
+
|
||||
+ @ApiStatus.Internal
|
||||
+ public LlamaLeaveCaravanEvent(Llama llama) {
|
||||
+ super(llama);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public Llama getEntity() {
|
||||
+ return (Llama) entity;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public HandlerList getHandlers() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+
|
||||
+ public static HandlerList getHandlerList() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+}
|
||||
113
patches/api/0011-AFK-API.patch
Normal file
113
patches/api/0011-AFK-API.patch
Normal file
@@ -0,0 +1,113 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: William Blake Galbreath <blake.galbreath@gmail.com>
|
||||
Date: Sat, 10 Aug 2019 22:19:56 -0500
|
||||
Subject: [PATCH] AFK API
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java
|
||||
index 76fd6c5377bb5b4d1c1f508456931bf27ad49e3e..5d449299f958cb747e62e9ccfc8ff6cc32236dcd 100644
|
||||
--- a/src/main/java/org/bukkit/entity/Player.java
|
||||
+++ b/src/main/java/org/bukkit/entity/Player.java
|
||||
@@ -3919,5 +3919,25 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
|
||||
* @return True if Player uses Purpur Client
|
||||
*/
|
||||
public boolean usesPurpurClient();
|
||||
+
|
||||
+ /**
|
||||
+ * Check if player is AFK
|
||||
+ *
|
||||
+ * @return True if AFK
|
||||
+ */
|
||||
+ boolean isAfk();
|
||||
+
|
||||
+ /**
|
||||
+ * Set player as AFK
|
||||
+ *
|
||||
+ * @param setAfk Whether to set AFK or not
|
||||
+ */
|
||||
+ void setAfk(boolean setAfk);
|
||||
+
|
||||
+ /**
|
||||
+ * Reset the idle timer back to 0
|
||||
+ * @deprecated Use {@link #resetIdleDuration()} instead
|
||||
+ */
|
||||
+ void resetIdleTimer();
|
||||
// Purpur end
|
||||
}
|
||||
diff --git a/src/main/java/org/purpurmc/purpur/event/PlayerAFKEvent.java b/src/main/java/org/purpurmc/purpur/event/PlayerAFKEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..e9637b82014fe3f4f4671b24d18f77f3d5e4b8ad
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/purpurmc/purpur/event/PlayerAFKEvent.java
|
||||
@@ -0,0 +1,71 @@
|
||||
+package org.purpurmc.purpur.event;
|
||||
+
|
||||
+import org.bukkit.entity.Player;
|
||||
+import org.bukkit.event.Cancellable;
|
||||
+import org.bukkit.event.HandlerList;
|
||||
+import org.bukkit.event.player.PlayerEvent;
|
||||
+import org.jetbrains.annotations.ApiStatus;
|
||||
+import org.jspecify.annotations.NullMarked;
|
||||
+import org.jspecify.annotations.Nullable;
|
||||
+
|
||||
+@NullMarked
|
||||
+public class PlayerAFKEvent extends PlayerEvent implements Cancellable {
|
||||
+ private static final HandlerList handlers = new HandlerList();
|
||||
+ private final boolean setAfk;
|
||||
+ private boolean shouldKick;
|
||||
+ private @Nullable String broadcast;
|
||||
+ private boolean cancel;
|
||||
+
|
||||
+ @ApiStatus.Internal
|
||||
+ public PlayerAFKEvent(Player player, boolean setAfk, boolean shouldKick, @Nullable String broadcast, boolean async) {
|
||||
+ super(player, async);
|
||||
+ this.setAfk = setAfk;
|
||||
+ this.shouldKick = shouldKick;
|
||||
+ this.broadcast = broadcast;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Whether player is going afk or coming back
|
||||
+ *
|
||||
+ * @return True if going afk. False is coming back
|
||||
+ */
|
||||
+ public boolean isGoingAfk() {
|
||||
+ return setAfk;
|
||||
+ }
|
||||
+
|
||||
+ public boolean shouldKick() {
|
||||
+ return shouldKick;
|
||||
+ }
|
||||
+
|
||||
+ public void setShouldKick(boolean shouldKick) {
|
||||
+ this.shouldKick = shouldKick;
|
||||
+ }
|
||||
+
|
||||
+ @Nullable
|
||||
+ public String getBroadcastMsg() {
|
||||
+ return broadcast;
|
||||
+ }
|
||||
+
|
||||
+ public void setBroadcastMsg(@Nullable String broadcast) {
|
||||
+ this.broadcast = broadcast;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isCancelled() {
|
||||
+ return cancel;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setCancelled(boolean cancel) {
|
||||
+ this.cancel = cancel;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public HandlerList getHandlers() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+
|
||||
+ public static HandlerList getHandlerList() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+}
|
||||
44
patches/api/0012-Bring-back-server-name.patch
Normal file
44
patches/api/0012-Bring-back-server-name.patch
Normal file
@@ -0,0 +1,44 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: William Blake Galbreath <blake.galbreath@gmail.com>
|
||||
Date: Sun, 26 May 2019 15:18:40 -0500
|
||||
Subject: [PATCH] Bring back server name
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
|
||||
index 2d466b308b2f8bd31c50f5d05416eadf20c9cb71..1f60816b6cd7a7bde13a49a0440ece2eb531fcd0 100644
|
||||
--- a/src/main/java/org/bukkit/Bukkit.java
|
||||
+++ b/src/main/java/org/bukkit/Bukkit.java
|
||||
@@ -2869,4 +2869,15 @@ public final class Bukkit {
|
||||
public static Server.Spigot spigot() {
|
||||
return server.spigot();
|
||||
}
|
||||
+
|
||||
+ // Purpur start
|
||||
+ /**
|
||||
+ * Get the name of this server
|
||||
+ * @return the name of the server
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public static String getServerName() {
|
||||
+ return server.getServerName();
|
||||
+ }
|
||||
+ // Purpur end
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
|
||||
index 959d6ec728ac6cb4d0b8e31056ab3a417c684a92..a300a50fc32497d9a33e3caa8142fb1f52d71afc 100644
|
||||
--- a/src/main/java/org/bukkit/Server.java
|
||||
+++ b/src/main/java/org/bukkit/Server.java
|
||||
@@ -2515,4 +2515,13 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
|
||||
*/
|
||||
boolean isOwnedByCurrentRegion(@NotNull Entity entity);
|
||||
// Paper end - Folia region threading API
|
||||
+
|
||||
+ // Purpur start
|
||||
+ /**
|
||||
+ * Get the name of this server
|
||||
+ * @return the name of the server
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ String getServerName();
|
||||
+ // Purpur end
|
||||
}
|
||||
172
patches/api/0013-ExecuteCommandEvent.patch
Normal file
172
patches/api/0013-ExecuteCommandEvent.patch
Normal file
@@ -0,0 +1,172 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: William Blake Galbreath <blake.galbreath@gmail.com>
|
||||
Date: Fri, 31 May 2019 00:08:28 -0500
|
||||
Subject: [PATCH] ExecuteCommandEvent
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/command/SimpleCommandMap.java b/src/main/java/org/bukkit/command/SimpleCommandMap.java
|
||||
index 5df19bd701c67506689fc7f49d91f99ebfbc83f0..a09b5458191eb5df4787859b72a37fa1fa2bffba 100644
|
||||
--- a/src/main/java/org/bukkit/command/SimpleCommandMap.java
|
||||
+++ b/src/main/java/org/bukkit/command/SimpleCommandMap.java
|
||||
@@ -153,6 +153,19 @@ public class SimpleCommandMap implements CommandMap {
|
||||
return false;
|
||||
}
|
||||
|
||||
+ // Purpur start
|
||||
+ String[] parsedArgs = Arrays.copyOfRange(args, 1, args.length);
|
||||
+ org.purpurmc.purpur.event.ExecuteCommandEvent event = new org.purpurmc.purpur.event.ExecuteCommandEvent(sender, target, sentCommandLabel, parsedArgs);
|
||||
+ if (!event.callEvent()) {
|
||||
+ return true; // cancelled
|
||||
+ }
|
||||
+
|
||||
+ sender = event.getSender();
|
||||
+ target = event.getCommand();
|
||||
+ sentCommandLabel = event.getLabel();
|
||||
+ parsedArgs = event.getArgs();
|
||||
+ // Purpur end
|
||||
+
|
||||
// Paper start - Plugins do weird things to workaround normal registration
|
||||
if (target.timings == null) {
|
||||
target.timings = co.aikar.timings.TimingsManager.getCommandTiming(null, target);
|
||||
@@ -162,7 +175,7 @@ public class SimpleCommandMap implements CommandMap {
|
||||
try {
|
||||
try (co.aikar.timings.Timing ignored = target.timings.startTiming()) { // Paper - use try with resources
|
||||
// Note: we don't return the result of target.execute as thats success / failure, we return handled (true) or not handled (false)
|
||||
- target.execute(sender, sentCommandLabel, Arrays.copyOfRange(args, 1, args.length));
|
||||
+ target.execute(sender, sentCommandLabel, parsedArgs); // Purpur
|
||||
} // target.timings.stopTiming(); // Spigot // Paper
|
||||
} catch (CommandException ex) {
|
||||
server.getPluginManager().callEvent(new com.destroystokyo.paper.event.server.ServerExceptionEvent(new com.destroystokyo.paper.exception.ServerCommandException(ex, target, sender, args))); // Paper
|
||||
diff --git a/src/main/java/org/purpurmc/purpur/event/ExecuteCommandEvent.java b/src/main/java/org/purpurmc/purpur/event/ExecuteCommandEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..55feef2321c7d966c72a33a58cf10136a9cacfa6
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/purpurmc/purpur/event/ExecuteCommandEvent.java
|
||||
@@ -0,0 +1,127 @@
|
||||
+package org.purpurmc.purpur.event;
|
||||
+
|
||||
+import com.google.common.base.Preconditions;
|
||||
+import org.bukkit.command.Command;
|
||||
+import org.bukkit.command.CommandSender;
|
||||
+import org.bukkit.event.Cancellable;
|
||||
+import org.bukkit.event.Event;
|
||||
+import org.bukkit.event.HandlerList;
|
||||
+import org.jetbrains.annotations.ApiStatus;
|
||||
+import org.jspecify.annotations.NullMarked;
|
||||
+import org.jspecify.annotations.Nullable;
|
||||
+
|
||||
+/**
|
||||
+ * This event is called whenever someone runs a command
|
||||
+ */
|
||||
+@NullMarked
|
||||
+public class ExecuteCommandEvent extends Event implements Cancellable {
|
||||
+ private static final HandlerList handlers = new HandlerList();
|
||||
+ private boolean cancel = false;
|
||||
+ private CommandSender sender;
|
||||
+ private Command command;
|
||||
+ private String label;
|
||||
+ private @Nullable String[] args;
|
||||
+
|
||||
+ @ApiStatus.Internal
|
||||
+ public ExecuteCommandEvent(CommandSender sender, Command command, String label, @Nullable String[] args) {
|
||||
+ this.sender = sender;
|
||||
+ this.command = command;
|
||||
+ this.label = label;
|
||||
+ this.args = args;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the command that the player is attempting to execute.
|
||||
+ *
|
||||
+ * @return Command the player is attempting to execute
|
||||
+ */
|
||||
+ public Command getCommand() {
|
||||
+ return command;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the command that the player will execute.
|
||||
+ *
|
||||
+ * @param command New command that the player will execute
|
||||
+ * @throws IllegalArgumentException if command is null or empty
|
||||
+ */
|
||||
+ public void setCommand(Command command) throws IllegalArgumentException {
|
||||
+ Preconditions.checkArgument(command != null, "Command cannot be null");
|
||||
+ this.command = command;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the sender that this command will be executed as.
|
||||
+ *
|
||||
+ * @return Sender this command will be executed as
|
||||
+ */
|
||||
+ public CommandSender getSender() {
|
||||
+ return sender;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the sender that this command will be executed as.
|
||||
+ *
|
||||
+ * @param sender New sender which this event will execute as
|
||||
+ * @throws IllegalArgumentException if the sender provided is null
|
||||
+ */
|
||||
+ public void setSender(final CommandSender sender) throws IllegalArgumentException {
|
||||
+ Preconditions.checkArgument(sender != null, "Sender cannot be null");
|
||||
+ this.sender = sender;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Get the label used to execute this command
|
||||
+ *
|
||||
+ * @return Label used to execute this command
|
||||
+ */
|
||||
+ public String getLabel() {
|
||||
+ return label;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Set the label used to execute this command
|
||||
+ *
|
||||
+ * @param label Label used
|
||||
+ */
|
||||
+ public void setLabel(String label) {
|
||||
+ this.label = label;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Get the args passed to the command
|
||||
+ *
|
||||
+ * @return Args passed to the command
|
||||
+ */
|
||||
+ public String[] getArgs() {
|
||||
+ return args;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Set the args passed to the command
|
||||
+ *
|
||||
+ * @param args Args passed to the command
|
||||
+ */
|
||||
+ public void setArgs(String[] args) {
|
||||
+ this.args = args;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isCancelled() {
|
||||
+ return cancel;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setCancelled(boolean cancel) {
|
||||
+ this.cancel = cancel;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public HandlerList getHandlers() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+
|
||||
+ public static HandlerList getHandlerList() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+}
|
||||
42
patches/api/0014-Lagging-threshold.patch
Normal file
42
patches/api/0014-Lagging-threshold.patch
Normal file
@@ -0,0 +1,42 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: William Blake Galbreath <blake.galbreath@gmail.com>
|
||||
Date: Tue, 23 Jul 2019 10:07:24 -0500
|
||||
Subject: [PATCH] Lagging threshold
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
|
||||
index 1f60816b6cd7a7bde13a49a0440ece2eb531fcd0..5fe1896c9d8c5848b1ba1220e52cbe4cfae75603 100644
|
||||
--- a/src/main/java/org/bukkit/Bukkit.java
|
||||
+++ b/src/main/java/org/bukkit/Bukkit.java
|
||||
@@ -2879,5 +2879,14 @@ public final class Bukkit {
|
||||
public static String getServerName() {
|
||||
return server.getServerName();
|
||||
}
|
||||
+
|
||||
+ /**
|
||||
+ * Check if server is lagging according to laggy threshold setting
|
||||
+ *
|
||||
+ * @return True if lagging
|
||||
+ */
|
||||
+ public static boolean isLagging() {
|
||||
+ return server.isLagging();
|
||||
+ }
|
||||
// Purpur end
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
|
||||
index a300a50fc32497d9a33e3caa8142fb1f52d71afc..7bef0845de3a3e51b375df735520ac8cc0f08636 100644
|
||||
--- a/src/main/java/org/bukkit/Server.java
|
||||
+++ b/src/main/java/org/bukkit/Server.java
|
||||
@@ -2523,5 +2523,12 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
|
||||
*/
|
||||
@NotNull
|
||||
String getServerName();
|
||||
+
|
||||
+ /**
|
||||
+ * Check if server is lagging according to laggy threshold setting
|
||||
+ *
|
||||
+ * @return True if lagging
|
||||
+ */
|
||||
+ boolean isLagging();
|
||||
// Purpur end
|
||||
}
|
||||
184
patches/api/0015-PlayerSetSpawnerTypeWithEggEvent.patch
Normal file
184
patches/api/0015-PlayerSetSpawnerTypeWithEggEvent.patch
Normal file
@@ -0,0 +1,184 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: William Blake Galbreath <blake.galbreath@gmail.com>
|
||||
Date: Fri, 5 Jul 2019 18:21:15 -0500
|
||||
Subject: [PATCH] PlayerSetSpawnerTypeWithEggEvent
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/purpurmc/purpur/event/PlayerSetSpawnerTypeWithEggEvent.java b/src/main/java/org/purpurmc/purpur/event/PlayerSetSpawnerTypeWithEggEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..795c558b481f4e2a550925bd88b8e7d41711456f
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/purpurmc/purpur/event/PlayerSetSpawnerTypeWithEggEvent.java
|
||||
@@ -0,0 +1,83 @@
|
||||
+package org.purpurmc.purpur.event;
|
||||
+
|
||||
+import org.bukkit.block.Block;
|
||||
+import org.bukkit.block.CreatureSpawner;
|
||||
+import org.bukkit.entity.EntityType;
|
||||
+import org.bukkit.entity.Player;
|
||||
+import org.bukkit.event.Cancellable;
|
||||
+import org.bukkit.event.HandlerList;
|
||||
+import org.bukkit.event.player.PlayerEvent;
|
||||
+import org.jetbrains.annotations.ApiStatus;
|
||||
+import org.jspecify.annotations.NullMarked;
|
||||
+
|
||||
+@NullMarked
|
||||
+public class PlayerSetSpawnerTypeWithEggEvent extends PlayerEvent implements Cancellable {
|
||||
+ private static final HandlerList handlers = new HandlerList();
|
||||
+ private final Block block;
|
||||
+ private final CreatureSpawner spawner;
|
||||
+ private EntityType type;
|
||||
+ private boolean cancel;
|
||||
+
|
||||
+ @ApiStatus.Internal
|
||||
+ public PlayerSetSpawnerTypeWithEggEvent(Player player, Block block, CreatureSpawner spawner, EntityType type) {
|
||||
+ super(player);
|
||||
+ this.block = block;
|
||||
+ this.spawner = spawner;
|
||||
+ this.type = type;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Get the spawner Block in the world
|
||||
+ *
|
||||
+ * @return Spawner Block
|
||||
+ */
|
||||
+ public Block getBlock() {
|
||||
+ return block;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Get the spawner state
|
||||
+ *
|
||||
+ * @return Spawner state
|
||||
+ */
|
||||
+ public CreatureSpawner getSpawner() {
|
||||
+ return spawner;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the EntityType being set on the spawner
|
||||
+ *
|
||||
+ * @return EntityType being set
|
||||
+ */
|
||||
+ public EntityType getEntityType() {
|
||||
+ return type;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the EntityType being set on the spawner
|
||||
+ *
|
||||
+ * @param type EntityType to set
|
||||
+ */
|
||||
+ public void setEntityType(EntityType type) {
|
||||
+ this.type = type;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isCancelled() {
|
||||
+ return cancel;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setCancelled(boolean cancel) {
|
||||
+ this.cancel = cancel;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public HandlerList getHandlers() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+
|
||||
+ public static HandlerList getHandlerList() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/org/purpurmc/purpur/event/PlayerSetTrialSpawnerTypeWithEggEvent.java b/src/main/java/org/purpurmc/purpur/event/PlayerSetTrialSpawnerTypeWithEggEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..1d4dbf60a182a2a5f93c449e387b82743d20616c
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/purpurmc/purpur/event/PlayerSetTrialSpawnerTypeWithEggEvent.java
|
||||
@@ -0,0 +1,83 @@
|
||||
+package org.purpurmc.purpur.event;
|
||||
+
|
||||
+import org.bukkit.block.Block;
|
||||
+import org.bukkit.block.TrialSpawner;
|
||||
+import org.bukkit.entity.EntityType;
|
||||
+import org.bukkit.entity.Player;
|
||||
+import org.bukkit.event.Cancellable;
|
||||
+import org.bukkit.event.HandlerList;
|
||||
+import org.bukkit.event.player.PlayerEvent;
|
||||
+import org.jetbrains.annotations.ApiStatus;
|
||||
+import org.jspecify.annotations.NullMarked;
|
||||
+
|
||||
+@NullMarked
|
||||
+public class PlayerSetTrialSpawnerTypeWithEggEvent extends PlayerEvent implements Cancellable {
|
||||
+ private static final HandlerList handlers = new HandlerList();
|
||||
+ private final Block block;
|
||||
+ private final TrialSpawner spawner;
|
||||
+ private EntityType type;
|
||||
+ private boolean cancel;
|
||||
+
|
||||
+ @ApiStatus.Internal
|
||||
+ public PlayerSetTrialSpawnerTypeWithEggEvent(Player player, Block block, TrialSpawner spawner, EntityType type) {
|
||||
+ super(player);
|
||||
+ this.block = block;
|
||||
+ this.spawner = spawner;
|
||||
+ this.type = type;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Get the spawner Block in the world
|
||||
+ *
|
||||
+ * @return Spawner Block
|
||||
+ */
|
||||
+ public Block getBlock() {
|
||||
+ return block;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Get the spawner state
|
||||
+ *
|
||||
+ * @return Spawner state
|
||||
+ */
|
||||
+ public TrialSpawner getSpawner() {
|
||||
+ return spawner;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the EntityType being set on the spawner
|
||||
+ *
|
||||
+ * @return EntityType being set
|
||||
+ */
|
||||
+ public EntityType getEntityType() {
|
||||
+ return type;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the EntityType being set on the spawner
|
||||
+ *
|
||||
+ * @param type EntityType to set
|
||||
+ */
|
||||
+ public void setEntityType(EntityType type) {
|
||||
+ this.type = type;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isCancelled() {
|
||||
+ return cancel;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setCancelled(boolean cancel) {
|
||||
+ this.cancel = cancel;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public HandlerList getHandlers() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+
|
||||
+ public static HandlerList getHandlerList() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+}
|
||||
189
patches/api/0016-Anvil-API.patch
Normal file
189
patches/api/0016-Anvil-API.patch
Normal file
@@ -0,0 +1,189 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
|
||||
Date: Sun, 19 Apr 2020 00:25:09 -0500
|
||||
Subject: [PATCH] Anvil API
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/inventory/AnvilInventory.java b/src/main/java/org/bukkit/inventory/AnvilInventory.java
|
||||
index f1f97a85ec713c05c882d7588f4a3e4a017f4795..813f6cd253322538bdf96eb323dd23a7809a1c1e 100644
|
||||
--- a/src/main/java/org/bukkit/inventory/AnvilInventory.java
|
||||
+++ b/src/main/java/org/bukkit/inventory/AnvilInventory.java
|
||||
@@ -138,4 +138,42 @@ public interface AnvilInventory extends Inventory {
|
||||
setItem(2, result);
|
||||
}
|
||||
// Paper end
|
||||
+
|
||||
+ // Purpur start
|
||||
+ /**
|
||||
+ * Gets if the player viewing the anvil inventory can bypass experience cost
|
||||
+ *
|
||||
+ * @return whether the player viewing the anvil inventory can bypass the experience cost
|
||||
+ * @deprecated use {@link AnvilView#canBypassCost()}.
|
||||
+ */
|
||||
+ @Deprecated(forRemoval = true, since = "1.21")
|
||||
+ boolean canBypassCost();
|
||||
+
|
||||
+ /**
|
||||
+ * Set if the player viewing the anvil inventory can bypass the experience cost
|
||||
+ *
|
||||
+ * @param bypassCost whether the player viewing the anvil inventory can bypass the experience cost
|
||||
+ * @deprecated use {@link AnvilView#setBypassCost(boolean)}.
|
||||
+ */
|
||||
+ @Deprecated(forRemoval = true, since = "1.21")
|
||||
+ void setBypassCost(boolean bypassCost);
|
||||
+
|
||||
+ /**
|
||||
+ * Gets if the player viewing the anvil inventory can do unsafe enchants
|
||||
+ *
|
||||
+ * @return whether the player viewing the anvil inventory can do unsafe enchants
|
||||
+ * @deprecated use {@link AnvilView#canDoUnsafeEnchants()}.
|
||||
+ */
|
||||
+ @Deprecated(forRemoval = true, since = "1.21")
|
||||
+ boolean canDoUnsafeEnchants();
|
||||
+
|
||||
+ /**
|
||||
+ * Set if the player viewing the anvil inventory can do unsafe enchants
|
||||
+ *
|
||||
+ * @param canDoUnsafeEnchants whether the player viewing the anvil inventory can do unsafe enchants
|
||||
+ * @deprecated use {@link AnvilView#setDoUnsafeEnchants(boolean)}.
|
||||
+ */
|
||||
+ @Deprecated(forRemoval = true, since = "1.21")
|
||||
+ void setDoUnsafeEnchants(boolean canDoUnsafeEnchants);
|
||||
+ // Purpur end
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/inventory/view/AnvilView.java b/src/main/java/org/bukkit/inventory/view/AnvilView.java
|
||||
index 3c1aa1e036bee08304c1cdca59f6a5bc0ba306c0..709fb2d1c7e3253034a651a9f68c003601b598a4 100644
|
||||
--- a/src/main/java/org/bukkit/inventory/view/AnvilView.java
|
||||
+++ b/src/main/java/org/bukkit/inventory/view/AnvilView.java
|
||||
@@ -89,4 +89,34 @@ public interface AnvilView extends InventoryView {
|
||||
*/
|
||||
void bypassEnchantmentLevelRestriction(boolean bypassEnchantmentLevelRestriction);
|
||||
// Paper end - bypass anvil level restrictions
|
||||
+
|
||||
+ // Purpur start
|
||||
+ /**
|
||||
+ * Gets if the player viewing the anvil inventory can bypass experience cost
|
||||
+ *
|
||||
+ * @return whether the player viewing the anvil inventory can bypass the experience cost
|
||||
+ */
|
||||
+ boolean canBypassCost();
|
||||
+
|
||||
+ /**
|
||||
+ * Set if the player viewing the anvil inventory can bypass the experience cost
|
||||
+ *
|
||||
+ * @param bypassCost whether the player viewing the anvil inventory can bypass the experience cost
|
||||
+ */
|
||||
+ void setBypassCost(boolean bypassCost);
|
||||
+
|
||||
+ /**
|
||||
+ * Gets if the player viewing the anvil inventory can do unsafe enchants
|
||||
+ *
|
||||
+ * @return whether the player viewing the anvil inventory can do unsafe enchants
|
||||
+ */
|
||||
+ boolean canDoUnsafeEnchants();
|
||||
+
|
||||
+ /**
|
||||
+ * Set if the player viewing the anvil inventory can do unsafe enchants
|
||||
+ *
|
||||
+ * @param canDoUnsafeEnchants whether the player viewing the anvil inventory can do unsafe enchants
|
||||
+ */
|
||||
+ void setDoUnsafeEnchants(boolean canDoUnsafeEnchants);
|
||||
+ // Purpur end
|
||||
}
|
||||
diff --git a/src/main/java/org/purpurmc/purpur/event/inventory/AnvilTakeResultEvent.java b/src/main/java/org/purpurmc/purpur/event/inventory/AnvilTakeResultEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..b2199854b5c7e74a673cbadbe584e5aaebbe3883
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/purpurmc/purpur/event/inventory/AnvilTakeResultEvent.java
|
||||
@@ -0,0 +1,50 @@
|
||||
+package org.purpurmc.purpur.event.inventory;
|
||||
+
|
||||
+import org.bukkit.entity.HumanEntity;
|
||||
+import org.bukkit.entity.Player;
|
||||
+import org.bukkit.event.HandlerList;
|
||||
+import org.bukkit.event.inventory.InventoryEvent;
|
||||
+import org.bukkit.inventory.AnvilInventory;
|
||||
+import org.bukkit.inventory.InventoryView;
|
||||
+import org.bukkit.inventory.ItemStack;
|
||||
+import org.jetbrains.annotations.ApiStatus;
|
||||
+import org.jspecify.annotations.NullMarked;
|
||||
+
|
||||
+/**
|
||||
+ * Called when a player takes the result item out of an anvil
|
||||
+ */
|
||||
+@NullMarked
|
||||
+public class AnvilTakeResultEvent extends InventoryEvent {
|
||||
+ private static final HandlerList handlers = new HandlerList();
|
||||
+ private final Player player;
|
||||
+ private final ItemStack result;
|
||||
+
|
||||
+ @ApiStatus.Internal
|
||||
+ public AnvilTakeResultEvent(HumanEntity player, InventoryView view, ItemStack result) {
|
||||
+ super(view);
|
||||
+ this.player = (Player) player;
|
||||
+ this.result = result;
|
||||
+ }
|
||||
+
|
||||
+ public Player getPlayer() {
|
||||
+ return player;
|
||||
+ }
|
||||
+
|
||||
+ public ItemStack getResult() {
|
||||
+ return result;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public AnvilInventory getInventory() {
|
||||
+ return (AnvilInventory) super.getInventory();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public HandlerList getHandlers() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+
|
||||
+ public static HandlerList getHandlerList() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/org/purpurmc/purpur/event/inventory/AnvilUpdateResultEvent.java b/src/main/java/org/purpurmc/purpur/event/inventory/AnvilUpdateResultEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..4293c4a57c1c054e8248b7712e8664bd4cb1a972
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/purpurmc/purpur/event/inventory/AnvilUpdateResultEvent.java
|
||||
@@ -0,0 +1,35 @@
|
||||
+package org.purpurmc.purpur.event.inventory;
|
||||
+
|
||||
+import org.bukkit.event.HandlerList;
|
||||
+import org.bukkit.event.inventory.InventoryEvent;
|
||||
+import org.bukkit.inventory.AnvilInventory;
|
||||
+import org.bukkit.inventory.InventoryView;
|
||||
+import org.jetbrains.annotations.ApiStatus;
|
||||
+import org.jspecify.annotations.NullMarked;
|
||||
+
|
||||
+/**
|
||||
+ * Called when anvil slots change, triggering the result slot to be updated
|
||||
+ */
|
||||
+@NullMarked
|
||||
+public class AnvilUpdateResultEvent extends InventoryEvent {
|
||||
+ private static final HandlerList handlers = new HandlerList();
|
||||
+
|
||||
+ @ApiStatus.Internal
|
||||
+ public AnvilUpdateResultEvent(InventoryView view) {
|
||||
+ super(view);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public AnvilInventory getInventory() {
|
||||
+ return (AnvilInventory) super.getInventory();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public HandlerList getHandlers() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+
|
||||
+ public static HandlerList getHandlerList() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+}
|
||||
552
patches/api/0017-ItemStack-convenience-methods.patch
Normal file
552
patches/api/0017-ItemStack-convenience-methods.patch
Normal file
@@ -0,0 +1,552 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
|
||||
Date: Sun, 15 Mar 2020 20:52:12 -0500
|
||||
Subject: [PATCH] ItemStack convenience methods
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/Material.java b/src/main/java/org/bukkit/Material.java
|
||||
index 615eb24ffdd8f6d55ccd4f21760b809c1098bc68..fbbe9e52ed3437d2407e042f45b0a18abdd48fe1 100644
|
||||
--- a/src/main/java/org/bukkit/Material.java
|
||||
+++ b/src/main/java/org/bukkit/Material.java
|
||||
@@ -5799,4 +5799,40 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla
|
||||
public BlockType asBlockType() {
|
||||
return blockType.get();
|
||||
}
|
||||
+
|
||||
+ // Purpur start
|
||||
+ public boolean isArmor() {
|
||||
+ switch (this) {
|
||||
+ // <editor-fold defaultstate="collapsed" desc="isarmor">
|
||||
+ case LEATHER_BOOTS:
|
||||
+ case LEATHER_CHESTPLATE:
|
||||
+ case LEATHER_HELMET:
|
||||
+ case LEATHER_LEGGINGS:
|
||||
+ case CHAINMAIL_BOOTS:
|
||||
+ case CHAINMAIL_CHESTPLATE:
|
||||
+ case CHAINMAIL_HELMET:
|
||||
+ case CHAINMAIL_LEGGINGS:
|
||||
+ case IRON_BOOTS:
|
||||
+ case IRON_CHESTPLATE:
|
||||
+ case IRON_HELMET:
|
||||
+ case IRON_LEGGINGS:
|
||||
+ case GOLDEN_BOOTS:
|
||||
+ case GOLDEN_CHESTPLATE:
|
||||
+ case GOLDEN_HELMET:
|
||||
+ case GOLDEN_LEGGINGS:
|
||||
+ case DIAMOND_BOOTS:
|
||||
+ case DIAMOND_CHESTPLATE:
|
||||
+ case DIAMOND_HELMET:
|
||||
+ case DIAMOND_LEGGINGS:
|
||||
+ case NETHERITE_BOOTS:
|
||||
+ case NETHERITE_CHESTPLATE:
|
||||
+ case NETHERITE_HELMET:
|
||||
+ case NETHERITE_LEGGINGS:
|
||||
+ case TURTLE_HELMET:
|
||||
+ return true;
|
||||
+ default:
|
||||
+ return false;
|
||||
+ }
|
||||
+ }
|
||||
+ // Purpur end
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/inventory/ItemStack.java b/src/main/java/org/bukkit/inventory/ItemStack.java
|
||||
index b59222b8c262545d100a9fd28b3bf1d2a4cf4eb0..4414381ac942c040480d53b03565b160eb85c444 100644
|
||||
--- a/src/main/java/org/bukkit/inventory/ItemStack.java
|
||||
+++ b/src/main/java/org/bukkit/inventory/ItemStack.java
|
||||
@@ -19,6 +19,13 @@ import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.material.MaterialData;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
+// Purpur start
|
||||
+import com.google.common.collect.Multimap;
|
||||
+import java.util.Collection;
|
||||
+import org.bukkit.attribute.Attribute;
|
||||
+import org.bukkit.attribute.AttributeModifier;
|
||||
+import org.bukkit.block.data.BlockData;
|
||||
+// Purpur end
|
||||
|
||||
/**
|
||||
* Represents a stack of items.
|
||||
@@ -1137,4 +1144,482 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat
|
||||
return Bukkit.getUnsafe().computeTooltipLines(this, tooltipContext, player);
|
||||
}
|
||||
// Paper end - expose itemstack tooltip lines
|
||||
+
|
||||
+ // Purpur start
|
||||
+ /**
|
||||
+ * Gets the display name that is set.
|
||||
+ * <p>
|
||||
+ * Plugins should check that hasDisplayName() returns <code>true</code>
|
||||
+ * before calling this method.
|
||||
+ *
|
||||
+ * @return the display name that is set
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public String getDisplayName() {
|
||||
+ return this.craftDelegate.getDisplayName();
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the display name.
|
||||
+ *
|
||||
+ * @param name the name to set
|
||||
+ */
|
||||
+ public void setDisplayName(@Nullable String name) {
|
||||
+ this.craftDelegate.setDisplayName(name);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Checks for existence of a display name.
|
||||
+ *
|
||||
+ * @return true if this has a display name
|
||||
+ */
|
||||
+ public boolean hasDisplayName() {
|
||||
+ return this.craftDelegate.hasDisplayName();
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the localized display name that is set.
|
||||
+ * <p>
|
||||
+ * Plugins should check that hasLocalizedName() returns <code>true</code>
|
||||
+ * before calling this method.
|
||||
+ *
|
||||
+ * @return the localized name that is set
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public String getLocalizedName() {
|
||||
+ return this.craftDelegate.getLocalizedName();
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the localized name.
|
||||
+ *
|
||||
+ * @param name the name to set
|
||||
+ */
|
||||
+ public void setLocalizedName(@Nullable String name) {
|
||||
+ this.craftDelegate.setLocalizedName(name);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Checks for existence of a localized name.
|
||||
+ *
|
||||
+ * @return true if this has a localized name
|
||||
+ */
|
||||
+ public boolean hasLocalizedName() {
|
||||
+ return this.craftDelegate.hasLocalizedName();
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Checks for existence of lore.
|
||||
+ *
|
||||
+ * @return true if this has lore
|
||||
+ */
|
||||
+ public boolean hasLore() {
|
||||
+ return this.craftDelegate.hasLore();
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Checks for existence of the specified enchantment.
|
||||
+ *
|
||||
+ * @param ench enchantment to check
|
||||
+ * @return true if this enchantment exists for this meta
|
||||
+ */
|
||||
+ public boolean hasEnchant(@NotNull Enchantment ench) {
|
||||
+ return this.craftDelegate.hasEnchant(ench);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Checks for the level of the specified enchantment.
|
||||
+ *
|
||||
+ * @param ench enchantment to check
|
||||
+ * @return The level that the specified enchantment has, or 0 if none
|
||||
+ */
|
||||
+ public int getEnchantLevel(@NotNull Enchantment ench) {
|
||||
+ return this.craftDelegate.getEnchantLevel(ench);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Returns a copy the enchantments in this ItemMeta. <br>
|
||||
+ * Returns an empty map if none.
|
||||
+ *
|
||||
+ * @return An immutable copy of the enchantments
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public Map<Enchantment, Integer> getEnchants() {
|
||||
+ return this.craftDelegate.getEnchants();
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Adds the specified enchantment to this item meta.
|
||||
+ *
|
||||
+ * @param ench Enchantment to add
|
||||
+ * @param level Level for the enchantment
|
||||
+ * @param ignoreLevelRestriction this indicates the enchantment should be
|
||||
+ * applied, ignoring the level limit
|
||||
+ * @return true if the item meta changed as a result of this call, false
|
||||
+ * otherwise
|
||||
+ */
|
||||
+ public boolean addEnchant(@NotNull Enchantment ench, int level, boolean ignoreLevelRestriction) {
|
||||
+ return this.craftDelegate.addEnchant(ench, level, ignoreLevelRestriction);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Removes the specified enchantment from this item meta.
|
||||
+ *
|
||||
+ * @param ench Enchantment to remove
|
||||
+ * @return true if the item meta changed as a result of this call, false
|
||||
+ * otherwise
|
||||
+ */
|
||||
+ public boolean removeEnchant(@NotNull Enchantment ench) {
|
||||
+ return this.craftDelegate.removeEnchant(ench);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Checks for the existence of any enchantments.
|
||||
+ *
|
||||
+ * @return true if an enchantment exists on this meta
|
||||
+ */
|
||||
+ public boolean hasEnchants() {
|
||||
+ return this.craftDelegate.hasEnchants();
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Checks if the specified enchantment conflicts with any enchantments in
|
||||
+ * this ItemMeta.
|
||||
+ *
|
||||
+ * @param ench enchantment to test
|
||||
+ * @return true if the enchantment conflicts, false otherwise
|
||||
+ */
|
||||
+ public boolean hasConflictingEnchant(@NotNull Enchantment ench) {
|
||||
+ return this.craftDelegate.hasConflictingEnchant(ench);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the custom model data.
|
||||
+ * <p>
|
||||
+ * CustomModelData is an integer that may be associated client side with a
|
||||
+ * custom item model.
|
||||
+ *
|
||||
+ * @param data the data to set, or null to clear
|
||||
+ */
|
||||
+ public void setCustomModelData(@Nullable Integer data) {
|
||||
+ this.craftDelegate.setCustomModelData(data);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the custom model data that is set.
|
||||
+ * <p>
|
||||
+ * CustomModelData is an integer that may be associated client side with a
|
||||
+ * custom item model.
|
||||
+ * <p>
|
||||
+ * Plugins should check that hasCustomModelData() returns <code>true</code>
|
||||
+ * before calling this method.
|
||||
+ *
|
||||
+ * @return the localized name that is set
|
||||
+ */
|
||||
+ public int getCustomModelData() {
|
||||
+ return this.craftDelegate.getCustomModelData();
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Checks for existence of custom model data.
|
||||
+ * <p>
|
||||
+ * CustomModelData is an integer that may be associated client side with a
|
||||
+ * custom item model.
|
||||
+ *
|
||||
+ * @return true if this has custom model data
|
||||
+ */
|
||||
+ public boolean hasCustomModelData() {
|
||||
+ return this.craftDelegate.hasCustomModelData();
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Returns whether the item has block data currently attached to it.
|
||||
+ *
|
||||
+ * @return whether block data is already attached
|
||||
+ */
|
||||
+ public boolean hasBlockData() {
|
||||
+ return this.craftDelegate.hasBlockData();
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Returns the currently attached block data for this item or creates a new
|
||||
+ * one if one doesn't exist.
|
||||
+ *
|
||||
+ * The state is a copy, it must be set back (or to another item) with
|
||||
+ * {@link #setBlockData(BlockData)}
|
||||
+ *
|
||||
+ * @param material the material we wish to get this data in the context of
|
||||
+ * @return the attached data or new data
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public BlockData getBlockData(@NotNull Material material) {
|
||||
+ return this.craftDelegate.getBlockData(material);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Attaches a copy of the passed block data to the item.
|
||||
+ *
|
||||
+ * @param blockData the block data to attach to the block.
|
||||
+ * @throws IllegalArgumentException if the blockData is null or invalid for
|
||||
+ * this item.
|
||||
+ */
|
||||
+ public void setBlockData(@NotNull BlockData blockData) {
|
||||
+ this.craftDelegate.setBlockData(blockData);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the repair penalty
|
||||
+ *
|
||||
+ * @return the repair penalty
|
||||
+ */
|
||||
+ public int getRepairCost() {
|
||||
+ return this.craftDelegate.getRepairCost();
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the repair penalty
|
||||
+ *
|
||||
+ * @param cost repair penalty
|
||||
+ */
|
||||
+ public void setRepairCost(int cost) {
|
||||
+ this.craftDelegate.setRepairCost(cost);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Checks to see if this has a repair penalty
|
||||
+ *
|
||||
+ * @return true if this has a repair penalty
|
||||
+ */
|
||||
+ public boolean hasRepairCost() {
|
||||
+ return this.craftDelegate.hasRepairCost();
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Return if the unbreakable tag is true. An unbreakable item will not lose
|
||||
+ * durability.
|
||||
+ *
|
||||
+ * @return true if the unbreakable tag is true
|
||||
+ */
|
||||
+ public boolean isUnbreakable() {
|
||||
+ return this.craftDelegate.isUnbreakable();
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the unbreakable tag. An unbreakable item will not lose durability.
|
||||
+ *
|
||||
+ * @param unbreakable true if set unbreakable
|
||||
+ */
|
||||
+ public void setUnbreakable(boolean unbreakable) {
|
||||
+ this.craftDelegate.setUnbreakable(unbreakable);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Checks for the existence of any AttributeModifiers.
|
||||
+ *
|
||||
+ * @return true if any AttributeModifiers exist
|
||||
+ */
|
||||
+ public boolean hasAttributeModifiers() {
|
||||
+ return this.craftDelegate.hasAttributeModifiers();
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Return an immutable copy of all Attributes and
|
||||
+ * their modifiers in this ItemMeta.<br>
|
||||
+ * Returns null if none exist.
|
||||
+ *
|
||||
+ * @return an immutable {@link Multimap} of Attributes
|
||||
+ * and their AttributeModifiers, or null if none exist
|
||||
+ */
|
||||
+ @Nullable
|
||||
+ public Multimap<Attribute, AttributeModifier> getAttributeModifiers() {
|
||||
+ return this.craftDelegate.getAttributeModifiers();
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Return an immutable copy of all {@link Attribute}s and their
|
||||
+ * {@link AttributeModifier}s for a given {@link EquipmentSlot}.<br>
|
||||
+ * Any {@link AttributeModifier} that does have have a given
|
||||
+ * {@link EquipmentSlot} will be returned. This is because
|
||||
+ * AttributeModifiers without a slot are active in any slot.<br>
|
||||
+ * If there are no attributes set for the given slot, an empty map
|
||||
+ * will be returned.
|
||||
+ *
|
||||
+ * @param slot the {@link EquipmentSlot} to check
|
||||
+ * @return the immutable {@link Multimap} with the
|
||||
+ * respective Attributes and modifiers, or an empty map
|
||||
+ * if no attributes are set.
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public Multimap<Attribute, AttributeModifier> getAttributeModifiers(@Nullable EquipmentSlot slot) {
|
||||
+ return this.craftDelegate.getAttributeModifiers(slot);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Return an immutable copy of all {@link AttributeModifier}s
|
||||
+ * for a given {@link Attribute}
|
||||
+ *
|
||||
+ * @param attribute the {@link Attribute}
|
||||
+ * @return an immutable collection of {@link AttributeModifier}s
|
||||
+ * or null if no AttributeModifiers exist for the Attribute.
|
||||
+ * @throws NullPointerException if Attribute is null
|
||||
+ */
|
||||
+ @Nullable
|
||||
+ public Collection<AttributeModifier> getAttributeModifiers(@NotNull Attribute attribute) {
|
||||
+ return this.craftDelegate.getAttributeModifiers(attribute);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Add an Attribute and it's Modifier.
|
||||
+ * AttributeModifiers can now support {@link EquipmentSlot}s.
|
||||
+ * If not set, the {@link AttributeModifier} will be active in ALL slots.
|
||||
+ * <br>
|
||||
+ * Two {@link AttributeModifier}s that have the same {@link java.util.UUID}
|
||||
+ * cannot exist on the same Attribute.
|
||||
+ *
|
||||
+ * @param attribute the {@link Attribute} to modify
|
||||
+ * @param modifier the {@link AttributeModifier} specifying the modification
|
||||
+ * @return true if the Attribute and AttributeModifier were
|
||||
+ * successfully added
|
||||
+ * @throws NullPointerException if Attribute is null
|
||||
+ * @throws NullPointerException if AttributeModifier is null
|
||||
+ * @throws IllegalArgumentException if AttributeModifier already exists
|
||||
+ */
|
||||
+ public boolean addAttributeModifier(@NotNull Attribute attribute, @NotNull AttributeModifier modifier) {
|
||||
+ return this.craftDelegate.addAttributeModifier(attribute, modifier);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Set all {@link Attribute}s and their {@link AttributeModifier}s.
|
||||
+ * To clear all currently set Attributes and AttributeModifiers use
|
||||
+ * null or an empty Multimap.
|
||||
+ * If not null nor empty, this will filter all entries that are not-null
|
||||
+ * and add them to the ItemStack.
|
||||
+ *
|
||||
+ * @param attributeModifiers the new Multimap containing the Attributes
|
||||
+ * and their AttributeModifiers
|
||||
+ */
|
||||
+ public void setAttributeModifiers(@Nullable Multimap<Attribute, AttributeModifier> attributeModifiers) {
|
||||
+ this.craftDelegate.setAttributeModifiers(attributeModifiers);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Remove all {@link AttributeModifier}s associated with the given
|
||||
+ * {@link Attribute}.
|
||||
+ * This will return false if nothing was removed.
|
||||
+ *
|
||||
+ * @param attribute attribute to remove
|
||||
+ * @return true if all modifiers were removed from a given
|
||||
+ * Attribute. Returns false if no attributes were
|
||||
+ * removed.
|
||||
+ * @throws NullPointerException if Attribute is null
|
||||
+ */
|
||||
+ public boolean removeAttributeModifier(@NotNull Attribute attribute) {
|
||||
+ return this.craftDelegate.removeAttributeModifier(attribute);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Remove all {@link Attribute}s and {@link AttributeModifier}s for a
|
||||
+ * given {@link EquipmentSlot}.<br>
|
||||
+ * If the given {@link EquipmentSlot} is null, this will remove all
|
||||
+ * {@link AttributeModifier}s that do not have an EquipmentSlot set.
|
||||
+ *
|
||||
+ * @param slot the {@link EquipmentSlot} to clear all Attributes and
|
||||
+ * their modifiers for
|
||||
+ * @return true if all modifiers were removed that match the given
|
||||
+ * EquipmentSlot.
|
||||
+ */
|
||||
+ public boolean removeAttributeModifier(@Nullable EquipmentSlot slot) {
|
||||
+ return this.craftDelegate.removeAttributeModifier(slot);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Remove a specific {@link Attribute} and {@link AttributeModifier}.
|
||||
+ * AttributeModifiers are matched according to their {@link java.util.UUID}.
|
||||
+ *
|
||||
+ * @param attribute the {@link Attribute} to remove
|
||||
+ * @param modifier the {@link AttributeModifier} to remove
|
||||
+ * @return if any attribute modifiers were remove
|
||||
+ *
|
||||
+ * @throws NullPointerException if the Attribute is null
|
||||
+ * @throws NullPointerException if the AttributeModifier is null
|
||||
+ *
|
||||
+ * @see AttributeModifier#getUniqueId()
|
||||
+ */
|
||||
+ public boolean removeAttributeModifier(@NotNull Attribute attribute, @NotNull AttributeModifier modifier) {
|
||||
+ return this.craftDelegate.removeAttributeModifier(attribute, modifier);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Checks to see if this item has damage
|
||||
+ *
|
||||
+ * @return true if this has damage
|
||||
+ */
|
||||
+ public boolean hasDamage() {
|
||||
+ return this.craftDelegate.hasDamage();
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the damage
|
||||
+ *
|
||||
+ * @return the damage
|
||||
+ */
|
||||
+ public int getDamage() {
|
||||
+ return this.craftDelegate.getDamage();
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the damage
|
||||
+ *
|
||||
+ * @param damage item damage
|
||||
+ */
|
||||
+ public void setDamage(int damage) {
|
||||
+ this.craftDelegate.setDamage(damage);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Repairs this item by 1 durability
|
||||
+ */
|
||||
+ public void repair() {
|
||||
+ repair(1);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Damages this item by 1 durability
|
||||
+ *
|
||||
+ * @return True if damage broke the item
|
||||
+ */
|
||||
+ public boolean damage() {
|
||||
+ return damage(1);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Repairs this item's durability by amount
|
||||
+ *
|
||||
+ * @param amount Amount of durability to repair
|
||||
+ */
|
||||
+ public void repair(int amount) {
|
||||
+ damage(-amount);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Damages this item's durability by amount
|
||||
+ *
|
||||
+ * @param amount Amount of durability to damage
|
||||
+ * @return True if damage broke the item
|
||||
+ */
|
||||
+ public boolean damage(int amount) {
|
||||
+ return damage(amount, false);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Damages this item's durability by amount
|
||||
+ *
|
||||
+ * @param amount Amount of durability to damage
|
||||
+ * @param ignoreUnbreaking Ignores unbreaking enchantment
|
||||
+ * @return True if damage broke the item
|
||||
+ */
|
||||
+ public boolean damage(int amount, boolean ignoreUnbreaking) {
|
||||
+ return this.craftDelegate.damage(amount, ignoreUnbreaking);
|
||||
+ }
|
||||
+ // Purpur end
|
||||
}
|
||||
88
patches/api/0018-ChatColor-conveniences.patch
Normal file
88
patches/api/0018-ChatColor-conveniences.patch
Normal file
@@ -0,0 +1,88 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
|
||||
Date: Fri, 10 Jul 2020 12:43:25 -0500
|
||||
Subject: [PATCH] ChatColor conveniences
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/ChatColor.java b/src/main/java/org/bukkit/ChatColor.java
|
||||
index 918a045165cdcde264bc24082b7afebb407271de..e98d6321c5f2cdde91b54f8a74cbcc045eae75a8 100644
|
||||
--- a/src/main/java/org/bukkit/ChatColor.java
|
||||
+++ b/src/main/java/org/bukkit/ChatColor.java
|
||||
@@ -456,4 +456,77 @@ public enum ChatColor {
|
||||
BY_CHAR.put(color.code, color);
|
||||
}
|
||||
}
|
||||
+
|
||||
+ // Purpur start
|
||||
+ /**
|
||||
+ * Convert legacy string into a string ready to be parsed by MiniMessage
|
||||
+ *
|
||||
+ * @param str Legacy string
|
||||
+ * @return MiniMessage ready string
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public static String toMM(@NotNull String str) {
|
||||
+ StringBuilder sb = new StringBuilder(str);
|
||||
+ java.util.regex.Matcher m = STRIP_COLOR_PATTERN.matcher(sb);
|
||||
+ while (m.find()) {
|
||||
+ sb.replace(m.start(), m.end(), sb.substring(m.start(), m.end()).toLowerCase());
|
||||
+ }
|
||||
+ return sb.toString()
|
||||
+ .replace("&0", "<black>")
|
||||
+ .replace("&1", "<dark_blue>")
|
||||
+ .replace("&2", "<dark_green>")
|
||||
+ .replace("&3", "<dark_aqua>")
|
||||
+ .replace("&4", "<dark_red>")
|
||||
+ .replace("&5", "<dark_purple>")
|
||||
+ .replace("&6", "<gold>")
|
||||
+ .replace("&7", "<grey>")
|
||||
+ .replace("&8", "<dark_grey>")
|
||||
+ .replace("&9", "<blue>")
|
||||
+ .replace("&a", "<green>")
|
||||
+ .replace("&b", "<aqua>")
|
||||
+ .replace("&c", "<red>")
|
||||
+ .replace("&d", "<light_purple>")
|
||||
+ .replace("&e", "<yellow>")
|
||||
+ .replace("&f", "<white>")
|
||||
+ .replace("&k", "<obf>")
|
||||
+ .replace("&l", "<b>")
|
||||
+ .replace("&m", "<st>")
|
||||
+ .replace("&n", "<u>")
|
||||
+ .replace("&o", "<i>")
|
||||
+ .replace("&r", "<r>");
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ public static net.kyori.adventure.text.Component parseMM(@NotNull String string, @Nullable Object... args) {
|
||||
+ return net.kyori.adventure.text.minimessage.MiniMessage.miniMessage().deserialize(String.format(string, args));
|
||||
+ }
|
||||
+
|
||||
+ @Deprecated
|
||||
+ public static final Pattern HEX_PATTERN = Pattern.compile("(#[A-Fa-f0-9]{6})");
|
||||
+
|
||||
+ @Deprecated
|
||||
+ @Nullable
|
||||
+ public static String replaceHex(@Nullable String str) {
|
||||
+ if (str != null) {
|
||||
+ java.util.regex.Matcher matcher = HEX_PATTERN.matcher(str);
|
||||
+ while (matcher.find()) {
|
||||
+ String group = matcher.group(1);
|
||||
+ str = str.replace(group, net.md_5.bungee.api.ChatColor.of(group).toString());
|
||||
+ }
|
||||
+ }
|
||||
+ return str;
|
||||
+ }
|
||||
+
|
||||
+ @Deprecated
|
||||
+ @Nullable
|
||||
+ public static String color(@Nullable String str) {
|
||||
+ return color(str, true);
|
||||
+ }
|
||||
+
|
||||
+ @Deprecated
|
||||
+ @Nullable
|
||||
+ public static String color(@Nullable String str, boolean parseHex) {
|
||||
+ return str != null ? net.md_5.bungee.api.ChatColor.translateAlternateColorCodes('&', parseHex ? replaceHex(str) : str) : str;
|
||||
+ }
|
||||
+ // Purpur end
|
||||
}
|
||||
73
patches/api/0019-Item-entity-immunities.patch
Normal file
73
patches/api/0019-Item-entity-immunities.patch
Normal file
@@ -0,0 +1,73 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
|
||||
Date: Sat, 22 Aug 2020 17:42:08 -0500
|
||||
Subject: [PATCH] Item entity immunities
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/entity/Item.java b/src/main/java/org/bukkit/entity/Item.java
|
||||
index bcc6ba95bd21c7972865838c636a03f50b6c1f1a..c3fcd8dd7dbb1e1a18e17c014c1e641149ea5960 100644
|
||||
--- a/src/main/java/org/bukkit/entity/Item.java
|
||||
+++ b/src/main/java/org/bukkit/entity/Item.java
|
||||
@@ -153,4 +153,62 @@ public interface Item extends Entity, io.papermc.paper.entity.Frictional { // Pa
|
||||
*/
|
||||
public void setHealth(int health);
|
||||
// Paper end
|
||||
+
|
||||
+ // Purpur start
|
||||
+ /**
|
||||
+ * Set whether or not this item is immune to cactus
|
||||
+ *
|
||||
+ * @param immuneToCactus True to make immune to cactus
|
||||
+ */
|
||||
+ void setImmuneToCactus(boolean immuneToCactus);
|
||||
+
|
||||
+ /**
|
||||
+ * Check if item is immune to cactus
|
||||
+ *
|
||||
+ * @return True if immune to cactus
|
||||
+ */
|
||||
+ boolean isImmuneToCactus();
|
||||
+
|
||||
+ /**
|
||||
+ * Set whether or not this item is immune to explosions
|
||||
+ *
|
||||
+ * @param immuneToExplosion True to make immune to explosions
|
||||
+ */
|
||||
+ void setImmuneToExplosion(boolean immuneToExplosion);
|
||||
+
|
||||
+ /**
|
||||
+ * Check if item is immune to explosions
|
||||
+ *
|
||||
+ * @return True if immune to explosions
|
||||
+ */
|
||||
+ boolean isImmuneToExplosion();
|
||||
+
|
||||
+ /**
|
||||
+ * Set whether or not this item is immune to fire
|
||||
+ *
|
||||
+ * @param immuneToFire True to make immune to fire
|
||||
+ */
|
||||
+ void setImmuneToFire(boolean immuneToFire);
|
||||
+
|
||||
+ /**
|
||||
+ * Check if item is immune to fire
|
||||
+ *
|
||||
+ * @return True if immune to fire
|
||||
+ */
|
||||
+ boolean isImmuneToFire();
|
||||
+
|
||||
+ /**
|
||||
+ * Set whether or not this item is immune to lightning
|
||||
+ *
|
||||
+ * @param immuneToLightning True to make immune to lightning
|
||||
+ */
|
||||
+ void setImmuneToLightning(boolean immuneToLightning);
|
||||
+
|
||||
+ /**
|
||||
+ * Check if item is immune to lightning
|
||||
+ *
|
||||
+ * @return True if immune to lightning
|
||||
+ */
|
||||
+ boolean isImmuneToLightning();
|
||||
+ // Purpur end
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
|
||||
Date: Fri, 2 Oct 2020 17:43:24 -0500
|
||||
Subject: [PATCH] Add predicate to recipe's ExactChoice ingredient
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/inventory/RecipeChoice.java b/src/main/java/org/bukkit/inventory/RecipeChoice.java
|
||||
index f1aa67997f904953742e8895e49341c2f73d44a2..993cf7995514fb0ef3c4388bb3ce49c3187ab251 100644
|
||||
--- a/src/main/java/org/bukkit/inventory/RecipeChoice.java
|
||||
+++ b/src/main/java/org/bukkit/inventory/RecipeChoice.java
|
||||
@@ -191,6 +191,7 @@ public interface RecipeChoice extends Predicate<ItemStack>, Cloneable {
|
||||
public static class ExactChoice implements RecipeChoice {
|
||||
|
||||
private List<ItemStack> choices;
|
||||
+ private Predicate<ItemStack> predicate; // Purpur
|
||||
|
||||
public ExactChoice(@NotNull ItemStack stack) {
|
||||
this(Arrays.asList(stack));
|
||||
@@ -241,6 +242,7 @@ public interface RecipeChoice extends Predicate<ItemStack>, Cloneable {
|
||||
|
||||
@Override
|
||||
public boolean test(@NotNull ItemStack t) {
|
||||
+ if (predicate != null) return predicate.test(t); // Purpur
|
||||
for (ItemStack match : choices) {
|
||||
if (t.isSimilar(match)) {
|
||||
return true;
|
||||
@@ -250,6 +252,17 @@ public interface RecipeChoice extends Predicate<ItemStack>, Cloneable {
|
||||
return false;
|
||||
}
|
||||
|
||||
+ // Purpur start
|
||||
+ @org.jetbrains.annotations.Nullable
|
||||
+ public Predicate<ItemStack> getPredicate() {
|
||||
+ return predicate;
|
||||
+ }
|
||||
+
|
||||
+ public void setPredicate(@org.jetbrains.annotations.Nullable Predicate<ItemStack> predicate) {
|
||||
+ this.predicate = predicate;
|
||||
+ }
|
||||
+ // Purpur end
|
||||
+
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 7;
|
||||
31
patches/api/0021-Rabid-Wolf-API.patch
Normal file
31
patches/api/0021-Rabid-Wolf-API.patch
Normal file
@@ -0,0 +1,31 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Encode42 <me@encode42.dev>
|
||||
Date: Tue, 8 Dec 2020 17:15:15 -0500
|
||||
Subject: [PATCH] Rabid Wolf API
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/entity/Wolf.java b/src/main/java/org/bukkit/entity/Wolf.java
|
||||
index c73489f4b745bc84501ce94f0227b034d9768eae..a97129e71f16ec691759add664bdfd35ab90aaed 100644
|
||||
--- a/src/main/java/org/bukkit/entity/Wolf.java
|
||||
+++ b/src/main/java/org/bukkit/entity/Wolf.java
|
||||
@@ -108,4 +108,20 @@ public interface Wolf extends Tameable, Sittable, io.papermc.paper.entity.Collar
|
||||
return Registry.WOLF_VARIANT.getOrThrow(NamespacedKey.minecraft(key));
|
||||
}
|
||||
}
|
||||
+
|
||||
+ // Purpur start
|
||||
+ /**
|
||||
+ * Checks if this wolf is rabid
|
||||
+ *
|
||||
+ * @return whether the wolf is rabid
|
||||
+ */
|
||||
+ public boolean isRabid();
|
||||
+
|
||||
+ /**
|
||||
+ * Sets this wolf to be rabid or not
|
||||
+ *
|
||||
+ * @param rabid whether the wolf should be rabid
|
||||
+ */
|
||||
+ public void setRabid(boolean rabid);
|
||||
+ // Purpur end
|
||||
}
|
||||
77
patches/api/0022-PlayerBookTooLargeEvent.patch
Normal file
77
patches/api/0022-PlayerBookTooLargeEvent.patch
Normal file
@@ -0,0 +1,77 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
|
||||
Date: Wed, 23 Dec 2020 00:43:27 -0600
|
||||
Subject: [PATCH] PlayerBookTooLargeEvent
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/purpurmc/purpur/event/player/PlayerBookTooLargeEvent.java b/src/main/java/org/purpurmc/purpur/event/player/PlayerBookTooLargeEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..31cce9f4e398135016114b96254376325a22ba7c
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/purpurmc/purpur/event/player/PlayerBookTooLargeEvent.java
|
||||
@@ -0,0 +1,65 @@
|
||||
+package org.purpurmc.purpur.event.player;
|
||||
+
|
||||
+import org.bukkit.Bukkit;
|
||||
+import org.bukkit.entity.Player;
|
||||
+import org.bukkit.event.HandlerList;
|
||||
+import org.bukkit.event.player.PlayerEvent;
|
||||
+import org.bukkit.inventory.ItemStack;
|
||||
+import org.jetbrains.annotations.ApiStatus;
|
||||
+import org.jspecify.annotations.NullMarked;
|
||||
+
|
||||
+/**
|
||||
+ * Called when a player tries to bypass book limitations
|
||||
+ */
|
||||
+@NullMarked
|
||||
+public class PlayerBookTooLargeEvent extends PlayerEvent {
|
||||
+ private static final HandlerList handlers = new HandlerList();
|
||||
+ private final ItemStack book;
|
||||
+ private boolean kickPlayer = true;
|
||||
+
|
||||
+ /**
|
||||
+ * @param player The player
|
||||
+ * @param book The book
|
||||
+ */
|
||||
+ @ApiStatus.Internal
|
||||
+ public PlayerBookTooLargeEvent(Player player, ItemStack book) {
|
||||
+ super(player, !Bukkit.isPrimaryThread());
|
||||
+ this.book = book;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Get the book containing the wanted edits
|
||||
+ *
|
||||
+ * @return The book
|
||||
+ */
|
||||
+ public ItemStack getBook() {
|
||||
+ return book;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Whether server should kick the player or not
|
||||
+ *
|
||||
+ * @return True to kick player
|
||||
+ */
|
||||
+ public boolean shouldKickPlayer() {
|
||||
+ return kickPlayer;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Whether server should kick the player or not
|
||||
+ *
|
||||
+ * @param kickPlayer True to kick player
|
||||
+ */
|
||||
+ public void setShouldKickPlayer(boolean kickPlayer) {
|
||||
+ this.kickPlayer = kickPlayer;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public HandlerList getHandlers() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+
|
||||
+ public static HandlerList getHandlerList() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+}
|
||||
@@ -0,0 +1,23 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
|
||||
Date: Thu, 24 Dec 2020 11:00:04 -0600
|
||||
Subject: [PATCH] Full netherite armor grants fire resistance
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/event/entity/EntityPotionEffectEvent.java b/src/main/java/org/bukkit/event/entity/EntityPotionEffectEvent.java
|
||||
index 8fdfcbc7d20fe0af6b220ab94516247093637621..f6a8928408e11a5ae723366e4ea1280dfcc6111e 100644
|
||||
--- a/src/main/java/org/bukkit/event/entity/EntityPotionEffectEvent.java
|
||||
+++ b/src/main/java/org/bukkit/event/entity/EntityPotionEffectEvent.java
|
||||
@@ -216,6 +216,12 @@ public class EntityPotionEffectEvent extends EntityEvent implements Cancellable
|
||||
* When all effects are removed due to a bucket of milk.
|
||||
*/
|
||||
MILK,
|
||||
+ // Purpur start
|
||||
+ /**
|
||||
+ * When a player wears full netherite armor
|
||||
+ */
|
||||
+ NETHERITE_ARMOR,
|
||||
+ // Purpur end
|
||||
/**
|
||||
* When a player gets bad omen after killing a patrol captain.
|
||||
*
|
||||
138
patches/api/0024-Add-EntityTeleportHinderedEvent.patch
Normal file
138
patches/api/0024-Add-EntityTeleportHinderedEvent.patch
Normal file
@@ -0,0 +1,138 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Mariell Hoversholm <proximyst@proximyst.com>
|
||||
Date: Sat, 9 Jan 2021 15:26:04 +0100
|
||||
Subject: [PATCH] Add EntityTeleportHinderedEvent
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
diff --git a/src/main/java/org/purpurmc/purpur/event/entity/EntityTeleportHinderedEvent.java b/src/main/java/org/purpurmc/purpur/event/entity/EntityTeleportHinderedEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..daf3bbf83ee76322828a38814b483fa2b337bd60
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/purpurmc/purpur/event/entity/EntityTeleportHinderedEvent.java
|
||||
@@ -0,0 +1,114 @@
|
||||
+package org.purpurmc.purpur.event.entity;
|
||||
+
|
||||
+import org.bukkit.entity.Entity;
|
||||
+import org.bukkit.event.HandlerList;
|
||||
+import org.bukkit.event.entity.EntityEvent;
|
||||
+import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
+import org.jetbrains.annotations.ApiStatus;
|
||||
+import org.jspecify.annotations.NullMarked;
|
||||
+import org.jspecify.annotations.Nullable;
|
||||
+
|
||||
+/**
|
||||
+ * Fired when an entity is hindered from teleporting.
|
||||
+ */
|
||||
+@NullMarked
|
||||
+public class EntityTeleportHinderedEvent extends EntityEvent {
|
||||
+ private static final HandlerList handlers = new HandlerList();
|
||||
+
|
||||
+ private final Reason reason;
|
||||
+
|
||||
+ private final @Nullable TeleportCause teleportCause;
|
||||
+
|
||||
+ private boolean retry = false;
|
||||
+
|
||||
+ @ApiStatus.Internal
|
||||
+ public EntityTeleportHinderedEvent(Entity what, Reason reason, @Nullable TeleportCause teleportCause) {
|
||||
+ super(what);
|
||||
+ this.reason = reason;
|
||||
+ this.teleportCause = teleportCause;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * @return why the teleport was hindered.
|
||||
+ */
|
||||
+ public Reason getReason() {
|
||||
+ return reason;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * @return why the teleport occurred if cause was given, otherwise {@code null}.
|
||||
+ */
|
||||
+ @Nullable
|
||||
+ public TeleportCause getTeleportCause() {
|
||||
+ return teleportCause;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Whether the teleport should be retried.
|
||||
+ * <p>
|
||||
+ * Note that this can put the server in a never-ending loop of trying to teleport someone resulting in a stack
|
||||
+ * overflow. Do not retry more than necessary.
|
||||
+ * </p>
|
||||
+ *
|
||||
+ * @return whether the teleport should be retried.
|
||||
+ */
|
||||
+ public boolean shouldRetry() {
|
||||
+ return retry;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Sets whether the teleport should be retried.
|
||||
+ * <p>
|
||||
+ * Note that this can put the server in a never-ending loop of trying to teleport someone resulting in a stack
|
||||
+ * overflow. Do not retry more than necessary.
|
||||
+ * </p>
|
||||
+ *
|
||||
+ * @param retry whether the teleport should be retried.
|
||||
+ */
|
||||
+ public void setShouldRetry(boolean retry) {
|
||||
+ this.retry = retry;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Calls the event and tests if should retry.
|
||||
+ *
|
||||
+ * @return whether the teleport should be retried.
|
||||
+ */
|
||||
+ @Override
|
||||
+ public boolean callEvent() {
|
||||
+ super.callEvent();
|
||||
+ return shouldRetry();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public HandlerList getHandlers() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+
|
||||
+ public static HandlerList getHandlerList() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Reason for hindrance in teleports.
|
||||
+ */
|
||||
+ public enum Reason {
|
||||
+ /**
|
||||
+ * The teleported entity is a passenger of another entity.
|
||||
+ */
|
||||
+ IS_PASSENGER,
|
||||
+
|
||||
+ /**
|
||||
+ * The teleported entity has passengers.
|
||||
+ */
|
||||
+ IS_VEHICLE,
|
||||
+
|
||||
+ /**
|
||||
+ * The teleport event was cancelled.
|
||||
+ * <p>
|
||||
+ * This is only caused by players teleporting.
|
||||
+ * </p>
|
||||
+ */
|
||||
+ EVENT_CANCELLED,
|
||||
+ }
|
||||
+}
|
||||
@@ -0,0 +1,29 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
|
||||
Date: Tue, 23 Mar 2021 15:01:03 -0500
|
||||
Subject: [PATCH] Add enchantment target for bows and crossbows
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/enchantments/EnchantmentTarget.java b/src/main/java/org/bukkit/enchantments/EnchantmentTarget.java
|
||||
index 455ff52d90565838fe7640c3f045b27082a6c2f1..5831ffe24eed01311c71989dcb1830dbc395607b 100644
|
||||
--- a/src/main/java/org/bukkit/enchantments/EnchantmentTarget.java
|
||||
+++ b/src/main/java/org/bukkit/enchantments/EnchantmentTarget.java
|
||||
@@ -227,6 +227,18 @@ public enum EnchantmentTarget {
|
||||
public boolean includes(@NotNull Material item) {
|
||||
return BREAKABLE.includes(item) || (WEARABLE.includes(item) && !item.equals(Material.ELYTRA)) || item.equals(Material.COMPASS);
|
||||
}
|
||||
+ // Purpur start
|
||||
+ },
|
||||
+
|
||||
+ /**
|
||||
+ * Allow the Enchantment to be placed on bows and crossbows.
|
||||
+ */
|
||||
+ BOW_AND_CROSSBOW {
|
||||
+ @Override
|
||||
+ public boolean includes(@NotNull Material item) {
|
||||
+ return item.equals(Material.BOW) || item.equals(Material.CROSSBOW);
|
||||
+ }
|
||||
+ // Purpur end
|
||||
};
|
||||
|
||||
/**
|
||||
49
patches/api/0026-API-for-any-mob-to-burn-daylight.patch
Normal file
49
patches/api/0026-API-for-any-mob-to-burn-daylight.patch
Normal file
@@ -0,0 +1,49 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Ben Kerllenevich <ben@omega24.dev>
|
||||
Date: Tue, 25 May 2021 16:30:30 -0400
|
||||
Subject: [PATCH] API for any mob to burn daylight
|
||||
|
||||
Co-authored by: Encode42 <me@encode42.dev>
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/entity/Entity.java b/src/main/java/org/bukkit/entity/Entity.java
|
||||
index bf6d13cc6b0566f4076383c8f170dc8c9589e416..22713e97e7c7b643b80c07a88ae890d7c4304730 100644
|
||||
--- a/src/main/java/org/bukkit/entity/Entity.java
|
||||
+++ b/src/main/java/org/bukkit/entity/Entity.java
|
||||
@@ -1202,5 +1202,12 @@ public interface Entity extends Metadatable, CommandSender, Nameable, Persistent
|
||||
* @return True if ridable in water
|
||||
*/
|
||||
boolean isRidableInWater();
|
||||
+
|
||||
+ /**
|
||||
+ * Checks if the entity is in daylight
|
||||
+ *
|
||||
+ * @return True if in daylight
|
||||
+ */
|
||||
+ boolean isInDaylight();
|
||||
// Purpur end
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/entity/LivingEntity.java b/src/main/java/org/bukkit/entity/LivingEntity.java
|
||||
index 68c08e7a212bc3e3885f9b5a4d9aef85fcb3b029..a22909446b7193b1de121bdd6d7b6fbf81dc3be4 100644
|
||||
--- a/src/main/java/org/bukkit/entity/LivingEntity.java
|
||||
+++ b/src/main/java/org/bukkit/entity/LivingEntity.java
|
||||
@@ -1468,4 +1468,20 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource
|
||||
*/
|
||||
boolean canUseEquipmentSlot(org.bukkit.inventory.@NotNull EquipmentSlot slot);
|
||||
// Paper end - Expose canUseSlot
|
||||
+
|
||||
+ // Purpur start - API for any mob to burn daylight
|
||||
+ /**
|
||||
+ * If this mob will burn in the sunlight
|
||||
+ *
|
||||
+ * @return True if mob will burn in sunlight
|
||||
+ */
|
||||
+ boolean shouldBurnInDay();
|
||||
+
|
||||
+ /**
|
||||
+ * Set if this mob should burn in the sunlight
|
||||
+ *
|
||||
+ * @param shouldBurnInDay True to burn in sunlight
|
||||
+ */
|
||||
+ void setShouldBurnInDay(boolean shouldBurnInDay);
|
||||
+ // Purpur end - API for any mob to burn daylight
|
||||
}
|
||||
40
patches/api/0027-Add-back-player-spawned-endermite-API.patch
Normal file
40
patches/api/0027-Add-back-player-spawned-endermite-API.patch
Normal file
@@ -0,0 +1,40 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: William Blake Galbreath <blake.galbreath@gmail.com>
|
||||
Date: Sat, 26 Jun 2021 22:08:57 -0500
|
||||
Subject: [PATCH] Add back player spawned endermite API
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/entity/Endermite.java b/src/main/java/org/bukkit/entity/Endermite.java
|
||||
index 138d2530de2410f4a9424dabd3e5ce0cd1c1dcd2..10a8d64ad2da0be2c14f34c3e7d1957c6f2883d1 100644
|
||||
--- a/src/main/java/org/bukkit/entity/Endermite.java
|
||||
+++ b/src/main/java/org/bukkit/entity/Endermite.java
|
||||
@@ -3,25 +3,21 @@ package org.bukkit.entity;
|
||||
public interface Endermite extends Monster {
|
||||
|
||||
/**
|
||||
- * Gets whether this Endermite was spawned by a player.
|
||||
+ * Gets whether this Endermite was spawned by a player from throwing an ender pearl
|
||||
*
|
||||
- * An Endermite spawned by a player will be attacked by nearby Enderman.
|
||||
+ * An Endermite spawned by a player might be attacked by nearby Enderman depending on purpur.yml settings
|
||||
*
|
||||
* @return player spawned status
|
||||
- * @deprecated this functionality no longer exists
|
||||
*/
|
||||
- @Deprecated
|
||||
boolean isPlayerSpawned();
|
||||
|
||||
/**
|
||||
- * Sets whether this Endermite was spawned by a player.
|
||||
+ * Sets whether this Endermite was spawned by a player from throwing an ender pearl
|
||||
*
|
||||
- * An Endermite spawned by a player will be attacked by nearby Enderman.
|
||||
+ * An Endermite spawned by a player might be attacked by nearby Enderman depending on purpur.yml settings
|
||||
*
|
||||
* @param playerSpawned player spawned status
|
||||
- * @deprecated this functionality no longer exists
|
||||
*/
|
||||
- @Deprecated
|
||||
void setPlayerSpawned(boolean playerSpawned);
|
||||
// Paper start
|
||||
/**
|
||||
77
patches/api/0028-Fix-default-permission-system.patch
Normal file
77
patches/api/0028-Fix-default-permission-system.patch
Normal file
@@ -0,0 +1,77 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: William Blake Galbreath <blake.galbreath@gmail.com>
|
||||
Date: Wed, 30 Jun 2021 17:44:27 -0500
|
||||
Subject: [PATCH] Fix default permission system
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/permissions/PermissibleBase.java b/src/main/java/org/bukkit/permissions/PermissibleBase.java
|
||||
index 75b77cc4fe189b4b6baa1af3663dc492e992a266..30b98d1645c571ba5c18e5cc93b0bec3f74b1d3b 100644
|
||||
--- a/src/main/java/org/bukkit/permissions/PermissibleBase.java
|
||||
+++ b/src/main/java/org/bukkit/permissions/PermissibleBase.java
|
||||
@@ -169,7 +169,7 @@ public class PermissibleBase implements Permissible {
|
||||
|
||||
for (Permission perm : defaults) {
|
||||
String name = perm.getName().toLowerCase(Locale.ROOT);
|
||||
- permissions.put(name, new PermissionAttachmentInfo(parent, name, null, true));
|
||||
+ permissions.put(name, new PermissionAttachmentInfo(parent, name, null, perm.getDefault().getValue(isOp()))); // Purpur
|
||||
Bukkit.getServer().getPluginManager().subscribeToPermission(name, parent);
|
||||
calculateChildPermissions(perm.getChildren(), false, null);
|
||||
}
|
||||
@@ -197,7 +197,7 @@ public class PermissibleBase implements Permissible {
|
||||
String name = entry.getKey();
|
||||
|
||||
Permission perm = Bukkit.getServer().getPluginManager().getPermission(name);
|
||||
- boolean value = entry.getValue() ^ invert;
|
||||
+ boolean value = (entry.getValue() == null && perm != null ? perm.getDefault().getValue(isOp()) : entry.getValue()) ^ invert; // Purpur
|
||||
String lname = name.toLowerCase(Locale.ROOT);
|
||||
|
||||
permissions.put(lname, new PermissionAttachmentInfo(parent, lname, attachment, value));
|
||||
diff --git a/src/main/java/org/bukkit/util/permissions/DefaultPermissions.java b/src/main/java/org/bukkit/util/permissions/DefaultPermissions.java
|
||||
index 8e481e3815f5645ee92f0d229e5ff25c8fc9a6c2..10627d2a11251a8cb01bbc3f6242d66f3505a16e 100644
|
||||
--- a/src/main/java/org/bukkit/util/permissions/DefaultPermissions.java
|
||||
+++ b/src/main/java/org/bukkit/util/permissions/DefaultPermissions.java
|
||||
@@ -31,7 +31,7 @@ public final class DefaultPermissions {
|
||||
|
||||
if (withLegacy) {
|
||||
Permission legacy = new Permission(LEGACY_PREFIX + result.getName(), result.getDescription(), PermissionDefault.FALSE);
|
||||
- legacy.getChildren().put(result.getName(), true);
|
||||
+ legacy.getChildren().put(result.getName(), null); // Purpur
|
||||
registerPermission(perm, false);
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ public final class DefaultPermissions {
|
||||
|
||||
@NotNull
|
||||
public static Permission registerPermission(@NotNull Permission perm, @NotNull Permission parent) {
|
||||
- parent.getChildren().put(perm.getName(), true);
|
||||
+ parent.getChildren().put(perm.getName(), null); // Purpur
|
||||
return registerPermission(perm);
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ public final class DefaultPermissions {
|
||||
@NotNull
|
||||
public static Permission registerPermission(@NotNull String name, @Nullable String desc, @NotNull Permission parent) {
|
||||
Permission perm = registerPermission(name, desc);
|
||||
- parent.getChildren().put(perm.getName(), true);
|
||||
+ parent.getChildren().put(perm.getName(), null); // Purpur
|
||||
return perm;
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ public final class DefaultPermissions {
|
||||
@NotNull
|
||||
public static Permission registerPermission(@NotNull String name, @Nullable String desc, @Nullable PermissionDefault def, @NotNull Permission parent) {
|
||||
Permission perm = registerPermission(name, desc, def);
|
||||
- parent.getChildren().put(perm.getName(), true);
|
||||
+ parent.getChildren().put(perm.getName(), null); // Purpur
|
||||
return perm;
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ public final class DefaultPermissions {
|
||||
@NotNull
|
||||
public static Permission registerPermission(@NotNull String name, @Nullable String desc, @Nullable PermissionDefault def, @Nullable Map<String, Boolean> children, @NotNull Permission parent) {
|
||||
Permission perm = registerPermission(name, desc, def, children);
|
||||
- parent.getChildren().put(perm.getName(), true);
|
||||
+ parent.getChildren().put(perm.getName(), null); // Purpur
|
||||
return perm;
|
||||
}
|
||||
|
||||
81
patches/api/0029-Summoner-API.patch
Normal file
81
patches/api/0029-Summoner-API.patch
Normal file
@@ -0,0 +1,81 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: William Blake Galbreath <blake.galbreath@gmail.com>
|
||||
Date: Sat, 3 Jul 2021 18:45:01 -0500
|
||||
Subject: [PATCH] Summoner API
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/entity/IronGolem.java b/src/main/java/org/bukkit/entity/IronGolem.java
|
||||
index 655e37cb3a09610a3f3df805d6dcad17d722da62..09fd716c8fc9ea34a1cbf87bcbe22df035422a51 100644
|
||||
--- a/src/main/java/org/bukkit/entity/IronGolem.java
|
||||
+++ b/src/main/java/org/bukkit/entity/IronGolem.java
|
||||
@@ -19,4 +19,20 @@ public interface IronGolem extends Golem {
|
||||
* player created, false if you want it to be a natural village golem.
|
||||
*/
|
||||
public void setPlayerCreated(boolean playerCreated);
|
||||
+
|
||||
+ // Purpur start
|
||||
+ /**
|
||||
+ * Get the player that summoned this iron golem
|
||||
+ *
|
||||
+ * @return UUID of summoner
|
||||
+ */
|
||||
+ @org.jetbrains.annotations.Nullable java.util.UUID getSummoner();
|
||||
+
|
||||
+ /**
|
||||
+ * Set the player that summoned this iron golem
|
||||
+ *
|
||||
+ * @param summoner UUID of summoner
|
||||
+ */
|
||||
+ void setSummoner(@org.jetbrains.annotations.Nullable java.util.UUID summoner);
|
||||
+ // Purpur end
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/entity/Snowman.java b/src/main/java/org/bukkit/entity/Snowman.java
|
||||
index 7fbfdb07585c7b28acea1f0c1f58ada0cc744441..21fcca092e2e31baa5ece0de9e44e3fade8c7123 100644
|
||||
--- a/src/main/java/org/bukkit/entity/Snowman.java
|
||||
+++ b/src/main/java/org/bukkit/entity/Snowman.java
|
||||
@@ -23,4 +23,20 @@ public interface Snowman extends Golem, RangedEntity, io.papermc.paper.entity.Sh
|
||||
* @param derpMode True to remove the pumpkin, false to add a pumpkin
|
||||
*/
|
||||
void setDerp(boolean derpMode);
|
||||
+
|
||||
+ // Purpur start
|
||||
+ /**
|
||||
+ * Get the player that summoned this snowman
|
||||
+ *
|
||||
+ * @return UUID of summoner
|
||||
+ */
|
||||
+ @org.jetbrains.annotations.Nullable java.util.UUID getSummoner();
|
||||
+
|
||||
+ /**
|
||||
+ * Set the player that summoned this snowman
|
||||
+ *
|
||||
+ * @param summoner UUID of summoner
|
||||
+ */
|
||||
+ void setSummoner(@org.jetbrains.annotations.Nullable java.util.UUID summoner);
|
||||
+ // Purpur end
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/entity/Wither.java b/src/main/java/org/bukkit/entity/Wither.java
|
||||
index 14543c2238b45c526dd9aebea2aa5c22f5df54dc..5312daf33405704c74e2c9e109754285ea6cf734 100644
|
||||
--- a/src/main/java/org/bukkit/entity/Wither.java
|
||||
+++ b/src/main/java/org/bukkit/entity/Wither.java
|
||||
@@ -107,4 +107,20 @@ public interface Wither extends Monster, Boss, com.destroystokyo.paper.entity.Ra
|
||||
*/
|
||||
void enterInvulnerabilityPhase();
|
||||
// Paper end
|
||||
+
|
||||
+ // Purpur start
|
||||
+ /**
|
||||
+ * Get the player that summoned this wither
|
||||
+ *
|
||||
+ * @return UUID of summoner
|
||||
+ */
|
||||
+ @org.jetbrains.annotations.Nullable java.util.UUID getSummoner();
|
||||
+
|
||||
+ /**
|
||||
+ * Set the player that summoned this wither
|
||||
+ *
|
||||
+ * @param summoner UUID of summoner
|
||||
+ */
|
||||
+ void setSummoner(@org.jetbrains.annotations.Nullable java.util.UUID summoner);
|
||||
+ // Purpur end
|
||||
}
|
||||
51
patches/api/0030-Clean-up-version-command-output.patch
Normal file
51
patches/api/0030-Clean-up-version-command-output.patch
Normal file
@@ -0,0 +1,51 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: William Blake Galbreath <blake.galbreath@gmail.com>
|
||||
Date: Thu, 15 Jul 2021 23:43:04 -0500
|
||||
Subject: [PATCH] Clean up version command output
|
||||
|
||||
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/util/VersionFetcher.java b/src/main/java/com/destroystokyo/paper/util/VersionFetcher.java
|
||||
index 023cc52a9e28e1238c7452c0f3f577f2850fd861..00b3f46ddd26ae08744d3dba211f92624d4b1063 100644
|
||||
--- a/src/main/java/com/destroystokyo/paper/util/VersionFetcher.java
|
||||
+++ b/src/main/java/com/destroystokyo/paper/util/VersionFetcher.java
|
||||
@@ -28,6 +28,12 @@ public interface VersionFetcher {
|
||||
*/
|
||||
Component getVersionMessage(String serverVersion);
|
||||
|
||||
+ // Purpur start
|
||||
+ default int distance() {
|
||||
+ return 0;
|
||||
+ }
|
||||
+ // Purpur end
|
||||
+
|
||||
@ApiStatus.Internal
|
||||
class DummyVersionFetcher implements VersionFetcher {
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/command/defaults/VersionCommand.java b/src/main/java/org/bukkit/command/defaults/VersionCommand.java
|
||||
index e64bb57f74e6d6f78927be228825b3e0bdf41f48..c880d0010849ab733ad13bbd18fab3c864d0cf61 100644
|
||||
--- a/src/main/java/org/bukkit/command/defaults/VersionCommand.java
|
||||
+++ b/src/main/java/org/bukkit/command/defaults/VersionCommand.java
|
||||
@@ -215,7 +215,7 @@ public class VersionCommand extends BukkitCommand {
|
||||
String version = Bukkit.getVersion();
|
||||
// Paper start
|
||||
if (version.startsWith("null")) { // running from ide?
|
||||
- setVersionMessage(Component.text("Unknown version, custom build?", NamedTextColor.YELLOW));
|
||||
+ setVersionMessage(Component.text("* Unknown version, custom build?", NamedTextColor.RED)); // Purpur
|
||||
return;
|
||||
}
|
||||
setVersionMessage(getVersionFetcher().getVersionMessage(version));
|
||||
@@ -256,9 +256,11 @@ public class VersionCommand extends BukkitCommand {
|
||||
// Paper start
|
||||
private void setVersionMessage(final @NotNull Component msg) {
|
||||
lastCheck = System.currentTimeMillis();
|
||||
- final Component message = Component.textOfChildren(
|
||||
- Component.text(Bukkit.getVersionMessage(), NamedTextColor.WHITE),
|
||||
- Component.newline(),
|
||||
+ // Purpur start
|
||||
+ int distance = getVersionFetcher().distance();
|
||||
+ final Component message = Component.join(net.kyori.adventure.text.JoinConfiguration.separator(Component.newline()),
|
||||
+ ChatColor.parseMM("<grey>Current Purpur Version: %s%s*", distance == 0 ? "<green>" : distance > 0 ? "<yellow>" : "<red>", Bukkit.getVersion()),
|
||||
+ // Purpur end
|
||||
msg
|
||||
);
|
||||
this.versionMessage = Component.text()
|
||||
117
patches/api/0031-Extended-OfflinePlayer-API.patch
Normal file
117
patches/api/0031-Extended-OfflinePlayer-API.patch
Normal file
@@ -0,0 +1,117 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: YouHaveTrouble <youhavetrouble@youhavetrouble.me>
|
||||
Date: Sun, 22 Aug 2021 05:11:09 +0200
|
||||
Subject: [PATCH] Extended OfflinePlayer API
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/OfflinePlayer.java b/src/main/java/org/bukkit/OfflinePlayer.java
|
||||
index a028f2fe541491729856051780b33dba07832fb6..fc64902368a068481f16d5db99c94386caf6b60b 100644
|
||||
--- a/src/main/java/org/bukkit/OfflinePlayer.java
|
||||
+++ b/src/main/java/org/bukkit/OfflinePlayer.java
|
||||
@@ -573,4 +573,106 @@ public interface OfflinePlayer extends ServerOperator, AnimalTamer, Configuratio
|
||||
@Override
|
||||
io.papermc.paper.persistence.@NotNull PersistentDataContainerView getPersistentDataContainer();
|
||||
// Paper end - add pdc to offline player
|
||||
+
|
||||
+ // Purpur start - OfflinePlayer API
|
||||
+ /**
|
||||
+ * Determines if the OfflinePlayer is allowed to fly via jump key double-tap like
|
||||
+ * in creative mode.
|
||||
+ *
|
||||
+ * @return True if the player is allowed to fly.
|
||||
+ */
|
||||
+ public boolean getAllowFlight();
|
||||
+
|
||||
+ /**
|
||||
+ * Sets if the OfflinePlayer is allowed to fly via jump key double-tap like in
|
||||
+ * creative mode.
|
||||
+ *
|
||||
+ * @param flight If flight should be allowed.
|
||||
+ */
|
||||
+ public void setAllowFlight(boolean flight);
|
||||
+
|
||||
+ /**
|
||||
+ * Checks to see if this player is currently flying or not.
|
||||
+ *
|
||||
+ * @return True if the player is flying, else false.
|
||||
+ */
|
||||
+ public boolean isFlying();
|
||||
+
|
||||
+ /**
|
||||
+ * Makes this player start or stop flying.
|
||||
+ *
|
||||
+ * @param value True to fly.
|
||||
+ */
|
||||
+ public void setFlying(boolean value);
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the speed at which a client will fly. Negative values indicate
|
||||
+ * reverse directions.
|
||||
+ *
|
||||
+ * @param value The new speed, from -1 to 1.
|
||||
+ * @throws IllegalArgumentException If new speed is less than -1 or
|
||||
+ * greater than 1
|
||||
+ */
|
||||
+ public void setFlySpeed(float value) throws IllegalArgumentException;
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the speed at which a client will walk. Negative values indicate
|
||||
+ * reverse directions.
|
||||
+ *
|
||||
+ * @param value The new speed, from -1 to 1.
|
||||
+ * @throws IllegalArgumentException If new speed is less than -1 or
|
||||
+ * greater than 1
|
||||
+ */
|
||||
+ public void setWalkSpeed(float value) throws IllegalArgumentException;
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the current allowed speed that a client can fly.
|
||||
+ *
|
||||
+ * @return The current allowed speed, from -1 to 1
|
||||
+ */
|
||||
+ public float getFlySpeed();
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the current allowed speed that a client can walk.
|
||||
+ *
|
||||
+ * @return The current allowed speed, from -1 to 1
|
||||
+ */
|
||||
+ public float getWalkSpeed();
|
||||
+
|
||||
+ /**
|
||||
+ * Sets OfflinePlayer's location. If player is online, it falls back to the Player#teleport implementation.
|
||||
+ *
|
||||
+ * @param destination
|
||||
+ * @return true if teleportation was successful
|
||||
+ */
|
||||
+ public boolean teleportOffline(@NotNull org.bukkit.Location destination);
|
||||
+
|
||||
+ /**
|
||||
+ * Sets OfflinePlayer's location. If player is online, it falls back to the Player#teleport implementation.
|
||||
+ *
|
||||
+ * @param destination
|
||||
+ * @param cause Teleport cause used if player is online
|
||||
+ * @return true if teleportation was successful
|
||||
+ */
|
||||
+ public boolean teleportOffline(@NotNull org.bukkit.Location destination, @NotNull org.bukkit.event.player.PlayerTeleportEvent.TeleportCause cause);
|
||||
+
|
||||
+ /**
|
||||
+ * Sets OfflinePlayer's location. If player is online, it falls back to the Player#teleportAsync implementation.
|
||||
+ *
|
||||
+ * @param destination
|
||||
+ * @return <code>true</code> if teleportation successful
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public java.util.concurrent.CompletableFuture<Boolean> teleportOfflineAsync(@NotNull Location destination);
|
||||
+
|
||||
+ /**
|
||||
+ * Sets OfflinePlayer's location. If player is online, it falls back to the Player#teleportAsync implementation.
|
||||
+ *
|
||||
+ * @param destination
|
||||
+ * @param cause Teleport cause used if player is online
|
||||
+ * @return <code>true</code> if teleportation successful
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public java.util.concurrent.CompletableFuture<Boolean> teleportOfflineAsync(@NotNull Location destination, @NotNull org.bukkit.event.player.PlayerTeleportEvent.TeleportCause cause);
|
||||
+ // Purpur end - OfflinePlayer API
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: DoctaEnkoda <bierquejason@gmail.com>
|
||||
Date: Mon, 9 Aug 2021 13:22:03 +0200
|
||||
Subject: [PATCH] Added the ability to add combustible items
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
|
||||
index 5fe1896c9d8c5848b1ba1220e52cbe4cfae75603..676cddfc8ae317ed750701af06964a22a0c03e10 100644
|
||||
--- a/src/main/java/org/bukkit/Bukkit.java
|
||||
+++ b/src/main/java/org/bukkit/Bukkit.java
|
||||
@@ -2888,5 +2888,24 @@ public final class Bukkit {
|
||||
public static boolean isLagging() {
|
||||
return server.isLagging();
|
||||
}
|
||||
+
|
||||
+ /**
|
||||
+ * Add an Item as fuel for furnaces
|
||||
+ *
|
||||
+ * @param material The material that will be the fuel
|
||||
+ * @param burnTime The time (in ticks) this item will burn for
|
||||
+ */
|
||||
+ public static void addFuel(@NotNull Material material, int burnTime) {
|
||||
+ server.addFuel(material, burnTime);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Remove an item as fuel for furnaces
|
||||
+ *
|
||||
+ * @param material The material that will no longer be a fuel
|
||||
+ */
|
||||
+ public static void removeFuel(@NotNull Material material) {
|
||||
+ server.removeFuel(material);
|
||||
+ }
|
||||
// Purpur end
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
|
||||
index 7bef0845de3a3e51b375df735520ac8cc0f08636..dd90bdfdf82073f87a9dfda92f743b6682d4a1b8 100644
|
||||
--- a/src/main/java/org/bukkit/Server.java
|
||||
+++ b/src/main/java/org/bukkit/Server.java
|
||||
@@ -2530,5 +2530,20 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
|
||||
* @return True if lagging
|
||||
*/
|
||||
boolean isLagging();
|
||||
+
|
||||
+ /**
|
||||
+ * Add an Item as fuel for furnaces
|
||||
+ *
|
||||
+ * @param material The material that will be the fuel
|
||||
+ * @param burnTime The time (in ticks) this item will burn for
|
||||
+ */
|
||||
+ public void addFuel(@NotNull Material material, int burnTime);
|
||||
+
|
||||
+ /**
|
||||
+ * Remove an item as fuel for furnaces
|
||||
+ *
|
||||
+ * @param material The material that will no longer be a fuel
|
||||
+ */
|
||||
+ public void removeFuel(@NotNull Material material);
|
||||
// Purpur end
|
||||
}
|
||||
84
patches/api/0033-Grindstone-API.patch
Normal file
84
patches/api/0033-Grindstone-API.patch
Normal file
@@ -0,0 +1,84 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: BillyGalbreath <blake.galbreath@gmail.com>
|
||||
Date: Mon, 27 Dec 2021 08:10:50 -0600
|
||||
Subject: [PATCH] Grindstone API
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/purpurmc/purpur/event/inventory/GrindstoneTakeResultEvent.java b/src/main/java/org/purpurmc/purpur/event/inventory/GrindstoneTakeResultEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..d6db2d355553c9c54b83328d237b9c75e7a8e375
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/purpurmc/purpur/event/inventory/GrindstoneTakeResultEvent.java
|
||||
@@ -0,0 +1,72 @@
|
||||
+package org.purpurmc.purpur.event.inventory;
|
||||
+
|
||||
+import org.bukkit.entity.HumanEntity;
|
||||
+import org.bukkit.entity.Player;
|
||||
+import org.bukkit.event.HandlerList;
|
||||
+import org.bukkit.event.inventory.InventoryEvent;
|
||||
+import org.bukkit.inventory.GrindstoneInventory;
|
||||
+import org.bukkit.inventory.InventoryView;
|
||||
+import org.bukkit.inventory.ItemStack;
|
||||
+import org.jetbrains.annotations.ApiStatus;
|
||||
+import org.jspecify.annotations.NullMarked;
|
||||
+
|
||||
+/**
|
||||
+ * Called when a player takes the result item out of a Grindstone
|
||||
+ */
|
||||
+@NullMarked
|
||||
+public class GrindstoneTakeResultEvent extends InventoryEvent {
|
||||
+ private static final HandlerList handlers = new HandlerList();
|
||||
+ private final Player player;
|
||||
+ private final ItemStack result;
|
||||
+ private int experienceAmount;
|
||||
+
|
||||
+ @ApiStatus.Internal
|
||||
+ public GrindstoneTakeResultEvent(HumanEntity player, InventoryView view, ItemStack result, int experienceAmount) {
|
||||
+ super(view);
|
||||
+ this.player = (Player) player;
|
||||
+ this.result = result;
|
||||
+ this.experienceAmount = experienceAmount;
|
||||
+ }
|
||||
+
|
||||
+ public Player getPlayer() {
|
||||
+ return player;
|
||||
+ }
|
||||
+
|
||||
+ public ItemStack getResult() {
|
||||
+ return result;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public GrindstoneInventory getInventory() {
|
||||
+ return (GrindstoneInventory) super.getInventory();
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Get the amount of experience this transaction will give
|
||||
+ * (takes priority over and uses result from {@link org.bukkit.event.block.BlockExpEvent})
|
||||
+ *
|
||||
+ * @return Amount of experience to give
|
||||
+ */
|
||||
+ public int getExperienceAmount() {
|
||||
+ return this.experienceAmount;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Set the amount of experience this transaction will give
|
||||
+ * (takes priority over {@link org.bukkit.event.block.BlockExpEvent})
|
||||
+ *
|
||||
+ * @param experienceAmount Amount of experience to give
|
||||
+ */
|
||||
+ public void setExperienceAmount(int experienceAmount) {
|
||||
+ this.experienceAmount = experienceAmount;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public HandlerList getHandlers() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+
|
||||
+ public static HandlerList getHandlerList() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+}
|
||||
27
patches/api/0034-Shears-can-have-looting-enchantment.patch
Normal file
27
patches/api/0034-Shears-can-have-looting-enchantment.patch
Normal file
@@ -0,0 +1,27 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: BillyGalbreath <Blake.Galbreath@Gmail.com>
|
||||
Date: Mon, 3 Jan 2022 02:00:50 -0600
|
||||
Subject: [PATCH] Shears can have looting enchantment
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/enchantments/EnchantmentTarget.java b/src/main/java/org/bukkit/enchantments/EnchantmentTarget.java
|
||||
index 5831ffe24eed01311c71989dcb1830dbc395607b..45f5493eebfecf56b7c0ef4659c078dfc62c0612 100644
|
||||
--- a/src/main/java/org/bukkit/enchantments/EnchantmentTarget.java
|
||||
+++ b/src/main/java/org/bukkit/enchantments/EnchantmentTarget.java
|
||||
@@ -238,6 +238,16 @@ public enum EnchantmentTarget {
|
||||
public boolean includes(@NotNull Material item) {
|
||||
return item.equals(Material.BOW) || item.equals(Material.CROSSBOW);
|
||||
}
|
||||
+ },
|
||||
+
|
||||
+ /**
|
||||
+ * Allow the Enchantment to be placed on shears.
|
||||
+ */
|
||||
+ WEAPON_AND_SHEARS {
|
||||
+ @Override
|
||||
+ public boolean includes(@NotNull Material item) {
|
||||
+ return WEAPON.includes(item) || item.equals(Material.SHEARS);
|
||||
+ }
|
||||
// Purpur end
|
||||
};
|
||||
|
||||
25
patches/api/0035-Lobotomize-stuck-villagers.patch
Normal file
25
patches/api/0035-Lobotomize-stuck-villagers.patch
Normal file
@@ -0,0 +1,25 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: BillyGalbreath <Blake.Galbreath@Gmail.com>
|
||||
Date: Mon, 24 Jan 2022 20:42:22 -0600
|
||||
Subject: [PATCH] Lobotomize stuck villagers
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/entity/Villager.java b/src/main/java/org/bukkit/entity/Villager.java
|
||||
index 1db3742024e9cd1b70af2d52b4b756a544c019df..9c722a762c88a88bb5ef18c3b9eab8b371360dac 100644
|
||||
--- a/src/main/java/org/bukkit/entity/Villager.java
|
||||
+++ b/src/main/java/org/bukkit/entity/Villager.java
|
||||
@@ -367,4 +367,14 @@ public interface Villager extends AbstractVillager {
|
||||
*/
|
||||
public void clearReputations();
|
||||
// Paper end
|
||||
+
|
||||
+ // Purpur start
|
||||
+
|
||||
+ /**
|
||||
+ * Check if villager is currently lobotomized
|
||||
+ *
|
||||
+ * @return True if lobotomized
|
||||
+ */
|
||||
+ boolean isLobotomized();
|
||||
+ // Purpur end
|
||||
}
|
||||
27
patches/api/0036-Add-local-difficulty-api.patch
Normal file
27
patches/api/0036-Add-local-difficulty-api.patch
Normal file
@@ -0,0 +1,27 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: BillyGalbreath <blake.galbreath@gmail.com>
|
||||
Date: Sat, 9 Jul 2022 00:57:26 -0500
|
||||
Subject: [PATCH] Add local difficulty api
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java
|
||||
index ef32a937e6faf1e8a5d6b1207986715bae5a246c..24d39c8c449e0ea6175989295d24eee902baec17 100644
|
||||
--- a/src/main/java/org/bukkit/World.java
|
||||
+++ b/src/main/java/org/bukkit/World.java
|
||||
@@ -4209,6 +4209,16 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
|
||||
@Nullable
|
||||
public DragonBattle getEnderDragonBattle();
|
||||
|
||||
+ // Purpur start
|
||||
+ /**
|
||||
+ * Gets the local difficulty (based on inhabited time) at a location
|
||||
+ *
|
||||
+ * @param location Location to check
|
||||
+ * @return The local difficulty
|
||||
+ */
|
||||
+ public float getLocalDifficultyAt(@NotNull Location location);
|
||||
+ // Purpur end
|
||||
+
|
||||
/**
|
||||
* Get all {@link FeatureFlag} enabled in this world.
|
||||
*
|
||||
170
patches/api/0037-Remove-Timings.patch
Normal file
170
patches/api/0037-Remove-Timings.patch
Normal file
@@ -0,0 +1,170 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: BillyGalbreath <blake.galbreath@gmail.com>
|
||||
Date: Fri, 1 Jul 2022 04:03:26 -0500
|
||||
Subject: [PATCH] Remove Timings
|
||||
|
||||
|
||||
diff --git a/src/main/java/co/aikar/timings/TimedEventExecutor.java b/src/main/java/co/aikar/timings/TimedEventExecutor.java
|
||||
index 157617933a772451f6c073d97afaf305769b4d40..438a9c76381ea3f5b774e2232ff56c5dc6f82586 100644
|
||||
--- a/src/main/java/co/aikar/timings/TimedEventExecutor.java
|
||||
+++ b/src/main/java/co/aikar/timings/TimedEventExecutor.java
|
||||
@@ -80,9 +80,9 @@ public class TimedEventExecutor implements EventExecutor {
|
||||
executor.execute(listener, event);
|
||||
return;
|
||||
}
|
||||
- try (Timing ignored = timings.startTiming()){
|
||||
+ //try (Timing ignored = timings.startTiming()){ // Purpur
|
||||
executor.execute(listener, event);
|
||||
- }
|
||||
+ //} // Purpur
|
||||
}
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/co/aikar/timings/Timing.java b/src/main/java/co/aikar/timings/Timing.java
|
||||
index 4195efcfe044618052bb03dea34a4fb2ca7c44f0..8709c955bac34bc546a8e022cfac808bc61ee793 100644
|
||||
--- a/src/main/java/co/aikar/timings/Timing.java
|
||||
+++ b/src/main/java/co/aikar/timings/Timing.java
|
||||
@@ -39,6 +39,7 @@ public interface Timing extends AutoCloseable {
|
||||
* @return Timing
|
||||
*/
|
||||
@NotNull
|
||||
+ @io.papermc.paper.annotation.DoNotUse // Purpur
|
||||
Timing startTiming();
|
||||
|
||||
/**
|
||||
@@ -46,6 +47,7 @@ public interface Timing extends AutoCloseable {
|
||||
*
|
||||
* Will automatically be called when this Timing is used with try-with-resources
|
||||
*/
|
||||
+ @io.papermc.paper.annotation.DoNotUse // Purpur
|
||||
void stopTiming();
|
||||
|
||||
/**
|
||||
@@ -56,6 +58,7 @@ public interface Timing extends AutoCloseable {
|
||||
* @return Timing
|
||||
*/
|
||||
@NotNull
|
||||
+ @io.papermc.paper.annotation.DoNotUse // Purpur
|
||||
Timing startTimingIfSync();
|
||||
|
||||
/**
|
||||
@@ -65,12 +68,14 @@ public interface Timing extends AutoCloseable {
|
||||
*
|
||||
* But only if we are on the primary thread.
|
||||
*/
|
||||
+ @io.papermc.paper.annotation.DoNotUse // Purpur
|
||||
void stopTimingIfSync();
|
||||
|
||||
/**
|
||||
* @deprecated Doesn't do anything - Removed
|
||||
*/
|
||||
@Deprecated
|
||||
+ @io.papermc.paper.annotation.DoNotUse // Purpur
|
||||
void abort();
|
||||
|
||||
/**
|
||||
@@ -82,5 +87,6 @@ public interface Timing extends AutoCloseable {
|
||||
TimingHandler getTimingHandler();
|
||||
|
||||
@Override
|
||||
+ @io.papermc.paper.annotation.DoNotUse // Purpur
|
||||
void close();
|
||||
}
|
||||
diff --git a/src/main/java/co/aikar/timings/Timings.java b/src/main/java/co/aikar/timings/Timings.java
|
||||
index e81d0bc309de877ed2b5da6122f55c162e9b5f10..3d663104c8e3089abdb9dc4d7309f873ac182e98 100644
|
||||
--- a/src/main/java/co/aikar/timings/Timings.java
|
||||
+++ b/src/main/java/co/aikar/timings/Timings.java
|
||||
@@ -124,7 +124,7 @@ public final class Timings {
|
||||
@NotNull
|
||||
public static Timing ofStart(@NotNull Plugin plugin, @NotNull String name, @Nullable Timing groupHandler) {
|
||||
Timing timing = of(plugin, name, groupHandler);
|
||||
- timing.startTiming();
|
||||
+ //timing.startTiming(); // Purpur
|
||||
return timing;
|
||||
}
|
||||
|
||||
@@ -145,9 +145,11 @@ public final class Timings {
|
||||
* @param enabled Should timings be reported
|
||||
*/
|
||||
public static void setTimingsEnabled(boolean enabled) {
|
||||
- timingsEnabled = enabled;
|
||||
- warnAboutDeprecationOnEnable();
|
||||
- reset();
|
||||
+ // Purpur start - we don't do that here...
|
||||
+ timingsEnabled = false;
|
||||
+ //warnAboutDeprecationOnEnable();
|
||||
+ //reset();
|
||||
+ // Purpur end
|
||||
}
|
||||
|
||||
private static void warnAboutDeprecationOnEnable() {
|
||||
diff --git a/src/main/java/co/aikar/timings/TimingsCommand.java b/src/main/java/co/aikar/timings/TimingsCommand.java
|
||||
index 95d87c9dbf2b237787294dfbe7fed87a36e6dedf..9e165525c4c4c07c783ae2899e07c37ae49ec2de 100644
|
||||
--- a/src/main/java/co/aikar/timings/TimingsCommand.java
|
||||
+++ b/src/main/java/co/aikar/timings/TimingsCommand.java
|
||||
@@ -47,7 +47,7 @@ public class TimingsCommand extends BukkitCommand {
|
||||
public TimingsCommand(@NotNull String name) {
|
||||
super(name);
|
||||
this.description = "Manages Spigot Timings data to see performance of the server.";
|
||||
- this.usageMessage = "/timings <reset|report|on|off|verbon|verboff>";
|
||||
+ this.usageMessage = "/timings";// <reset|report|on|off|verbon|verboff>"; // Purpur
|
||||
this.setPermission("bukkit.command.timings");
|
||||
}
|
||||
|
||||
@@ -56,8 +56,14 @@ public class TimingsCommand extends BukkitCommand {
|
||||
if (!testPermission(sender)) {
|
||||
return true;
|
||||
}
|
||||
- if (false) {
|
||||
- sender.sendMessage(Timings.deprecationMessage());
|
||||
+ // Purpur start
|
||||
+ if (true) {
|
||||
+ net.kyori.adventure.text.minimessage.MiniMessage mm = net.kyori.adventure.text.minimessage.MiniMessage.miniMessage();
|
||||
+ sender.sendMessage(mm.deserialize("<gold>Purpur has removed timings to save your performance. Please use <click:suggest_command:'/spark'><grey>/spark</grey></click> instead"));
|
||||
+ sender.sendMessage(mm.deserialize("<gold>For more information, view its documentation at"));
|
||||
+ sender.sendMessage(mm.deserialize("<gold><click:open_url:'https://spark.lucko.me/docs/Command-Usage'>https://spark.lucko.me/docs/Command-Usage</click>"));
|
||||
+ return true;
|
||||
+ // Purpur end
|
||||
}
|
||||
if (args.length < 1) {
|
||||
sender.sendMessage(text("Usage: " + this.usageMessage, NamedTextColor.RED));
|
||||
@@ -117,7 +123,7 @@ public class TimingsCommand extends BukkitCommand {
|
||||
Preconditions.checkNotNull(args, "Arguments cannot be null");
|
||||
Preconditions.checkNotNull(alias, "Alias cannot be null");
|
||||
|
||||
- if (args.length == 1) {
|
||||
+ if (false && args.length == 1) { // Purpur
|
||||
return StringUtil.copyPartialMatches(args[0], TIMINGS_SUBCOMMANDS,
|
||||
new ArrayList<String>(TIMINGS_SUBCOMMANDS.size()));
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/command/SimpleCommandMap.java b/src/main/java/org/bukkit/command/SimpleCommandMap.java
|
||||
index a09b5458191eb5df4787859b72a37fa1fa2bffba..7740ad53796d08584bb0110f99af5639993e4d71 100644
|
||||
--- a/src/main/java/org/bukkit/command/SimpleCommandMap.java
|
||||
+++ b/src/main/java/org/bukkit/command/SimpleCommandMap.java
|
||||
@@ -173,10 +173,10 @@ public class SimpleCommandMap implements CommandMap {
|
||||
// Paper end
|
||||
|
||||
try {
|
||||
- try (co.aikar.timings.Timing ignored = target.timings.startTiming()) { // Paper - use try with resources
|
||||
+ //try (co.aikar.timings.Timing ignored = target.timings.startTiming()) { // Paper - use try with resources // Purpur
|
||||
// Note: we don't return the result of target.execute as thats success / failure, we return handled (true) or not handled (false)
|
||||
target.execute(sender, sentCommandLabel, parsedArgs); // Purpur
|
||||
- } // target.timings.stopTiming(); // Spigot // Paper
|
||||
+ //} // target.timings.stopTiming(); // Spigot // Paper // Purpur
|
||||
} catch (CommandException ex) {
|
||||
server.getPluginManager().callEvent(new com.destroystokyo.paper.event.server.ServerExceptionEvent(new com.destroystokyo.paper.exception.ServerCommandException(ex, target, sender, args))); // Paper
|
||||
//target.timings.stopTiming(); // Spigot // Paper
|
||||
diff --git a/src/main/java/org/spigotmc/CustomTimingsHandler.java b/src/main/java/org/spigotmc/CustomTimingsHandler.java
|
||||
index 12946bd55fcf7c40d39081779a7fa30049ee6165..9c2d605c50cbf9aefa56ec209df9f6cea1392e89 100644
|
||||
--- a/src/main/java/org/spigotmc/CustomTimingsHandler.java
|
||||
+++ b/src/main/java/org/spigotmc/CustomTimingsHandler.java
|
||||
@@ -61,7 +61,7 @@ public final class CustomTimingsHandler {
|
||||
handler = timing;
|
||||
}
|
||||
|
||||
- public void startTiming() { handler.startTiming(); }
|
||||
- public void stopTiming() { handler.stopTiming(); }
|
||||
+ public void startTiming() { /*handler.startTiming();*/ } // Purpur
|
||||
+ public void stopTiming() { /*handler.stopTiming();*/ } // Purpur
|
||||
|
||||
}
|
||||
178
patches/api/0038-Add-Bee-API.patch
Normal file
178
patches/api/0038-Add-Bee-API.patch
Normal file
@@ -0,0 +1,178 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: SageSphinx63920 <sage@sagesphinx63920.dev>
|
||||
Date: Mon, 25 Jul 2022 19:33:49 +0200
|
||||
Subject: [PATCH] Add Bee API
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/purpurmc/purpur/event/entity/BeeFoundFlowerEvent.java b/src/main/java/org/purpurmc/purpur/event/entity/BeeFoundFlowerEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..7f631a41abee4640a37339a7896ce96e61747735
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/purpurmc/purpur/event/entity/BeeFoundFlowerEvent.java
|
||||
@@ -0,0 +1,48 @@
|
||||
+package org.purpurmc.purpur.event.entity;
|
||||
+
|
||||
+import org.bukkit.Location;
|
||||
+import org.bukkit.entity.Bee;
|
||||
+import org.bukkit.event.HandlerList;
|
||||
+import org.bukkit.event.entity.EntityEvent;
|
||||
+import org.jetbrains.annotations.ApiStatus;
|
||||
+import org.jspecify.annotations.NullMarked;
|
||||
+import org.jspecify.annotations.Nullable;
|
||||
+
|
||||
+/**
|
||||
+ * Called when a bee targets a flower
|
||||
+ */
|
||||
+@NullMarked
|
||||
+public class BeeFoundFlowerEvent extends EntityEvent {
|
||||
+ private static final HandlerList handlers = new HandlerList();
|
||||
+ private final Location location;
|
||||
+
|
||||
+ @ApiStatus.Internal
|
||||
+ public BeeFoundFlowerEvent(Bee bee, @Nullable Location location) {
|
||||
+ super(bee);
|
||||
+ this.location = location;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public Bee getEntity() {
|
||||
+ return (Bee) super.getEntity();
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Returns the location of the flower that the bee targets
|
||||
+ *
|
||||
+ * @return The location of the flower
|
||||
+ */
|
||||
+ @Nullable
|
||||
+ public Location getLocation() {
|
||||
+ return location;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public HandlerList getHandlers() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+
|
||||
+ public static HandlerList getHandlerList() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/org/purpurmc/purpur/event/entity/BeeStartedPollinatingEvent.java b/src/main/java/org/purpurmc/purpur/event/entity/BeeStartedPollinatingEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..e260145d6dc556bbe9e3654296b965c4e393084d
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/purpurmc/purpur/event/entity/BeeStartedPollinatingEvent.java
|
||||
@@ -0,0 +1,46 @@
|
||||
+package org.purpurmc.purpur.event.entity;
|
||||
+
|
||||
+import org.bukkit.Location;
|
||||
+import org.bukkit.entity.Bee;
|
||||
+import org.bukkit.event.HandlerList;
|
||||
+import org.bukkit.event.entity.EntityEvent;
|
||||
+import org.jetbrains.annotations.ApiStatus;
|
||||
+import org.jspecify.annotations.NullMarked;
|
||||
+
|
||||
+/**
|
||||
+ * Called when a bee starts pollinating
|
||||
+ */
|
||||
+@NullMarked
|
||||
+public class BeeStartedPollinatingEvent extends EntityEvent {
|
||||
+ private static final HandlerList handlers = new HandlerList();
|
||||
+ private final Location location;
|
||||
+
|
||||
+ @ApiStatus.Internal
|
||||
+ public BeeStartedPollinatingEvent(Bee bee, Location location) {
|
||||
+ super(bee);
|
||||
+ this.location = location;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public Bee getEntity() {
|
||||
+ return (Bee) super.getEntity();
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Returns the location of the flower that the bee pollinates
|
||||
+ *
|
||||
+ * @return The location of the flower
|
||||
+ */
|
||||
+ public Location getLocation() {
|
||||
+ return this.location;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public HandlerList getHandlers() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+
|
||||
+ public static HandlerList getHandlerList() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/org/purpurmc/purpur/event/entity/BeeStopPollinatingEvent.java b/src/main/java/org/purpurmc/purpur/event/entity/BeeStopPollinatingEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..8b2b351d620c749cdf58d7e824b55cf55578fde6
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/purpurmc/purpur/event/entity/BeeStopPollinatingEvent.java
|
||||
@@ -0,0 +1,60 @@
|
||||
+package org.purpurmc.purpur.event.entity;
|
||||
+
|
||||
+import org.bukkit.Location;
|
||||
+import org.bukkit.entity.Bee;
|
||||
+import org.bukkit.event.HandlerList;
|
||||
+import org.bukkit.event.entity.EntityEvent;
|
||||
+import org.jetbrains.annotations.ApiStatus;
|
||||
+import org.jspecify.annotations.NullMarked;
|
||||
+import org.jspecify.annotations.Nullable;
|
||||
+
|
||||
+/**
|
||||
+ * Called when a bee stops pollinating
|
||||
+ */
|
||||
+@NullMarked
|
||||
+public class BeeStopPollinatingEvent extends EntityEvent {
|
||||
+ private static final HandlerList handlers = new HandlerList();
|
||||
+ private final Location location;
|
||||
+ private final boolean success;
|
||||
+
|
||||
+ @ApiStatus.Internal
|
||||
+ public BeeStopPollinatingEvent(Bee bee, @Nullable Location location, boolean success) {
|
||||
+ super(bee);
|
||||
+ this.location = location;
|
||||
+ this.success = success;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public Bee getEntity() {
|
||||
+ return (Bee) super.getEntity();
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Returns the location of the flower that the bee stopped pollinating
|
||||
+ *
|
||||
+ * @return The location of the flower
|
||||
+ */
|
||||
+ @Nullable
|
||||
+ public Location getLocation() {
|
||||
+ return location;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Returns whether the bee successfully pollinated the flower
|
||||
+ *
|
||||
+ * @return True if the pollination was successful
|
||||
+ */
|
||||
+ public boolean wasSuccessful() {
|
||||
+ return success;
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ @Override
|
||||
+ public HandlerList getHandlers() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+
|
||||
+ public static HandlerList getHandlerList() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+}
|
||||
341
patches/api/0039-Debug-Marker-API.patch
Normal file
341
patches/api/0039-Debug-Marker-API.patch
Normal file
@@ -0,0 +1,341 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: YouHaveTrouble <youhavetrouble@youhavetrouble.me>
|
||||
Date: Sat, 23 Jul 2022 14:40:17 +0200
|
||||
Subject: [PATCH] Debug Marker API
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
|
||||
index 676cddfc8ae317ed750701af06964a22a0c03e10..b3667b1699f6ec23697a65cd8c0cb18b07e6675f 100644
|
||||
--- a/src/main/java/org/bukkit/Bukkit.java
|
||||
+++ b/src/main/java/org/bukkit/Bukkit.java
|
||||
@@ -2907,5 +2907,89 @@ public final class Bukkit {
|
||||
public static void removeFuel(@NotNull Material material) {
|
||||
server.removeFuel(material);
|
||||
}
|
||||
+
|
||||
+ /**
|
||||
+ * Creates debug block highlight on specified block location and show it to all players on the server.
|
||||
+ * <p>
|
||||
+ * Clients may be inconsistent in displaying it.
|
||||
+ * @param location Location to highlight
|
||||
+ * @param duration Duration for highlight to show in milliseconds
|
||||
+ */
|
||||
+ public static void sendBlockHighlight(@NotNull Location location, int duration) {
|
||||
+ server.sendBlockHighlight(location, duration);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Creates debug block highlight on specified block location and show it to all players on the server.
|
||||
+ * <p>
|
||||
+ * Clients may be inconsistent in displaying it.
|
||||
+ * @param location Location to highlight
|
||||
+ * @param duration Duration for highlight to show in milliseconds
|
||||
+ * @param argb Color of the highlight. ARGB int. Will be ignored on some versions of vanilla client
|
||||
+ */
|
||||
+ public static void sendBlockHighlight(@NotNull Location location, int duration, int argb) {
|
||||
+ server.sendBlockHighlight(location, duration, argb);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Creates debug block highlight on specified block location and show it to all players on the server.
|
||||
+ * <p>
|
||||
+ * Clients may be inconsistent in displaying it.
|
||||
+ * @param location Location to highlight
|
||||
+ * @param duration Duration for highlight to show in milliseconds
|
||||
+ * @param text Text to show above the highlight
|
||||
+ */
|
||||
+ public static void sendBlockHighlight(@NotNull Location location, int duration, @NotNull String text) {
|
||||
+ server.sendBlockHighlight(location, duration, text);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Creates debug block highlight on specified block location and show it to all players on the server.
|
||||
+ * <p>
|
||||
+ * Clients may be inconsistent in displaying it.
|
||||
+ * @param location Location to highlight
|
||||
+ * @param duration Duration for highlight to show in milliseconds
|
||||
+ * @param text Text to show above the highlight
|
||||
+ * @param argb Color of the highlight. ARGB int. Will be ignored on some versions of vanilla client
|
||||
+ */
|
||||
+ public static void sendBlockHighlight(@NotNull Location location, int duration, @NotNull String text, int argb) {
|
||||
+ server.sendBlockHighlight(location, duration, text, argb);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Creates debug block highlight on specified block location and show it to all players on the server.
|
||||
+ * <p>
|
||||
+ * Clients may be inconsistent in displaying it.
|
||||
+ * @param location Location to highlight
|
||||
+ * @param duration Duration for highlight to show in milliseconds
|
||||
+ * @param color Color of the highlight. Will be ignored on some versions of vanilla client
|
||||
+ * @param transparency Transparency of the highlight
|
||||
+ * @throws IllegalArgumentException If transparency is outside 0-255 range
|
||||
+ */
|
||||
+ public static void sendBlockHighlight(@NotNull Location location, int duration, @NotNull org.bukkit.Color color, int transparency) {
|
||||
+ server.sendBlockHighlight(location, duration, color, transparency);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Creates debug block highlight on specified block location and show it to all players on the server.
|
||||
+ * <p>
|
||||
+ * Clients may be inconsistent in displaying it.
|
||||
+ * @param location Location to highlight
|
||||
+ * @param duration Duration for highlight to show in milliseconds
|
||||
+ * @param text Text to show above the highlight
|
||||
+ * @param color Color of the highlight. Will be ignored on some versions of vanilla client
|
||||
+ * @param transparency Transparency of the highlight
|
||||
+ * @throws IllegalArgumentException If transparency is outside 0-255 range
|
||||
+ */
|
||||
+ public static void sendBlockHighlight(@NotNull Location location, int duration, @NotNull String text, @NotNull org.bukkit.Color color, int transparency) {
|
||||
+ server.sendBlockHighlight(location, duration, text, color, transparency);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Clears all debug block highlights for all players on the server.
|
||||
+ */
|
||||
+ public static void clearBlockHighlights() {
|
||||
+ server.clearBlockHighlights();
|
||||
+ }
|
||||
// Purpur end
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
|
||||
index dd90bdfdf82073f87a9dfda92f743b6682d4a1b8..bda870841507e3ce728064e446cf92caa2d803a1 100644
|
||||
--- a/src/main/java/org/bukkit/Server.java
|
||||
+++ b/src/main/java/org/bukkit/Server.java
|
||||
@@ -2545,5 +2545,75 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
|
||||
* @param material The material that will no longer be a fuel
|
||||
*/
|
||||
public void removeFuel(@NotNull Material material);
|
||||
+
|
||||
+ /**
|
||||
+ * Creates debug block highlight on specified block location and show it to all players on the server.
|
||||
+ * <p>
|
||||
+ * Clients may be inconsistent in displaying it.
|
||||
+ * @param location Location to highlight
|
||||
+ * @param duration Duration for highlight to show in milliseconds
|
||||
+ */
|
||||
+ void sendBlockHighlight(@NotNull Location location, int duration);
|
||||
+
|
||||
+ /**
|
||||
+ * Creates debug block highlight on specified block location and show it to all players on the server.
|
||||
+ * <p>
|
||||
+ * Clients may be inconsistent in displaying it.
|
||||
+ * @param location Location to highlight
|
||||
+ * @param duration Duration for highlight to show in milliseconds
|
||||
+ * @param argb Color of the highlight. ARGB int. Will be ignored on some versions of vanilla client
|
||||
+ */
|
||||
+ void sendBlockHighlight(@NotNull Location location, int duration, int argb);
|
||||
+
|
||||
+ /**
|
||||
+ * Creates debug block highlight on specified block location and show it to all players on the server.
|
||||
+ * <p>
|
||||
+ * Clients may be inconsistent in displaying it.
|
||||
+ * @param location Location to highlight
|
||||
+ * @param duration Duration for highlight to show in milliseconds
|
||||
+ * @param text Text to show above the highlight
|
||||
+ */
|
||||
+ void sendBlockHighlight(@NotNull Location location, int duration, @NotNull String text);
|
||||
+
|
||||
+ /**
|
||||
+ * Creates debug block highlight on specified block location and show it to all players on the server.
|
||||
+ * <p>
|
||||
+ * Clients may be inconsistent in displaying it.
|
||||
+ * @param location Location to highlight
|
||||
+ * @param duration Duration for highlight to show in milliseconds
|
||||
+ * @param text Text to show above the highlight
|
||||
+ * @param argb Color of the highlight. ARGB int. Will be ignored on some versions of vanilla client
|
||||
+ */
|
||||
+ void sendBlockHighlight(@NotNull Location location, int duration, @NotNull String text, int argb);
|
||||
+
|
||||
+ /**
|
||||
+ * Creates debug block highlight on specified block location and show it to all players on the server.
|
||||
+ * <p>
|
||||
+ * Clients may be inconsistent in displaying it.
|
||||
+ * @param location Location to highlight
|
||||
+ * @param duration Duration for highlight to show in milliseconds
|
||||
+ * @param color Color of the highlight. Will be ignored on some versions of vanilla client
|
||||
+ * @param transparency Transparency of the highlight
|
||||
+ * @throws IllegalArgumentException If transparency is outside 0-255 range
|
||||
+ */
|
||||
+ void sendBlockHighlight(@NotNull Location location, int duration, @NotNull org.bukkit.Color color, int transparency);
|
||||
+
|
||||
+ /**
|
||||
+ * Creates debug block highlight on specified block location and show it to all players on the server.
|
||||
+ * <p>
|
||||
+ * Clients may be inconsistent in displaying it.
|
||||
+ * @param location Location to highlight
|
||||
+ * @param duration Duration for highlight to show in milliseconds
|
||||
+ * @param text Text to show above the highlight
|
||||
+ * @param color Color of the highlight. Will be ignored on some versions of vanilla client
|
||||
+ * @param transparency Transparency of the highlight
|
||||
+ * @throws IllegalArgumentException If transparency is outside 0-255 range
|
||||
+ */
|
||||
+ void sendBlockHighlight(@NotNull Location location, int duration, @NotNull String text, @NotNull org.bukkit.Color color, int transparency);
|
||||
+
|
||||
+ /**
|
||||
+ * Clears all debug block highlights for all players on the server.
|
||||
+ */
|
||||
+ void clearBlockHighlights();
|
||||
// Purpur end
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java
|
||||
index 24d39c8c449e0ea6175989295d24eee902baec17..36cf567973900d1e472616748926aecb9afcb42f 100644
|
||||
--- a/src/main/java/org/bukkit/World.java
|
||||
+++ b/src/main/java/org/bukkit/World.java
|
||||
@@ -4217,6 +4217,76 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
|
||||
* @return The local difficulty
|
||||
*/
|
||||
public float getLocalDifficultyAt(@NotNull Location location);
|
||||
+
|
||||
+ /**
|
||||
+ * Creates debug block highlight on specified block location and show it to all players on this world.
|
||||
+ * <p>
|
||||
+ * Clients may be inconsistent in displaying it.
|
||||
+ * @param location Location to highlight
|
||||
+ * @param duration Duration for highlight to show in milliseconds
|
||||
+ */
|
||||
+ void sendBlockHighlight(@NotNull Location location, int duration);
|
||||
+
|
||||
+ /**
|
||||
+ * Creates debug block highlight on specified block location and show it to all players on this world.
|
||||
+ * <p>
|
||||
+ * Clients may be inconsistent in displaying it.
|
||||
+ * @param location Location to highlight
|
||||
+ * @param duration Duration for highlight to show in milliseconds
|
||||
+ * @param argb Color of the highlight. ARGB int. Will be ignored on some versions of vanilla client
|
||||
+ */
|
||||
+ void sendBlockHighlight(@NotNull Location location, int duration, int argb);
|
||||
+
|
||||
+ /**
|
||||
+ * Creates debug block highlight on specified block location and show it to all players on this world.
|
||||
+ * <p>
|
||||
+ * Clients may be inconsistent in displaying it.
|
||||
+ * @param location Location to highlight
|
||||
+ * @param duration Duration for highlight to show in milliseconds
|
||||
+ * @param text Text to show above the highlight
|
||||
+ */
|
||||
+ void sendBlockHighlight(@NotNull Location location, int duration, @NotNull String text);
|
||||
+
|
||||
+ /**
|
||||
+ * Creates debug block highlight on specified block location and show it to all players on this world.
|
||||
+ * <p>
|
||||
+ * Clients may be inconsistent in displaying it.
|
||||
+ * @param location Location to highlight
|
||||
+ * @param duration Duration for highlight to show in milliseconds
|
||||
+ * @param text Text to show above the highlight
|
||||
+ * @param argb Color of the highlight. ARGB int. Will be ignored on some versions of vanilla client
|
||||
+ */
|
||||
+ void sendBlockHighlight(@NotNull Location location, int duration, @NotNull String text, int argb);
|
||||
+
|
||||
+ /**
|
||||
+ * Creates debug block highlight on specified block location and show it to all players on this world.
|
||||
+ * <p>
|
||||
+ * Clients may be inconsistent in displaying it.
|
||||
+ * @param location Location to highlight
|
||||
+ * @param duration Duration for highlight to show in milliseconds
|
||||
+ * @param color Color of the highlight. Will be ignored on some versions of vanilla client
|
||||
+ * @param transparency Transparency of the highlight
|
||||
+ * @throws IllegalArgumentException If transparency is outside 0-255 range
|
||||
+ */
|
||||
+ void sendBlockHighlight(@NotNull Location location, int duration, @NotNull org.bukkit.Color color, int transparency);
|
||||
+
|
||||
+ /**
|
||||
+ * Creates debug block highlight on specified block location and show it to all players on this world.
|
||||
+ * <p>
|
||||
+ * Clients may be inconsistent in displaying it.
|
||||
+ * @param location Location to highlight
|
||||
+ * @param duration Duration for highlight to show in milliseconds
|
||||
+ * @param text Text to show above the highlight
|
||||
+ * @param color Color of the highlight. Will be ignored on some versions of vanilla client
|
||||
+ * @param transparency Transparency of the highlight
|
||||
+ * @throws IllegalArgumentException If transparency is outside 0-255 range
|
||||
+ */
|
||||
+ void sendBlockHighlight(@NotNull Location location, int duration, @NotNull String text, @NotNull org.bukkit.Color color, int transparency);
|
||||
+
|
||||
+ /**
|
||||
+ * Clears all debug block highlights for all players on this world.
|
||||
+ */
|
||||
+ void clearBlockHighlights();
|
||||
// Purpur end
|
||||
|
||||
/**
|
||||
diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java
|
||||
index 5d449299f958cb747e62e9ccfc8ff6cc32236dcd..0b8f7c39ff90b57eb7104d3a0cf1c29ee551b522 100644
|
||||
--- a/src/main/java/org/bukkit/entity/Player.java
|
||||
+++ b/src/main/java/org/bukkit/entity/Player.java
|
||||
@@ -3939,5 +3939,75 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
|
||||
* @deprecated Use {@link #resetIdleDuration()} instead
|
||||
*/
|
||||
void resetIdleTimer();
|
||||
+
|
||||
+ /**
|
||||
+ * Creates debug block highlight on specified block location and show it to this player.
|
||||
+ * <p>
|
||||
+ * Clients may be inconsistent in displaying it.
|
||||
+ * @param location Location to highlight
|
||||
+ * @param duration Duration for highlight to show in milliseconds
|
||||
+ */
|
||||
+ void sendBlockHighlight(@NotNull Location location, int duration);
|
||||
+
|
||||
+ /**
|
||||
+ * Creates debug block highlight on specified block location and show it to this player.
|
||||
+ * <p>
|
||||
+ * Clients may be inconsistent in displaying it.
|
||||
+ * @param location Location to highlight
|
||||
+ * @param duration Duration for highlight to show in milliseconds
|
||||
+ * @param argb Color of the highlight. ARGB int. Will be ignored on some versions of vanilla client
|
||||
+ */
|
||||
+ void sendBlockHighlight(@NotNull Location location, int duration, int argb);
|
||||
+
|
||||
+ /**
|
||||
+ * Creates debug block highlight on specified block location and show it to this player.
|
||||
+ * <p>
|
||||
+ * Clients may be inconsistent in displaying it.
|
||||
+ * @param location Location to highlight
|
||||
+ * @param duration Duration for highlight to show in milliseconds
|
||||
+ * @param text Text to show above the highlight
|
||||
+ */
|
||||
+ void sendBlockHighlight(@NotNull Location location, int duration, @NotNull String text);
|
||||
+
|
||||
+ /**
|
||||
+ * Creates debug block highlight on specified block location and show it to this player.
|
||||
+ * <p>
|
||||
+ * Clients may be inconsistent in displaying it.
|
||||
+ * @param location Location to highlight
|
||||
+ * @param duration Duration for highlight to show in milliseconds
|
||||
+ * @param text Text to show above the highlight
|
||||
+ * @param argb Color of the highlight. ARGB int. Will be ignored on some versions of vanilla client
|
||||
+ */
|
||||
+ void sendBlockHighlight(@NotNull Location location, int duration, @NotNull String text, int argb);
|
||||
+
|
||||
+ /**
|
||||
+ * Creates debug block highlight on specified block location and show it to this player.
|
||||
+ * <p>
|
||||
+ * Clients may be inconsistent in displaying it.
|
||||
+ * @param location Location to highlight
|
||||
+ * @param duration Duration for highlight to show in milliseconds
|
||||
+ * @param color Color of the highlight. Will be ignored on some versions of vanilla client
|
||||
+ * @param transparency Transparency of the highlight
|
||||
+ * @throws IllegalArgumentException If transparency is outside 0-255 range
|
||||
+ */
|
||||
+ void sendBlockHighlight(@NotNull Location location, int duration, @NotNull org.bukkit.Color color, int transparency);
|
||||
+
|
||||
+ /**
|
||||
+ * Creates debug block highlight on specified block location and show it to this player.
|
||||
+ * <p>
|
||||
+ * Clients may be inconsistent in displaying it.
|
||||
+ * @param location Location to highlight
|
||||
+ * @param duration Duration for highlight to show in milliseconds
|
||||
+ * @param text Text to show above the highlight
|
||||
+ * @param color Color of the highlight. Will be ignored on some versions of vanilla client
|
||||
+ * @param transparency Transparency of the highlight
|
||||
+ * @throws IllegalArgumentException If transparency is outside 0-255 range
|
||||
+ */
|
||||
+ void sendBlockHighlight(@NotNull Location location, int duration, @NotNull String text, @NotNull org.bukkit.Color color, int transparency);
|
||||
+
|
||||
+ /**
|
||||
+ * Clears all debug block highlights
|
||||
+ */
|
||||
+ void clearBlockHighlights();
|
||||
// Purpur end
|
||||
}
|
||||
36
patches/api/0040-Add-death-screen-API.patch
Normal file
36
patches/api/0040-Add-death-screen-API.patch
Normal file
@@ -0,0 +1,36 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MelnCat <melncatuwu@gmail.com>
|
||||
Date: Fri, 23 Sep 2022 18:35:28 -0700
|
||||
Subject: [PATCH] Add death screen API
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java
|
||||
index 0b8f7c39ff90b57eb7104d3a0cf1c29ee551b522..a7f989121c493baff9d2b6910c39145a0e12477d 100644
|
||||
--- a/src/main/java/org/bukkit/entity/Player.java
|
||||
+++ b/src/main/java/org/bukkit/entity/Player.java
|
||||
@@ -4009,5 +4009,25 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
|
||||
* Clears all debug block highlights
|
||||
*/
|
||||
void clearBlockHighlights();
|
||||
+
|
||||
+ /**
|
||||
+ * Sends a player the death screen with a specified death message.
|
||||
+ *
|
||||
+ * @param message The death message to show the player
|
||||
+ */
|
||||
+ void sendDeathScreen(@NotNull net.kyori.adventure.text.Component message);
|
||||
+
|
||||
+ /**
|
||||
+ * Sends a player the death screen with a specified death message,
|
||||
+ * along with the entity that caused the death.
|
||||
+ *
|
||||
+ * @param message The death message to show the player
|
||||
+ * @param killer The entity that killed the player
|
||||
+ * @deprecated Use {@link #sendDeathScreen(net.kyori.adventure.text.Component)} instead, as 1.20 removed the killer ID from the packet.
|
||||
+ */
|
||||
+ @Deprecated(since = "1.20")
|
||||
+ default void sendDeathScreen(@NotNull net.kyori.adventure.text.Component message, @Nullable Entity killer) {
|
||||
+ sendDeathScreen(message);
|
||||
+ }
|
||||
// Purpur end
|
||||
}
|
||||
72
patches/api/0041-Language-API.patch
Normal file
72
patches/api/0041-Language-API.patch
Normal file
@@ -0,0 +1,72 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MelnCat <melncatuwu@gmail.com>
|
||||
Date: Sat, 1 Oct 2022 17:08:23 -0700
|
||||
Subject: [PATCH] Language API
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/purpurmc/purpur/language/Language.java b/src/main/java/org/purpurmc/purpur/language/Language.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..cbdad4cf09c170064a45644efdf7aa0b28608301
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/purpurmc/purpur/language/Language.java
|
||||
@@ -0,0 +1,60 @@
|
||||
+package org.purpurmc.purpur.language;
|
||||
+
|
||||
+import net.kyori.adventure.translation.Translatable;
|
||||
+import org.jspecify.annotations.NullMarked;
|
||||
+import org.jspecify.annotations.Nullable;
|
||||
+
|
||||
+/**
|
||||
+ * Represents a language that can translate translation keys
|
||||
+ */
|
||||
+@NullMarked
|
||||
+public abstract class Language {
|
||||
+ private static @Nullable Language language;
|
||||
+
|
||||
+ /**
|
||||
+ * Returns the default language of the server
|
||||
+ */
|
||||
+ @Nullable
|
||||
+ public static Language getLanguage() {
|
||||
+ return language;
|
||||
+ }
|
||||
+
|
||||
+ public static void setLanguage(Language language) {
|
||||
+ if (Language.language != null) {
|
||||
+ throw new UnsupportedOperationException("Cannot redefine singleton Language");
|
||||
+ }
|
||||
+ Language.language = language;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Checks if a certain translation key is translatable with this language
|
||||
+ * @param key The translation key
|
||||
+ * @return Whether this language can translate the key
|
||||
+ */
|
||||
+ abstract public boolean has(String key);
|
||||
+
|
||||
+ /**
|
||||
+ * Checks if a certain translation key is translatable with this language
|
||||
+ * @param key The translation key
|
||||
+ * @return Whether this language can translate the key
|
||||
+ */
|
||||
+ public boolean has(Translatable key) {
|
||||
+ return has(key.translationKey());
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Translates a translation key to this language
|
||||
+ * @param key The translation key
|
||||
+ * @return The translated key, or the translation key if it couldn't be translated
|
||||
+ */
|
||||
+ abstract public String getOrDefault(String key);
|
||||
+
|
||||
+ /**
|
||||
+ * Translates a translation key to this language
|
||||
+ * @param key The translation key
|
||||
+ * @return The translated key, or the translation key if it couldn't be translated
|
||||
+ */
|
||||
+ public String getOrDefault(Translatable key) {
|
||||
+ return getOrDefault(key.translationKey());
|
||||
+ }
|
||||
+}
|
||||
46
patches/api/0042-Add-log-suppression-for-LibraryLoader.patch
Normal file
46
patches/api/0042-Add-log-suppression-for-LibraryLoader.patch
Normal file
@@ -0,0 +1,46 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Krakenied <Krakenied1@gmail.com>
|
||||
Date: Fri, 14 Oct 2022 23:11:27 +0200
|
||||
Subject: [PATCH] Add log suppression for LibraryLoader
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
|
||||
index 301e82369603f3dd6e6c1bd380da4bacacd7ef6c..0c6ca7588fb3d6b6497ddf032fe75e5c6c9719e5 100644
|
||||
--- a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
|
||||
+++ b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
|
||||
@@ -55,6 +55,7 @@ public final class JavaPluginLoader implements PluginLoader {
|
||||
private final Pattern[] fileFilters = new Pattern[]{Pattern.compile("\\.jar$")};
|
||||
private final List<PluginClassLoader> loaders = new CopyOnWriteArrayList<PluginClassLoader>();
|
||||
private final LibraryLoader libraryLoader;
|
||||
+ public static boolean SuppressLibraryLoaderLogger = false; // Purpur
|
||||
|
||||
/**
|
||||
* This class was not meant to be constructed explicitly
|
||||
diff --git a/src/main/java/org/bukkit/plugin/java/LibraryLoader.java b/src/main/java/org/bukkit/plugin/java/LibraryLoader.java
|
||||
index c66252802c51174bc26f266cb5cdecdd856ff220..97f580fccd06a8db5f592a53c8b95a7a6159adac 100644
|
||||
--- a/src/main/java/org/bukkit/plugin/java/LibraryLoader.java
|
||||
+++ b/src/main/java/org/bukkit/plugin/java/LibraryLoader.java
|
||||
@@ -68,6 +68,7 @@ public class LibraryLoader
|
||||
@Override
|
||||
public void transferStarted(@NotNull TransferEvent event) throws TransferCancelledException
|
||||
{
|
||||
+ if (!JavaPluginLoader.SuppressLibraryLoaderLogger) // Purpur
|
||||
logger.log( Level.INFO, "Downloading {0}", event.getResource().getRepositoryUrl() + event.getResource().getResourceName() );
|
||||
}
|
||||
} );
|
||||
@@ -94,6 +95,7 @@ public class LibraryLoader
|
||||
{
|
||||
return null;
|
||||
}
|
||||
+ if (!JavaPluginLoader.SuppressLibraryLoaderLogger) // Purpur
|
||||
logger.log( Level.INFO, "[{0}] Loading {1} libraries... please wait", new Object[]
|
||||
{
|
||||
java.util.Objects.requireNonNullElseGet(desc.getPrefix(), desc::getName), desc.getLibraries().size() // Paper - use configured log prefix
|
||||
@@ -144,6 +146,7 @@ public class LibraryLoader
|
||||
}
|
||||
|
||||
jarFiles.add( url );
|
||||
+ if (!JavaPluginLoader.SuppressLibraryLoaderLogger) // Purpur
|
||||
logger.log( Level.INFO, "[{0}] Loaded library {1}", new Object[]
|
||||
{
|
||||
java.util.Objects.requireNonNullElseGet(desc.getPrefix(), desc::getName), file // Paper - use configured log prefix
|
||||
29
patches/api/0043-Fire-Immunity-API.patch
Normal file
29
patches/api/0043-Fire-Immunity-API.patch
Normal file
@@ -0,0 +1,29 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Racci <90304606+DaRacci@users.noreply.github.com>
|
||||
Date: Fri, 4 Feb 2022 16:09:47 +1100
|
||||
Subject: [PATCH] Fire Immunity API
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/entity/Entity.java b/src/main/java/org/bukkit/entity/Entity.java
|
||||
index 22713e97e7c7b643b80c07a88ae890d7c4304730..b7d53973ac4e829a03821d59e0b3a28d6f6a4373 100644
|
||||
--- a/src/main/java/org/bukkit/entity/Entity.java
|
||||
+++ b/src/main/java/org/bukkit/entity/Entity.java
|
||||
@@ -1209,5 +1209,18 @@ public interface Entity extends Metadatable, CommandSender, Nameable, Persistent
|
||||
* @return True if in daylight
|
||||
*/
|
||||
boolean isInDaylight();
|
||||
+
|
||||
+ /**
|
||||
+ * Checks if the entity is fire immune
|
||||
+ *
|
||||
+ * @return True if fire immune
|
||||
+ */
|
||||
+ boolean isImmuneToFire();
|
||||
+
|
||||
+ /**
|
||||
+ * Sets if the entity is fire immune
|
||||
+ * Set this to null to restore the entity type default
|
||||
+ */
|
||||
+ void setImmuneToFire(@Nullable Boolean fireImmune);
|
||||
// Purpur end
|
||||
}
|
||||
70
patches/api/0044-Added-goat-ram-event.patch
Normal file
70
patches/api/0044-Added-goat-ram-event.patch
Normal file
@@ -0,0 +1,70 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: SageSphinx63920 <sage@sagesphinx63920.dev>
|
||||
Date: Sat, 29 Oct 2022 00:06:05 +0200
|
||||
Subject: [PATCH] Added goat ram event
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/purpurmc/purpur/event/entity/GoatRamEntityEvent.java b/src/main/java/org/purpurmc/purpur/event/entity/GoatRamEntityEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..f0a7fe694db145294ff93d320382d1baecc68702
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/purpurmc/purpur/event/entity/GoatRamEntityEvent.java
|
||||
@@ -0,0 +1,58 @@
|
||||
+package org.purpurmc.purpur.event.entity;
|
||||
+
|
||||
+import org.bukkit.entity.Goat;
|
||||
+import org.bukkit.entity.LivingEntity;
|
||||
+import org.bukkit.event.Cancellable;
|
||||
+import org.bukkit.event.HandlerList;
|
||||
+import org.bukkit.event.entity.EntityEvent;
|
||||
+import org.jetbrains.annotations.ApiStatus;
|
||||
+import org.jspecify.annotations.NullMarked;
|
||||
+
|
||||
+/**
|
||||
+ * Called when a goat rams an entity
|
||||
+ */
|
||||
+@NullMarked
|
||||
+public class GoatRamEntityEvent extends EntityEvent implements Cancellable {
|
||||
+ private static final HandlerList handlers = new HandlerList();
|
||||
+ private final LivingEntity rammedEntity;
|
||||
+ private boolean cancelled;
|
||||
+
|
||||
+ @ApiStatus.Internal
|
||||
+ public GoatRamEntityEvent(Goat goat, LivingEntity rammedEntity) {
|
||||
+ super(goat);
|
||||
+ this.rammedEntity = rammedEntity;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Returns the entity that was rammed by the goat
|
||||
+ *
|
||||
+ * @return The rammed entity
|
||||
+ */
|
||||
+ public LivingEntity getRammedEntity() {
|
||||
+ return this.rammedEntity;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public Goat getEntity() {
|
||||
+ return (Goat) super.getEntity();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public HandlerList getHandlers() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+
|
||||
+ public static HandlerList getHandlerList() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isCancelled() {
|
||||
+ return this.cancelled;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setCancelled(boolean cancel) {
|
||||
+ this.cancelled = cancel;
|
||||
+ }
|
||||
+}
|
||||
140
patches/api/0045-Add-PreExplodeEvents.patch
Normal file
140
patches/api/0045-Add-PreExplodeEvents.patch
Normal file
@@ -0,0 +1,140 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: SageSphinx63920 <sage@sagesphinx63920.dev>
|
||||
Date: Mon, 26 Dec 2022 23:40:13 +0100
|
||||
Subject: [PATCH] Add PreExplodeEvents
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/purpurmc/purpur/event/PreBlockExplodeEvent.java b/src/main/java/org/purpurmc/purpur/event/PreBlockExplodeEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..4b4d32c58224e1208f14024ca214078a37550bb5
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/purpurmc/purpur/event/PreBlockExplodeEvent.java
|
||||
@@ -0,0 +1,56 @@
|
||||
+package org.purpurmc.purpur.event;
|
||||
+
|
||||
+import org.bukkit.ExplosionResult;
|
||||
+import org.bukkit.block.Block;
|
||||
+import org.bukkit.block.BlockState;
|
||||
+import org.bukkit.event.Cancellable;
|
||||
+import org.bukkit.event.HandlerList;
|
||||
+import org.bukkit.event.block.BlockExplodeEvent;
|
||||
+import org.jetbrains.annotations.ApiStatus;
|
||||
+import java.util.Collections;
|
||||
+import org.jspecify.annotations.NullMarked;
|
||||
+
|
||||
+/**
|
||||
+ * Called before a block's explosion is processed
|
||||
+ */
|
||||
+@NullMarked
|
||||
+public class PreBlockExplodeEvent extends BlockExplodeEvent implements Cancellable {
|
||||
+ private static final HandlerList handlers = new HandlerList();
|
||||
+ private boolean cancelled;
|
||||
+ private final float yield;
|
||||
+
|
||||
+ @ApiStatus.Internal
|
||||
+ public PreBlockExplodeEvent(final Block what, final float yield, BlockState explodedBlockState, ExplosionResult result) {
|
||||
+ super(what, explodedBlockState, Collections.emptyList(), yield, result);
|
||||
+ this.yield = yield;
|
||||
+ this.cancelled = false;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Returns the percentage of blocks to drop from this explosion
|
||||
+ *
|
||||
+ * @return The yield.
|
||||
+ */
|
||||
+ public float getYield() {
|
||||
+ return yield;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isCancelled() {
|
||||
+ return this.cancelled;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setCancelled(boolean cancel) {
|
||||
+ this.cancelled = cancel;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public HandlerList getHandlers() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+
|
||||
+ public static HandlerList getHandlerList() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/org/purpurmc/purpur/event/entity/PreEntityExplodeEvent.java b/src/main/java/org/purpurmc/purpur/event/entity/PreEntityExplodeEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..d56fb066455007cc710f7ba34ba722af6e89bc1d
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/purpurmc/purpur/event/entity/PreEntityExplodeEvent.java
|
||||
@@ -0,0 +1,66 @@
|
||||
+package org.purpurmc.purpur.event.entity;
|
||||
+
|
||||
+import org.bukkit.ExplosionResult;
|
||||
+import org.bukkit.Location;
|
||||
+import org.bukkit.event.Cancellable;
|
||||
+import org.bukkit.event.HandlerList;
|
||||
+import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
+import org.jetbrains.annotations.ApiStatus;
|
||||
+import java.util.Collections;
|
||||
+import org.jspecify.annotations.NullMarked;
|
||||
+
|
||||
+/**
|
||||
+ * Called before an entity's explosion is processed
|
||||
+ */
|
||||
+@NullMarked
|
||||
+public class PreEntityExplodeEvent extends EntityExplodeEvent implements Cancellable {
|
||||
+ private static final HandlerList handlers = new HandlerList();
|
||||
+ private boolean cancelled;
|
||||
+ private final float yield;
|
||||
+ private final Location location;
|
||||
+
|
||||
+ @ApiStatus.Internal
|
||||
+ public PreEntityExplodeEvent(org.bukkit.entity.Entity what, final Location location, final float yield, ExplosionResult result) {
|
||||
+ super(what, location, Collections.emptyList(), yield, result);
|
||||
+ this.cancelled = false;
|
||||
+ this.yield = yield;
|
||||
+ this.location = location;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Returns the percentage of blocks to drop from this explosion
|
||||
+ *
|
||||
+ * @return The yield.
|
||||
+ */
|
||||
+ public float getYield() {
|
||||
+ return yield;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Returns the location where the explosion happened.
|
||||
+ *
|
||||
+ * @return The location of the explosion
|
||||
+ */
|
||||
+ public Location getLocation() {
|
||||
+ return location;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isCancelled() {
|
||||
+ return this.cancelled;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setCancelled(boolean cancel) {
|
||||
+ this.cancelled = cancel;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public HandlerList getHandlers() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+
|
||||
+ public static HandlerList getHandlerList() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+}
|
||||
93
patches/api/0046-Stored-Bee-API.patch
Normal file
93
patches/api/0046-Stored-Bee-API.patch
Normal file
@@ -0,0 +1,93 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: EOT3000 <egor.tolstenkov@outlook.com>
|
||||
Date: Sat, 10 Jun 2023 20:27:14 -0400
|
||||
Subject: [PATCH] Stored Bee API
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/block/EntityBlockStorage.java b/src/main/java/org/bukkit/block/EntityBlockStorage.java
|
||||
index 739911cda33b373f99df627a3a378b37d7d461aa..51e78c22cd021722b963fe31d1d9175d141add1a 100644
|
||||
--- a/src/main/java/org/bukkit/block/EntityBlockStorage.java
|
||||
+++ b/src/main/java/org/bukkit/block/EntityBlockStorage.java
|
||||
@@ -47,6 +47,24 @@ public interface EntityBlockStorage<T extends Entity> extends TileState {
|
||||
@NotNull
|
||||
List<T> releaseEntities();
|
||||
|
||||
+ // Purpur start
|
||||
+ /**
|
||||
+ * Releases a stored entity, and returns the entity in the world.
|
||||
+ *
|
||||
+ * @param entity Entity to release
|
||||
+ * @return The entity which was released, or null if the stored entity is not in the hive
|
||||
+ */
|
||||
+ @org.jetbrains.annotations.Nullable
|
||||
+ T releaseEntity(@NotNull org.purpurmc.purpur.entity.StoredEntity<T> entity);
|
||||
+
|
||||
+ /**
|
||||
+ * Gets all the entities currently stored in the block.
|
||||
+ *
|
||||
+ * @return List of all entities which are stored in the block
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ List<org.purpurmc.purpur.entity.StoredEntity<T>> getEntities();
|
||||
+ //Purpur end
|
||||
/**
|
||||
* Add an entity to the block.
|
||||
*
|
||||
diff --git a/src/main/java/org/purpurmc/purpur/entity/StoredEntity.java b/src/main/java/org/purpurmc/purpur/entity/StoredEntity.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..29540d55532197d2381a52ea9222b5785d224ef8
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/purpurmc/purpur/entity/StoredEntity.java
|
||||
@@ -0,0 +1,52 @@
|
||||
+package org.purpurmc.purpur.entity;
|
||||
+
|
||||
+import org.bukkit.Nameable;
|
||||
+import org.bukkit.block.EntityBlockStorage;
|
||||
+import org.bukkit.entity.Entity;
|
||||
+import org.bukkit.entity.EntityType;
|
||||
+import org.bukkit.persistence.PersistentDataHolder;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import org.jetbrains.annotations.Nullable;
|
||||
+
|
||||
+/**
|
||||
+ * Represents an entity stored in a block
|
||||
+ *
|
||||
+ * @see org.bukkit.block.EntityBlockStorage
|
||||
+ */
|
||||
+public interface StoredEntity<T extends Entity> extends PersistentDataHolder, Nameable {
|
||||
+ /**
|
||||
+ * Checks if this entity has been released yet
|
||||
+ *
|
||||
+ * @return if this entity has been released
|
||||
+ */
|
||||
+ boolean hasBeenReleased();
|
||||
+
|
||||
+ /**
|
||||
+ * Releases the entity from its stored block
|
||||
+ *
|
||||
+ * @return the released entity, or null if unsuccessful (including if this entity has already been released)
|
||||
+ */
|
||||
+ @Nullable
|
||||
+ T release();
|
||||
+
|
||||
+ /**
|
||||
+ * Returns the block in which this entity is stored
|
||||
+ *
|
||||
+ * @return the EntityBlockStorage in which this entity is stored, or null if it has been released
|
||||
+ */
|
||||
+ @Nullable
|
||||
+ EntityBlockStorage<T> getBlockStorage();
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the entity type of this stored entity
|
||||
+ *
|
||||
+ * @return the type of entity this stored entity represents
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ EntityType getType();
|
||||
+
|
||||
+ /**
|
||||
+ * Writes data to the block entity snapshot. {@link EntityBlockStorage#update()} must be run in order to update the block in game.
|
||||
+ */
|
||||
+ void update();
|
||||
+}
|
||||
23
patches/api/0047-Explorer-Map-API.patch
Normal file
23
patches/api/0047-Explorer-Map-API.patch
Normal file
@@ -0,0 +1,23 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: William Blake Galbreath <blake.galbreath@gmail.com>
|
||||
Date: Wed, 5 Jul 2023 12:48:08 -0500
|
||||
Subject: [PATCH] Explorer Map API
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/map/MapRenderer.java b/src/main/java/org/bukkit/map/MapRenderer.java
|
||||
index cb7040876a99a5a7e49b81684ef0f3b79584c376..22d8f31b1b8a5dbb5ab3275068642937c097abfe 100644
|
||||
--- a/src/main/java/org/bukkit/map/MapRenderer.java
|
||||
+++ b/src/main/java/org/bukkit/map/MapRenderer.java
|
||||
@@ -54,4 +54,12 @@ public abstract class MapRenderer {
|
||||
*/
|
||||
public abstract void render(@NotNull MapView map, @NotNull MapCanvas canvas, @NotNull Player player);
|
||||
|
||||
+ // Purpur - start
|
||||
+ /**
|
||||
+ * Check if this is an explorer (aka treasure) map.
|
||||
+ *
|
||||
+ * @return True if explorer map
|
||||
+ */
|
||||
+ public abstract boolean isExplorerMap();
|
||||
+ // Purpur - end
|
||||
}
|
||||
20
patches/api/0048-Stonecutter-damage.patch
Normal file
20
patches/api/0048-Stonecutter-damage.patch
Normal file
@@ -0,0 +1,20 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: granny <contact@granny.dev>
|
||||
Date: Sun, 11 Feb 2024 23:07:47 -0800
|
||||
Subject: [PATCH] Stonecutter damage
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/event/entity/EntityDamageEvent.java b/src/main/java/org/bukkit/event/entity/EntityDamageEvent.java
|
||||
index ef5b2a0f18c1c126db0b0c4a4d2a57483680665a..e6c8ffc2583af754eaedc55160ef45c61c22e213 100644
|
||||
--- a/src/main/java/org/bukkit/event/entity/EntityDamageEvent.java
|
||||
+++ b/src/main/java/org/bukkit/event/entity/EntityDamageEvent.java
|
||||
@@ -307,7 +307,8 @@ public class EntityDamageEvent extends EntityEvent implements Cancellable {
|
||||
WORLD_BORDER,
|
||||
/**
|
||||
* Damage caused when an entity contacts a block such as a Cactus,
|
||||
- * Dripstone (Stalagmite) or Berry Bush.
|
||||
+ * Dripstone (Stalagmite) or Berry Bush. (Stonecutters too if you
|
||||
+ * have the Stonecutter damage Purpur feature enabled)
|
||||
* <p>
|
||||
* Damage: variable
|
||||
*/
|
||||
Reference in New Issue
Block a user