Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-15 12:30:06 +01:00
94 Zeilen
4.5 KiB
Diff
94 Zeilen
4.5 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Jedediah Smith <jedediah@silencegreys.com>
|
|
Date: Sat, 4 Apr 2015 23:17:52 -0400
|
|
Subject: [PATCH] Complete resource pack API
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
index 580f126ad3681306bfff24c1e19dab39a6d4e888..8f21a18d2ba6e9fc1c8d3076ca668c885a9ba19e 100644
|
|
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
@@ -1764,8 +1764,11 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
|
ServerGamePacketListenerImpl.LOGGER.info("Disconnecting {} due to resource pack rejection", this.player.getName());
|
|
this.disconnect(Component.translatable("multiplayer.requiredTexturePrompt.disconnect"));
|
|
}
|
|
- this.cserver.getPluginManager().callEvent(new PlayerResourcePackStatusEvent(this.getCraftPlayer(), PlayerResourcePackStatusEvent.Status.values()[packet.action.ordinal()])); // CraftBukkit
|
|
-
|
|
+ // Paper start
|
|
+ PlayerResourcePackStatusEvent.Status packStatus = PlayerResourcePackStatusEvent.Status.values()[packet.action.ordinal()];
|
|
+ player.getBukkitEntity().setResourcePackStatus(packStatus);
|
|
+ this.cserver.getPluginManager().callEvent(new PlayerResourcePackStatusEvent(this.getCraftPlayer(), packStatus)); // CraftBukkit
|
|
+ // Paper end
|
|
}
|
|
|
|
@Override
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
index af4e9891da2584c791ce85f5eb6315a06fcc77e8..921c00c2a5e7d3487c35ee27714ae6bb6666f86f 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
@@ -152,6 +152,7 @@ import org.bukkit.plugin.Plugin;
|
|
import org.bukkit.plugin.messaging.StandardMessenger;
|
|
import org.bukkit.profile.PlayerProfile;
|
|
import org.bukkit.scoreboard.Scoreboard;
|
|
+import org.jetbrains.annotations.NotNull;
|
|
|
|
import net.md_5.bungee.api.chat.BaseComponent; // Spigot
|
|
|
|
@@ -170,6 +171,10 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|
private double healthScale = 20;
|
|
private CraftWorldBorder clientWorldBorder = null;
|
|
private BorderChangeListener clientWorldBorderListener = this.createWorldBorderListener();
|
|
+ // Paper start
|
|
+ private org.bukkit.event.player.PlayerResourcePackStatusEvent.Status resourcePackStatus;
|
|
+ private String resourcePackHash;
|
|
+ // Paper end
|
|
|
|
public CraftPlayer(CraftServer server, ServerPlayer entity) {
|
|
super(server, entity);
|
|
@@ -2208,6 +2213,45 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|
public boolean getAffectsSpawning() {
|
|
return this.getHandle().affectsSpawning;
|
|
}
|
|
+
|
|
+ @Override
|
|
+ public void setResourcePack(@NotNull String url, @NotNull String hash) {
|
|
+ this.setResourcePack(url, hash, false, null);
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void setResourcePack(@NotNull String url, @NotNull String hash, boolean required) {
|
|
+ this.setResourcePack(url, hash, required, null);
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void setResourcePack(@NotNull String url, @NotNull String hash, boolean required, net.kyori.adventure.text.Component resourcePackPrompt) {
|
|
+ Validate.notNull(url, "Resource pack URL cannot be null");
|
|
+ Validate.notNull(hash, "Hash cannot be null");
|
|
+ net.minecraft.network.chat.Component promptComponent = resourcePackPrompt != null ?
|
|
+ io.papermc.paper.adventure.PaperAdventure.asVanilla(resourcePackPrompt) :
|
|
+ null;
|
|
+ this.getHandle().sendTexturePack(url, hash, required, promptComponent);
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public org.bukkit.event.player.PlayerResourcePackStatusEvent.Status getResourcePackStatus() {
|
|
+ return this.resourcePackStatus;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public String getResourcePackHash() {
|
|
+ return this.resourcePackHash;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean hasResourcePack() {
|
|
+ return this.resourcePackStatus == org.bukkit.event.player.PlayerResourcePackStatusEvent.Status.SUCCESSFULLY_LOADED;
|
|
+ }
|
|
+
|
|
+ public void setResourcePackStatus(org.bukkit.event.player.PlayerResourcePackStatusEvent.Status status) {
|
|
+ this.resourcePackStatus = status;
|
|
+ }
|
|
// Paper end
|
|
|
|
@Override
|