mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-18 22:03:51 -07:00
moaaaaaaaar patches
This commit is contained in:
@@ -1,26 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Mon, 6 Jul 2020 12:44:23 -0700
|
||||
Subject: [PATCH] Add Block#isValidTool
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/block/Block.java b/src/main/java/org/bukkit/block/Block.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/block/Block.java
|
||||
+++ b/src/main/java/org/bukkit/block/Block.java
|
||||
@@ -0,0 +0,0 @@ public interface Block extends Metadatable, net.kyori.adventure.translation.Tran
|
||||
public static int getBlockKeyZ(long packed) {
|
||||
return (int) ((packed << 10) >> 37);
|
||||
}
|
||||
+
|
||||
+ /**
|
||||
+ * Checks if the itemstack is a valid tool to
|
||||
+ * break the block with
|
||||
+ *
|
||||
+ * @param itemStack The (tool) itemstack
|
||||
+ * @return whether the block will drop items
|
||||
+ */
|
||||
+ boolean isValidTool(@NotNull ItemStack itemStack);
|
||||
// Paper End
|
||||
|
||||
/**
|
@@ -1,69 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Thonk <30448663+ExcessiveAmountsOfZombies@users.noreply.github.com>
|
||||
Date: Wed, 6 Jan 2021 12:05:29 -0800
|
||||
Subject: [PATCH] Add recipe to cook events
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/event/block/BlockCookEvent.java b/src/main/java/org/bukkit/event/block/BlockCookEvent.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/event/block/BlockCookEvent.java
|
||||
+++ b/src/main/java/org/bukkit/event/block/BlockCookEvent.java
|
||||
@@ -0,0 +0,0 @@ public class BlockCookEvent extends BlockEvent implements Cancellable {
|
||||
private final ItemStack source;
|
||||
private ItemStack result;
|
||||
private boolean cancelled;
|
||||
+ private final org.bukkit.inventory.CookingRecipe<?> recipe; // Paper
|
||||
|
||||
+ @Deprecated // Paper
|
||||
public BlockCookEvent(@NotNull final Block block, @NotNull final ItemStack source, @NotNull final ItemStack result) {
|
||||
+ // Paper start
|
||||
+ this(block, source, result, null);
|
||||
+ }
|
||||
+
|
||||
+ public BlockCookEvent(@NotNull final Block block, @NotNull final ItemStack source, @NotNull final ItemStack result, @org.jetbrains.annotations.Nullable org.bukkit.inventory.CookingRecipe<?> recipe) {
|
||||
+ // Paper end
|
||||
super(block);
|
||||
this.source = source;
|
||||
this.result = result;
|
||||
this.cancelled = false;
|
||||
+ this.recipe = recipe; // Paper
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -0,0 +0,0 @@ public class BlockCookEvent extends BlockEvent implements Cancellable {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ /**
|
||||
+ * Gets the cooking recipe associated with this event.
|
||||
+ *
|
||||
+ * @return the recipe
|
||||
+ */
|
||||
+ @org.jetbrains.annotations.Nullable
|
||||
+ public org.bukkit.inventory.CookingRecipe<?> getRecipe() {
|
||||
+ return recipe;
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
@NotNull
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
diff --git a/src/main/java/org/bukkit/event/inventory/FurnaceSmeltEvent.java b/src/main/java/org/bukkit/event/inventory/FurnaceSmeltEvent.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/event/inventory/FurnaceSmeltEvent.java
|
||||
+++ b/src/main/java/org/bukkit/event/inventory/FurnaceSmeltEvent.java
|
||||
@@ -0,0 +0,0 @@ import org.jetbrains.annotations.NotNull;
|
||||
*/
|
||||
public class FurnaceSmeltEvent extends BlockCookEvent {
|
||||
|
||||
+ @Deprecated // Paper
|
||||
public FurnaceSmeltEvent(@NotNull final Block furnace, @NotNull final ItemStack source, @NotNull final ItemStack result) {
|
||||
super(furnace, source, result);
|
||||
}
|
||||
+ // Paper start
|
||||
+ public FurnaceSmeltEvent(@NotNull final Block furnace, @NotNull final ItemStack source, @NotNull final ItemStack result, @org.jetbrains.annotations.Nullable org.bukkit.inventory.CookingRecipe<?> recipe) {
|
||||
+ super(furnace, source, result, recipe);
|
||||
+ }
|
||||
+ // Paper end
|
||||
}
|
@@ -1,308 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Mon, 4 Jan 2021 22:40:26 -0800
|
||||
Subject: [PATCH] Add worldborder events
|
||||
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/event/world/border/WorldBorderBoundsChangeEvent.java b/src/main/java/io/papermc/paper/event/world/border/WorldBorderBoundsChangeEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/event/world/border/WorldBorderBoundsChangeEvent.java
|
||||
@@ -0,0 +0,0 @@
|
||||
+package io.papermc.paper.event.world.border;
|
||||
+
|
||||
+import org.bukkit.World;
|
||||
+import org.bukkit.WorldBorder;
|
||||
+import org.bukkit.event.Cancellable;
|
||||
+import org.bukkit.event.HandlerList;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+/**
|
||||
+ * Called when a world border changes its bounds, either over time, or instantly.
|
||||
+ */
|
||||
+public class WorldBorderBoundsChangeEvent extends WorldBorderEvent implements Cancellable {
|
||||
+
|
||||
+ private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
+
|
||||
+ private Type type;
|
||||
+ private final double oldSize;
|
||||
+ private double newSize;
|
||||
+ private long duration;
|
||||
+ private boolean cancelled;
|
||||
+
|
||||
+ public WorldBorderBoundsChangeEvent(@NotNull World world, @NotNull WorldBorder worldBorder, @NotNull Type type, double oldSize, double newSize, long duration) {
|
||||
+ super(world, worldBorder);
|
||||
+ this.type = type;
|
||||
+ this.oldSize = oldSize;
|
||||
+ this.newSize = newSize;
|
||||
+ this.duration = duration;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets if this change is an instant change or over-time change.
|
||||
+ *
|
||||
+ * @return the change type
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public Type getType() {
|
||||
+ return type;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the old size or the world border.
|
||||
+ *
|
||||
+ * @return the old size
|
||||
+ */
|
||||
+ public double getOldSize() {
|
||||
+ return oldSize;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the new size of the world border.
|
||||
+ *
|
||||
+ * @return the new size
|
||||
+ */
|
||||
+ public double getNewSize() {
|
||||
+ return newSize;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the new size of the world border.
|
||||
+ *
|
||||
+ * @param newSize the new size
|
||||
+ */
|
||||
+ public void setNewSize(double newSize) {
|
||||
+ // PAIL: TODO: Magic Values
|
||||
+ this.newSize = Math.min(6.0E7D, Math.max(1.0D, newSize));
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the time in milliseconds for the change. Will be 0 if instant.
|
||||
+ *
|
||||
+ * @return the time in milliseconds for the change
|
||||
+ */
|
||||
+ public long getDuration() {
|
||||
+ return duration;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the time in milliseconds for the change. Will change {@link #getType()} to return
|
||||
+ * {@link Type#STARTED_MOVE}.
|
||||
+ *
|
||||
+ * @param duration the time in milliseconds for the change
|
||||
+ */
|
||||
+ public void setDuration(long duration) {
|
||||
+ // PAIL: TODO: Magic Values
|
||||
+ this.duration = Math.min(9223372036854775L, Math.max(0L, duration));
|
||||
+ if (duration >= 0 && type == Type.INSTANT_MOVE) type = Type.STARTED_MOVE;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isCancelled() {
|
||||
+ return cancelled;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setCancelled(boolean cancel) {
|
||||
+ this.cancelled = cancel;
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ @Override
|
||||
+ public HandlerList getHandlers() {
|
||||
+ return HANDLER_LIST;
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ public static HandlerList getHandlerList() {
|
||||
+ return HANDLER_LIST;
|
||||
+ }
|
||||
+
|
||||
+ public enum Type {
|
||||
+ STARTED_MOVE,
|
||||
+ INSTANT_MOVE
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/event/world/border/WorldBorderBoundsChangeFinishEvent.java b/src/main/java/io/papermc/paper/event/world/border/WorldBorderBoundsChangeFinishEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/event/world/border/WorldBorderBoundsChangeFinishEvent.java
|
||||
@@ -0,0 +0,0 @@
|
||||
+package io.papermc.paper.event.world.border;
|
||||
+
|
||||
+import org.bukkit.World;
|
||||
+import org.bukkit.WorldBorder;
|
||||
+import org.bukkit.event.HandlerList;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+/**
|
||||
+ * Called when a moving world border has finished it's move.
|
||||
+ */
|
||||
+public class WorldBorderBoundsChangeFinishEvent extends WorldBorderEvent {
|
||||
+
|
||||
+ private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
+
|
||||
+ private final double oldSize;
|
||||
+ private final double newSize;
|
||||
+ private final double duration;
|
||||
+
|
||||
+ public WorldBorderBoundsChangeFinishEvent(@NotNull World world, @NotNull WorldBorder worldBorder, double oldSize, double newSize, double duration) {
|
||||
+ super(world, worldBorder);
|
||||
+ this.oldSize = oldSize;
|
||||
+ this.newSize = newSize;
|
||||
+ this.duration = duration;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the old size of the worldborder.
|
||||
+ *
|
||||
+ * @return the old size
|
||||
+ */
|
||||
+ public double getOldSize() {
|
||||
+ return oldSize;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the new size of the worldborder.
|
||||
+ *
|
||||
+ * @return the new size
|
||||
+ */
|
||||
+ public double getNewSize() {
|
||||
+ return newSize;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the duration this worldborder took to make the change.
|
||||
+ * <p>
|
||||
+ * Can be 0 if handlers for {@link io.papermc.paper.event.world.border.WorldBorderCenterChangeEvent} set the duration to 0.
|
||||
+ *
|
||||
+ * @return the duration of the transition
|
||||
+ */
|
||||
+ public double getDuration() {
|
||||
+ return duration;
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ @Override
|
||||
+ public HandlerList getHandlers() {
|
||||
+ return HANDLER_LIST;
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ public static HandlerList getHandlerList() {
|
||||
+ return HANDLER_LIST;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/event/world/border/WorldBorderCenterChangeEvent.java b/src/main/java/io/papermc/paper/event/world/border/WorldBorderCenterChangeEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/event/world/border/WorldBorderCenterChangeEvent.java
|
||||
@@ -0,0 +0,0 @@
|
||||
+package io.papermc.paper.event.world.border;
|
||||
+
|
||||
+import org.bukkit.Location;
|
||||
+import org.bukkit.World;
|
||||
+import org.bukkit.WorldBorder;
|
||||
+import org.bukkit.event.Cancellable;
|
||||
+import org.bukkit.event.HandlerList;
|
||||
+import org.bukkit.event.world.WorldEvent;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+/**
|
||||
+ * Called when a world border's center is changed.
|
||||
+ */
|
||||
+public class WorldBorderCenterChangeEvent extends WorldBorderEvent implements Cancellable {
|
||||
+
|
||||
+ private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
+
|
||||
+ private final Location oldCenter;
|
||||
+ private Location newCenter;
|
||||
+ private boolean cancelled;
|
||||
+
|
||||
+ public WorldBorderCenterChangeEvent(@NotNull World world, @NotNull WorldBorder worldBorder, @NotNull Location oldCenter, @NotNull Location newCenter) {
|
||||
+ super(world, worldBorder);
|
||||
+ this.oldCenter = oldCenter;
|
||||
+ this.newCenter = newCenter;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the original center location of the world border.
|
||||
+ *
|
||||
+ * @return the old center
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public Location getOldCenter() {
|
||||
+ return oldCenter;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the new center location for the world border.
|
||||
+ *
|
||||
+ * @return the new center
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public Location getNewCenter() {
|
||||
+ return newCenter;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the new center location for the world border. Y coordinate is ignored.
|
||||
+ *
|
||||
+ * @param newCenter the new center
|
||||
+ */
|
||||
+ public void setNewCenter(@NotNull Location newCenter) {
|
||||
+ this.newCenter = newCenter;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isCancelled() {
|
||||
+ return cancelled;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setCancelled(boolean cancel) {
|
||||
+ this.cancelled = cancel;
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ @Override
|
||||
+ public HandlerList getHandlers() {
|
||||
+ return HANDLER_LIST;
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ public static HandlerList getHandlerList() {
|
||||
+ return HANDLER_LIST;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/io/papermc/paper/event/world/border/WorldBorderEvent.java b/src/main/java/io/papermc/paper/event/world/border/WorldBorderEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/event/world/border/WorldBorderEvent.java
|
||||
@@ -0,0 +0,0 @@
|
||||
+package io.papermc.paper.event.world.border;
|
||||
+
|
||||
+import org.bukkit.World;
|
||||
+import org.bukkit.WorldBorder;
|
||||
+import org.bukkit.event.Cancellable;
|
||||
+import org.bukkit.event.world.WorldEvent;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+public abstract class WorldBorderEvent extends WorldEvent {
|
||||
+
|
||||
+ private final WorldBorder worldBorder;
|
||||
+
|
||||
+ public WorldBorderEvent(@NotNull World world, @NotNull WorldBorder worldBorder) {
|
||||
+ super(world);
|
||||
+ this.worldBorder = worldBorder;
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ public WorldBorder getWorldBorder() {
|
||||
+ return worldBorder;
|
||||
+ }
|
||||
+}
|
@@ -1,38 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
|
||||
Date: Tue, 2 Mar 2021 15:24:58 -0800
|
||||
Subject: [PATCH] Cache the result of Material#isBlock
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/Material.java b/src/main/java/org/bukkit/Material.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/Material.java
|
||||
+++ b/src/main/java/org/bukkit/Material.java
|
||||
@@ -0,0 +0,0 @@ public enum Material implements Keyed, net.kyori.adventure.translation.Translata
|
||||
public final Class<?> data;
|
||||
private final boolean legacy;
|
||||
private final NamespacedKey key;
|
||||
+ private boolean isBlock; // Paper
|
||||
|
||||
private Material(final int id) {
|
||||
this(id, 64);
|
||||
@@ -0,0 +0,0 @@ public enum Material implements Keyed, net.kyori.adventure.translation.Translata
|
||||
* @return true if this material is a block
|
||||
*/
|
||||
public boolean isBlock() {
|
||||
+ // Paper start - cache isBlock
|
||||
+ return this.isBlock;
|
||||
+ }
|
||||
+ private boolean isBlock0() {
|
||||
+ // Paper end
|
||||
switch (this) {
|
||||
//<editor-fold defaultstate="collapsed" desc="isBlock">
|
||||
case ACACIA_BUTTON:
|
||||
@@ -0,0 +0,0 @@ public enum Material implements Keyed, net.kyori.adventure.translation.Translata
|
||||
static {
|
||||
for (Material material : values()) {
|
||||
BY_NAME.put(material.name(), material);
|
||||
+ material.isBlock = material.isBlock0(); // Paper
|
||||
}
|
||||
}
|
||||
|
@@ -1,164 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Wed, 6 Jan 2021 00:34:10 -0800
|
||||
Subject: [PATCH] Implement Keyed on World
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/Bukkit.java
|
||||
+++ b/src/main/java/org/bukkit/Bukkit.java
|
||||
@@ -0,0 +0,0 @@ public final class Bukkit {
|
||||
public static World getWorld(@NotNull UUID uid) {
|
||||
return server.getWorld(uid);
|
||||
}
|
||||
+ // Paper start
|
||||
+ /**
|
||||
+ * Gets the world from the given NamespacedKey
|
||||
+ *
|
||||
+ * @param worldKey the NamespacedKey of the world to retrieve
|
||||
+ * @return a world with the given NamespacedKey, or null if none exists
|
||||
+ */
|
||||
+ @Nullable
|
||||
+ public static World getWorld(@NotNull NamespacedKey worldKey) {
|
||||
+ return server.getWorld(worldKey);
|
||||
+ }
|
||||
+ // Paper end
|
||||
|
||||
/**
|
||||
* Gets the map from the given item ID.
|
||||
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/Server.java
|
||||
+++ b/src/main/java/org/bukkit/Server.java
|
||||
@@ -0,0 +0,0 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
|
||||
@Nullable
|
||||
public World getWorld(@NotNull UUID uid);
|
||||
|
||||
+ // Paper start
|
||||
+ /**
|
||||
+ * Gets the world from the given NamespacedKey
|
||||
+ *
|
||||
+ * @param worldKey the NamespacedKey of the world to retrieve
|
||||
+ * @return a world with the given NamespacedKey, or null if none exists
|
||||
+ */
|
||||
+ @Nullable
|
||||
+ public World getWorld(@NotNull NamespacedKey worldKey);
|
||||
+ // Paper end
|
||||
+
|
||||
/**
|
||||
* Gets the map from the given item ID.
|
||||
*
|
||||
diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/World.java
|
||||
+++ b/src/main/java/org/bukkit/World.java
|
||||
@@ -0,0 +0,0 @@ import org.jetbrains.annotations.Nullable;
|
||||
/**
|
||||
* Represents a world, which may contain entities, chunks and blocks
|
||||
*/
|
||||
-public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient, Metadatable, net.kyori.adventure.audience.ForwardingAudience { // Paper
|
||||
+public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient, Metadatable, net.kyori.adventure.audience.ForwardingAudience, Keyed { // Paper
|
||||
|
||||
// Paper start
|
||||
/**
|
||||
@@ -0,0 +0,0 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
|
||||
|
||||
@NotNull
|
||||
java.util.concurrent.CompletableFuture<Chunk> getChunkAtAsync(int x, int z, boolean gen, boolean urgent);
|
||||
+
|
||||
+ /**
|
||||
+ * Get the world's key
|
||||
+ *
|
||||
+ * @return the world's key
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ @Override
|
||||
+ NamespacedKey getKey();
|
||||
// Paper end
|
||||
|
||||
/**
|
||||
diff --git a/src/main/java/org/bukkit/WorldCreator.java b/src/main/java/org/bukkit/WorldCreator.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/WorldCreator.java
|
||||
+++ b/src/main/java/org/bukkit/WorldCreator.java
|
||||
@@ -0,0 +0,0 @@ import org.jetbrains.annotations.Nullable;
|
||||
* Represents various types of options that may be used to create a world.
|
||||
*/
|
||||
public class WorldCreator {
|
||||
+ private final NamespacedKey key; // Paper
|
||||
private final String name;
|
||||
private long seed;
|
||||
private World.Environment environment = World.Environment.NORMAL;
|
||||
@@ -0,0 +0,0 @@ public class WorldCreator {
|
||||
* @param name Name of the world that will be created
|
||||
*/
|
||||
public WorldCreator(@NotNull String name) {
|
||||
- if (name == null) {
|
||||
- throw new IllegalArgumentException("World name cannot be null");
|
||||
- }
|
||||
+ // Paper start
|
||||
+ this(name, NamespacedKey.minecraft(name.toLowerCase(java.util.Locale.ENGLISH).replace(" ", "_")));
|
||||
+ }
|
||||
|
||||
- this.name = name;
|
||||
+ /**
|
||||
+ * Creates an empty WorldCreator for the given world name and key
|
||||
+ *
|
||||
+ * @param levelName LevelName of the world that will be created
|
||||
+ * @param worldKey NamespacedKey of the world that will be created
|
||||
+ */
|
||||
+ public WorldCreator(@NotNull String levelName, @NotNull NamespacedKey worldKey) {
|
||||
+ if (levelName == null || worldKey == null) {
|
||||
+ throw new IllegalArgumentException("World name and key cannot be null");
|
||||
+ }
|
||||
+ this.name = levelName;
|
||||
this.seed = (new Random()).nextLong();
|
||||
+ this.key = worldKey;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Creates an empty WorldCreator for the given key.
|
||||
+ * LevelName will be the Key part of the NamespacedKey.
|
||||
+ *
|
||||
+ * @param worldKey NamespacedKey of the world that will be created
|
||||
+ */
|
||||
+ public WorldCreator(@NotNull NamespacedKey worldKey) {
|
||||
+ this(worldKey.getKey(), worldKey);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the key for this WorldCreator
|
||||
+ *
|
||||
+ * @return the key
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public NamespacedKey key() {
|
||||
+ return key;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Creates an empty WorldCreator for the given world name and key
|
||||
+ *
|
||||
+ * @param levelName LevelName of the world that will be created
|
||||
+ * @param worldKey NamespacedKey of the world that will be created
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public static WorldCreator ofNameAndKey(@NotNull String levelName, @NotNull NamespacedKey worldKey) {
|
||||
+ return new WorldCreator(levelName, worldKey);
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Creates an empty WorldCreator for the given key.
|
||||
+ * LevelName will be the Key part of the NamespacedKey.
|
||||
+ *
|
||||
+ * @param worldKey NamespacedKey of the world that will be created
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public static WorldCreator ofKey(@NotNull NamespacedKey worldKey) {
|
||||
+ return new WorldCreator(worldKey);
|
||||
}
|
||||
+ // Paper end
|
||||
|
||||
/**
|
||||
* Copies the options from the specified world
|
@@ -1,109 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Fri, 12 Mar 2021 17:09:40 -0800
|
||||
Subject: [PATCH] Item Rarity API
|
||||
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/inventory/ItemRarity.java b/src/main/java/io/papermc/paper/inventory/ItemRarity.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/inventory/ItemRarity.java
|
||||
@@ -0,0 +0,0 @@
|
||||
+package io.papermc.paper.inventory;
|
||||
+
|
||||
+import net.kyori.adventure.text.format.NamedTextColor;
|
||||
+import net.kyori.adventure.text.format.TextColor;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+public enum ItemRarity {
|
||||
+
|
||||
+ COMMON(NamedTextColor.WHITE),
|
||||
+ UNCOMMON(NamedTextColor.YELLOW),
|
||||
+ RARE(NamedTextColor.AQUA),
|
||||
+ EPIC(NamedTextColor.LIGHT_PURPLE);
|
||||
+
|
||||
+ TextColor color;
|
||||
+
|
||||
+ ItemRarity(TextColor color) {
|
||||
+ this.color = color;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the color formatting associated with the rarity.
|
||||
+ * @return
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public TextColor getColor() {
|
||||
+ return color;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/org/bukkit/Material.java b/src/main/java/org/bukkit/Material.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/Material.java
|
||||
+++ b/src/main/java/org/bukkit/Material.java
|
||||
@@ -0,0 +0,0 @@ public enum Material implements Keyed, net.kyori.adventure.translation.Translata
|
||||
public @NotNull String translationKey() {
|
||||
return Bukkit.getUnsafe().getTranslationKey(this);
|
||||
}
|
||||
+
|
||||
+ /**
|
||||
+ * Returns the item rarity for the item. The Material <b>MUST</b> be an Item not a block.
|
||||
+ * Use {@link #isItem()} before this.
|
||||
+ *
|
||||
+ * @return the item rarity
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public io.papermc.paper.inventory.ItemRarity getItemRarity() {
|
||||
+ return Bukkit.getUnsafe().getItemRarity(this);
|
||||
+ }
|
||||
// Paper end
|
||||
|
||||
/**
|
||||
diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/UnsafeValues.java
|
||||
+++ b/src/main/java/org/bukkit/UnsafeValues.java
|
||||
@@ -0,0 +0,0 @@ public interface UnsafeValues {
|
||||
* Use this when sending custom packets, so that there are no collisions on the client or server.
|
||||
*/
|
||||
public int nextEntityId();
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the item rarity of a material. The material <b>MUST</b> be an item.
|
||||
+ * Use {@link Material#isItem()} before this.
|
||||
+ *
|
||||
+ * @param material the material to get the rarity of
|
||||
+ * @return the item rarity
|
||||
+ */
|
||||
+ public io.papermc.paper.inventory.ItemRarity getItemRarity(Material material);
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the item rarity of the itemstack. The rarity can change based on enchantements.
|
||||
+ *
|
||||
+ * @param itemStack the itemstack to get the rarity of
|
||||
+ * @return the itemstack rarity
|
||||
+ */
|
||||
+ public io.papermc.paper.inventory.ItemRarity getItemStackRarity(ItemStack itemStack);
|
||||
// Paper end
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/inventory/ItemStack.java b/src/main/java/org/bukkit/inventory/ItemStack.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/inventory/ItemStack.java
|
||||
+++ b/src/main/java/org/bukkit/inventory/ItemStack.java
|
||||
@@ -0,0 +0,0 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, net.kyor
|
||||
public @NotNull String translationKey() {
|
||||
return Bukkit.getUnsafe().getTranslationKey(this);
|
||||
}
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the item rarity of the itemstack. The rarity can change based on enchantements.
|
||||
+ *
|
||||
+ * @return the itemstack rarity
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public io.papermc.paper.inventory.ItemRarity getRarity() {
|
||||
+ return Bukkit.getUnsafe().getItemStackRarity(this);
|
||||
+ }
|
||||
// Paper end
|
||||
}
|
@@ -1,130 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Sun, 5 Jul 2020 00:34:24 -0700
|
||||
Subject: [PATCH] added PlayerNameEntityEvent
|
||||
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/event/player/PlayerNameEntityEvent.java b/src/main/java/io/papermc/paper/event/player/PlayerNameEntityEvent.java
|
||||
new file mode 100755
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/io/papermc/paper/event/player/PlayerNameEntityEvent.java
|
||||
@@ -0,0 +0,0 @@
|
||||
+package io.papermc.paper.event.player;
|
||||
+
|
||||
+import net.kyori.adventure.text.Component;
|
||||
+import org.bukkit.entity.LivingEntity;
|
||||
+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.NotNull;
|
||||
+import org.jetbrains.annotations.Nullable;
|
||||
+
|
||||
+/**
|
||||
+ * Called when the player is attempting to rename a mob
|
||||
+ */
|
||||
+public class PlayerNameEntityEvent extends PlayerEvent implements Cancellable {
|
||||
+
|
||||
+ private LivingEntity entity;
|
||||
+ private Component name;
|
||||
+ private boolean persistent;
|
||||
+ private boolean cancelled;
|
||||
+
|
||||
+ public PlayerNameEntityEvent(@NotNull Player player, @NotNull LivingEntity entity, @NotNull Component name, boolean persistent) {
|
||||
+ super(player);
|
||||
+ this.entity = entity;
|
||||
+ this.name = name;
|
||||
+ this.persistent = persistent;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the name to be given to the entity.
|
||||
+ * @return the name
|
||||
+ */
|
||||
+ @Nullable
|
||||
+ public Component getName() {
|
||||
+ return name;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the name to be given to the entity.
|
||||
+ *
|
||||
+ * @param name the name
|
||||
+ */
|
||||
+ public void setName(@Nullable Component name) {
|
||||
+ this.name = name;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the entity involved in this event.
|
||||
+ *
|
||||
+ * @return the entity
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public LivingEntity getEntity() {
|
||||
+ return entity;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the entity involved in this event.
|
||||
+ *
|
||||
+ * @param entity the entity
|
||||
+ */
|
||||
+ public void setEntity(@NotNull LivingEntity entity) {
|
||||
+ this.entity = entity;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets whether this will set the mob to be persistent.
|
||||
+ *
|
||||
+ * @return persistent
|
||||
+ */
|
||||
+ public boolean isPersistent() {
|
||||
+ return persistent;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Sets whether this will set the mob to be persistent.
|
||||
+ *
|
||||
+ * @param persistent persistent
|
||||
+ */
|
||||
+ public void setPersistent(boolean persistent) {
|
||||
+ this.persistent = persistent;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the cancellation state of this event. A cancelled event will not
|
||||
+ * be executed in the server, but will still pass to other plugins
|
||||
+ *
|
||||
+ * @return true if this event is cancelled
|
||||
+ */
|
||||
+ @Override
|
||||
+ public boolean isCancelled() {
|
||||
+ return cancelled;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the cancellation state of this event. A cancelled event will not
|
||||
+ * be executed in the server, but will still pass to other plugins.
|
||||
+ *
|
||||
+ * @param cancel true if you wish to cancel this event
|
||||
+ */
|
||||
+ @Override
|
||||
+ public void setCancelled(boolean cancel) {
|
||||
+ this.cancelled = cancel;
|
||||
+ }
|
||||
+
|
||||
+ private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
+
|
||||
+ @NotNull
|
||||
+ @Override
|
||||
+ public HandlerList getHandlers() {
|
||||
+ return HANDLER_LIST;
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ public static HandlerList getHandlerList() {
|
||||
+ return HANDLER_LIST;
|
||||
+ }
|
||||
+}
|
@@ -1,22 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: CDFN <codefun@protonmail.com>
|
||||
Date: Fri, 12 Mar 2021 18:31:31 +0100
|
||||
Subject: [PATCH] fix Inventory#getContents null annotations
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/inventory/Inventory.java b/src/main/java/org/bukkit/inventory/Inventory.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/inventory/Inventory.java
|
||||
+++ b/src/main/java/org/bukkit/inventory/Inventory.java
|
||||
@@ -0,0 +0,0 @@ public interface Inventory extends Iterable<ItemStack> {
|
||||
*
|
||||
* @return An array of ItemStacks from the inventory. Individual items may be null.
|
||||
*/
|
||||
- @NotNull
|
||||
- public ItemStack[] getContents();
|
||||
-
|
||||
+ public @org.checkerframework.checker.nullness.qual.Nullable ItemStack @org.checkerframework.checker.nullness.qual.NonNull [] getContents(); // Paper - make array elements nullable instead array
|
||||
+
|
||||
/**
|
||||
* Completely replaces the inventory's contents. Removes all existing
|
||||
* contents and replaces it with the ItemStacks given in the array.
|
Reference in New Issue
Block a user