| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
| From: Jedediah Smith <jedediah@silencegreys.com> | ||
| Date: Mon, 29 Feb 2016 17:22:34 -0600 | ||
| Subject: [PATCH] Player affects spawning API | ||
|
|
||
|
|
||
| diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java | ||
| index 171e2663301f654258dbd772a57688b5a2f8469c..76ac0b20842002ce1b593e338bea98483e7080ac 100644 | ||
| --- a/src/main/java/org/bukkit/entity/Player.java | ||
| +++ b/src/main/java/org/bukkit/entity/Player.java | ||
| @@ -1380,6 +1380,22 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM | ||
| @Deprecated // Paper | ||
| public String getLocale(); | ||
|
|
||
| + // Paper start | ||
| + /** | ||
| + * Get whether the player can affect mob spawning | ||
| + * | ||
| + * @return if the player can affect mob spawning | ||
| + */ | ||
| + public boolean getAffectsSpawning(); | ||
| + | ||
| + /** | ||
| + * Set whether the player can affect mob spawning | ||
| + * | ||
| + * @param affects Whether the player can affect mob spawning | ||
| + */ | ||
| + public void setAffectsSpawning(boolean affects); | ||
| + // Paper end | ||
| + | ||
| /** | ||
| * Update the list of commands sent to the client. | ||
| * <br> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
| From: Aikar <aikar@aikar.co> | ||
| Date: Mon, 29 Feb 2016 17:24:57 -0600 | ||
| Subject: [PATCH] Add getTPS method | ||
|
|
||
|
|
||
| diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java | ||
| index ab4d5aca6251b620ef5d654fa4ea3fc31783c2f2..0636edd8d9121eabfa60957c8c224261d228a16b 100644 | ||
| --- a/src/main/java/org/bukkit/Bukkit.java | ||
| +++ b/src/main/java/org/bukkit/Bukkit.java | ||
| @@ -1543,6 +1543,17 @@ public final class Bukkit { | ||
| return server.getEntity(uuid); | ||
| } | ||
|
|
||
| + // Paper start | ||
| + /** | ||
| + * Gets the current server TPS | ||
| + * @return current server TPS (1m, 5m, 15m in Paper-Server) | ||
| + */ | ||
| + @NotNull | ||
| + public static double[] getTPS() { | ||
| + return server.getTPS(); | ||
| + } | ||
| + // Paper end | ||
| + | ||
| /** | ||
| * Get the advancement specified by this key. | ||
| * | ||
| diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java | ||
| index b862f22d5f31934eb46b50ecf04f8c1bf23c5044..5c638e0d45e8896382bdbf9b9c10474b05a97df5 100644 | ||
| --- a/src/main/java/org/bukkit/Server.java | ||
| +++ b/src/main/java/org/bukkit/Server.java | ||
| @@ -1301,6 +1301,16 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi | ||
| @Nullable | ||
| Entity getEntity(@NotNull UUID uuid); | ||
|
|
||
| + // Paper start | ||
| + /** | ||
| + * Gets the current server TPS | ||
| + * | ||
| + * @return current server TPS (1m, 5m, 15m in Paper-Server) | ||
| + */ | ||
| + @NotNull | ||
| + public double[] getTPS(); | ||
| + // Paper end | ||
| + | ||
| /** | ||
| * Get the advancement specified by this key. | ||
| * |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
| From: Byteflux <byte@byteflux.net> | ||
| Date: Mon, 29 Feb 2016 17:50:31 -0600 | ||
| Subject: [PATCH] Entity Origin API | ||
|
|
||
|
|
||
| diff --git a/src/main/java/org/bukkit/entity/Entity.java b/src/main/java/org/bukkit/entity/Entity.java | ||
| index 03e12de470f983e89a473c4e42c21941085b1d37..fdce246aecac775c3ff4a028c307b09762505258 100644 | ||
| --- a/src/main/java/org/bukkit/entity/Entity.java | ||
| +++ b/src/main/java/org/bukkit/entity/Entity.java | ||
| @@ -655,5 +655,15 @@ public interface Entity extends Metadatable, CommandSender, Nameable, Persistent | ||
| default net.kyori.adventure.text.event.HoverEvent<net.kyori.adventure.text.event.HoverEvent.ShowEntity> asHoverEvent(final @NotNull java.util.function.UnaryOperator<net.kyori.adventure.text.event.HoverEvent.ShowEntity> op) { | ||
| return net.kyori.adventure.text.event.HoverEvent.showEntity(op.apply(net.kyori.adventure.text.event.HoverEvent.ShowEntity.of(this.getType().getKey(), this.getUniqueId(), this.customName()))); | ||
| } | ||
| + | ||
| + /** | ||
| + * Gets the location where this entity originates from. | ||
| + * <p> | ||
| + * This value can be null if the entity hasn't yet been added to the world. | ||
| + * | ||
| + * @return Location where entity originates or null if not yet added | ||
| + */ | ||
| + @Nullable | ||
| + Location getOrigin(); | ||
| // Paper end | ||
| } | ||
| diff --git a/src/main/java/org/bukkit/entity/FallingBlock.java b/src/main/java/org/bukkit/entity/FallingBlock.java | ||
| index 64f9d3fd870d65afd2ee9a85625b149163eee144..14cb0d770561151570ab4399ca5facff43076819 100644 | ||
| --- a/src/main/java/org/bukkit/entity/FallingBlock.java | ||
| +++ b/src/main/java/org/bukkit/entity/FallingBlock.java | ||
| @@ -54,4 +54,15 @@ public interface FallingBlock extends Entity { | ||
| * @param hurtEntities whether entities will be damaged by this block. | ||
| */ | ||
| void setHurtEntities(boolean hurtEntities); | ||
| + | ||
| + /** | ||
| + * Gets the source block location of the FallingBlock | ||
| + * | ||
| + * @return the source block location the FallingBlock was spawned from | ||
| + * @deprecated replaced by {@link Entity#getOrigin()} | ||
| + */ | ||
| + @Deprecated | ||
| + default org.bukkit.Location getSourceLoc() { | ||
| + return this.getOrigin(); | ||
| + } | ||
| } | ||
| diff --git a/src/main/java/org/bukkit/entity/TNTPrimed.java b/src/main/java/org/bukkit/entity/TNTPrimed.java | ||
| index a23cfdf66877f0a61eae700de084c76e6ee7b431..0813bd913c8fdb2001963ce3e82c07c2af105418 100644 | ||
| --- a/src/main/java/org/bukkit/entity/TNTPrimed.java | ||
| +++ b/src/main/java/org/bukkit/entity/TNTPrimed.java | ||
| @@ -53,4 +53,15 @@ public interface TNTPrimed extends Explosive { | ||
| * @param source the source of this primed TNT | ||
| */ | ||
| public void setSource(@Nullable Entity source); | ||
| + | ||
| + /** | ||
| + * Gets the source block location of the TNTPrimed | ||
| + * | ||
| + * @return the source block location the TNTPrimed was spawned from | ||
| + * @deprecated replaced by {@link Entity#getOrigin()} | ||
| + */ | ||
| + @Deprecated | ||
| + default org.bukkit.Location getSourceLoc() { | ||
| + return this.getOrigin(); | ||
| + } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,185 @@ | ||
| From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
| From: Zach Brown <zach@zachbr.io> | ||
| Date: Mon, 27 May 2019 01:10:06 -0500 | ||
| Subject: [PATCH] Version Command 2.0 | ||
|
|
||
|
|
||
| diff --git a/src/main/java/com/destroystokyo/paper/util/VersionFetcher.java b/src/main/java/com/destroystokyo/paper/util/VersionFetcher.java | ||
| new file mode 100644 | ||
| index 0000000000000000000000000000000000000000..a736d7bcdc5861a01b66ba36158db1c716339346 | ||
| --- /dev/null | ||
| +++ b/src/main/java/com/destroystokyo/paper/util/VersionFetcher.java | ||
| @@ -0,0 +1,45 @@ | ||
| +package com.destroystokyo.paper.util; | ||
| + | ||
| +import net.kyori.adventure.text.Component; | ||
| +import net.kyori.adventure.text.format.NamedTextColor; | ||
| +import org.bukkit.Bukkit; | ||
| +import org.jetbrains.annotations.NotNull; | ||
| + | ||
| +public interface VersionFetcher { | ||
| + /** | ||
| + * Amount of time to cache results for in milliseconds | ||
| + * <p> | ||
| + * Negative values will never cache. | ||
| + * | ||
| + * @return cache time | ||
| + */ | ||
| + long getCacheTime(); | ||
| + | ||
| + /** | ||
| + * Gets the version message to cache and show to command senders. | ||
| + * | ||
| + * <p>NOTE: This is run in a new thread separate from that of the command processing thread</p> | ||
| + * | ||
| + * @param serverVersion the current version of the server (will match {@link Bukkit#getVersion()}) | ||
| + * @return the message to show when requesting a version | ||
| + */ | ||
| + @NotNull | ||
| + Component getVersionMessage(@NotNull String serverVersion); | ||
| + | ||
| + class DummyVersionFetcher implements VersionFetcher { | ||
| + | ||
| + @Override | ||
| + public long getCacheTime() { | ||
| + return -1; | ||
| + } | ||
| + | ||
| + @NotNull | ||
| + @Override | ||
| + public Component getVersionMessage(@NotNull String serverVersion) { | ||
| + Bukkit.getLogger().warning("Version provider has not been set, cannot check for updates!"); | ||
| + Bukkit.getLogger().info("Override the default implementation of org.bukkit.UnsafeValues#getVersionFetcher()"); | ||
| + new Throwable().printStackTrace(); | ||
| + return Component.text("Unable to check for updates. No version provider set.", NamedTextColor.RED); | ||
| + } | ||
| + } | ||
| +} | ||
| diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java | ||
| index 207c656c0a11a3a630bc70491efcf433b2681e18..195b6bb328de92c4d17d1cd14e13578226b1ac3c 100644 | ||
| --- a/src/main/java/org/bukkit/UnsafeValues.java | ||
| +++ b/src/main/java/org/bukkit/UnsafeValues.java | ||
| @@ -84,5 +84,12 @@ public interface UnsafeValues { | ||
| * @return name | ||
| */ | ||
| String getTimingsServerName(); | ||
| + | ||
| + /** | ||
| + * Called once by the version command on first use, then cached. | ||
| + */ | ||
| + default com.destroystokyo.paper.util.VersionFetcher getVersionFetcher() { | ||
| + return new com.destroystokyo.paper.util.VersionFetcher.DummyVersionFetcher(); | ||
| + } | ||
| // Paper end | ||
| } | ||
| diff --git a/src/main/java/org/bukkit/command/defaults/VersionCommand.java b/src/main/java/org/bukkit/command/defaults/VersionCommand.java | ||
| index 2305eb40832a82159cd89162934870cf57e1aa0e..4c2ddc722a9dc4011906ad9530b13fa9be1d3ff9 100644 | ||
| --- a/src/main/java/org/bukkit/command/defaults/VersionCommand.java | ||
| +++ b/src/main/java/org/bukkit/command/defaults/VersionCommand.java | ||
| @@ -1,5 +1,6 @@ | ||
| package org.bukkit.command.defaults; | ||
|
|
||
| +import com.destroystokyo.paper.util.VersionFetcher; // Paper - version supplier | ||
| import com.google.common.base.Charsets; | ||
| import com.google.common.collect.ImmutableList; | ||
| import com.google.common.io.Resources; | ||
| @@ -16,6 +17,7 @@ import java.util.HashSet; | ||
| import java.util.List; | ||
| import java.util.Set; | ||
| import java.util.concurrent.locks.ReentrantLock; | ||
| +import net.kyori.adventure.text.Component; // Paper | ||
| import org.apache.commons.lang.Validate; | ||
| import org.bukkit.Bukkit; | ||
| import org.bukkit.ChatColor; | ||
| @@ -26,6 +28,15 @@ import org.bukkit.util.StringUtil; | ||
| import org.jetbrains.annotations.NotNull; | ||
|
|
||
| public class VersionCommand extends BukkitCommand { | ||
| + private VersionFetcher versionFetcher; | ||
| + private VersionFetcher getVersionFetcher() { // lazy load because unsafe isn't available at command registration | ||
| + if (versionFetcher == null) { | ||
| + versionFetcher = Bukkit.getUnsafe().getVersionFetcher(); | ||
| + } | ||
| + | ||
| + return versionFetcher; | ||
| + } | ||
| + | ||
| public VersionCommand(@NotNull String name) { | ||
| super(name); | ||
|
|
||
| @@ -40,7 +51,7 @@ public class VersionCommand extends BukkitCommand { | ||
| if (!testPermission(sender)) return true; | ||
|
|
||
| if (args.length == 0) { | ||
| - sender.sendMessage("This server is running " + Bukkit.getName() + " version " + Bukkit.getVersion() + " (Implementing API version " + Bukkit.getBukkitVersion() + ")"); | ||
| + //sender.sendMessage("This server is running " + Bukkit.getName() + " version " + Bukkit.getVersion() + " (Implementing API version " + Bukkit.getBukkitVersion() + ")"); // Paper - moved to setVersionMessage | ||
| sendVersion(sender); | ||
| } else { | ||
| StringBuilder name = new StringBuilder(); | ||
| @@ -146,14 +157,14 @@ public class VersionCommand extends BukkitCommand { | ||
|
|
||
| private final ReentrantLock versionLock = new ReentrantLock(); | ||
| private boolean hasVersion = false; | ||
| - private String versionMessage = null; | ||
| + private Component versionMessage = null; // Paper | ||
| private final Set<CommandSender> versionWaiters = new HashSet<CommandSender>(); | ||
| private boolean versionTaskStarted = false; | ||
| private long lastCheck = 0; | ||
|
|
||
| private void sendVersion(@NotNull CommandSender sender) { | ||
| if (hasVersion) { | ||
| - if (System.currentTimeMillis() - lastCheck > 21600000) { | ||
| + if (System.currentTimeMillis() - lastCheck > getVersionFetcher().getCacheTime()) { // Paper - use version supplier | ||
| lastCheck = System.currentTimeMillis(); | ||
| hasVersion = false; | ||
| } else { | ||
| @@ -168,7 +179,7 @@ public class VersionCommand extends BukkitCommand { | ||
| return; | ||
| } | ||
| versionWaiters.add(sender); | ||
| - sender.sendMessage("Checking version, please wait..."); | ||
| + sender.sendMessage(Component.text("Checking version, please wait...", net.kyori.adventure.text.format.NamedTextColor.WHITE, net.kyori.adventure.text.format.TextDecoration.ITALIC)); // Paper | ||
| if (!versionTaskStarted) { | ||
| versionTaskStarted = true; | ||
| new Thread(new Runnable() { | ||
| @@ -186,6 +197,13 @@ public class VersionCommand extends BukkitCommand { | ||
|
|
||
| private void obtainVersion() { | ||
| String version = Bukkit.getVersion(); | ||
| + // Paper start | ||
| + if (version.startsWith("null")) { // running from ide? | ||
| + setVersionMessage(Component.text("Unknown version, custom build?", net.kyori.adventure.text.format.NamedTextColor.YELLOW)); | ||
| + return; | ||
| + } | ||
| + setVersionMessage(getVersionFetcher().getVersionMessage(version)); | ||
| + /* | ||
| if (version == null) version = "Custom"; | ||
| String[] parts = version.substring(0, version.indexOf(' ')).split("-"); | ||
| if (parts.length == 4) { | ||
| @@ -215,11 +233,24 @@ public class VersionCommand extends BukkitCommand { | ||
| } else { | ||
| setVersionMessage("Unknown version, custom build?"); | ||
| } | ||
| + */ | ||
| + // Paper end | ||
| } | ||
|
|
||
| - private void setVersionMessage(@NotNull String msg) { | ||
| + // Paper start | ||
| + private void setVersionMessage(final @NotNull Component msg) { | ||
| lastCheck = System.currentTimeMillis(); | ||
| - versionMessage = msg; | ||
| + final Component message = net.kyori.adventure.text.TextComponent.ofChildren( | ||
| + Component.text("This server is running " + Bukkit.getName() + " version " + Bukkit.getVersion() + " (Implementing API version " + Bukkit.getBukkitVersion() + ")", net.kyori.adventure.text.format.NamedTextColor.WHITE), | ||
| + Component.newline(), | ||
| + msg | ||
| + ); | ||
| + this.versionMessage = Component.text() | ||
| + .append(message) | ||
| + .hoverEvent(Component.text("Click to copy to clipboard", net.kyori.adventure.text.format.NamedTextColor.WHITE)) | ||
| + .clickEvent(net.kyori.adventure.text.event.ClickEvent.copyToClipboard(net.kyori.adventure.text.serializer.plain.PlainComponentSerializer.plain().serialize(message))) | ||
| + .build(); | ||
| + // Paper end | ||
| versionLock.lock(); | ||
| try { | ||
| hasVersion = true; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
| From: Isaac Moore <rmsy@me.com> | ||
| Date: Mon, 29 Feb 2016 18:02:25 -0600 | ||
| Subject: [PATCH] Add PlayerLocaleChangeEvent | ||
|
|
||
|
|
||
| diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerLocaleChangeEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerLocaleChangeEvent.java | ||
| new file mode 100644 | ||
| index 0000000000000000000000000000000000000000..29dd763a99ce7c6ecb176b9fb346a400369d48a0 | ||
| --- /dev/null | ||
| +++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerLocaleChangeEvent.java | ||
| @@ -0,0 +1,50 @@ | ||
| +package com.destroystokyo.paper.event.player; | ||
| + | ||
| +import org.bukkit.entity.Player; | ||
| +import org.bukkit.event.HandlerList; | ||
| +import org.bukkit.event.player.PlayerEvent; | ||
| + | ||
| +/** | ||
| + * Called when the locale of the player is changed. | ||
| + * | ||
| + * @deprecated Replaced by {@link org.bukkit.event.player.PlayerLocaleChangeEvent} upstream | ||
| + */ | ||
| +@Deprecated | ||
| +public class PlayerLocaleChangeEvent extends PlayerEvent { | ||
| + private static final HandlerList handlers = new HandlerList(); | ||
| + private final String oldLocale; | ||
| + private final String newLocale; | ||
| + | ||
| + public PlayerLocaleChangeEvent(final Player player, final String oldLocale, final String newLocale) { | ||
| + super(player); | ||
| + this.oldLocale = oldLocale; | ||
| + this.newLocale = newLocale; | ||
| + } | ||
| + | ||
| + /** | ||
| + * Gets the locale the player switched from. | ||
| + * | ||
| + * @return player's old locale | ||
| + */ | ||
| + public String getOldLocale() { | ||
| + return oldLocale; | ||
| + } | ||
| + | ||
| + /** | ||
| + * Gets the locale the player is changed to. | ||
| + * | ||
| + * @return player's new locale | ||
| + */ | ||
| + public String getNewLocale() { | ||
| + return newLocale; | ||
| + } | ||
| + | ||
| + @Override | ||
| + public HandlerList getHandlers() { | ||
| + return handlers; | ||
| + } | ||
| + | ||
| + public static HandlerList getHandlerList() { | ||
| + return handlers; | ||
| + } | ||
| +} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
| From: Byteflux <byte@byteflux.net> | ||
| Date: Mon, 29 Feb 2016 18:05:37 -0600 | ||
| Subject: [PATCH] Add player view distance API | ||
|
|
||
|
|
||
| diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java | ||
| index 76ac0b20842002ce1b593e338bea98483e7080ac..f34601480a3b3069c30c52d258a35a2a79c981fb 100644 | ||
| --- a/src/main/java/org/bukkit/entity/Player.java | ||
| +++ b/src/main/java/org/bukkit/entity/Player.java | ||
| @@ -1394,6 +1394,28 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM | ||
| * @param affects Whether the player can affect mob spawning | ||
| */ | ||
| public void setAffectsSpawning(boolean affects); | ||
| + | ||
| + /** | ||
| + * Gets the view distance for this player | ||
| + * | ||
| + * @return the player's view distance | ||
| + * @deprecated This is unimplemented and <i>will</i> throw an exception at runtime. The {@link org.bukkit.World World}-based methods still work. | ||
| + * @see org.bukkit.World#getViewDistance() | ||
| + * @see org.bukkit.World#getNoTickViewDistance() | ||
| + */ | ||
| + @Deprecated | ||
| + public int getViewDistance(); | ||
| + | ||
| + /** | ||
| + * Sets the view distance for this player | ||
| + * | ||
| + * @param viewDistance the player's view distance | ||
| + * @deprecated This is unimplemented and <i>will</i> throw an exception at runtime. The {@link org.bukkit.World World}-based methods still work. | ||
| + * @see org.bukkit.World#setViewDistance(int) | ||
| + * @see org.bukkit.World#setNoTickViewDistance(int) | ||
| + */ | ||
| + @Deprecated | ||
| + public void setViewDistance(int viewDistance); | ||
| // Paper end | ||
|
|
||
| /** |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
| From: Byteflux <byte@byteflux.net> | ||
| Date: Mon, 29 Feb 2016 18:09:40 -0600 | ||
| Subject: [PATCH] Add BeaconEffectEvent | ||
|
|
||
|
|
||
| diff --git a/src/main/java/com/destroystokyo/paper/event/block/BeaconEffectEvent.java b/src/main/java/com/destroystokyo/paper/event/block/BeaconEffectEvent.java | ||
| new file mode 100644 | ||
| index 0000000000000000000000000000000000000000..978813b94a5eae0afccbd3b38b463091a46b56ac | ||
| --- /dev/null | ||
| +++ b/src/main/java/com/destroystokyo/paper/event/block/BeaconEffectEvent.java | ||
| @@ -0,0 +1,86 @@ | ||
| +package com.destroystokyo.paper.event.block; | ||
| + | ||
| +import org.bukkit.block.Block; | ||
| +import org.bukkit.entity.Player; | ||
| +import org.bukkit.event.Cancellable; | ||
| +import org.bukkit.event.HandlerList; | ||
| +import org.bukkit.event.block.BlockEvent; | ||
| +import org.bukkit.potion.PotionEffect; | ||
| +import org.jetbrains.annotations.NotNull; | ||
| + | ||
| +/** | ||
| + * Called when a beacon effect is being applied to a player. | ||
| + */ | ||
| +public class BeaconEffectEvent extends BlockEvent implements Cancellable { | ||
| + private static final HandlerList handlers = new HandlerList(); | ||
| + private boolean cancelled; | ||
| + private PotionEffect effect; | ||
| + private Player player; | ||
| + private boolean primary; | ||
| + | ||
| + public BeaconEffectEvent(@NotNull Block block, @NotNull PotionEffect effect, @NotNull Player player, boolean primary) { | ||
| + super(block); | ||
| + this.effect = effect; | ||
| + this.player = player; | ||
| + this.primary = primary; | ||
| + } | ||
| + | ||
| + @Override | ||
| + public boolean isCancelled() { | ||
| + return cancelled; | ||
| + } | ||
| + | ||
| + @Override | ||
| + public void setCancelled(boolean cancelled) { | ||
| + this.cancelled = cancelled; | ||
| + } | ||
| + | ||
| + /** | ||
| + * Gets the potion effect being applied. | ||
| + * | ||
| + * @return Potion effect | ||
| + */ | ||
| + @NotNull | ||
| + public PotionEffect getEffect() { | ||
| + return effect; | ||
| + } | ||
| + | ||
| + /** | ||
| + * Sets the potion effect that will be applied. | ||
| + * | ||
| + * @param effect Potion effect | ||
| + */ | ||
| + public void setEffect(@NotNull PotionEffect effect) { | ||
| + this.effect = effect; | ||
| + } | ||
| + | ||
| + /** | ||
| + * Gets the player who the potion effect is being applied to. | ||
| + * | ||
| + * @return Affected player | ||
| + */ | ||
| + @NotNull | ||
| + public Player getPlayer() { | ||
| + return player; | ||
| + } | ||
| + | ||
| + /** | ||
| + * Gets whether the effect is a primary beacon effect. | ||
| + * | ||
| + * @return true if this event represents a primary effect | ||
| + */ | ||
| + public boolean isPrimary() { | ||
| + return primary; | ||
| + } | ||
| + | ||
| + @NotNull | ||
| + @Override | ||
| + public HandlerList getHandlers() { | ||
| + return handlers; | ||
| + } | ||
| + | ||
| + @NotNull | ||
| + public static HandlerList getHandlerList() { | ||
| + return handlers; | ||
| + } | ||
| +} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
| From: Steve Anton <anxuiz.nx@gmail.com> | ||
| Date: Mon, 29 Feb 2016 18:13:58 -0600 | ||
| Subject: [PATCH] Add PlayerInitialSpawnEvent | ||
|
|
||
| For modifying a player's initial spawn location as they join the server | ||
|
|
||
| diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerInitialSpawnEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerInitialSpawnEvent.java | ||
| new file mode 100644 | ||
| index 0000000000000000000000000000000000000000..8b1fdb9d2869d4c1862d557c91bf8a1d8c537507 | ||
| --- /dev/null | ||
| +++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerInitialSpawnEvent.java | ||
| @@ -0,0 +1,16 @@ | ||
| +package com.destroystokyo.paper.event.player; | ||
| + | ||
| +import org.bukkit.Location; | ||
| +import org.bukkit.entity.Player; | ||
| +import org.jetbrains.annotations.NotNull; | ||
| +import org.spigotmc.event.player.PlayerSpawnLocationEvent; | ||
| + | ||
| +/** | ||
| + * @deprecated Use {@link PlayerSpawnLocationEvent}, Duplicate API | ||
| + */ | ||
| +public class PlayerInitialSpawnEvent extends PlayerSpawnLocationEvent { | ||
| + | ||
| + public PlayerInitialSpawnEvent(@NotNull Player who, @NotNull Location spawnLocation) { | ||
| + super(who, spawnLocation); | ||
| + } | ||
| +} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
| From: Aikar <aikar@aikar.co> | ||
| Date: Mon, 29 Feb 2016 19:45:21 -0600 | ||
| Subject: [PATCH] Automatically disable plugins that fail to load | ||
|
|
||
|
|
||
| diff --git a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java | ||
| index cf2f517765d8f2a23cc4a17d9ee2dcd81f841b1b..2e306c7b984a02e12a74fac14589bf29ab6488bf 100644 | ||
| --- a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java | ||
| +++ b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java | ||
| @@ -335,6 +335,10 @@ public final class JavaPluginLoader implements PluginLoader { | ||
| jPlugin.setEnabled(true); | ||
| } catch (Throwable ex) { | ||
| server.getLogger().log(Level.SEVERE, "Error occurred while enabling " + plugin.getDescription().getFullName() + " (Is it up to date?)", ex); | ||
| + // Paper start - Disable plugins that fail to load | ||
| + disablePlugin(jPlugin); | ||
| + return; | ||
| + // Paper end | ||
| } | ||
|
|
||
| // Perhaps abort here, rather than continue going, but as it stands, |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
| From: kashike <kashike@vq.lc> | ||
| Date: Mon, 29 Feb 2016 19:48:59 -0600 | ||
| Subject: [PATCH] Expose server CommandMap | ||
|
|
||
|
|
||
| diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java | ||
| index 0636edd8d9121eabfa60957c8c224261d228a16b..8d707e117035d5bc0d8c9a5fd386ee8355359259 100644 | ||
| --- a/src/main/java/org/bukkit/Bukkit.java | ||
| +++ b/src/main/java/org/bukkit/Bukkit.java | ||
| @@ -1717,6 +1717,19 @@ public final class Bukkit { | ||
| return server.getUnsafe(); | ||
| } | ||
|
|
||
| + | ||
| + // Paper start | ||
| + /** | ||
| + * Gets the active {@link org.bukkit.command.CommandMap} | ||
| + * | ||
| + * @return the active command map | ||
| + */ | ||
| + @NotNull | ||
| + public static org.bukkit.command.CommandMap getCommandMap() { | ||
| + return server.getCommandMap(); | ||
| + } | ||
| + // Paper end | ||
| + | ||
| @NotNull | ||
| public static Server.Spigot spigot() { | ||
| return server.spigot(); | ||
| diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java | ||
| index 5c638e0d45e8896382bdbf9b9c10474b05a97df5..24bcc63afbda5f27aad385dc707f262d1a3a3399 100644 | ||
| --- a/src/main/java/org/bukkit/Server.java | ||
| +++ b/src/main/java/org/bukkit/Server.java | ||
| @@ -1311,6 +1311,15 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi | ||
| public double[] getTPS(); | ||
| // Paper end | ||
|
|
||
| + // Paper start | ||
| + /** | ||
| + * Gets the active {@link org.bukkit.command.CommandMap} | ||
| + * | ||
| + * @return the active command map | ||
| + */ | ||
| + @NotNull | ||
| + org.bukkit.command.CommandMap getCommandMap(); | ||
| + | ||
| /** | ||
| * Get the advancement specified by this key. | ||
| * |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,124 @@ | ||
| From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
| From: Zach Brown <zach.brown@destroystokyo.com> | ||
| Date: Mon, 29 Feb 2016 19:54:32 -0600 | ||
| Subject: [PATCH] Graduate bungeecord chat API from spigot subclasses | ||
|
|
||
| Change Javadoc to be accurate | ||
|
|
||
| diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java | ||
| index 10274053320f1ec690a65d3794abb44b58658059..22b83b142de97dcba28fa9a49730de7880d0b5d2 100644 | ||
| --- a/src/main/java/org/bukkit/Bukkit.java | ||
| +++ b/src/main/java/org/bukkit/Bukkit.java | ||
| @@ -285,6 +285,30 @@ public final class Bukkit { | ||
| return server.broadcastMessage(message); | ||
| } | ||
|
|
||
| + // Paper start | ||
| + /** | ||
| + * Sends the component to all online players. | ||
| + * | ||
| + * @param component the component to send | ||
| + * @deprecated use {@code sendMessage} methods on {@link #getServer()} that accept {@link net.kyori.adventure.text.Component} | ||
| + */ | ||
| + @Deprecated | ||
| + public static void broadcast(@NotNull net.md_5.bungee.api.chat.BaseComponent component) { | ||
| + server.broadcast(component); | ||
| + } | ||
| + | ||
| + /** | ||
| + * Sends an array of components as a single message to all online players. | ||
| + * | ||
| + * @param components the components to send | ||
| + * @deprecated use {@code sendMessage} methods on {@link #getServer()} that accept {@link net.kyori.adventure.text.Component} | ||
| + */ | ||
| + @Deprecated | ||
| + public static void broadcast(@NotNull net.md_5.bungee.api.chat.BaseComponent... components) { | ||
| + server.broadcast(components); | ||
| + } | ||
| + // Paper end | ||
| + | ||
| /** | ||
| * Gets the name of the update folder. The update folder is used to safely | ||
| * update plugins at the right moment on a plugin load. | ||
| diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java | ||
| index 7e4a728ceb943b6a32b9ba9b84bada34e71c0980..9ce9b4ce2da6c57c62607502ae2042e30fc26d88 100644 | ||
| --- a/src/main/java/org/bukkit/Server.java | ||
| +++ b/src/main/java/org/bukkit/Server.java | ||
| @@ -234,6 +234,30 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi | ||
| @Deprecated // Paper | ||
| public int broadcastMessage(@NotNull String message); | ||
|
|
||
| + // Paper start | ||
| + /** | ||
| + * Sends the component to all online players. | ||
| + * | ||
| + * @param component the component to send | ||
| + * @deprecated use {@code sendMessage} methods that accept {@link net.kyori.adventure.text.Component} | ||
| + */ | ||
| + @Deprecated | ||
| + public default void broadcast(@NotNull net.md_5.bungee.api.chat.BaseComponent component) { | ||
| + spigot().broadcast(component); | ||
| + } | ||
| + | ||
| + /** | ||
| + * Sends an array of components as a single message to all online players. | ||
| + * | ||
| + * @param components the components to send | ||
| + * @deprecated use {@code sendMessage} methods that accept {@link net.kyori.adventure.text.Component} | ||
| + */ | ||
| + @Deprecated | ||
| + public default void broadcast(@NotNull net.md_5.bungee.api.chat.BaseComponent... components) { | ||
| + spigot().broadcast(components); | ||
| + } | ||
| + // Paper end | ||
| + | ||
| /** | ||
| * Gets the name of the update folder. The update folder is used to safely | ||
| * update plugins at the right moment on a plugin load. | ||
| diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java | ||
| index 68795a48cb15d322906ce0569b7701231c1f94c2..88853cc165c67fd60a0a8f87e4ce356e4ca045f9 100644 | ||
| --- a/src/main/java/org/bukkit/entity/Player.java | ||
| +++ b/src/main/java/org/bukkit/entity/Player.java | ||
| @@ -614,6 +614,42 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM | ||
| */ | ||
| public void sendMap(@NotNull MapView map); | ||
|
|
||
| + // Paper start | ||
| + /** | ||
| + * Sends the component to the player | ||
| + * | ||
| + * @param component the components to send | ||
| + * @deprecated use {@code sendMessage} methods that accept {@link net.kyori.adventure.text.Component} | ||
| + */ | ||
| + @Override | ||
| + @Deprecated | ||
| + public default void sendMessage(@NotNull net.md_5.bungee.api.chat.BaseComponent component) { | ||
| + spigot().sendMessage(component); | ||
| + } | ||
| + | ||
| + /** | ||
| + * Sends an array of components as a single message to the player | ||
| + * | ||
| + * @param components the components to send | ||
| + * @deprecated use {@code sendMessage} methods that accept {@link net.kyori.adventure.text.Component} | ||
| + */ | ||
| + @Override | ||
| + @Deprecated | ||
| + public default void sendMessage(@NotNull net.md_5.bungee.api.chat.BaseComponent... components) { | ||
| + spigot().sendMessage(components); | ||
| + } | ||
| + | ||
| + /** | ||
| + * Sends an array of components as a single message to the specified screen position of this player | ||
| + * | ||
| + * @param position the screen position | ||
| + * @param components the components to send | ||
| + */ | ||
| + public default void sendMessage(net.md_5.bungee.api.ChatMessageType position, net.md_5.bungee.api.chat.BaseComponent... components) { | ||
| + spigot().sendMessage(position, components); | ||
| + } | ||
| + // Paper end | ||
| + | ||
| /** | ||
| * Forces an update of the player's entire inventory. | ||
| * |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
| From: Aikar <aikar@aikar.co> | ||
| Date: Mon, 29 Feb 2016 20:26:39 -0600 | ||
| Subject: [PATCH] Fix ServerListPingEvent flagging as Async | ||
|
|
||
| This event can sometimes fire Async, set the proper boolean | ||
|
|
||
| diff --git a/src/main/java/org/bukkit/event/server/ServerEvent.java b/src/main/java/org/bukkit/event/server/ServerEvent.java | ||
| index 46b119017a1e3dfcd9ae5fb91b4fe8c20b0d6b86..05167fb34e4c42edc67af6e6700a2a3cc0f92769 100644 | ||
| --- a/src/main/java/org/bukkit/event/server/ServerEvent.java | ||
| +++ b/src/main/java/org/bukkit/event/server/ServerEvent.java | ||
| @@ -1,5 +1,6 @@ | ||
| package org.bukkit.event.server; | ||
|
|
||
| +import org.bukkit.Bukkit; | ||
| import org.bukkit.event.Event; | ||
|
|
||
| /** | ||
| @@ -8,7 +9,7 @@ import org.bukkit.event.Event; | ||
| public abstract class ServerEvent extends Event { | ||
|
|
||
| public ServerEvent() { | ||
| - super(); | ||
| + super(!Bukkit.isPrimaryThread()); // Paper | ||
| } | ||
|
|
||
| public ServerEvent(boolean isAsync) { |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
| From: kashike <kashike@vq.lc> | ||
| Date: Tue, 8 Mar 2016 13:05:59 -0800 | ||
| Subject: [PATCH] Add BaseComponent sendMessage methods to CommandSender | ||
|
|
||
|
|
||
| diff --git a/src/main/java/org/bukkit/command/CommandSender.java b/src/main/java/org/bukkit/command/CommandSender.java | ||
| index c88418c7aa19b4fecdfa9af3d18ff202a5dc5763..fb0e608fa92dae99b9eee8fc1cbdf4b91a33e620 100644 | ||
| --- a/src/main/java/org/bukkit/command/CommandSender.java | ||
| +++ b/src/main/java/org/bukkit/command/CommandSender.java | ||
| @@ -1,6 +1,9 @@ | ||
| package org.bukkit.command; | ||
|
|
||
| import java.util.UUID; | ||
| +import net.kyori.adventure.audience.MessageType; | ||
| +import net.kyori.adventure.identity.Identity; | ||
| +import net.kyori.adventure.text.Component; | ||
| import org.bukkit.Server; | ||
| import org.bukkit.permissions.Permissible; | ||
| import org.jetbrains.annotations.NotNull; | ||
| @@ -117,5 +120,33 @@ public interface CommandSender extends net.kyori.adventure.audience.Audience, Pe | ||
| default void sendMessage(final @NotNull net.kyori.adventure.identity.Identity identity, final @NotNull net.kyori.adventure.text.Component message, final @NotNull net.kyori.adventure.audience.MessageType type) { | ||
| this.sendMessage(org.bukkit.Bukkit.getUnsafe().legacyComponentSerializer().serialize(message)); | ||
| } | ||
| + | ||
| + /** | ||
| + * Sends the component to the sender | ||
| + * | ||
| + * <p>If this sender does not support sending full components then | ||
| + * the component will be sent as legacy text.</p> | ||
| + * | ||
| + * @param component the component to send | ||
| + * @deprecated use {@link #sendMessage(Identity, Component, MessageType)} instead | ||
| + */ | ||
| + @Deprecated | ||
| + default void sendMessage(@NotNull net.md_5.bungee.api.chat.BaseComponent component) { | ||
| + this.sendMessage(component.toLegacyText()); | ||
| + } | ||
| + | ||
| + /** | ||
| + * Sends an array of components as a single message to the sender | ||
| + * | ||
| + * <p>If this sender does not support sending full components then | ||
| + * the components will be sent as legacy text.</p> | ||
| + * | ||
| + * @param components the components to send | ||
| + * @deprecated use {@link #sendMessage(Identity, Component, MessageType)} instead | ||
| + */ | ||
| + @Deprecated | ||
| + default void sendMessage(@NotNull net.md_5.bungee.api.chat.BaseComponent... components) { | ||
| + this.sendMessage(new net.md_5.bungee.api.chat.TextComponent(components).toLegacyText()); | ||
| + } | ||
| // Paper end | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
| From: mrapple <tony@oc.tc> | ||
| Date: Sun, 25 Nov 2012 13:47:27 -0600 | ||
| Subject: [PATCH] Add methods for working with arrows stuck in living entities | ||
|
|
||
|
|
||
| diff --git a/src/main/java/org/bukkit/entity/LivingEntity.java b/src/main/java/org/bukkit/entity/LivingEntity.java | ||
| index 24c858182f25496cc7254f7cf9e996b3bea1f9ec..45e9f585c3e522ecf94a6bc42cdc190e1a191a5c 100644 | ||
| --- a/src/main/java/org/bukkit/entity/LivingEntity.java | ||
| +++ b/src/main/java/org/bukkit/entity/LivingEntity.java | ||
| @@ -605,4 +605,19 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource | ||
| * @return Whether the entity is invisible | ||
| */ | ||
| public boolean isInvisible(); | ||
| + | ||
| + // Paper start | ||
| + /** | ||
| + * Get the number of arrows stuck in this entity | ||
| + * @return Number of arrows stuck | ||
| + */ | ||
| + int getArrowsStuck(); | ||
| + | ||
| + /** | ||
| + * Set the number of arrows stuck in this entity | ||
| + * | ||
| + * @param arrows Number of arrows to stick in this entity | ||
| + */ | ||
| + void setArrowsStuck(int arrows); | ||
| + // Paper end | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,118 @@ | ||
| From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
| From: Jedediah Smith <jedediah@silencegreys.com> | ||
| Date: Sat, 4 Apr 2015 22:59:54 -0400 | ||
| Subject: [PATCH] Complete resource pack API | ||
|
|
||
|
|
||
| diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java | ||
| index 769ad98fd7a6a866b320e1ccffd7962228d564cf..ddbe5734ac0f905b0c388e30f17a281530b82262 100644 | ||
| --- a/src/main/java/org/bukkit/entity/Player.java | ||
| +++ b/src/main/java/org/bukkit/entity/Player.java | ||
| @@ -1124,7 +1124,9 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM | ||
| * @throws IllegalArgumentException Thrown if the URL is null. | ||
| * @throws IllegalArgumentException Thrown if the URL is too long. The | ||
| * length restriction is an implementation specific arbitrary value. | ||
| + * @deprecated use {@link #setResourcePack(String, String)} | ||
| */ | ||
| + @Deprecated // Paper | ||
| public void setResourcePack(@NotNull String url); | ||
|
|
||
| /** | ||
| @@ -1601,6 +1603,60 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM | ||
| default net.kyori.adventure.text.event.HoverEvent<net.kyori.adventure.text.event.HoverEvent.ShowEntity> asHoverEvent(final @NotNull java.util.function.UnaryOperator<net.kyori.adventure.text.event.HoverEvent.ShowEntity> op) { | ||
| return net.kyori.adventure.text.event.HoverEvent.showEntity(op.apply(net.kyori.adventure.text.event.HoverEvent.ShowEntity.of(this.getType().getKey(), this.getUniqueId(), this.displayName()))); | ||
| } | ||
| + | ||
| + /** | ||
| + * Request that the player's client download and switch resource packs. | ||
| + * <p> | ||
| + * The player's client will download the new resource pack asynchronously | ||
| + * in the background, and will automatically switch to it once the | ||
| + * download is complete. If the client has downloaded and cached the same | ||
| + * resource pack in the past, it will perform a quick timestamp check | ||
| + * over the network to determine if the resource pack has changed and | ||
| + * needs to be downloaded again. When this request is sent for the very | ||
| + * first time from a given server, the client will first display a | ||
| + * confirmation GUI to the player before proceeding with the download. | ||
| + * <p> | ||
| + * Notes: | ||
| + * <ul> | ||
| + * <li>Players can disable server resources on their client, in which | ||
| + * case this method will have no affect on them. | ||
| + * <li>There is no concept of resetting resource packs back to default | ||
| + * within Minecraft, so players will have to relog to do so. | ||
| + * </ul> | ||
| + * | ||
| + * @param url The URL from which the client will download the resource | ||
| + * pack. The string must contain only US-ASCII characters and should | ||
| + * be encoded as per RFC 1738. | ||
| + * @param hash A 40 character hexadecimal and lowercase SHA-1 digest of | ||
| + * the resource pack file. | ||
| + * @throws IllegalArgumentException Thrown if the URL is null. | ||
| + * @throws IllegalArgumentException Thrown if the URL is too long. The | ||
| + * length restriction is an implementation specific arbitrary value. | ||
| + */ | ||
| + void setResourcePack(@NotNull String url, @NotNull String hash); | ||
| + | ||
| + /** | ||
| + * @return the most recent resource pack status received from the player, | ||
| + * or null if no status has ever been received from this player. | ||
| + */ | ||
| + @Nullable | ||
| + org.bukkit.event.player.PlayerResourcePackStatusEvent.Status getResourcePackStatus(); | ||
| + | ||
| + /** | ||
| + * @return the most recent resource pack hash received from the player, | ||
| + * or null if no hash has ever been received from this player. | ||
| + * | ||
| + * @deprecated This is no longer sent from the client and will always be null | ||
| + */ | ||
| + @Nullable | ||
| + @Deprecated | ||
| + String getResourcePackHash(); | ||
| + | ||
| + /** | ||
| + * @return true if the last resource pack status received from this player | ||
| + * was {@link org.bukkit.event.player.PlayerResourcePackStatusEvent.Status#SUCCESSFULLY_LOADED} | ||
| + */ | ||
| + boolean hasResourcePack(); | ||
| // Paper end | ||
|
|
||
| // Spigot start | ||
| diff --git a/src/main/java/org/bukkit/event/player/PlayerResourcePackStatusEvent.java b/src/main/java/org/bukkit/event/player/PlayerResourcePackStatusEvent.java | ||
| index b98195650d49d78ec35970ca0376b6289b861e4b..4c2102a11c3d682d98f0db4ccafa35231e66bcdd 100644 | ||
| --- a/src/main/java/org/bukkit/event/player/PlayerResourcePackStatusEvent.java | ||
| +++ b/src/main/java/org/bukkit/event/player/PlayerResourcePackStatusEvent.java | ||
| @@ -11,13 +11,32 @@ import org.jetbrains.annotations.NotNull; | ||
| public class PlayerResourcePackStatusEvent extends PlayerEvent { | ||
|
|
||
| private static final HandlerList handlers = new HandlerList(); | ||
| + @Deprecated | ||
| + private final String hash; // Paper | ||
| private final Status status; | ||
|
|
||
| public PlayerResourcePackStatusEvent(@NotNull final Player who, @NotNull Status resourcePackStatus) { | ||
| super(who); | ||
| + this.hash = null; // Paper | ||
| this.status = resourcePackStatus; | ||
| } | ||
|
|
||
| + @Deprecated // Paper | ||
| + public PlayerResourcePackStatusEvent(final Player who, Status resourcePackStatus, String hash) { | ||
| + super(who); | ||
| + this.hash = hash; // Paper | ||
| + this.status = resourcePackStatus; | ||
| + } | ||
| + | ||
| + @Deprecated | ||
| + /** | ||
| + * @deprecated Hash does not seem to ever be set | ||
| + */ | ||
| + public String getHash() { | ||
| + return this.hash; | ||
| + } | ||
| + // Paper end | ||
| + | ||
| /** | ||
| * Gets the status of this pack. | ||
| * |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
| From: Aikar <aikar@aikar.co> | ||
| Date: Sun, 19 May 2013 20:36:58 -0400 | ||
| Subject: [PATCH] Add a call helper to Event | ||
|
|
||
| Reduces diff in Server patches | ||
|
|
||
| diff --git a/src/main/java/org/bukkit/event/Event.java b/src/main/java/org/bukkit/event/Event.java | ||
| index 18d0636b749913bfdcea8eebc7d0840d192fb071..8ec56cd6b8e0f5c5dd8c7c88b4671e18dcf109d0 100644 | ||
| --- a/src/main/java/org/bukkit/event/Event.java | ||
| +++ b/src/main/java/org/bukkit/event/Event.java | ||
| @@ -35,6 +35,22 @@ public abstract class Event { | ||
| this.async = isAsync; | ||
| } | ||
|
|
||
| + // Paper start | ||
| + /** | ||
| + * Calls the event and tests if cancelled. | ||
| + * | ||
| + * @return false if event was cancelled, if cancellable. otherwise true. | ||
| + */ | ||
| + public boolean callEvent() { | ||
| + org.bukkit.Bukkit.getPluginManager().callEvent(this); | ||
| + if (this instanceof Cancellable) { | ||
| + return !((Cancellable) this).isCancelled(); | ||
| + } else { | ||
| + return true; | ||
| + } | ||
| + } | ||
| + // Paper end | ||
| + | ||
| /** | ||
| * Convenience method for providing a user-friendly identifier. By | ||
| * default, it is the event's class's {@linkplain Class#getSimpleName() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
| From: Aikar <aikar@aikar.co> | ||
| Date: Wed, 22 Jul 2015 18:50:41 -0400 | ||
| Subject: [PATCH] Add sender name to commands.yml replacement | ||
|
|
||
| This allows you to use $sender in commands.yml definitions to make | ||
| commands that auto target self. | ||
|
|
||
| diff --git a/src/main/java/org/bukkit/command/FormattedCommandAlias.java b/src/main/java/org/bukkit/command/FormattedCommandAlias.java | ||
| index a6ad94ef98a1df1d2842635d850bc990b0137849..9d4f553c04784cca63901a56a7aea62a5cae1d72 100644 | ||
| --- a/src/main/java/org/bukkit/command/FormattedCommandAlias.java | ||
| +++ b/src/main/java/org/bukkit/command/FormattedCommandAlias.java | ||
| @@ -1,6 +1,9 @@ | ||
| package org.bukkit.command; | ||
|
|
||
| import java.util.ArrayList; | ||
| +import java.util.regex.Matcher; // Paper | ||
| +import java.util.regex.Pattern; // Paper | ||
| + | ||
| import org.bukkit.Bukkit; | ||
| import org.jetbrains.annotations.NotNull; | ||
|
|
||
| @@ -19,7 +22,7 @@ public class FormattedCommandAlias extends Command { | ||
| ArrayList<String> commands = new ArrayList<String>(); | ||
| for (String formatString : formatStrings) { | ||
| try { | ||
| - commands.add(buildCommand(formatString, args)); | ||
| + commands.add(buildCommand(sender, formatString, args)); // Paper | ||
| } catch (Throwable throwable) { | ||
| if (throwable instanceof IllegalArgumentException) { | ||
| sender.sendMessage(throwable.getMessage()); | ||
| @@ -37,7 +40,10 @@ public class FormattedCommandAlias extends Command { | ||
| return result; | ||
| } | ||
|
|
||
| - private String buildCommand(@NotNull String formatString, @NotNull String[] args) { | ||
| + private String buildCommand(@NotNull CommandSender sender, @NotNull String formatString, @NotNull String[] args) { // Paper | ||
| + if (formatString.contains("$sender")) { // Paper | ||
| + formatString = formatString.replaceAll(Pattern.quote("$sender"), Matcher.quoteReplacement(sender.getName())); // Paper | ||
| + } // Paper | ||
| int index = formatString.indexOf('$'); | ||
| while (index != -1) { | ||
| int start = index; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
| From: William <admin@domnian.com> | ||
| Date: Fri, 18 Mar 2016 03:28:07 -0400 | ||
| Subject: [PATCH] Add command to reload permissions.yml and require confirm to | ||
| reload | ||
|
|
||
|
|
||
| diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java | ||
| index 8646fc0987a8833996c5d977c36fe0d01bf72992..72375883b07ede041a7ea5f7b6785f71aef702c0 100644 | ||
| --- a/src/main/java/org/bukkit/Bukkit.java | ||
| +++ b/src/main/java/org/bukkit/Bukkit.java | ||
| @@ -1752,6 +1752,13 @@ public final class Bukkit { | ||
| public static org.bukkit.command.CommandMap getCommandMap() { | ||
| return server.getCommandMap(); | ||
| } | ||
| + | ||
| + /** | ||
| + * Reload the Permissions in permissions.yml | ||
| + */ | ||
| + public static void reloadPermissions() { | ||
| + server.reloadPermissions(); | ||
| + } | ||
| // Paper end | ||
|
|
||
| @NotNull | ||
| diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java | ||
| index 599347ef656acad9a40be15fc5030e5d0f1630df..a2940eafa61814aae7f766262309495e991533d6 100644 | ||
| --- a/src/main/java/org/bukkit/Server.java | ||
| +++ b/src/main/java/org/bukkit/Server.java | ||
| @@ -1549,4 +1549,6 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi | ||
| @NotNull | ||
| Spigot spigot(); | ||
| // Spigot end | ||
| + | ||
| + void reloadPermissions(); // Paper | ||
| } | ||
| diff --git a/src/main/java/org/bukkit/command/defaults/ReloadCommand.java b/src/main/java/org/bukkit/command/defaults/ReloadCommand.java | ||
| index 50cc311be7904cc8fc6070a21c8e4de3a489fd20..c62da4131b17e66892678e8b618fb9ba3de93b56 100644 | ||
| --- a/src/main/java/org/bukkit/command/defaults/ReloadCommand.java | ||
| +++ b/src/main/java/org/bukkit/command/defaults/ReloadCommand.java | ||
| @@ -13,15 +13,35 @@ public class ReloadCommand extends BukkitCommand { | ||
| public ReloadCommand(@NotNull String name) { | ||
| super(name); | ||
| this.description = "Reloads the server configuration and plugins"; | ||
| - this.usageMessage = "/reload"; | ||
| + this.usageMessage = "/reload [permissions]"; // Paper | ||
| this.setPermission("bukkit.command.reload"); | ||
| this.setAliases(Arrays.asList("rl")); | ||
| } | ||
|
|
||
| @Override | ||
| - public boolean execute(@NotNull CommandSender sender, @NotNull String currentAlias, @NotNull String[] args) { | ||
| + public boolean execute(@NotNull CommandSender sender, @NotNull String currentAlias, @NotNull String[] args) { // Paper | ||
| if (!testPermission(sender)) return true; | ||
|
|
||
| + // Paper start - Reload permissions.yml & require confirm | ||
| + boolean confirmed = System.getProperty("LetMeReload") != null; | ||
| + if (args.length == 1) { | ||
| + if (args[0].equalsIgnoreCase("permissions")) { | ||
| + Bukkit.getServer().reloadPermissions(); | ||
| + Command.broadcastCommandMessage(sender, ChatColor.GREEN + "Permissions successfully reloaded."); | ||
| + return true; | ||
| + } else if ("confirm".equalsIgnoreCase(args[0])) { | ||
| + confirmed = true; | ||
| + } else { | ||
| + Command.broadcastCommandMessage(sender, ChatColor.RED + "Usage: " + usageMessage); | ||
| + return true; | ||
| + } | ||
| + } | ||
| + if (!confirmed) { | ||
| + Command.broadcastCommandMessage(sender, ChatColor.RED + "Are you sure you wish to reload your server? Doing so may cause bugs and memory leaks. It is recommended to restart instead of using /reload. To confirm, please type " + ChatColor.YELLOW + "/reload confirm"); | ||
| + return true; | ||
| + } | ||
| + // Paper end | ||
| + | ||
| Command.broadcastCommandMessage(sender, ChatColor.RED + "Please note that this command is not supported and may cause issues when using some plugins."); | ||
| Command.broadcastCommandMessage(sender, ChatColor.RED + "If you encounter any issues please use the /stop command to restart your server."); | ||
| Bukkit.reload(); | ||
| @@ -33,6 +53,6 @@ public class ReloadCommand extends BukkitCommand { | ||
| @NotNull | ||
| @Override | ||
| public List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException { | ||
| - return Collections.emptyList(); | ||
| + return java.util.Collections.singletonList("permissions"); // Paper | ||
| } | ||
| } | ||
| diff --git a/src/main/java/org/bukkit/plugin/SimplePluginManager.java b/src/main/java/org/bukkit/plugin/SimplePluginManager.java | ||
| index c2c49ee9b5531bc4761d2da54cd707c57fc647bf..2d27dfb859c312d46a14d0356c7c3f227e965a67 100644 | ||
| --- a/src/main/java/org/bukkit/plugin/SimplePluginManager.java | ||
| +++ b/src/main/java/org/bukkit/plugin/SimplePluginManager.java | ||
| @@ -895,4 +895,13 @@ public final class SimplePluginManager implements PluginManager { | ||
| public void useTimings(boolean use) { | ||
| co.aikar.timings.Timings.setTimingsEnabled(use); // Paper | ||
| } | ||
| + | ||
| + // Paper start | ||
| + public void clearPermissions() { | ||
| + permissions.clear(); | ||
| + defaultPerms.get(true).clear(); | ||
| + defaultPerms.get(false).clear(); | ||
| + } | ||
| + // Paper end | ||
| + | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
| From: Jedediah Smith <jedediah@silencegreys.com> | ||
| Date: Sun, 21 Jun 2015 15:05:21 -0400 | ||
| Subject: [PATCH] Custom replacement for eaten items | ||
|
|
||
|
|
||
| diff --git a/src/main/java/org/bukkit/event/player/PlayerItemConsumeEvent.java b/src/main/java/org/bukkit/event/player/PlayerItemConsumeEvent.java | ||
| index c2793f3ef01c1246c130971c17e1c2bf8f551435..373f4b5b5185aa81ff728da89c9cc4e0ccf87889 100644 | ||
| --- a/src/main/java/org/bukkit/event/player/PlayerItemConsumeEvent.java | ||
| +++ b/src/main/java/org/bukkit/event/player/PlayerItemConsumeEvent.java | ||
| @@ -22,6 +22,7 @@ public class PlayerItemConsumeEvent extends PlayerEvent implements Cancellable { | ||
| private static final HandlerList handlers = new HandlerList(); | ||
| private boolean isCancelled = false; | ||
| private ItemStack item; | ||
| + @Nullable private ItemStack replacement; // Paper | ||
|
|
||
| /** | ||
| * @param player the player consuming | ||
| @@ -58,6 +59,29 @@ public class PlayerItemConsumeEvent extends PlayerEvent implements Cancellable { | ||
| } | ||
| } | ||
|
|
||
| + // Paper start | ||
| + /** | ||
| + * Return the custom item stack that will replace the consumed item, or null if no | ||
| + * custom replacement has been set (which means the default replacement will be used). | ||
| + * | ||
| + * @return The custom item stack that will replace the consumed item or null | ||
| + */ | ||
| + @Nullable | ||
| + public ItemStack getReplacement() { | ||
| + return this.replacement; | ||
| + } | ||
| + | ||
| + /** | ||
| + * Set a custom item stack to replace the consumed item. Pass null to clear any custom | ||
| + * stack that has been set and use the default replacement. | ||
| + * | ||
| + * @param replacement Replacement item to set, null to clear any custom stack and use default | ||
| + */ | ||
| + public void setReplacement(@Nullable ItemStack replacement) { | ||
| + this.replacement = replacement; | ||
| + } | ||
| + // Paper end | ||
| + | ||
| @Override | ||
| public boolean isCancelled() { | ||
| return this.isCancelled; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
| From: Aikar <aikar@aikar.co> | ||
| Date: Mon, 28 Mar 2016 20:26:34 -0400 | ||
| Subject: [PATCH] Entity AddTo/RemoveFrom World Events | ||
|
|
||
|
|
||
| diff --git a/src/main/java/com/destroystokyo/paper/event/entity/EntityAddToWorldEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/EntityAddToWorldEvent.java | ||
| new file mode 100644 | ||
| index 0000000000000000000000000000000000000000..07660202e41ee86f1b66bad3335cf6fe126e7f9c | ||
| --- /dev/null | ||
| +++ b/src/main/java/com/destroystokyo/paper/event/entity/EntityAddToWorldEvent.java | ||
| @@ -0,0 +1,32 @@ | ||
| +package com.destroystokyo.paper.event.entity; | ||
| + | ||
| +import org.bukkit.entity.Entity; | ||
| +import org.bukkit.event.Event; | ||
| +import org.bukkit.event.HandlerList; | ||
| +import org.bukkit.event.entity.EntityEvent; | ||
| +import org.jetbrains.annotations.NotNull; | ||
| + | ||
| +/** | ||
| + * Fired any time an entity is being added to the world for any reason. | ||
| + * | ||
| + * Not to be confused with {@link org.bukkit.event.entity.CreatureSpawnEvent} | ||
| + * This will fire anytime a chunk is reloaded too. | ||
| + */ | ||
| +public class EntityAddToWorldEvent extends EntityEvent { | ||
| + | ||
| + public EntityAddToWorldEvent(@NotNull Entity entity) { | ||
| + super(entity); | ||
| + } | ||
| + | ||
| + private static final HandlerList handlers = new HandlerList(); | ||
| + | ||
| + @NotNull | ||
| + public HandlerList getHandlers() { | ||
| + return handlers; | ||
| + } | ||
| + | ||
| + @NotNull | ||
| + public static HandlerList getHandlerList() { | ||
| + return handlers; | ||
| + } | ||
| +} | ||
| diff --git a/src/main/java/com/destroystokyo/paper/event/entity/EntityRemoveFromWorldEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/EntityRemoveFromWorldEvent.java | ||
| new file mode 100644 | ||
| index 0000000000000000000000000000000000000000..e5dbbd660409bae0d3b96e83390511d3a423a52e | ||
| --- /dev/null | ||
| +++ b/src/main/java/com/destroystokyo/paper/event/entity/EntityRemoveFromWorldEvent.java | ||
| @@ -0,0 +1,29 @@ | ||
| +package com.destroystokyo.paper.event.entity; | ||
| + | ||
| +import org.bukkit.entity.Entity; | ||
| +import org.bukkit.event.Event; | ||
| +import org.bukkit.event.HandlerList; | ||
| +import org.bukkit.event.entity.EntityEvent; | ||
| +import org.jetbrains.annotations.NotNull; | ||
| + | ||
| +/** | ||
| + * Fired any time an entity is being removed from a world for any reason | ||
| + */ | ||
| +public class EntityRemoveFromWorldEvent extends EntityEvent { | ||
| + | ||
| + public EntityRemoveFromWorldEvent(@NotNull Entity entity) { | ||
| + super(entity); | ||
| + } | ||
| + | ||
| + private static final HandlerList handlers = new HandlerList(); | ||
| + | ||
| + @NotNull | ||
| + public HandlerList getHandlers() { | ||
| + return handlers; | ||
| + } | ||
| + | ||
| + @NotNull | ||
| + public static HandlerList getHandlerList() { | ||
| + return handlers; | ||
| + } | ||
| +} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
| From: Aikar <aikar@aikar.co> | ||
| Date: Mon, 28 Mar 2016 21:15:34 -0400 | ||
| Subject: [PATCH] EntityPathfindEvent | ||
|
|
||
| Fires when an Entity decides to start moving to a location. | ||
|
|
||
| diff --git a/src/main/java/com/destroystokyo/paper/event/entity/EntityPathfindEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/EntityPathfindEvent.java | ||
| new file mode 100644 | ||
| index 0000000000000000000000000000000000000000..63e46b2fb1b12b36fcb1e98b178cf29dd2e3d1b5 | ||
| --- /dev/null | ||
| +++ b/src/main/java/com/destroystokyo/paper/event/entity/EntityPathfindEvent.java | ||
| @@ -0,0 +1,82 @@ | ||
| +package com.destroystokyo.paper.event.entity; | ||
| + | ||
| +import org.bukkit.Location; | ||
| +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.NotNull; | ||
| +import org.jetbrains.annotations.Nullable; | ||
| + | ||
| +/** | ||
| + * Fired when an Entity decides to start moving towards a location. | ||
| + * | ||
| + * This event does not fire for the entities actual movement. Only when it | ||
| + * is choosing to start moving to a location. | ||
| + */ | ||
| +public class EntityPathfindEvent extends EntityEvent implements Cancellable { | ||
| + @Nullable private final Entity targetEntity; | ||
| + @NotNull private final Location loc; | ||
| + | ||
| + public EntityPathfindEvent(@NotNull Entity entity, @NotNull Location loc, @Nullable Entity targetEntity) { | ||
| + super(entity); | ||
| + this.targetEntity = targetEntity; | ||
| + this.loc = loc; | ||
| + } | ||
| + | ||
| + /** | ||
| + * The Entity that is pathfinding. | ||
| + * @return The Entity that is pathfinding. | ||
| + */ | ||
| + @NotNull | ||
| + public Entity getEntity() { | ||
| + return entity; | ||
| + } | ||
| + | ||
| + /** | ||
| + * If the Entity is trying to pathfind to an entity, this is the entity in relation. | ||
| + * | ||
| + * Otherwise this will return null. | ||
| + * | ||
| + * @return The entity target or null | ||
| + */ | ||
| + @Nullable | ||
| + public Entity getTargetEntity() { | ||
| + return targetEntity; | ||
| + } | ||
| + | ||
| + /** | ||
| + * The Location of where the entity is about to move to. | ||
| + * | ||
| + * Note that if the target happened to of been an entity | ||
| + * @return Location of where the entity is trying to pathfind to. | ||
| + */ | ||
| + @NotNull | ||
| + public Location getLoc() { | ||
| + return loc; | ||
| + } | ||
| + | ||
| + private static final HandlerList handlers = new HandlerList(); | ||
| + | ||
| + @NotNull | ||
| + public HandlerList getHandlers() { | ||
| + return handlers; | ||
| + } | ||
| + | ||
| + @NotNull | ||
| + public static HandlerList getHandlerList() { | ||
| + return handlers; | ||
| + } | ||
| + | ||
| + private boolean cancelled = false; | ||
| + | ||
| + @Override | ||
| + public boolean isCancelled() { | ||
| + return cancelled; | ||
| + } | ||
| + | ||
| + @Override | ||
| + public void setCancelled(boolean cancel) { | ||
| + cancelled = cancel; | ||
| + } | ||
| +} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
| From: crast <contact@jamescrasta.com> | ||
| Date: Sat, 1 Jun 2013 13:52:30 -0600 | ||
| Subject: [PATCH] Reduce thread synchronization in MetadataStoreBase | ||
|
|
||
| Use ConcurrentHashMap to allow thread-safe access methods and very | ||
| limited synchronized portions to allow much higher concurrency in | ||
| MetadataStore as well as far less locking, especially on reads | ||
|
|
||
| diff --git a/src/main/java/org/bukkit/metadata/MetadataStoreBase.java b/src/main/java/org/bukkit/metadata/MetadataStoreBase.java | ||
| index baf850226aed8545a5794deba6dff9603953b4b2..d363d517c05b3335101d829ce4ec22d049059c24 100644 | ||
| --- a/src/main/java/org/bukkit/metadata/MetadataStoreBase.java | ||
| +++ b/src/main/java/org/bukkit/metadata/MetadataStoreBase.java | ||
| @@ -12,7 +12,7 @@ import org.bukkit.plugin.Plugin; | ||
| import org.jetbrains.annotations.NotNull; | ||
|
|
||
| public abstract class MetadataStoreBase<T> { | ||
| - private Map<String, Map<Plugin, MetadataValue>> metadataMap = new HashMap<String, Map<Plugin, MetadataValue>>(); | ||
| + private Map<String, Map<Plugin, MetadataValue>> metadataMap = new java.util.concurrent.ConcurrentHashMap<String, Map<Plugin, MetadataValue>>(); // Paper | ||
|
|
||
| /** | ||
| * Adds a metadata value to an object. Each metadata value is owned by a | ||
| @@ -46,7 +46,9 @@ public abstract class MetadataStoreBase<T> { | ||
| entry = new WeakHashMap<Plugin, MetadataValue>(1); | ||
| metadataMap.put(key, entry); | ||
| } | ||
| - entry.put(owningPlugin, newMetadataValue); | ||
| + synchronized (entry) { | ||
| + entry.put(owningPlugin, newMetadataValue); | ||
| + } | ||
| } | ||
|
|
||
| /** | ||
| @@ -60,10 +62,11 @@ public abstract class MetadataStoreBase<T> { | ||
| * @see MetadataStore#getMetadata(Object, String) | ||
| */ | ||
| @NotNull | ||
| - public synchronized List<MetadataValue> getMetadata(@NotNull T subject, @NotNull String metadataKey) { | ||
| + public List<MetadataValue> getMetadata(@NotNull T subject, @NotNull String metadataKey) { // Paper | ||
| String key = disambiguate(subject, metadataKey); | ||
| - if (metadataMap.containsKey(key)) { | ||
| - Collection<MetadataValue> values = metadataMap.get(key).values(); | ||
| + Map<Plugin, MetadataValue> entry = metadataMap.get(key); | ||
| + if (entry != null) { | ||
| + Collection<MetadataValue> values = entry.values(); | ||
| return Collections.unmodifiableList(new ArrayList<MetadataValue>(values)); | ||
| } else { | ||
| return Collections.emptyList(); | ||
| @@ -78,7 +81,7 @@ public abstract class MetadataStoreBase<T> { | ||
| * @param metadataKey the unique metadata key being queried. | ||
| * @return the existence of the metadataKey within subject. | ||
| */ | ||
| - public synchronized boolean hasMetadata(@NotNull T subject, @NotNull String metadataKey) { | ||
| + public boolean hasMetadata(@NotNull T subject, @NotNull String metadataKey) { // Paper | ||
| String key = disambiguate(subject, metadataKey); | ||
| return metadataMap.containsKey(key); | ||
| } | ||
| @@ -94,17 +97,18 @@ public abstract class MetadataStoreBase<T> { | ||
| * @see MetadataStore#removeMetadata(Object, String, | ||
| * org.bukkit.plugin.Plugin) | ||
| */ | ||
| - public synchronized void removeMetadata(@NotNull T subject, @NotNull String metadataKey, @NotNull Plugin owningPlugin) { | ||
| + public void removeMetadata(@NotNull T subject, @NotNull String metadataKey, @NotNull Plugin owningPlugin) { // Paper | ||
| Validate.notNull(owningPlugin, "Plugin cannot be null"); | ||
| String key = disambiguate(subject, metadataKey); | ||
| Map<Plugin, MetadataValue> entry = metadataMap.get(key); | ||
| if (entry == null) { | ||
| return; | ||
| } | ||
| - | ||
| - entry.remove(owningPlugin); | ||
| - if (entry.isEmpty()) { | ||
| - metadataMap.remove(key); | ||
| + synchronized (entry) { | ||
| + entry.remove(owningPlugin); | ||
| + if (entry.isEmpty()) { | ||
| + metadataMap.remove(key); | ||
| + } | ||
| } | ||
| } | ||
|
|
||
| @@ -117,7 +121,7 @@ public abstract class MetadataStoreBase<T> { | ||
| * @throws IllegalArgumentException If plugin is null | ||
| * @see MetadataStore#invalidateAll(org.bukkit.plugin.Plugin) | ||
| */ | ||
| - public synchronized void invalidateAll(@NotNull Plugin owningPlugin) { | ||
| + public void invalidateAll(@NotNull Plugin owningPlugin) { // Paper | ||
| Validate.notNull(owningPlugin, "Plugin cannot be null"); | ||
| for (Map<Plugin, MetadataValue> values : metadataMap.values()) { | ||
| if (values.containsKey(owningPlugin)) { |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
| From: Aikar <aikar@aikar.co> | ||
| Date: Tue, 16 Jul 2013 21:26:50 -0400 | ||
| Subject: [PATCH] Add MetadataStoreBase.removeAll(Plugin) | ||
|
|
||
| So that on reload, metadata will be cleared | ||
|
|
||
| diff --git a/src/main/java/org/bukkit/metadata/MetadataStoreBase.java b/src/main/java/org/bukkit/metadata/MetadataStoreBase.java | ||
| index d363d517c05b3335101d829ce4ec22d049059c24..abbe545af572687a0399c2387434863cd2b70f68 100644 | ||
| --- a/src/main/java/org/bukkit/metadata/MetadataStoreBase.java | ||
| +++ b/src/main/java/org/bukkit/metadata/MetadataStoreBase.java | ||
| @@ -4,6 +4,7 @@ import java.util.ArrayList; | ||
| import java.util.Collection; | ||
| import java.util.Collections; | ||
| import java.util.HashMap; | ||
| +import java.util.Iterator; // Paper | ||
| import java.util.List; | ||
| import java.util.Map; | ||
| import java.util.WeakHashMap; | ||
| @@ -130,6 +131,26 @@ public abstract class MetadataStoreBase<T> { | ||
| } | ||
| } | ||
|
|
||
| + /** | ||
| + * Removes all metadata in the metadata store that originates from the | ||
| + * given plugin. | ||
| + * | ||
| + * @param owningPlugin the plugin requesting the invalidation. | ||
| + * @throws IllegalArgumentException If plugin is null | ||
| + */ | ||
| + public void removeAll(@NotNull Plugin owningPlugin) { | ||
| + Validate.notNull(owningPlugin, "Plugin cannot be null"); | ||
| + for (Iterator<Map<Plugin, MetadataValue>> iterator = metadataMap.values().iterator(); iterator.hasNext(); ) { | ||
| + Map<Plugin, MetadataValue> values = iterator.next(); | ||
| + if (values.containsKey(owningPlugin)) { | ||
| + values.remove(owningPlugin); | ||
| + } | ||
| + if (values.isEmpty()) { | ||
| + iterator.remove(); | ||
| + } | ||
| + } | ||
| + } | ||
| + | ||
| /** | ||
| * Creates a unique name for the object receiving metadata by combining | ||
| * unique data from the subject with a metadataKey. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
| From: Jedediah Smith <jedediah@silencegreys.com> | ||
| Date: Sat, 2 Apr 2016 05:08:36 -0400 | ||
| Subject: [PATCH] Add PlayerUseUnknownEntityEvent | ||
|
|
||
|
|
||
| diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerUseUnknownEntityEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerUseUnknownEntityEvent.java | ||
| new file mode 100644 | ||
| index 0000000000000000000000000000000000000000..09cfdf48ead8f03f3497646537292174241b0868 | ||
| --- /dev/null | ||
| +++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerUseUnknownEntityEvent.java | ||
| @@ -0,0 +1,46 @@ | ||
| +package com.destroystokyo.paper.event.player; | ||
| + | ||
| +import org.bukkit.entity.Player; | ||
| +import org.bukkit.event.HandlerList; | ||
| +import org.bukkit.event.player.PlayerEvent; | ||
| +import org.bukkit.inventory.EquipmentSlot; | ||
| +import org.jetbrains.annotations.NotNull; | ||
| + | ||
| +public class PlayerUseUnknownEntityEvent extends PlayerEvent { | ||
| + | ||
| + private static final HandlerList handlers = new HandlerList(); | ||
| + private final int entityId; | ||
| + private final boolean attack; | ||
| + @NotNull private final EquipmentSlot hand; | ||
| + | ||
| + public PlayerUseUnknownEntityEvent(@NotNull Player who, int entityId, boolean attack, @NotNull EquipmentSlot hand) { | ||
| + super(who); | ||
| + this.entityId = entityId; | ||
| + this.attack = attack; | ||
| + this.hand = hand; | ||
| + } | ||
| + | ||
| + public int getEntityId() { | ||
| + return this.entityId; | ||
| + } | ||
| + | ||
| + public boolean isAttack() { | ||
| + return this.attack; | ||
| + } | ||
| + | ||
| + @NotNull | ||
| + public EquipmentSlot getHand() { | ||
| + return this.hand; | ||
| + } | ||
| + | ||
| + @NotNull | ||
| + @Override | ||
| + public HandlerList getHandlers() { | ||
| + return handlers; | ||
| + } | ||
| + | ||
| + @NotNull | ||
| + public static HandlerList getHandlerList() { | ||
| + return handlers; | ||
| + } | ||
| +} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,290 @@ | ||
| From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
| From: kashike <kashike@vq.lc> | ||
| Date: Wed, 13 Apr 2016 20:20:18 -0700 | ||
| Subject: [PATCH] Add handshake event to allow plugins to handle client | ||
| handshaking logic themselves | ||
|
|
||
|
|
||
| diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerHandshakeEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerHandshakeEvent.java | ||
| new file mode 100644 | ||
| index 0000000000000000000000000000000000000000..a077962fa786a3291849abfa823c7f0ec4664fce | ||
| --- /dev/null | ||
| +++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerHandshakeEvent.java | ||
| @@ -0,0 +1,277 @@ | ||
| +package com.destroystokyo.paper.event.player; | ||
| + | ||
| +import net.kyori.adventure.text.Component; | ||
| +import net.kyori.adventure.text.format.NamedTextColor; | ||
| +import org.apache.commons.lang.Validate; | ||
| +import org.bukkit.Bukkit; | ||
| +import org.bukkit.event.Cancellable; | ||
| +import org.bukkit.event.Event; | ||
| +import org.bukkit.event.HandlerList; | ||
| + | ||
| +import java.util.UUID; | ||
| +import org.jetbrains.annotations.NotNull; | ||
| +import org.jetbrains.annotations.Nullable; | ||
| + | ||
| +/** | ||
| + * This event is fired during a player handshake. | ||
| + * | ||
| + * <p>If there are no listeners listening to this event, the logic default | ||
| + * to your server platform will be ran.</p> | ||
| + * | ||
| + * <p>WARNING: TAMPERING WITH THIS EVENT CAN BE DANGEROUS</p> | ||
| + */ | ||
| +public class PlayerHandshakeEvent extends Event implements Cancellable { | ||
| + | ||
| + private static final HandlerList HANDLERS = new HandlerList(); | ||
| + @NotNull private final String originalHandshake; | ||
| + @NotNull private final String originalSocketAddressHostname; | ||
| + private boolean cancelled; | ||
| + @Nullable private String serverHostname; | ||
| + @Nullable private String socketAddressHostname; | ||
| + @Nullable private UUID uniqueId; | ||
| + @Nullable private String propertiesJson; | ||
| + private boolean failed; | ||
| + private Component failMessage = Component.text("If you wish to use IP forwarding, please enable it in your BungeeCord config as well!", NamedTextColor.YELLOW); | ||
| + | ||
| + /** | ||
| + * Creates a new {@link PlayerHandshakeEvent}. | ||
| + * | ||
| + * @param originalHandshake the original handshake string | ||
| + * @param cancelled if this event is enabled | ||
| + * | ||
| + * @deprecated in favour of {@link PlayerHandshakeEvent(String, String, boolean)} | ||
| + */ | ||
| + @Deprecated | ||
| + public PlayerHandshakeEvent(@NotNull String originalHandshake, boolean cancelled) { | ||
| + this(originalHandshake, "127.0.0.1", cancelled); | ||
| + } | ||
| + | ||
| + /** | ||
| + * Creates a new {@link PlayerHandshakeEvent}. | ||
| + * | ||
| + * @param originalHandshake the original handshake string | ||
| + * @param originalSocketAddressHostname the original socket address hostname | ||
| + * @param cancelled if this event is enabled | ||
| + */ | ||
| + public PlayerHandshakeEvent(@NotNull String originalHandshake, @NotNull String originalSocketAddressHostname, boolean cancelled) { | ||
| + super(true); | ||
| + this.originalHandshake = originalHandshake; | ||
| + this.originalSocketAddressHostname = originalSocketAddressHostname; | ||
| + this.cancelled = cancelled; | ||
| + } | ||
| + | ||
| + /** | ||
| + * Determines if this event is cancelled. | ||
| + * | ||
| + * <p>When this event is cancelled, custom handshake logic will not | ||
| + * be processed.</p> | ||
| + * | ||
| + * @return {@code true} if this event is cancelled, {@code false} otherwise | ||
| + */ | ||
| + @Override | ||
| + public boolean isCancelled() { | ||
| + return this.cancelled; | ||
| + } | ||
| + | ||
| + /** | ||
| + * Sets if this event is cancelled. | ||
| + * | ||
| + * <p>When this event is cancelled, custom handshake logic will not | ||
| + * be processed.</p> | ||
| + * | ||
| + * @param cancelled {@code true} if this event is cancelled, {@code false} otherwise | ||
| + */ | ||
| + @Override | ||
| + public void setCancelled(boolean cancelled) { | ||
| + this.cancelled = cancelled; | ||
| + } | ||
| + | ||
| + /** | ||
| + * Gets the original handshake string. | ||
| + * | ||
| + * @return the original handshake string | ||
| + */ | ||
| + @NotNull | ||
| + public String getOriginalHandshake() { | ||
| + return this.originalHandshake; | ||
| + } | ||
| + | ||
| + /** | ||
| + * Gets the original socket address hostname. | ||
| + * | ||
| + * <p>This does not include the port.</p> | ||
| + * <p>In cases where this event is manually fired and the plugin wasn't updated yet, the default is {@code "127.0.0.1"}.</p> | ||
| + * | ||
| + * @return the original socket address hostname | ||
| + */ | ||
| + @NotNull | ||
| + public String getOriginalSocketAddressHostname() { | ||
| + return this.originalSocketAddressHostname; | ||
| + } | ||
| + | ||
| + /** | ||
| + * Gets the server hostname string. | ||
| + * | ||
| + * <p>This should not include the port.</p> | ||
| + * | ||
| + * @return the server hostname string | ||
| + */ | ||
| + @Nullable | ||
| + public String getServerHostname() { | ||
| + return this.serverHostname; | ||
| + } | ||
| + | ||
| + /** | ||
| + * Sets the server hostname string. | ||
| + * | ||
| + * <p>This should not include the port.</p> | ||
| + * | ||
| + * @param serverHostname the server hostname string | ||
| + */ | ||
| + public void setServerHostname(@NotNull String serverHostname) { | ||
| + this.serverHostname = serverHostname; | ||
| + } | ||
| + | ||
| + /** | ||
| + * Gets the socket address hostname string. | ||
| + * | ||
| + * <p>This should not include the port.</p> | ||
| + * | ||
| + * @return the socket address hostname string | ||
| + */ | ||
| + @Nullable | ||
| + public String getSocketAddressHostname() { | ||
| + return this.socketAddressHostname; | ||
| + } | ||
| + | ||
| + /** | ||
| + * Sets the socket address hostname string. | ||
| + * | ||
| + * <p>This should not include the port.</p> | ||
| + * | ||
| + * @param socketAddressHostname the socket address hostname string | ||
| + */ | ||
| + public void setSocketAddressHostname(@NotNull String socketAddressHostname) { | ||
| + this.socketAddressHostname = socketAddressHostname; | ||
| + } | ||
| + | ||
| + /** | ||
| + * Gets the unique id. | ||
| + * | ||
| + * @return the unique id | ||
| + */ | ||
| + @Nullable | ||
| + public UUID getUniqueId() { | ||
| + return this.uniqueId; | ||
| + } | ||
| + | ||
| + /** | ||
| + * Sets the unique id. | ||
| + * | ||
| + * @param uniqueId the unique id | ||
| + */ | ||
| + public void setUniqueId(@NotNull UUID uniqueId) { | ||
| + this.uniqueId = uniqueId; | ||
| + } | ||
| + | ||
| + /** | ||
| + * Gets the profile properties. | ||
| + * | ||
| + * <p>This should be a valid JSON string.</p> | ||
| + * | ||
| + * @return the profile properties, as JSON | ||
| + */ | ||
| + @Nullable | ||
| + public String getPropertiesJson() { | ||
| + return this.propertiesJson; | ||
| + } | ||
| + | ||
| + /** | ||
| + * Determines if authentication failed. | ||
| + * | ||
| + * <p>When {@code true}, the client connecting will be disconnected | ||
| + * with the {@link #getFailMessage() fail message}.</p> | ||
| + * | ||
| + * @return {@code true} if authentication failed, {@code false} otherwise | ||
| + */ | ||
| + public boolean isFailed() { | ||
| + return this.failed; | ||
| + } | ||
| + | ||
| + /** | ||
| + * Sets if authentication failed and the client should be disconnected. | ||
| + * | ||
| + * <p>When {@code true}, the client connecting will be disconnected | ||
| + * with the {@link #getFailMessage() fail message}.</p> | ||
| + * | ||
| + * @param failed {@code true} if authentication failed, {@code false} otherwise | ||
| + */ | ||
| + public void setFailed(boolean failed) { | ||
| + this.failed = failed; | ||
| + } | ||
| + | ||
| + /** | ||
| + * Sets the profile properties. | ||
| + * | ||
| + * <p>This should be a valid JSON string.</p> | ||
| + * | ||
| + * @param propertiesJson the profile properties, as JSON | ||
| + */ | ||
| + public void setPropertiesJson(@NotNull String propertiesJson) { | ||
| + this.propertiesJson = propertiesJson; | ||
| + } | ||
| + | ||
| + /** | ||
| + * Gets the message to display to the client when authentication fails. | ||
| + * | ||
| + * @return the message to display to the client | ||
| + */ | ||
| + @NotNull | ||
| + public Component failMessage() { | ||
| + return this.failMessage; | ||
| + } | ||
| + | ||
| + /** | ||
| + * Sets the message to display to the client when authentication fails. | ||
| + * | ||
| + * @param failMessage the message to display to the client | ||
| + */ | ||
| + public void failMessage(@NotNull Component failMessage) { | ||
| + this.failMessage = failMessage; | ||
| + } | ||
| + | ||
| + /** | ||
| + * Gets the message to display to the client when authentication fails. | ||
| + * | ||
| + * @return the message to display to the client | ||
| + * @deprecated use {@link #failMessage()} | ||
| + */ | ||
| + @NotNull | ||
| + @Deprecated | ||
| + public String getFailMessage() { | ||
| + return Bukkit.getUnsafe().legacyComponentSerializer().serialize(this.failMessage()); | ||
| + } | ||
| + | ||
| + /** | ||
| + * Sets the message to display to the client when authentication fails. | ||
| + * | ||
| + * @param failMessage the message to display to the client | ||
| + * @deprecated use {@link #failMessage(Component)} | ||
| + */ | ||
| + @Deprecated | ||
| + public void setFailMessage(@NotNull String failMessage) { | ||
| + Validate.notEmpty(failMessage, "fail message cannot be null or empty"); | ||
| + this.failMessage(Bukkit.getUnsafe().legacyComponentSerializer().deserialize(failMessage)); | ||
| + } | ||
| + | ||
| + @NotNull | ||
| + @Override | ||
| + public HandlerList getHandlers() { | ||
| + return HANDLERS; | ||
| + } | ||
| + | ||
| + @NotNull | ||
| + public static HandlerList getHandlerList() { | ||
| + return HANDLERS; | ||
| + } | ||
| +} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
| From: Jedediah Smith <jedediah@silencegreys.com> | ||
| Date: Fri, 4 Mar 2016 03:13:18 -0500 | ||
| Subject: [PATCH] Arrow pickup rule API | ||
|
|
||
|
|
||
| diff --git a/src/main/java/org/bukkit/entity/AbstractArrow.java b/src/main/java/org/bukkit/entity/AbstractArrow.java | ||
| index 5b50a4e10e8ace8cc53ad3c8d7c3185f88d5c8db..e8e56e89e32d84af0639fe2e9b0eeabd747b6007 100644 | ||
| --- a/src/main/java/org/bukkit/entity/AbstractArrow.java | ||
| +++ b/src/main/java/org/bukkit/entity/AbstractArrow.java | ||
| @@ -141,4 +141,38 @@ public interface AbstractArrow extends Projectile { | ||
| */ | ||
| CREATIVE_ONLY | ||
| } | ||
| + | ||
| + // Paper start | ||
| + /** | ||
| + * Gets the {@link PickupRule} for this arrow. | ||
| + * | ||
| + * <p>This is generally {@link PickupRule#ALLOWED} only if the arrow was | ||
| + * <b>not</b> fired from a bow with the infinity enchantment.</p> | ||
| + * | ||
| + * @return The pickup rule | ||
| + * @deprecated Use {@link Arrow#getPickupStatus()} as an upstream compatible replacement for this function | ||
| + */ | ||
| + @Deprecated | ||
| + default PickupRule getPickupRule() { | ||
| + return PickupRule.valueOf(this.getPickupStatus().name()); | ||
| + } | ||
| + | ||
| + /** | ||
| + * Set the rule for which players can pickup this arrow as an item. | ||
| + * | ||
| + * @param rule The pickup rule | ||
| + * @deprecated Use {@link Arrow#setPickupStatus(PickupStatus)} with {@link PickupStatus} as an upstream compatible replacement for this function | ||
| + */ | ||
| + @Deprecated | ||
| + default void setPickupRule(PickupRule rule) { | ||
| + this.setPickupStatus(PickupStatus.valueOf(rule.name())); | ||
| + } | ||
| + | ||
| + @Deprecated | ||
| + enum PickupRule { | ||
| + DISALLOWED, | ||
| + ALLOWED, | ||
| + CREATIVE_ONLY; | ||
| + } | ||
| + // Paper end | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
| From: Zach Brown <zach.brown@destroystokyo.com> | ||
| Date: Fri, 22 Apr 2016 01:43:11 -0500 | ||
| Subject: [PATCH] EntityRegainHealthEvent isFastRegen API | ||
|
|
||
|
|
||
| diff --git a/src/main/java/org/bukkit/event/entity/EntityRegainHealthEvent.java b/src/main/java/org/bukkit/event/entity/EntityRegainHealthEvent.java | ||
| index 8feb6698f9630f099be99e52d1149cd6bc615197..d51d2ec1d04d9ea8a25a70d0d856f2355ebfcb4a 100644 | ||
| --- a/src/main/java/org/bukkit/event/entity/EntityRegainHealthEvent.java | ||
| +++ b/src/main/java/org/bukkit/event/entity/EntityRegainHealthEvent.java | ||
| @@ -13,12 +13,31 @@ public class EntityRegainHealthEvent extends EntityEvent implements Cancellable | ||
| private boolean cancelled; | ||
| private double amount; | ||
| private final RegainReason regainReason; | ||
| + private final boolean isFastRegen; // Paper | ||
|
|
||
| public EntityRegainHealthEvent(@NotNull final Entity entity, final double amount, @NotNull final RegainReason regainReason) { | ||
| + // Paper start - Forward | ||
| + this(entity, amount, regainReason, false); | ||
| + } | ||
| + | ||
| + public EntityRegainHealthEvent(@NotNull final Entity entity, final double amount, @NotNull final RegainReason regainReason, boolean isFastRegen) { | ||
| + // Paper end | ||
| super(entity); | ||
| this.amount = amount; | ||
| this.regainReason = regainReason; | ||
| + this.isFastRegen = isFastRegen; // Paper | ||
| + } | ||
| + | ||
| + // Paper start - Add getter for isFastRegen | ||
| + /** | ||
| + * Is this event a result of the fast regeneration mechanic | ||
| + * | ||
| + * @return Whether the event is the result of a fast regeneration mechanic | ||
| + */ | ||
| + public boolean isFastRegen() { | ||
| + return isFastRegen; | ||
| } | ||
| + // Paper end | ||
|
|
||
| /** | ||
| * Gets the amount of regained health |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,123 @@ | ||
| From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
| From: AlphaBlend <whizkid3000@hotmail.com> | ||
| Date: Sun, 16 Oct 2016 23:19:34 -0700 | ||
| Subject: [PATCH] Add EntityZapEvent | ||
|
|
||
|
|
||
| diff --git a/src/main/java/com/destroystokyo/paper/event/entity/EntityZapEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/EntityZapEvent.java | ||
| new file mode 100644 | ||
| index 0000000000000000000000000000000000000000..3b725a489008d333630af166d2be5fc48168a6b9 | ||
| --- /dev/null | ||
| +++ b/src/main/java/com/destroystokyo/paper/event/entity/EntityZapEvent.java | ||
| @@ -0,0 +1,65 @@ | ||
| +package com.destroystokyo.paper.event.entity; | ||
| + | ||
| +import org.apache.commons.lang.Validate; | ||
| +import org.bukkit.entity.Entity; | ||
| +import org.bukkit.entity.LightningStrike; | ||
| +import org.bukkit.event.Cancellable; | ||
| +import org.bukkit.event.HandlerList; | ||
| +import org.bukkit.event.entity.EntityEvent; | ||
| +import org.bukkit.event.entity.EntityTransformEvent; | ||
| + | ||
| +import java.util.Collections; | ||
| +import org.jetbrains.annotations.NotNull; | ||
| + | ||
| +/** | ||
| + * Fired when lightning strikes an entity | ||
| + */ | ||
| +public class EntityZapEvent extends EntityTransformEvent implements Cancellable { | ||
| + private static final HandlerList handlers = new HandlerList(); | ||
| + private boolean cancelled; | ||
| + @NotNull private final LightningStrike bolt; | ||
| + | ||
| + public EntityZapEvent(@NotNull final Entity entity, @NotNull final LightningStrike bolt, @NotNull final Entity replacementEntity) { | ||
| + super(entity, Collections.singletonList(replacementEntity), TransformReason.LIGHTNING); | ||
| + Validate.notNull(bolt); | ||
| + Validate.notNull(replacementEntity); | ||
| + this.bolt = bolt; | ||
| + } | ||
| + | ||
| + public boolean isCancelled() { | ||
| + return cancelled; | ||
| + } | ||
| + | ||
| + public void setCancelled(boolean cancel) { | ||
| + this.cancelled = cancel; | ||
| + } | ||
| + | ||
| + /** | ||
| + * Gets the lightning bolt that is striking the entity. | ||
| + * @return The lightning bolt responsible for this event | ||
| + */ | ||
| + @NotNull | ||
| + public LightningStrike getBolt() { | ||
| + return bolt; | ||
| + } | ||
| + | ||
| + /** | ||
| + * Gets the entity that will replace the struck entity. | ||
| + * @return The entity that will replace the struck entity | ||
| + */ | ||
| + @NotNull | ||
| + public Entity getReplacementEntity() { | ||
| + return getTransformedEntity(); | ||
| + } | ||
| + | ||
| + @NotNull | ||
| + @Override | ||
| + public HandlerList getHandlers() { | ||
| + return handlers; | ||
| + } | ||
| + | ||
| + @NotNull | ||
| + public static HandlerList getHandlerList() { | ||
| + return handlers; | ||
| + } | ||
| +} | ||
| diff --git a/src/main/java/org/bukkit/event/entity/PigZapEvent.java b/src/main/java/org/bukkit/event/entity/PigZapEvent.java | ||
| index 0e0ed93b568fd2c0d8f6e359c31dc29cb0fa71c2..d3949edfc736b3d67a627ef378748b374769e183 100644 | ||
| --- a/src/main/java/org/bukkit/event/entity/PigZapEvent.java | ||
| +++ b/src/main/java/org/bukkit/event/entity/PigZapEvent.java | ||
| @@ -2,6 +2,7 @@ package org.bukkit.event.entity; | ||
|
|
||
| import java.util.Collections; | ||
| import org.bukkit.entity.Entity; | ||
| +import com.destroystokyo.paper.event.entity.EntityZapEvent; | ||
| import org.bukkit.entity.LightningStrike; | ||
| import org.bukkit.entity.Pig; | ||
| import org.bukkit.entity.PigZombie; | ||
| @@ -12,14 +13,14 @@ import org.jetbrains.annotations.NotNull; | ||
| /** | ||
| * Stores data for pigs being zapped | ||
| */ | ||
| -public class PigZapEvent extends EntityTransformEvent implements Cancellable { | ||
| - private static final HandlerList handlers = new HandlerList(); | ||
| +public class PigZapEvent extends EntityZapEvent implements Cancellable { | ||
| + //private static final HandlerList handlers = new HandlerList(); | ||
| private boolean canceled; | ||
| private final PigZombie pigzombie; | ||
| private final LightningStrike bolt; | ||
|
|
||
| public PigZapEvent(@NotNull final Pig pig, @NotNull final LightningStrike bolt, @NotNull final PigZombie pigzombie) { | ||
| - super(pig, Collections.singletonList((Entity) pigzombie), TransformReason.LIGHTNING); | ||
| + super(pig, bolt, pigzombie); | ||
| this.bolt = bolt; | ||
| this.pigzombie = pigzombie; | ||
| } | ||
| @@ -63,6 +64,8 @@ public class PigZapEvent extends EntityTransformEvent implements Cancellable { | ||
| return pigzombie; | ||
| } | ||
|
|
||
| + // Paper start | ||
| + /* | ||
| @NotNull | ||
| @Override | ||
| public HandlerList getHandlers() { | ||
| @@ -73,4 +76,6 @@ public class PigZapEvent extends EntityTransformEvent implements Cancellable { | ||
| public static HandlerList getHandlerList() { | ||
| return handlers; | ||
| } | ||
| + */ | ||
| + // Paper end | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
| From: vemacs <d@nkmem.es> | ||
| Date: Wed, 23 Nov 2016 12:53:43 -0500 | ||
| Subject: [PATCH] Misc Utils | ||
|
|
||
|
|
||
| diff --git a/src/main/java/com/destroystokyo/paper/utils/CachedSizeConcurrentLinkedQueue.java b/src/main/java/com/destroystokyo/paper/utils/CachedSizeConcurrentLinkedQueue.java | ||
| new file mode 100644 | ||
| index 0000000000000000000000000000000000000000..5bb677ce585b856b3d3e589e29786a29619c56a7 | ||
| --- /dev/null | ||
| +++ b/src/main/java/com/destroystokyo/paper/utils/CachedSizeConcurrentLinkedQueue.java | ||
| @@ -0,0 +1,34 @@ | ||
| +package com.destroystokyo.paper.utils; | ||
| + | ||
| +import java.util.concurrent.ConcurrentLinkedQueue; | ||
| +import java.util.concurrent.atomic.LongAdder; | ||
| +import org.jetbrains.annotations.NotNull; | ||
| +import org.jetbrains.annotations.Nullable; | ||
| + | ||
| +public class CachedSizeConcurrentLinkedQueue<E> extends ConcurrentLinkedQueue<E> { | ||
| + private final LongAdder cachedSize = new LongAdder(); | ||
| + | ||
| + @Override | ||
| + public boolean add(@NotNull E e) { | ||
| + boolean result = super.add(e); | ||
| + if (result) { | ||
| + cachedSize.increment(); | ||
| + } | ||
| + return result; | ||
| + } | ||
| + | ||
| + @Nullable | ||
| + @Override | ||
| + public E poll() { | ||
| + E result = super.poll(); | ||
| + if (result != null) { | ||
| + cachedSize.decrement(); | ||
| + } | ||
| + return result; | ||
| + } | ||
| + | ||
| + @Override | ||
| + public int size() { | ||
| + return cachedSize.intValue(); | ||
| + } | ||
| +} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
| From: willies952002 <admin@domnian.com> | ||
| Date: Mon, 28 Nov 2016 10:16:39 -0500 | ||
| Subject: [PATCH] Allow Reloading of Command Aliases | ||
|
|
||
| Reload the aliases stored in commands.yml | ||
|
|
||
| diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java | ||
| index 1380a26f34a9d2b162e88fbea14b17118945643c..7b3a0c958b4b4bffb6c19a0e4d3bf4824f8db237 100644 | ||
| --- a/src/main/java/org/bukkit/Bukkit.java | ||
| +++ b/src/main/java/org/bukkit/Bukkit.java | ||
| @@ -1759,6 +1759,15 @@ public final class Bukkit { | ||
| public static void reloadPermissions() { | ||
| server.reloadPermissions(); | ||
| } | ||
| + | ||
| + /** | ||
| + * Reload the Command Aliases in commands.yml | ||
| + * | ||
| + * @return Whether the reload was successful | ||
| + */ | ||
| + public static boolean reloadCommandAliases() { | ||
| + return server.reloadCommandAliases(); | ||
| + } | ||
| // Paper end | ||
|
|
||
| @NotNull | ||
| diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java | ||
| index 4c201097ef98f545acb604fa72d56413553e4d4f..6f4817af249e258905c97f4dac3d2f33804bdfc5 100644 | ||
| --- a/src/main/java/org/bukkit/Server.java | ||
| +++ b/src/main/java/org/bukkit/Server.java | ||
| @@ -1551,4 +1551,6 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi | ||
| // Spigot end | ||
|
|
||
| void reloadPermissions(); // Paper | ||
| + | ||
| + boolean reloadCommandAliases(); // Paper | ||
| } | ||
| diff --git a/src/main/java/org/bukkit/command/CommandMap.java b/src/main/java/org/bukkit/command/CommandMap.java | ||
| index bd2c7a6964722412148fae39e1b4951fc0002b9b..864c263bbd4dd6dd7c37a74b39b1a40a884d0731 100644 | ||
| --- a/src/main/java/org/bukkit/command/CommandMap.java | ||
| +++ b/src/main/java/org/bukkit/command/CommandMap.java | ||
| @@ -128,4 +128,14 @@ public interface CommandMap { | ||
| */ | ||
| @Nullable | ||
| public List<String> tabComplete(@NotNull CommandSender sender, @NotNull String cmdLine, @Nullable Location location) throws IllegalArgumentException; | ||
| + | ||
| + // Paper start - Expose Known Commands | ||
| + /** | ||
| + * Return a Map of known commands | ||
| + * | ||
| + * @return known commands | ||
| + */ | ||
| + @NotNull | ||
| + public java.util.Map<String, Command> getKnownCommands(); | ||
| + // Paper end | ||
| } | ||
| diff --git a/src/main/java/org/bukkit/command/SimpleCommandMap.java b/src/main/java/org/bukkit/command/SimpleCommandMap.java | ||
| index adfc7aae2c0f49bbcdd358e83b04a0cf078a7d52..460fda05a62b12db2edcfb7ea8b2a5dd8e4b110d 100644 | ||
| --- a/src/main/java/org/bukkit/command/SimpleCommandMap.java | ||
| +++ b/src/main/java/org/bukkit/command/SimpleCommandMap.java | ||
| @@ -297,4 +297,11 @@ public class SimpleCommandMap implements CommandMap { | ||
| } | ||
| } | ||
| } | ||
| + | ||
| + // Paper start - Expose Known Commands | ||
| + @NotNull | ||
| + public Map<String, Command> getKnownCommands() { | ||
| + return knownCommands; | ||
| + } | ||
| + // Paper end | ||
| } | ||
| diff --git a/src/main/java/org/bukkit/command/defaults/ReloadCommand.java b/src/main/java/org/bukkit/command/defaults/ReloadCommand.java | ||
| index c62da4131b17e66892678e8b618fb9ba3de93b56..0c7ba0718de2b93d013968ca0fec34ffd423990f 100644 | ||
| --- a/src/main/java/org/bukkit/command/defaults/ReloadCommand.java | ||
| +++ b/src/main/java/org/bukkit/command/defaults/ReloadCommand.java | ||
| @@ -13,7 +13,7 @@ public class ReloadCommand extends BukkitCommand { | ||
| public ReloadCommand(@NotNull String name) { | ||
| super(name); | ||
| this.description = "Reloads the server configuration and plugins"; | ||
| - this.usageMessage = "/reload [permissions]"; // Paper | ||
| + this.usageMessage = "/reload [permissions|commands|confirm]"; // Paper | ||
| this.setPermission("bukkit.command.reload"); | ||
| this.setAliases(Arrays.asList("rl")); | ||
| } | ||
| @@ -29,6 +29,13 @@ public class ReloadCommand extends BukkitCommand { | ||
| Bukkit.getServer().reloadPermissions(); | ||
| Command.broadcastCommandMessage(sender, ChatColor.GREEN + "Permissions successfully reloaded."); | ||
| return true; | ||
| + } else if ("commands".equalsIgnoreCase(args[0])) { | ||
| + if (Bukkit.getServer().reloadCommandAliases()) { | ||
| + Command.broadcastCommandMessage(sender, ChatColor.GREEN + "Command aliases successfully reloaded."); | ||
| + } else { | ||
| + Command.broadcastCommandMessage(sender, ChatColor.RED + "An error occurred while trying to reload command aliases."); | ||
| + } | ||
| + return true; | ||
| } else if ("confirm".equalsIgnoreCase(args[0])) { | ||
| confirmed = true; | ||
| } else { | ||
| @@ -53,6 +60,6 @@ public class ReloadCommand extends BukkitCommand { | ||
| @NotNull | ||
| @Override | ||
| public List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException { | ||
| - return java.util.Collections.singletonList("permissions"); // Paper | ||
| + return com.google.common.collect.Lists.newArrayList("permissions", "commands"); // Paper | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
| From: AlphaBlend <whizkid3000@hotmail.com> | ||
| Date: Thu, 8 Sep 2016 08:47:08 -0700 | ||
| Subject: [PATCH] Add source to PlayerExpChangeEvent | ||
|
|
||
|
|
||
| diff --git a/src/main/java/org/bukkit/event/player/PlayerExpChangeEvent.java b/src/main/java/org/bukkit/event/player/PlayerExpChangeEvent.java | ||
| index c99c9281e98e4b510dddb711b8785bcd56b3b92f..7c340f539c31a431d7d9204a8135e0bfc31863a8 100644 | ||
| --- a/src/main/java/org/bukkit/event/player/PlayerExpChangeEvent.java | ||
| +++ b/src/main/java/org/bukkit/event/player/PlayerExpChangeEvent.java | ||
| @@ -1,21 +1,43 @@ | ||
| package org.bukkit.event.player; | ||
|
|
||
| +import org.bukkit.entity.Entity; // Paper | ||
| import org.bukkit.entity.Player; | ||
| import org.bukkit.event.HandlerList; | ||
| import org.jetbrains.annotations.NotNull; | ||
|
|
||
| +import org.jetbrains.annotations.Nullable; // Paper | ||
| + | ||
| /** | ||
| * Called when a players experience changes naturally | ||
| */ | ||
| public class PlayerExpChangeEvent extends PlayerEvent { | ||
| private static final HandlerList handlers = new HandlerList(); | ||
| + // Paper start | ||
| + @Nullable | ||
| + private final Entity source; | ||
| private int exp; | ||
|
|
||
| public PlayerExpChangeEvent(@NotNull final Player player, final int expAmount) { | ||
| + this(player, null, expAmount); | ||
| + } | ||
| + | ||
| + public PlayerExpChangeEvent(@NotNull final Player player, @Nullable final Entity sourceEntity, final int expAmount) { | ||
| super(player); | ||
| + source = sourceEntity; | ||
| exp = expAmount; | ||
| } | ||
|
|
||
| + /** | ||
| + * Get the source that provided the experience. | ||
| + * | ||
| + * @return The source of the experience | ||
| + */ | ||
| + @Nullable | ||
| + public Entity getSource() { | ||
| + return source; | ||
| + } | ||
| + // Paper end | ||
| + | ||
| /** | ||
| * Get the amount of experience the player will receive | ||
| * |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
| From: Techcable <Techcable@outlook.com> | ||
| Date: Fri, 16 Dec 2016 21:25:39 -0600 | ||
| Subject: [PATCH] Add ProjectileCollideEvent | ||
|
|
||
|
|
||
| diff --git a/src/main/java/com/destroystokyo/paper/event/entity/ProjectileCollideEvent.java b/src/main/java/com/destroystokyo/paper/event/entity/ProjectileCollideEvent.java | ||
| new file mode 100644 | ||
| index 0000000000000000000000000000000000000000..453663893021768ae21d4980ce17ffba55d9e129 | ||
| --- /dev/null | ||
| +++ b/src/main/java/com/destroystokyo/paper/event/entity/ProjectileCollideEvent.java | ||
| @@ -0,0 +1,67 @@ | ||
| +package com.destroystokyo.paper.event.entity; | ||
| + | ||
| +import org.bukkit.entity.Entity; | ||
| +import org.bukkit.entity.Projectile; | ||
| +import org.bukkit.event.Cancellable; | ||
| +import org.bukkit.event.HandlerList; | ||
| +import org.bukkit.event.entity.EntityEvent; | ||
| +import org.jetbrains.annotations.NotNull; | ||
| + | ||
| +/** | ||
| + * Called when an projectile collides with an entity | ||
| + * <p> | ||
| + * This event is called <b>before</b> {@link org.bukkit.event.entity.EntityDamageByEntityEvent}, and cancelling it will allow the projectile to continue flying | ||
| + */ | ||
| +public class ProjectileCollideEvent extends EntityEvent implements Cancellable { | ||
| + @NotNull private final Entity collidedWith; | ||
| + | ||
| + /** | ||
| + * Get the entity the projectile collided with | ||
| + * | ||
| + * @return the entity collided with | ||
| + */ | ||
| + @NotNull | ||
| + public Entity getCollidedWith() { | ||
| + return collidedWith; | ||
| + } | ||
| + | ||
| + public ProjectileCollideEvent(@NotNull Projectile what, @NotNull Entity collidedWith) { | ||
| + super(what); | ||
| + this.collidedWith = collidedWith; | ||
| + } | ||
| + | ||
| + /** | ||
| + * Get the projectile that collided | ||
| + * | ||
| + * @return the projectile that collided | ||
| + */ | ||
| + @NotNull | ||
| + public Projectile getEntity() { | ||
| + return (Projectile) super.getEntity(); | ||
| + } | ||
| + | ||
| + private static final HandlerList handlerList = new HandlerList(); | ||
| + | ||
| + @NotNull | ||
| + public static HandlerList getHandlerList() { | ||
| + return handlerList; | ||
| + } | ||
| + | ||
| + @NotNull | ||
| + @Override | ||
| + public HandlerList getHandlers() { | ||
| + return handlerList; | ||
| + } | ||
| + | ||
| + private boolean cancelled = false; | ||
| + | ||
| + @Override | ||
| + public boolean isCancelled() { | ||
| + return cancelled; | ||
| + } | ||
| + | ||
| + @Override | ||
| + public void setCancelled(boolean cancel) { | ||
| + this.cancelled = cancel; | ||
| + } | ||
| +} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
| From: Aikar <aikar@aikar.co> | ||
| Date: Tue, 20 Dec 2016 15:55:55 -0500 | ||
| Subject: [PATCH] Add String based Action Bar API | ||
|
|
||
|
|
||
| diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java | ||
| index ddbe5734ac0f905b0c388e30f17a281530b82262..6bb0bb8052c12c5a215abf4bd9602fbefc769523 100644 | ||
| --- a/src/main/java/org/bukkit/entity/Player.java | ||
| +++ b/src/main/java/org/bukkit/entity/Player.java | ||
| @@ -3,6 +3,7 @@ package org.bukkit.entity; | ||
| import java.net.InetSocketAddress; | ||
| import java.util.UUID; | ||
| import com.destroystokyo.paper.Title; // Paper | ||
| +import net.kyori.adventure.text.Component; | ||
| import org.bukkit.DyeColor; | ||
| import org.bukkit.Effect; | ||
| import org.bukkit.GameMode; | ||
| @@ -616,6 +617,39 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM | ||
| public void sendMap(@NotNull MapView map); | ||
|
|
||
| // Paper start | ||
| + | ||
| + /** | ||
| + * Sends an Action Bar message to the client. | ||
| + * | ||
| + * Use Section symbols for legacy color codes to send formatting. | ||
| + * | ||
| + * @param message The message to send | ||
| + * @deprecated use {@link #sendActionBar(Component)} | ||
| + */ | ||
| + @Deprecated | ||
| + public void sendActionBar(@NotNull String message); | ||
| + | ||
| + /** | ||
| + * Sends an Action Bar message to the client. | ||
| + * | ||
| + * Use supplied alternative character to the section symbol to represent legacy color codes. | ||
| + * | ||
| + * @param alternateChar Alternate symbol such as '&' | ||
| + * @param message The message to send | ||
| + * @deprecated use {@link #sendActionBar(Component)} | ||
| + */ | ||
| + @Deprecated | ||
| + public void sendActionBar(char alternateChar, @NotNull String message); | ||
| + | ||
| + /** | ||
| + * Sends an Action Bar message to the client. | ||
| + * | ||
| + * @param message The components to send | ||
| + * @deprecated use {@link #sendActionBar(Component)} | ||
| + */ | ||
| + @Deprecated | ||
| + public void sendActionBar(@NotNull net.md_5.bungee.api.chat.BaseComponent... message); | ||
| + | ||
| /** | ||
| * Sends the component to the player | ||
| * | ||
| @@ -643,9 +677,11 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM | ||
| /** | ||
| * Sends an array of components as a single message to the specified screen position of this player | ||
| * | ||
| + * @deprecated This is unlikely the API you want to use. See {@link #sendActionBar(String)} for a more proper Action Bar API. This deprecated API may send unsafe items to the client. | ||
| * @param position the screen position | ||
| * @param components the components to send | ||
| */ | ||
| + @Deprecated | ||
| public default void sendMessage(net.md_5.bungee.api.ChatMessageType position, net.md_5.bungee.api.chat.BaseComponent... components) { | ||
| spigot().sendMessage(position, components); | ||
| } | ||
| @@ -1728,6 +1764,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM | ||
| /** | ||
| * Sends the component to the specified screen position of this player | ||
| * | ||
| + * @deprecated This is unlikely the API you want to use. See {@link #sendActionBar(String)} for a more proper Action Bar API. This deprecated API may send unsafe items to the client. | ||
| * @param position the screen position | ||
| * @param component the components to send | ||
| * @deprecated use {@code sendMessage} methods that accept {@link net.kyori.adventure.text.Component} | ||
| @@ -1740,6 +1777,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM | ||
| /** | ||
| * Sends an array of components as a single message to the specified screen position of this player | ||
| * | ||
| + * @deprecated This is unlikely the API you want to use. See {@link #sendActionBar(String)} for a more proper Action Bar API. This deprecated API may send unsafe items to the client. | ||
| * @param position the screen position | ||
| * @param components the components to send | ||
| * @deprecated use {@code sendMessage} methods that accept {@link net.kyori.adventure.text.Component} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
| From: kashike <kashike@vq.lc> | ||
| Date: Wed, 21 Dec 2016 11:47:25 -0600 | ||
| Subject: [PATCH] Add API methods to control if armour stands can move | ||
|
|
||
|
|
||
| diff --git a/src/main/java/org/bukkit/entity/ArmorStand.java b/src/main/java/org/bukkit/entity/ArmorStand.java | ||
| index e94ec567fbda93f4f5783f84b4b5136b309d0eab..fddc063798edc8084ca695578a47485204a7f3cd 100644 | ||
| --- a/src/main/java/org/bukkit/entity/ArmorStand.java | ||
| +++ b/src/main/java/org/bukkit/entity/ArmorStand.java | ||
| @@ -344,4 +344,21 @@ public interface ArmorStand extends LivingEntity { | ||
| */ | ||
| ADDING; | ||
| } | ||
| + // Paper start | ||
| + /** | ||
| + * Tests if this armor stand can move. | ||
| + * | ||
| + * <p>The default value is {@code true}.</p> | ||
| + * | ||
| + * @return {@code true} if this armour stand can move, {@code false} otherwise | ||
| + */ | ||
| + boolean canMove(); | ||
| + | ||
| + /** | ||
| + * Sets if this armor stand can move. | ||
| + * | ||
| + * @param move {@code true} if this armour stand can move, {@code false} otherwise | ||
| + */ | ||
| + void setCanMove(boolean move); | ||
| + // Paper end | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
| From: Aikar <aikar@aikar.co> | ||
| Date: Sun, 4 Dec 2016 01:19:14 -0500 | ||
| Subject: [PATCH] IllegalPacketEvent | ||
|
|
||
| Fire an event when an illegal packet is received to let plugins handle it | ||
|
|
||
| Lets plugins change the kick message and if it should kick or not. | ||
|
|
||
| diff --git a/src/main/java/com/destroystokyo/paper/event/player/IllegalPacketEvent.java b/src/main/java/com/destroystokyo/paper/event/player/IllegalPacketEvent.java | ||
| new file mode 100644 | ||
| index 0000000000000000000000000000000000000000..8d8e9b16f2a6707d2af7567c7682dfc5db51a737 | ||
| --- /dev/null | ||
| +++ b/src/main/java/com/destroystokyo/paper/event/player/IllegalPacketEvent.java | ||
| @@ -0,0 +1,74 @@ | ||
| +package com.destroystokyo.paper.event.player; | ||
| + | ||
| +import org.bukkit.Bukkit; | ||
| +import org.bukkit.entity.Player; | ||
| +import org.bukkit.event.HandlerList; | ||
| +import org.bukkit.event.player.PlayerEvent; | ||
| +import org.jetbrains.annotations.NotNull; | ||
| +import org.jetbrains.annotations.Nullable; | ||
| + | ||
| +/** | ||
| + * @deprecated Not used | ||
| + */ | ||
| +@Deprecated | ||
| +public class IllegalPacketEvent extends PlayerEvent { | ||
| + @Nullable private final String type; | ||
| + @Nullable private final String ex; | ||
| + @Nullable private String kickMessage; | ||
| + private boolean shouldKick = true; | ||
| + | ||
| + public IllegalPacketEvent(@NotNull Player player, @Nullable String type, @Nullable String kickMessage, @NotNull Exception e) { | ||
| + super(player); | ||
| + this.type = type; | ||
| + this.kickMessage = kickMessage; | ||
| + this.ex = e.getMessage(); | ||
| + } | ||
| + | ||
| + public boolean isShouldKick() { | ||
| + return shouldKick; | ||
| + } | ||
| + | ||
| + public void setShouldKick(boolean shouldKick) { | ||
| + this.shouldKick = shouldKick; | ||
| + } | ||
| + | ||
| + @Nullable | ||
| + public String getKickMessage() { | ||
| + return kickMessage; | ||
| + } | ||
| + | ||
| + public void setKickMessage(@Nullable String kickMessage) { | ||
| + this.kickMessage = kickMessage; | ||
| + } | ||
| + | ||
| + @Nullable | ||
| + public String getType() { | ||
| + return type; | ||
| + } | ||
| + | ||
| + @Nullable | ||
| + public String getExceptionMessage() { | ||
| + return ex; | ||
| + } | ||
| + | ||
| + private static final HandlerList handlers = new HandlerList(); | ||
| + | ||
| + @NotNull | ||
| + public HandlerList getHandlers() { | ||
| + return handlers; | ||
| + } | ||
| + | ||
| + @NotNull | ||
| + public static HandlerList getHandlerList() { | ||
| + return handlers; | ||
| + } | ||
| + | ||
| + public static void process(@NotNull Player player, @Nullable String type, @Nullable String kickMessage, @NotNull Exception exception) { | ||
| + IllegalPacketEvent event = new IllegalPacketEvent(player, type, kickMessage, exception); | ||
| + event.callEvent(); | ||
| + if (event.shouldKick) { | ||
| + player.kickPlayer(kickMessage); | ||
| + } | ||
| + Bukkit.getLogger().severe(player.getName() + "/" + type + ": " + exception.getMessage()); | ||
| + } | ||
| +} |