patches and patches
This commit is contained in:
parent
79f1d1a078
commit
41a5f14f9e
34 changed files with 231 additions and 261 deletions
|
@ -1,57 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Shane Freeder <theboyetronic@gmail.com>
|
||||
Date: Sun, 18 Nov 2018 19:44:54 +0000
|
||||
Subject: [PATCH] Make the default permission message configurable
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
|
||||
index 6b619b85fee86ccc599cb46d789e39b81af3201c..dcaefdaf5a0de8486f59115c8c4d4c211b7d64cd 100644
|
||||
--- a/src/main/java/org/bukkit/Bukkit.java
|
||||
+++ b/src/main/java/org/bukkit/Bukkit.java
|
||||
@@ -1793,6 +1793,15 @@ public final class Bukkit {
|
||||
return server.suggestPlayerNamesWhenNullTabCompletions();
|
||||
}
|
||||
|
||||
+ /**
|
||||
+ *
|
||||
+ * @return the default no permission message used on the server
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public static String getPermissionMessage() {
|
||||
+ return server.getPermissionMessage();
|
||||
+ }
|
||||
+
|
||||
/**
|
||||
* Creates a PlayerProfile for the specified uuid, with name as null
|
||||
* @param uuid UUID to create profile for
|
||||
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
|
||||
index c642fe9cfae6407404f5cf17264f42ef83a01280..9b8e6b7bbbed44e2659379c8046acaa35aaa8910 100644
|
||||
--- a/src/main/java/org/bukkit/Server.java
|
||||
+++ b/src/main/java/org/bukkit/Server.java
|
||||
@@ -1575,6 +1575,13 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
|
||||
*/
|
||||
boolean suggestPlayerNamesWhenNullTabCompletions();
|
||||
|
||||
+ /**
|
||||
+ *
|
||||
+ * @return the default no permission message used on the server
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ String getPermissionMessage();
|
||||
+
|
||||
/**
|
||||
* Creates a PlayerProfile for the specified uuid, with name as null
|
||||
* @param uuid UUID to create profile for
|
||||
diff --git a/src/main/java/org/bukkit/command/Command.java b/src/main/java/org/bukkit/command/Command.java
|
||||
index 7c80dc54776d0d66f7816b77136f6dbd9b801704..c10fc8d2386301bc2caddcdb1cd18566bcaa8689 100644
|
||||
--- a/src/main/java/org/bukkit/command/Command.java
|
||||
+++ b/src/main/java/org/bukkit/command/Command.java
|
||||
@@ -185,7 +185,7 @@ public abstract class Command {
|
||||
}
|
||||
|
||||
if (permissionMessage == null) {
|
||||
- target.sendMessage(ChatColor.RED + "I'm sorry, but you do not have permission to perform this command. Please contact the server administrators if you believe that this is a mistake.");
|
||||
+ target.sendMessage(Bukkit.getPermissionMessage()); // Paper
|
||||
} else if (permissionMessage.length() != 0) {
|
||||
for (String line : permissionMessage.replace("<permission>", permission).split("\n")) {
|
||||
target.sendMessage(line);
|
|
@ -1,109 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Shane Freeder <theboyetronic@gmail.com>
|
||||
Date: Sun, 18 Nov 2018 15:53:43 +0000
|
||||
Subject: [PATCH] Support cancellation supression of EntityDismount/VehicleExit
|
||||
events"
|
||||
|
||||
Entities must be dismounted before teleportation in order to avoid
|
||||
multiple issues in the server with regards to teleportation, shamefully,
|
||||
too many plugins rely on the events firing, which means that not firing
|
||||
these events caues more issues than it solves;
|
||||
|
||||
In order to counteract this, Entity dismount/exit vehicle events have
|
||||
been modified to supress cancellation (and has a method to allow plugins
|
||||
to check if this has been set), noting that cancellation will be silently
|
||||
surpressed given that plugins are not expecting this event to not be cancellable.
|
||||
|
||||
This is a far from ideal scenario, however: given the current state of this
|
||||
event and other alternatives causing issues elsewhere, I believe that
|
||||
this is going to be the best soultion all around.
|
||||
|
||||
Improvements/suggestions welcome!
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/event/vehicle/VehicleExitEvent.java b/src/main/java/org/bukkit/event/vehicle/VehicleExitEvent.java
|
||||
index 963b9ead4ca0426b2e95c5641b0e89317c48853d..a976c32de6ad5e90b0a96a0f387136ab0f5eb52e 100644
|
||||
--- a/src/main/java/org/bukkit/event/vehicle/VehicleExitEvent.java
|
||||
+++ b/src/main/java/org/bukkit/event/vehicle/VehicleExitEvent.java
|
||||
@@ -13,10 +13,18 @@ public class VehicleExitEvent extends VehicleEvent implements Cancellable {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean cancelled;
|
||||
private final LivingEntity exited;
|
||||
+ private final boolean isCancellable; // Paper
|
||||
|
||||
- public VehicleExitEvent(@NotNull final Vehicle vehicle, @NotNull final LivingEntity exited) {
|
||||
+ public VehicleExitEvent(@NotNull final Vehicle vehicle, @NotNull final LivingEntity exited, boolean isCancellable) { // Paper
|
||||
super(vehicle);
|
||||
this.exited = exited;
|
||||
+ // Paper start
|
||||
+ this.isCancellable = isCancellable;
|
||||
+ }
|
||||
+
|
||||
+ public VehicleExitEvent(@NotNull final Vehicle vehicle, @NotNull final LivingEntity exited) {
|
||||
+ this(vehicle, exited, true);
|
||||
+ // Paper end
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -36,9 +44,18 @@ public class VehicleExitEvent extends VehicleEvent implements Cancellable {
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
+ // Paper start
|
||||
+ if (cancel && !isCancellable) {
|
||||
+ return;
|
||||
+ }
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
+ public boolean isCancellable() {
|
||||
+ return isCancellable;
|
||||
+ // paper end
|
||||
+ }
|
||||
+
|
||||
@NotNull
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
diff --git a/src/main/java/org/spigotmc/event/entity/EntityDismountEvent.java b/src/main/java/org/spigotmc/event/entity/EntityDismountEvent.java
|
||||
index 00d8ec81b4ae6ca5e438161ec9135e3c1edea6f4..a7632c8f5cb1bce4be0e456ec34f4a69c5ce80f3 100644
|
||||
--- a/src/main/java/org/spigotmc/event/entity/EntityDismountEvent.java
|
||||
+++ b/src/main/java/org/spigotmc/event/entity/EntityDismountEvent.java
|
||||
@@ -14,10 +14,19 @@ public class EntityDismountEvent extends EntityEvent implements Cancellable {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean cancelled;
|
||||
private final Entity dismounted;
|
||||
+ private final boolean isCancellable; // Paper
|
||||
|
||||
public EntityDismountEvent(@NotNull Entity what, @NotNull Entity dismounted) {
|
||||
- super(what);
|
||||
+ // Paper start
|
||||
+ this(what, dismounted, true);
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ public EntityDismountEvent(@NotNull Entity what, @NotNull Entity dismounted, boolean isCancellable) {
|
||||
+ // Paper end
|
||||
+ super( what );
|
||||
this.dismounted = dismounted;
|
||||
+ this.isCancellable = isCancellable; // Paper
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -32,9 +41,18 @@ public class EntityDismountEvent extends EntityEvent implements Cancellable {
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
+ // Paper start
|
||||
+ if (cancel && !isCancellable) {
|
||||
+ return;
|
||||
+ }
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
+ public boolean isCancellable() {
|
||||
+ return isCancellable;
|
||||
+ // Paper end
|
||||
+ }
|
||||
+
|
||||
@NotNull
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
|
@ -1,66 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: BillyGalbreath <Blake.Galbreath@GMail.com>
|
||||
Date: Sun, 7 Oct 2018 04:29:51 -0500
|
||||
Subject: [PATCH] Add more Zombie API
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/entity/Zombie.java b/src/main/java/org/bukkit/entity/Zombie.java
|
||||
index a5b20b0454af5ea78e2bb7f16a56c38670c84efb..1217576e6f08abf0175ab800cfca058d5deda116 100644
|
||||
--- a/src/main/java/org/bukkit/entity/Zombie.java
|
||||
+++ b/src/main/java/org/bukkit/entity/Zombie.java
|
||||
@@ -90,4 +90,55 @@ public interface Zombie extends Monster, Ageable {
|
||||
* @param time new conversion time
|
||||
*/
|
||||
void setConversionTime(int time);
|
||||
+ // Paper start
|
||||
+ /**
|
||||
+ * Check if zombie is drowning
|
||||
+ *
|
||||
+ * @return True if zombie conversion process has begun
|
||||
+ */
|
||||
+ boolean isDrowning();
|
||||
+
|
||||
+ /**
|
||||
+ * Make zombie start drowning
|
||||
+ *
|
||||
+ * @param drownedConversionTime Amount of time until zombie converts from drowning
|
||||
+ *
|
||||
+ * @deprecated See {@link #setConversionTime(int)}
|
||||
+ */
|
||||
+ @Deprecated
|
||||
+ void startDrowning(int drownedConversionTime);
|
||||
+
|
||||
+ /**
|
||||
+ * Stop a zombie from starting the drowning conversion process
|
||||
+ */
|
||||
+ void stopDrowning();
|
||||
+
|
||||
+ /**
|
||||
+ * Set if zombie has its arms raised
|
||||
+ *
|
||||
+ * @param raised True to raise arms
|
||||
+ */
|
||||
+ void setArmsRaised(boolean raised);
|
||||
+
|
||||
+ /**
|
||||
+ * Check if zombie has arms raised
|
||||
+ *
|
||||
+ * @return True if arms are raised
|
||||
+ */
|
||||
+ boolean isArmsRaised();
|
||||
+
|
||||
+ /**
|
||||
+ * Check if this zombie will burn in the sunlight
|
||||
+ *
|
||||
+ * @return True if zombie will burn in sunlight
|
||||
+ */
|
||||
+ boolean shouldBurnInDay();
|
||||
+
|
||||
+ /**
|
||||
+ * Set if this zombie should burn in the sunlight
|
||||
+ *
|
||||
+ * @param shouldBurnInDay True to burn in sunlight
|
||||
+ */
|
||||
+ void setShouldBurnInDay(boolean shouldBurnInDay);
|
||||
+ // Paper end
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: DoNotSpamPls <7570108+DoNotSpamPls@users.noreply.github.com>
|
||||
Date: Tue, 23 Oct 2018 19:32:55 +0300
|
||||
Subject: [PATCH] Change the reserved channel check to be sensible
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/plugin/messaging/StandardMessenger.java b/src/main/java/org/bukkit/plugin/messaging/StandardMessenger.java
|
||||
index 1d061412cdafa28c6940c7433747ab1dabe23de1..6fda7f3aa68e76af64362e9afed70fc6a5e92986 100644
|
||||
--- a/src/main/java/org/bukkit/plugin/messaging/StandardMessenger.java
|
||||
+++ b/src/main/java/org/bukkit/plugin/messaging/StandardMessenger.java
|
||||
@@ -172,7 +172,7 @@ public class StandardMessenger implements Messenger {
|
||||
public boolean isReservedChannel(@NotNull String channel) {
|
||||
channel = validateAndCorrectChannel(channel);
|
||||
|
||||
- return channel.contains("minecraft") && !channel.equals("minecraft:brand");
|
||||
+ return channel.equals("minecraft:register") || channel.equals("minecraft:unregister"); // Paper
|
||||
}
|
||||
|
||||
@Override
|
||||
diff --git a/src/test/java/org/bukkit/plugin/messaging/StandardMessengerTest.java b/src/test/java/org/bukkit/plugin/messaging/StandardMessengerTest.java
|
||||
index dce3d619a6f1791197e44277c2dee9eaf19ff56f..7e2335ed8acc692af1e70eddcf97ee7a56e30f68 100644
|
||||
--- a/src/test/java/org/bukkit/plugin/messaging/StandardMessengerTest.java
|
||||
+++ b/src/test/java/org/bukkit/plugin/messaging/StandardMessengerTest.java
|
||||
@@ -25,8 +25,8 @@ public class StandardMessengerTest {
|
||||
assertTrue(messenger.isReservedChannel("minecraft:register"));
|
||||
assertFalse(messenger.isReservedChannel("test:register"));
|
||||
assertTrue(messenger.isReservedChannel("minecraft:unregister"));
|
||||
- assertFalse(messenger.isReservedChannel("test:nregister"));
|
||||
- assertTrue(messenger.isReservedChannel("minecraft:something"));
|
||||
+ assertFalse(messenger.isReservedChannel("test:unregister")); // Paper - fix typo
|
||||
+ assertFalse(messenger.isReservedChannel("minecraft:something")); // Paper - now less strict
|
||||
assertFalse(messenger.isReservedChannel("minecraft:brand"));
|
||||
}
|
||||
|
|
@ -1,136 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
|
||||
Date: Sun, 7 Oct 2018 12:05:06 -0700
|
||||
Subject: [PATCH] Add PlayerConnectionCloseEvent
|
||||
|
||||
This event is invoked when a player has disconnected. It is guaranteed that,
|
||||
if the server is in online-mode, that the provided uuid and username have been
|
||||
validated.
|
||||
|
||||
The event is invoked for players who have not yet logged into the world, whereas
|
||||
PlayerQuitEvent is only invoked on players who have logged into the world.
|
||||
|
||||
The event is invoked for players who have already logged into the world,
|
||||
although whether or not the player exists in the world at the time of
|
||||
firing is undefined. (That is, whether the plugin can retrieve a Player object
|
||||
using the event parameters is undefined). However, it is guaranteed that this
|
||||
event is invoked AFTER PlayerQuitEvent, if the player has already logged into
|
||||
the world.
|
||||
|
||||
This event is guaranteed to never fire unless AsyncPlayerPreLoginEvent has
|
||||
been called beforehand, and this event may not be called in parallel with
|
||||
AsyncPlayerPreLoginEvent for the same connection.
|
||||
|
||||
Cancelling the AsyncPlayerPreLoginEvent guarantees the corresponding
|
||||
PlayerConnectionCloseEvent is never called.
|
||||
|
||||
The event may be invoked asynchronously or synchronously. As it stands,
|
||||
it is never invoked asynchronously. However, plugins should check
|
||||
Event#isAsynchronous to be future-proof.
|
||||
|
||||
On purpose, the deprecated PlayerPreLoginEvent event is left out of the
|
||||
API spec for this event. Plugins should not be using that event, and
|
||||
how PlayerPreLoginEvent interacts with PlayerConnectionCloseEvent
|
||||
is undefined.
|
||||
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerConnectionCloseEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerConnectionCloseEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..12c1c6fe9dc8dc5f5faf6dcf99f6857219ef22b8
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerConnectionCloseEvent.java
|
||||
@@ -0,0 +1,95 @@
|
||||
+package com.destroystokyo.paper.event.player;
|
||||
+
|
||||
+import org.bukkit.event.Event;
|
||||
+import org.bukkit.event.HandlerList;
|
||||
+
|
||||
+import java.net.InetAddress;
|
||||
+import java.util.UUID;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+/**
|
||||
+ * <p>
|
||||
+ * This event is invoked when a player has disconnected. It is guaranteed that,
|
||||
+ * if the server is in online-mode, that the provided uuid and username have been
|
||||
+ * validated.
|
||||
+ * </p>
|
||||
+ *
|
||||
+ * <p>
|
||||
+ * The event is invoked for players who have not yet logged into the world, whereas
|
||||
+ * {@link org.bukkit.event.player.PlayerQuitEvent} is only invoked on players who have logged into the world.
|
||||
+ * </p>
|
||||
+ *
|
||||
+ * <p>
|
||||
+ * The event is invoked for players who have already logged into the world,
|
||||
+ * although whether or not the player exists in the world at the time of
|
||||
+ * firing is undefined. (That is, whether the plugin can retrieve a Player object
|
||||
+ * using the event parameters is undefined). However, it is guaranteed that this
|
||||
+ * event is invoked AFTER {@link org.bukkit.event.player.PlayerQuitEvent}, if the player has already logged into the world.
|
||||
+ * </p>
|
||||
+ *
|
||||
+ * <p>
|
||||
+ * This event is guaranteed to never fire unless {@link org.bukkit.event.player.AsyncPlayerPreLoginEvent} has
|
||||
+ * been fired beforehand, and this event may not be called in parallel with
|
||||
+ * {@link org.bukkit.event.player.AsyncPlayerPreLoginEvent} for the same connection.
|
||||
+ * </p>
|
||||
+ *
|
||||
+ * <p>
|
||||
+ * Cancelling the {@link org.bukkit.event.player.AsyncPlayerPreLoginEvent} guarantees the corresponding
|
||||
+ * {@code PlayerConnectionCloseEvent} is never called.
|
||||
+ * </p>
|
||||
+ *
|
||||
+ * <p>
|
||||
+ * The event may be invoked asynchronously or synchronously. Plugins should check
|
||||
+ * {@link Event#isAsynchronous()} and handle accordingly.
|
||||
+ * </p>
|
||||
+ */
|
||||
+public class PlayerConnectionCloseEvent extends Event {
|
||||
+
|
||||
+ private static final HandlerList HANDLERS = new HandlerList();
|
||||
+
|
||||
+ @NotNull private final UUID playerUniqueId;
|
||||
+ @NotNull private final String playerName;
|
||||
+ @NotNull private final InetAddress ipAddress;
|
||||
+
|
||||
+ public PlayerConnectionCloseEvent(@NotNull final UUID playerUniqueId, @NotNull final String playerName, @NotNull final InetAddress ipAddress, final boolean async) {
|
||||
+ super(async);
|
||||
+ this.playerUniqueId = playerUniqueId;
|
||||
+ this.playerName = playerName;
|
||||
+ this.ipAddress = ipAddress;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Returns the {@code UUID} of the player disconnecting.
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public UUID getPlayerUniqueId() {
|
||||
+ return this.playerUniqueId;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Returns the name of the player disconnecting.
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public String getPlayerName() {
|
||||
+ return this.playerName;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Returns the player's IP address.
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public InetAddress getIpAddress() {
|
||||
+ return this.ipAddress;
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ @Override
|
||||
+ public HandlerList getHandlers() {
|
||||
+ return HANDLERS;
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ public static HandlerList getHandlerList() {
|
||||
+ return HANDLERS;
|
||||
+ }
|
||||
+}
|
|
@ -1,62 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Zach Brown <zach@zachbr.io>
|
||||
Date: Wed, 2 Jan 2019 00:31:12 -0600
|
||||
Subject: [PATCH] Add APIs to replace OfflinePlayer#getLastPlayed
|
||||
|
||||
Currently OfflinePlayer#getLastPlayed could more accurately be described
|
||||
as "OfflinePlayer#getLastTimeTheirDataWasSaved".
|
||||
|
||||
The API doc says it should return the last time the server "witnessed"
|
||||
the player, whilst also saying it should return the last time they
|
||||
logged in. The current implementation does neither.
|
||||
|
||||
Given this interesting contradiction in the API documentation and the
|
||||
current defacto implementation, I've elected to deprecate (with no
|
||||
intent to remove) and replace it with two new methods, clearly named and
|
||||
documented as to their purpose.
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/OfflinePlayer.java b/src/main/java/org/bukkit/OfflinePlayer.java
|
||||
index 6cf05fed701c67a2c797a4e0839c795802a238a1..3afd5f5c0208a4ee93b5dbfc2aab2b9d2e8a7544 100644
|
||||
--- a/src/main/java/org/bukkit/OfflinePlayer.java
|
||||
+++ b/src/main/java/org/bukkit/OfflinePlayer.java
|
||||
@@ -147,7 +147,9 @@ public interface OfflinePlayer extends ServerOperator, AnimalTamer, Configuratio
|
||||
* UTC.
|
||||
*
|
||||
* @return Date of last log-in for this player, or 0
|
||||
+ * @deprecated The API contract is ambiguous and the implementation may or may not return the correct value given this API ambiguity. It is instead recommended use {@link #getLastLogin()} or {@link #getLastSeen()} depending on your needs.
|
||||
*/
|
||||
+ @Deprecated
|
||||
public long getLastPlayed();
|
||||
|
||||
/**
|
||||
@@ -165,6 +167,30 @@ public interface OfflinePlayer extends ServerOperator, AnimalTamer, Configuratio
|
||||
*/
|
||||
@Nullable
|
||||
public Location getBedSpawnLocation();
|
||||
+ // Paper start
|
||||
+ /**
|
||||
+ * Gets the last date and time that this player logged into the server.
|
||||
+ * <p>
|
||||
+ * If the player has never played before, this will return 0. Otherwise,
|
||||
+ * it will be the amount of milliseconds since midnight, January 1, 1970
|
||||
+ * UTC.
|
||||
+ *
|
||||
+ * @return last login time
|
||||
+ */
|
||||
+ public long getLastLogin();
|
||||
+
|
||||
+ /**
|
||||
+ * Gets the last date and time that this player was seen on the server.
|
||||
+ * <p>
|
||||
+ * If the player has never played before, this will return 0. If the
|
||||
+ * player is currently online, this will return the current time.
|
||||
+ * Otherwise it will be the amount of milliseconds since midnight,
|
||||
+ * January 1, 1970 UTC.
|
||||
+ *
|
||||
+ * @return last seen time
|
||||
+ */
|
||||
+ public long getLastSeen();
|
||||
+ // Paper end
|
||||
|
||||
/**
|
||||
* Increments the given statistic for this player.
|
|
@ -1,110 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Wed, 6 Feb 2019 00:19:33 -0500
|
||||
Subject: [PATCH] BlockDestroyEvent
|
||||
|
||||
Adds an event for when the server is going to destroy a current block,
|
||||
potentially causing it to drop. This event can be cancelled to avoid
|
||||
the block destruction, such as preventing signs from popping when
|
||||
floating in the air.
|
||||
|
||||
This can replace many uses of BlockPhysicsEvent
|
||||
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/event/block/BlockDestroyEvent.java b/src/main/java/com/destroystokyo/paper/event/block/BlockDestroyEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..28255dc39eab5faf324d1fe556ab12daed527ff6
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/com/destroystokyo/paper/event/block/BlockDestroyEvent.java
|
||||
@@ -0,0 +1,92 @@
|
||||
+package com.destroystokyo.paper.event.block;
|
||||
+
|
||||
+import org.bukkit.block.Block;
|
||||
+import org.bukkit.block.data.BlockData;
|
||||
+import org.bukkit.event.Cancellable;
|
||||
+import org.bukkit.event.HandlerList;
|
||||
+import org.bukkit.event.block.BlockEvent;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+/**
|
||||
+ * Fired anytime the server intends to 'destroy' a block through some triggering reason.
|
||||
+ * This does not fire anytime a block is set to air, but only with more direct triggers such
|
||||
+ * as physics updates, pistons, Entities changing blocks, commands set to "Destroy".
|
||||
+ *
|
||||
+ * This event is associated with the game playing a sound effect at the block in question, when
|
||||
+ * something can be described as "intend to destroy what is there",
|
||||
+ *
|
||||
+ * Events such as leaves decaying, pistons retracting (where the block is moving), does NOT fire this event.
|
||||
+ *
|
||||
+ */
|
||||
+public class BlockDestroyEvent extends BlockEvent implements Cancellable {
|
||||
+
|
||||
+ private static final HandlerList handlers = new HandlerList();
|
||||
+
|
||||
+ @NotNull private final BlockData newState;
|
||||
+ private final boolean willDrop;
|
||||
+ private boolean playEffect = true;
|
||||
+
|
||||
+ private boolean cancelled = false;
|
||||
+
|
||||
+ public BlockDestroyEvent(@NotNull Block block, @NotNull BlockData newState, boolean willDrop) {
|
||||
+ super(block);
|
||||
+ this.newState = newState;
|
||||
+ this.willDrop = willDrop;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * @return The new state of this block (Air, or a Fluid type)
|
||||
+ */
|
||||
+ @NotNull
|
||||
+ public BlockData getNewState() {
|
||||
+ return newState;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * @return If the server is going to drop the block in question with this destroy event
|
||||
+ */
|
||||
+ public boolean willDrop() {
|
||||
+ return this.willDrop;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * @return If the server is going to play the sound effect for this destruction
|
||||
+ */
|
||||
+ public boolean playEffect() {
|
||||
+ return this.playEffect;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * @param playEffect If the server should play the sound effect for this destruction
|
||||
+ */
|
||||
+ public void setPlayEffect(boolean playEffect) {
|
||||
+ this.playEffect = playEffect;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * @return If the event is cancelled, meaning the block will not be destroyed
|
||||
+ */
|
||||
+ @Override
|
||||
+ public boolean isCancelled() {
|
||||
+ return cancelled;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * If the event is cancelled, the block will remain in its previous state.
|
||||
+ * @param cancel true if you wish to cancel this event
|
||||
+ */
|
||||
+ @Override
|
||||
+ public void setCancelled(boolean cancel) {
|
||||
+ cancelled = cancel;
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ public HandlerList getHandlers() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ public static HandlerList getHandlerList() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+}
|
|
@ -1,70 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Tue, 28 Jan 2014 19:13:57 -0500
|
||||
Subject: [PATCH] Add ItemStack Recipe API helper methods
|
||||
|
||||
Allows using ExactChoice Recipes with easier methodss
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/inventory/ShapedRecipe.java b/src/main/java/org/bukkit/inventory/ShapedRecipe.java
|
||||
index d742c4058ba9aed4fbe1591fd755a06608b06e98..222a12baa8e93ad686ab59426653f066d5876e38 100644
|
||||
--- a/src/main/java/org/bukkit/inventory/ShapedRecipe.java
|
||||
+++ b/src/main/java/org/bukkit/inventory/ShapedRecipe.java
|
||||
@@ -145,6 +145,13 @@ public class ShapedRecipe implements Recipe, Keyed {
|
||||
return this;
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ @NotNull
|
||||
+ public ShapedRecipe setIngredient(char key, @NotNull ItemStack item) {
|
||||
+ return setIngredient(key, new RecipeChoice.ExactChoice(item));
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
/**
|
||||
* Get a copy of the ingredients map.
|
||||
*
|
||||
diff --git a/src/main/java/org/bukkit/inventory/ShapelessRecipe.java b/src/main/java/org/bukkit/inventory/ShapelessRecipe.java
|
||||
index 84062dd719cb8a6142dc8c806777cb208c6b42b2..7f6d3c71c5b3a9aa54c84a4c3b7c3614a0d477ce 100644
|
||||
--- a/src/main/java/org/bukkit/inventory/ShapelessRecipe.java
|
||||
+++ b/src/main/java/org/bukkit/inventory/ShapelessRecipe.java
|
||||
@@ -143,6 +143,40 @@ public class ShapelessRecipe implements Recipe, Keyed {
|
||||
return this;
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ @NotNull
|
||||
+ public ShapelessRecipe addIngredient(@NotNull ItemStack item) {
|
||||
+ return addIngredient(item.getAmount(), item);
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ public ShapelessRecipe addIngredient(int count, @NotNull ItemStack item) {
|
||||
+ Validate.isTrue(ingredients.size() + count <= 9, "Shapeless recipes cannot have more than 9 ingredients");
|
||||
+ while (count-- > 0) {
|
||||
+ ingredients.add(new RecipeChoice.ExactChoice(item));
|
||||
+ }
|
||||
+ return this;
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ public ShapelessRecipe removeIngredient(@NotNull ItemStack item) {
|
||||
+ return removeIngredient(1, item);
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ public ShapelessRecipe removeIngredient(int count, @NotNull ItemStack item) {
|
||||
+ Iterator<RecipeChoice> iterator = ingredients.iterator();
|
||||
+ while (count > 0 && iterator.hasNext()) {
|
||||
+ ItemStack stack = iterator.next().getItemStack();
|
||||
+ if (stack.equals(item)) {
|
||||
+ iterator.remove();
|
||||
+ count--;
|
||||
+ }
|
||||
+ }
|
||||
+ return this;
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
/**
|
||||
* Removes an ingredient from the list.
|
||||
*
|
|
@ -1,52 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Mark Vainomaa <mikroskeem@mikroskeem.eu>
|
||||
Date: Wed, 13 Mar 2019 20:04:43 +0200
|
||||
Subject: [PATCH] Add WhitelistToggleEvent
|
||||
|
||||
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/event/server/WhitelistToggleEvent.java b/src/main/java/com/destroystokyo/paper/event/server/WhitelistToggleEvent.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..fdd5eedb2b7401439912a3a4343a920f32edc860
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/com/destroystokyo/paper/event/server/WhitelistToggleEvent.java
|
||||
@@ -0,0 +1,40 @@
|
||||
+package com.destroystokyo.paper.event.server;
|
||||
+
|
||||
+import org.bukkit.event.Event;
|
||||
+import org.bukkit.event.HandlerList;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+/**
|
||||
+ * This event is fired when whitelist is toggled
|
||||
+ *
|
||||
+ * @author Mark Vainomaa
|
||||
+ */
|
||||
+public class WhitelistToggleEvent extends Event {
|
||||
+ private static final HandlerList handlers = new HandlerList();
|
||||
+
|
||||
+ private boolean enabled;
|
||||
+
|
||||
+ public WhitelistToggleEvent(boolean enabled) {
|
||||
+ this.enabled = enabled;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets whether whitelist is going to be enabled or not
|
||||
+ *
|
||||
+ * @return Whether whitelist is going to be enabled or not
|
||||
+ */
|
||||
+ public boolean isEnabled() {
|
||||
+ return enabled;
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ @Override
|
||||
+ public HandlerList getHandlers() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ public static HandlerList getHandlerList() {
|
||||
+ return handlers;
|
||||
+ }
|
||||
+}
|
Loading…
Add table
Add a link
Reference in a new issue