1
0
Fork 0
mirror of https://github.com/PaperMC/Paper.git synced 2025-02-03 21:37:28 +01:00

API patches

This commit is contained in:
Nassim Jahnke 2022-06-07 19:20:30 +02:00
parent 1148687a8d
commit 66eb6f7632
381 changed files with 63 additions and 111 deletions
patches/api
API-for-creating-command-sender-which-forwards-feedb.patchAPI-to-get-a-BlockState-without-a-snapshot.patchAbility-to-apply-mending-to-XP-API.patchAbility-to-change-PlayerProfile-in-AsyncPreLoginEven.patchAbility-to-get-Tile-Entities-from-a-chunk-without-sn.patchAdd-API-for-item-entity-health.patchAdd-API-for-quit-reason.patchAdd-API-for-resetting-a-single-score.patchAdd-API-methods-to-control-if-armour-stands-can-move.patchAdd-API-to-get-Material-from-Boats-and-Minecarts.patchAdd-API-to-get-exact-interaction-point-in-PlayerInte.patchAdd-APIs-to-replace-OfflinePlayer-getLastPlayed.patchAdd-Adventure-message-to-PlayerAdvancementDoneEvent.patchAdd-ArmorStand-Item-Meta.patchAdd-Ban-Methods-to-Player-Objects.patchAdd-BaseComponent-sendMessage-methods-to-CommandSend.patchAdd-BeaconEffectEvent.patchAdd-BellRevealRaiderEvent.patchAdd-BellRingEvent.patchAdd-Block-isValidTool.patchAdd-BlockBreakBlockEvent.patchAdd-BlockFailedDispenseEvent.patchAdd-BlockPreDispenseEvent.patchAdd-BlockSoundGroup-interface.patchAdd-Destroy-Speed-API.patchAdd-ElderGuardianAppearanceEvent.patchAdd-EntityBlockStorage-clearEntities.patchAdd-EntityDyeEvent-and-CollarColorable-interface.patchAdd-EntityInsideBlockEvent.patchAdd-EntityKnockbackByEntityEvent.patchAdd-EntityLoadCrossbowEvent.patchAdd-EntityTeleportEndGatewayEvent.patchAdd-EntityZapEvent.patchAdd-FastUtil-to-Bukkit.patchAdd-GS4-Query-event.patchAdd-GameEvent-tags.patchAdd-Git-information-to-version-command-on-startup.patchAdd-Heightmap-API.patchAdd-ItemFactory-getMonsterEgg-API.patchAdd-ItemStack-Recipe-API-helper-methods.patchAdd-ItemStackRecipeChoice-Draft-API.patchAdd-LivingEntity-clearActiveItem.patchAdd-LivingEntity-getTargetEntity.patchAdd-Material-Tags.patchAdd-MetadataStoreBase.removeAll-Plugin.patchAdd-Mob-Goal-API.patchAdd-Mob-lookAt-API.patchAdd-More-Creeper-API.patchAdd-OBSTRUCTED-reason-to-BedEnterResult.patchAdd-PaperRegistry.patchAdd-PhantomPreSpawnEvent.patchAdd-Player-Client-Options-API.patchAdd-PlayerArmorChangeEvent.patchAdd-PlayerAttackEntityCooldownResetEvent.patchAdd-PlayerConnectionCloseEvent.patchAdd-PlayerFlowerPotManipulateEvent.patchAdd-PlayerInitialSpawnEvent.patchAdd-PlayerItemCooldownEvent.patchAdd-PlayerItemFrameChangeEvent.patchAdd-PlayerJumpEvent.patchAdd-PlayerKickEvent-causes.patchAdd-PlayerLocaleChangeEvent.patchAdd-PlayerPostRespawnEvent.patchAdd-PlayerSetSpawnEvent.patchAdd-PlayerShearBlockEvent.patchAdd-PlayerSignCommandPreprocessEvent.patchAdd-PlayerStopUsingItemEvent.patchAdd-PlayerUseUnknownEntityEvent.patchAdd-PrepareResultEvent-PrepareGrindstoneEvent.patchAdd-ProjectileCollideEvent.patchAdd-PufferFishStateChangeEvent.patchAdd-Raw-Byte-Entity-Serialization.patchAdd-Raw-Byte-ItemStack-Serialization.patchAdd-String-based-Action-Bar-API.patchAdd-StructuresLocateEvent.patchAdd-TNTPrimeEvent.patchAdd-TameableDeathMessageEvent.patchAdd-TargetHitEvent-API.patchAdd-ThrownEggHatchEvent.patchAdd-UnknownCommandEvent.patchAdd-WhitelistToggleEvent.patchAdd-World.getEntity-UUID-API.patchAdd-a-call-helper-to-Event.patchAdd-a-should-burn-in-sunlight-API-for-Phantoms-and-S.patchAdd-additional-open-container-api-to-HumanEntity.patchAdd-advancement-display-API.patchAdd-an-API-for-CanPlaceOn-and-CanDestroy-NBT-values.patchAdd-an-asterisk-to-legacy-API-plugins.patchAdd-and-implement-PlayerRecipeBookClickEvent.patchAdd-basic-Datapack-API.patchAdd-cause-to-Weather-ThunderChangeEvents.patchAdd-command-line-option-to-load-extra-plugin-jars-no.patchAdd-command-to-reload-permissions.yml-and-require-co.patchAdd-configuration-option-to-prevent-player-names-fro.patchAdd-critical-damage-API.patchAdd-dropLeash-variable-to-EntityUnleashEvent.patchAdd-effect-to-block-break-naturally.patchAdd-enchantWithLevels-API.patchAdd-entity-liquid-API.patchAdd-exception-reporting-event.patch

