more cleanup and resource pack api fixes
This commit is contained in:
@@ -110,28 +110,28 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
@@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
private org.bukkit.event.player.PlayerResourcePackStatusEvent.Status resourcePackStatus;
|
||||
private String resourcePackHash;
|
||||
private BorderChangeListener clientWorldBorderListener = this.createWorldBorderListener();
|
||||
public org.bukkit.event.player.PlayerResourcePackStatusEvent.Status resourcePackStatus; // Paper - more resource pack API
|
||||
private static final boolean DISABLE_CHANNEL_LIMIT = System.getProperty("paper.disableChannelLimit") != null; // Paper - add a flag to disable the channel limit
|
||||
+ private long lastSaveTime;
|
||||
// Paper end
|
||||
+ private long lastSaveTime; // Paper - getLastPlayed replacement API
|
||||
|
||||
public CraftPlayer(CraftServer server, ServerPlayer entity) {
|
||||
super(server, entity);
|
||||
@@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
this.firstPlayed = firstPlayed;
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ // Paper start - getLastPlayed replacement API
|
||||
+ @Override
|
||||
+ public long getLastLogin() {
|
||||
+ return getHandle().loginTime;
|
||||
+ return this.getHandle().loginTime;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public long getLastSeen() {
|
||||
+ return isOnline() ? System.currentTimeMillis() : this.lastSaveTime;
|
||||
+ return this.isOnline() ? System.currentTimeMillis() : this.lastSaveTime;
|
||||
+ }
|
||||
+ // Paper end
|
||||
+ // Paper end - getLastPlayed replacement API
|
||||
+
|
||||
public void readExtraData(CompoundTag nbttagcompound) {
|
||||
this.hasPlayedBefore = true;
|
||||
|
||||
@@ -13,7 +13,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
SignedMessageLink signedMessageLink = this.advanceLink();
|
||||
if (signedMessageLink == null) {
|
||||
- throw new SignedMessageChain.DecodeException(Component.translatable("chat.disabled.chain_broken"), false);
|
||||
+ throw new SignedMessageChain.DecodeException(Component.translatable("chat.disabled.chain_broken"), false); // Paper - TODO 1.20.3 - new kick cause?
|
||||
+ throw new SignedMessageChain.DecodeException(Component.translatable("chat.disabled.chain_broken"), false); // Paper - diff on change (if disconnects, need a new kick event cause)
|
||||
} else if (playerPublicKey.data().hasExpired()) {
|
||||
- throw new SignedMessageChain.DecodeException(Component.translatable("chat.disabled.expiredProfileKey"), false);
|
||||
+ throw new SignedMessageChain.DecodeException(Component.translatable("chat.disabled.expiredProfileKey", org.bukkit.event.player.PlayerKickEvent.Cause.EXPIRED_PROFILE_PUBLIC_KEY), false); // Paper - kick event causes
|
||||
|
||||
@@ -3755,10 +3755,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
}
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ // TODO UUID API
|
||||
+ // Paper start - adventure
|
||||
+ @Override
|
||||
+ public void setResourcePack(String url, byte[] hashBytes, net.kyori.adventure.text.Component prompt, boolean force) {
|
||||
+ public void setResourcePack(final UUID uuid, final String url, final byte[] hashBytes, final net.kyori.adventure.text.Component prompt, final boolean force) {
|
||||
+ Preconditions.checkArgument(uuid != null, "Resource pack UUID cannot be null");
|
||||
+ Preconditions.checkArgument(url != null, "Resource pack URL cannot be null");
|
||||
+ final String hash;
|
||||
+ if (hashBytes != null) {
|
||||
@@ -3767,9 +3767,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ } else {
|
||||
+ hash = "";
|
||||
+ }
|
||||
+ this.getHandle().connection.send(new ClientboundResourcePackPushPacket(UUID.randomUUID(), url, hash, force, io.papermc.paper.adventure.PaperAdventure.asVanilla(prompt)));
|
||||
+ this.getHandle().connection.send(new net.minecraft.network.protocol.common.ClientboundResourcePackPopPacket(Optional.empty()));
|
||||
+ this.getHandle().connection.send(new ClientboundResourcePackPushPacket(uuid, url, hash, force, io.papermc.paper.adventure.PaperAdventure.asVanilla(prompt)));
|
||||
+ }
|
||||
+ // Paper end
|
||||
+ // Paper end - adventure
|
||||
+
|
||||
public void addChannel(String channel) {
|
||||
Preconditions.checkState(this.channels.size() < 128, "Cannot register channel '%s'. Too many channels registered!", channel);
|
||||
|
||||
@@ -15,7 +15,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
- this.cserver.getPluginManager().callEvent(new PlayerResourcePackStatusEvent(this.getCraftPlayer(), packet.id(), PlayerResourcePackStatusEvent.Status.values()[packet.action().ordinal()])); // CraftBukkit
|
||||
+ // Paper start
|
||||
+ PlayerResourcePackStatusEvent.Status packStatus = PlayerResourcePackStatusEvent.Status.values()[packet.action().ordinal()];
|
||||
+ player.getBukkitEntity().setResourcePackStatus(packStatus);
|
||||
+ player.getBukkitEntity().resourcePackStatus = packStatus;
|
||||
+ this.cserver.getPluginManager().callEvent(new PlayerResourcePackStatusEvent(this.getCraftPlayer(), packet.id(), packStatus)); // CraftBukkit
|
||||
+ // Paper end
|
||||
|
||||
@@ -25,48 +25,28 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
@@ -0,0 +0,0 @@ import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.PlayerChatMessage;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
import net.minecraft.network.protocol.common.ClientboundCustomPayloadPacket;
|
||||
+import net.minecraft.network.protocol.common.ClientboundResourcePackPopPacket;
|
||||
import net.minecraft.network.protocol.common.ClientboundResourcePackPushPacket;
|
||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||
import net.minecraft.network.protocol.game.ClientboundBlockDestructionPacket;
|
||||
@@ -0,0 +0,0 @@ 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 org.bukkit.event.player.PlayerResourcePackStatusEvent.Status resourcePackStatus; // Paper - more resource pack API
|
||||
|
||||
public CraftPlayer(CraftServer server, ServerPlayer entity) {
|
||||
super(server, entity);
|
||||
@@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
public boolean getAffectsSpawning() {
|
||||
return this.getHandle().affectsSpawning;
|
||||
}
|
||||
+
|
||||
// Paper end - adventure
|
||||
|
||||
+ // Paper start - more resource pack API
|
||||
+ @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) {
|
||||
+ public void setResourcePack(@NotNull UUID uuid, @NotNull String url, @NotNull String hash, net.kyori.adventure.text.Component resourcePackPrompt, boolean required) {
|
||||
+ Preconditions.checkArgument(uuid != null, "Resource pack UUID cannot be null");
|
||||
+ Preconditions.checkArgument(url != null, "Resource pack URL cannot be null");
|
||||
+ Preconditions.checkArgument(hash != null, "Hash cannot be null");
|
||||
+ net.minecraft.network.chat.Component promptComponent = resourcePackPrompt != null ?
|
||||
+ io.papermc.paper.adventure.PaperAdventure.asVanilla(resourcePackPrompt) :
|
||||
+ null;
|
||||
+ this.getHandle().connection.send(new ClientboundResourcePackPopPacket(Optional.empty()));
|
||||
+ final net.minecraft.network.chat.Component promptComponent = resourcePackPrompt != null ?
|
||||
+ io.papermc.paper.adventure.PaperAdventure.asVanilla(resourcePackPrompt) :
|
||||
+ null;
|
||||
+ this.getHandle().connection.send(new net.minecraft.network.protocol.common.ClientboundResourcePackPopPacket(Optional.empty()));
|
||||
+ this.getHandle().connection.send(new ClientboundResourcePackPushPacket(UUID.randomUUID(), url, hash, required, promptComponent));
|
||||
+ }
|
||||
+
|
||||
@@ -74,20 +54,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+ public org.bukkit.event.player.PlayerResourcePackStatusEvent.Status getResourcePackStatus() {
|
||||
+ return this.resourcePackStatus;
|
||||
+ }
|
||||
+ // Paper end - more resource pack API
|
||||
+
|
||||
+ @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
|
||||
public void addChannel(String channel) {
|
||||
Preconditions.checkState(this.channels.size() < 128, "Cannot register channel '%s'. Too many channels registered!", channel);
|
||||
channel = StandardMessenger.validateAndCorrectChannel(channel);
|
||||
|
||||
@@ -13,15 +13,15 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
@@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
// Paper start
|
||||
private org.bukkit.event.player.PlayerResourcePackStatusEvent.Status resourcePackStatus;
|
||||
private String resourcePackHash;
|
||||
private CraftWorldBorder clientWorldBorder = null;
|
||||
private BorderChangeListener clientWorldBorderListener = this.createWorldBorderListener();
|
||||
public org.bukkit.event.player.PlayerResourcePackStatusEvent.Status resourcePackStatus; // Paper - more resource pack API
|
||||
+ private static final boolean DISABLE_CHANNEL_LIMIT = System.getProperty("paper.disableChannelLimit") != null; // Paper - add a flag to disable the channel limit
|
||||
// Paper end
|
||||
|
||||
public CraftPlayer(CraftServer server, ServerPlayer entity) {
|
||||
super(server, entity);
|
||||
@@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
// Paper end
|
||||
// Paper end - more resource pack API
|
||||
|
||||
public void addChannel(String channel) {
|
||||
- Preconditions.checkState(this.channels.size() < 128, "Cannot register channel '%s'. Too many channels registered!", channel);
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jake Potrebic <jake.m.potrebic@gmail.com>
|
||||
Date: Fri, 8 Dec 2023 15:06:16 -0800
|
||||
Subject: [PATCH] Keep previous behavior for setResourcePack
|
||||
|
||||
Before multiple packs were allowed, setResourcePack
|
||||
resulted in the client's existing server pack being
|
||||
replaced. To keep this behavior, we will remove all
|
||||
packs before sending the new pack. Other API exists
|
||||
for adding a new pack to the existing packs on a client.
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
||||
@@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
if (hash != null) {
|
||||
Preconditions.checkArgument(hash.length == 20, "Resource pack hash should be 20 bytes long but was %s", hash.length);
|
||||
|
||||
+ this.getHandle().connection.send(new net.minecraft.network.protocol.common.ClientboundResourcePackPopPacket(Optional.empty())); // Paper - keep previous behavior of clearing packs
|
||||
this.getHandle().connection.send(new ClientboundResourcePackPushPacket(id, url, BaseEncoding.base16().lowerCase().encode(hash), force, CraftChatMessage.fromStringOrNull(prompt, true)));
|
||||
} else {
|
||||
+ this.getHandle().connection.send(new net.minecraft.network.protocol.common.ClientboundResourcePackPopPacket(Optional.empty())); // Paper - keep previous behavior of clearing packs
|
||||
this.getHandle().connection.send(new ClientboundResourcePackPushPacket(id, url, "", force, CraftChatMessage.fromStringOrNull(prompt, true)));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user