-
-
Notifications
You must be signed in to change notification settings - Fork 478
Add Player send death screen API #1129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
Add death screen API
- Loading branch information
commit d1b6bd56d69200bfd408c065131c139abe1df58b
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
| From: MelnCat <melncatuwu@gmail.com> | ||
| Date: Fri, 23 Sep 2022 18:35:28 -0700 | ||
| Subject: [PATCH] Add death screen API | ||
|
|
||
|
|
||
| diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java | ||
| index f50c61a8c375af03f3f0f5469e376e3f9c19f03e..872a1c0f4ac33ee6739b3d73ee99670da05e33c6 100644 | ||
| --- a/src/main/java/org/bukkit/entity/Player.java | ||
| +++ b/src/main/java/org/bukkit/entity/Player.java | ||
| @@ -2948,5 +2948,21 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM | ||
| * Clears all debug block highlights | ||
| */ | ||
| void clearBlockHighlights(); | ||
| + | ||
| + /** | ||
| + * Sends a player the death screen with a specified death message. | ||
| + * | ||
| + * @param message The death message to show the player | ||
| + */ | ||
| + void sendDeathScreen(@NotNull Component message); | ||
| + | ||
| + /** | ||
| + * Sends a player the death screen with a specified death message, | ||
| + * along with the entity that caused the death. | ||
| + * | ||
| + * @param message The death message to show the player | ||
| + * @param killer The entity that killed the player | ||
| + */ | ||
| + void sendDeathScreen(@NotNull Component message, @Nullable Entity killer); | ||
| // Purpur end | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
| From: MelnCat <melncatuwu@gmail.com> | ||
| Date: Fri, 23 Sep 2022 18:41:05 -0700 | ||
| Subject: [PATCH] Add death screen API | ||
|
|
||
|
|
||
| diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundPlayerCombatKillPacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundPlayerCombatKillPacket.java | ||
| index 53b75f5737a910ffc5448cd9a85eae57f9c1488f..ea95873dd034779e56a8b924cd27f9375be05daf 100644 | ||
| --- a/src/main/java/net/minecraft/network/protocol/game/ClientboundPlayerCombatKillPacket.java | ||
| +++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundPlayerCombatKillPacket.java | ||
| @@ -9,6 +9,7 @@ public class ClientboundPlayerCombatKillPacket implements Packet<ClientGamePacke | ||
| private final int playerId; | ||
| private final int killerId; | ||
| private final Component message; | ||
| + public net.kyori.adventure.text.Component adventure$message; // Purpur | ||
|
|
||
| public ClientboundPlayerCombatKillPacket(CombatTracker damageTracker, Component message) { | ||
| this(damageTracker.getMob().getId(), damageTracker.getKillerId(), message); | ||
| @@ -30,6 +31,12 @@ public class ClientboundPlayerCombatKillPacket implements Packet<ClientGamePacke | ||
| public void write(FriendlyByteBuf buf) { | ||
| buf.writeVarInt(this.playerId); | ||
| buf.writeInt(this.killerId); | ||
| + // Purpur start | ||
| + if (this.adventure$message != null) { | ||
| + buf.writeComponent(this.adventure$message); | ||
| + return; | ||
| + } | ||
| + // Purpur end | ||
| buf.writeComponent(this.message); | ||
| } | ||
|
|
||
| diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java | ||
| index 3b5ff0b3013a10b5515b13d1b660ec421531d772..c503b886013bc053d32b8afd8cd9bca09132a882 100644 | ||
| --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java | ||
| +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java | ||
| @@ -3026,5 +3026,18 @@ public class CraftPlayer extends CraftHumanEntity implements Player { | ||
| if (this.getHandle().connection == null) return; | ||
| this.getHandle().connection.send(new net.minecraft.network.protocol.game.ClientboundCustomPayloadPacket(ClientboundCustomPayloadPacket.DEBUG_GAME_TEST_CLEAR, new FriendlyByteBuf(io.netty.buffer.Unpooled.buffer()))); | ||
| } | ||
| + | ||
| + @Override | ||
| + public void sendDeathScreen(net.kyori.adventure.text.Component message) { | ||
| + sendDeathScreen(message, null); | ||
| + } | ||
| + | ||
| + @Override | ||
| + public void sendDeathScreen(net.kyori.adventure.text.Component message, org.bukkit.entity.Entity killer) { | ||
| + if (this.getHandle().connection == null) return; | ||
| + net.minecraft.network.protocol.game.ClientboundPlayerCombatKillPacket packet = new net.minecraft.network.protocol.game.ClientboundPlayerCombatKillPacket(getEntityId(), killer == null ? -1 : killer.getEntityId(), null); | ||
| + packet.adventure$message = message; | ||
| + this.getHandle().connection.send(packet); | ||
| + } | ||
| // Purpur end | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.