View file

@ -91,11 +91,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/org/bukkit/command/defaults/VersionCommand.java
+++ b/src/main/java/org/bukkit/command/defaults/VersionCommand.java
@@ -0,0 +0,0 @@ public class VersionCommand extends BukkitCommand {
private void setVersionMessage(final @NotNull Component msg) {
private void setVersionMessage(final @NotNull net.kyori.adventure.text.Component msg) {
lastCheck = System.currentTimeMillis();
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.text(Bukkit.getVersionMessage(), net.kyori.adventure.text.format.NamedTextColor.WHITE),
Component.newline(),
final net.kyori.adventure.text.Component message = net.kyori.adventure.text.TextComponent.ofChildren(
- net.kyori.adventure.text.Component.text("This server is running " + Bukkit.getName() + " version " + Bukkit.getVersion() + " (Implementing API version " + Bukkit.getBukkitVersion() + ")", net.kyori.adventure.text.format.NamedTextColor.WHITE),
+ net.kyori.adventure.text.Component.text(Bukkit.getVersionMessage(), net.kyori.adventure.text.format.NamedTextColor.WHITE),
net.kyori.adventure.text.Component.newline(),
msg
);

View file

@ -49,7 +49,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
+++ b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java
@@ -0,0 +0,0 @@ public final class JavaPluginLoader implements PluginLoader {
Validate.isTrue(plugin instanceof JavaPlugin, "Plugin is not associated with this PluginLoader");
Preconditions.checkArgument(plugin instanceof JavaPlugin, "Plugin is not associated with this PluginLoader");
if (!plugin.isEnabled()) {
- plugin.getLogger().info("Enabling " + plugin.getDescription().getFullName());

View file

@ -68,8 +68,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ @NotNull
+ public Plugin[] loadPlugins(final @NotNull File directory, final @NotNull List<File> extraPluginJars) {
+ // Paper end
Validate.notNull(directory, "Directory cannot be null");
Validate.isTrue(directory.isDirectory(), "Directory must be a directory");
Preconditions.checkArgument(directory != null, "Directory cannot be null");
Preconditions.checkArgument(directory.isDirectory(), "Directory must be a directory");
@@ -0,0 +0,0 @@ public final class SimplePluginManager implements PluginManager {
Map<String, Collection<String>> softDependencies = new HashMap<String, Collection<String>>();

View file

@ -50,8 +50,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/org/bukkit/command/Command.java
+++ b/src/main/java/org/bukkit/command/Command.java
@@ -0,0 +0,0 @@ public abstract class Command {
Validate.notNull(args, "Arguments cannot be null");
Validate.notNull(alias, "Alias cannot be null");
Preconditions.checkArgument(args != null, "Arguments cannot be null");
Preconditions.checkArgument(alias != null, "Alias cannot be null");
- if (args.length == 0) {
+ if (args.length == 0 || !sender.getServer().suggestPlayerNamesWhenNullTabCompletions()) { // Paper - allow preventing player name suggestions by default) {

View file

@ -467,29 +467,18 @@ diff --git a/src/main/java/org/bukkit/command/SimpleCommandMap.java b/src/main/j
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/command/SimpleCommandMap.java
+++ b/src/main/java/org/bukkit/command/SimpleCommandMap.java
@@ -0,0 +0,0 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+
+import com.destroystokyo.paper.event.server.ServerExceptionEvent;
+import com.destroystokyo.paper.exception.ServerCommandException;
+import com.destroystokyo.paper.exception.ServerTabCompleteException;
import org.apache.commons.lang.Validate;
import org.bukkit.Location;
import org.bukkit.Server;
@@ -0,0 +0,0 @@ public class SimpleCommandMap implements CommandMap {
target.execute(sender, sentCommandLabel, Arrays.copyOfRange(args, 1, args.length));
} // target.timings.stopTiming(); // Spigot // Paper
} catch (CommandException ex) {
+ server.getPluginManager().callEvent(new ServerExceptionEvent(new ServerCommandException(ex, target, sender, args))); // Paper
+ server.getPluginManager().callEvent(new com.destroystokyo.paper.event.server.ServerExceptionEvent(new com.destroystokyo.paper.exception.ServerCommandException(ex, target, sender, args))); // Paper
//target.timings.stopTiming(); // Spigot // Paper
throw ex;
} catch (Throwable ex) {
//target.timings.stopTiming(); // Spigot // Paper
- throw new CommandException("Unhandled exception executing '" + commandLine + "' in " + target, ex);
+ String msg = "Unhandled exception executing '" + commandLine + "' in " + target;
+ server.getPluginManager().callEvent(new ServerExceptionEvent(new ServerCommandException(ex, target, sender, args))); // Paper
+ server.getPluginManager().callEvent(new com.destroystokyo.paper.event.server.ServerExceptionEvent(new com.destroystokyo.paper.exception.ServerCommandException(ex, target, sender, args))); // Paper
+ throw new CommandException(msg, ex);
}
@ -500,7 +489,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} catch (Throwable ex) {
- throw new CommandException("Unhandled exception executing tab-completer for '" + cmdLine + "' in " + target, ex);
+ String msg = "Unhandled exception executing tab-completer for '" + cmdLine + "' in " + target;
+ server.getPluginManager().callEvent(new ServerExceptionEvent(new ServerTabCompleteException(msg, ex, target, sender, args))); // Paper
+ server.getPluginManager().callEvent(new com.destroystokyo.paper.event.server.ServerExceptionEvent(new com.destroystokyo.paper.exception.ServerTabCompleteException(msg, ex, target, sender, args))); // Paper
+ throw new CommandException(msg, ex);
}
}
@ -509,17 +498,6 @@ diff --git a/src/main/java/org/bukkit/plugin/SimplePluginManager.java b/src/main
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/plugin/SimplePluginManager.java
+++ b/src/main/java/org/bukkit/plugin/SimplePluginManager.java
@@ -0,0 +0,0 @@ import java.util.WeakHashMap;
import java.util.logging.Level;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+
+import com.destroystokyo.paper.event.server.ServerExceptionEvent;
+import com.destroystokyo.paper.exception.ServerEventException;
+import com.destroystokyo.paper.exception.ServerPluginEnableDisableException;
import org.apache.commons.lang.Validate;
import org.bukkit.Server;
import org.bukkit.World;
@@ -0,0 +0,0 @@ public final class SimplePluginManager implements PluginManager {
try {
plugin.getPluginLoader().enablePlugin(plugin);
@ -580,7 +558,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // Paper start
+ private void handlePluginException(String msg, Throwable ex, Plugin plugin) {
+ server.getLogger().log(Level.SEVERE, msg, ex);
+ callEvent(new ServerExceptionEvent(new ServerPluginEnableDisableException(msg, ex, plugin)));
+ callEvent(new com.destroystokyo.paper.event.server.ServerExceptionEvent(new com.destroystokyo.paper.exception.ServerPluginEnableDisableException(msg, ex, plugin)));
+ }
+ // Paper end
+
@ -595,8 +573,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // Paper start - error reporting
+ String msg = "Could not pass event " + event.getEventName() + " to " + registration.getPlugin().getDescription().getFullName();
+ server.getLogger().log(Level.SEVERE, msg, ex);
+ if (!(event instanceof ServerExceptionEvent)) { // We don't want to cause an endless event loop
+ callEvent(new ServerExceptionEvent(new ServerEventException(msg, ex, registration.getPlugin(), registration.getListener(), event)));
+ if (!(event instanceof com.destroystokyo.paper.event.server.ServerExceptionEvent)) { // We don't want to cause an endless event loop
+ callEvent(new com.destroystokyo.paper.event.server.ServerExceptionEvent(new com.destroystokyo.paper.exception.ServerEventException(msg, ex, registration.getPlugin(), registration.getListener(), event)));
+ }
+ // Paper end
}

Some files were not shown because too many files have changed in this diff Show more