3
0
Mirror von https://github.com/PaperMC/Velocity.git synchronisiert 2024-12-26 00:00:55 +01:00

Introduce PlayerClientBrandEvent, fired when the player sends the minecraft:brand message (#567)

Dieser Commit ist enthalten in:
James Puleo 2021-10-15 10:26:25 -04:00 committet von GitHub
Ursprung 41f66c7c04
Commit 996ada1f39
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
2 geänderte Dateien mit 51 neuen und 1 gelöschten Zeilen

Datei anzeigen

@ -0,0 +1,47 @@
/*
* Copyright (C) 2018 Velocity Contributors
*
* The Velocity API is licensed under the terms of the MIT License. For more details,
* reference the LICENSE file in the api top-level directory.
*/
package com.velocitypowered.api.event.player;
import com.google.common.base.Preconditions;
import com.velocitypowered.api.proxy.Player;
/**
* Fired when a {@link Player} sends the <code>minecraft:brand</code> plugin message.
*/
public final class PlayerClientBrandEvent {
private final Player player;
private final String brand;
/**
* Creates a new instance.
*
* @param player the {@link Player} of the sent client brand
* @param brand the sent client brand
*/
public PlayerClientBrandEvent(Player player, String brand) {
this.player = Preconditions.checkNotNull(player);
this.brand = Preconditions.checkNotNull(brand);
}
public Player getPlayer() {
return player;
}
public String getBrand() {
return brand;
}
@Override
public String toString() {
return "PlayerClientBrandEvent{"
+ "player=" + player
+ ", brand='" + brand + '\''
+ '}';
}
}

Datei anzeigen

@ -27,6 +27,7 @@ import com.velocitypowered.api.event.command.CommandExecuteEvent.CommandResult;
import com.velocitypowered.api.event.connection.PluginMessageEvent; import com.velocitypowered.api.event.connection.PluginMessageEvent;
import com.velocitypowered.api.event.player.PlayerChannelRegisterEvent; import com.velocitypowered.api.event.player.PlayerChannelRegisterEvent;
import com.velocitypowered.api.event.player.PlayerChatEvent; import com.velocitypowered.api.event.player.PlayerChatEvent;
import com.velocitypowered.api.event.player.PlayerClientBrandEvent;
import com.velocitypowered.api.event.player.PlayerResourcePackStatusEvent; import com.velocitypowered.api.event.player.PlayerResourcePackStatusEvent;
import com.velocitypowered.api.event.player.TabCompleteEvent; import com.velocitypowered.api.event.player.TabCompleteEvent;
import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.api.network.ProtocolVersion;
@ -236,7 +237,9 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
player.getKnownChannels().removeAll(PluginMessageUtil.getChannels(packet)); player.getKnownChannels().removeAll(PluginMessageUtil.getChannels(packet));
backendConn.write(packet.retain()); backendConn.write(packet.retain());
} else if (PluginMessageUtil.isMcBrand(packet)) { } else if (PluginMessageUtil.isMcBrand(packet)) {
player.setClientBrand(PluginMessageUtil.readBrandMessage(packet.content())); String brand = PluginMessageUtil.readBrandMessage(packet.content());
server.getEventManager().fireAndForget(new PlayerClientBrandEvent(player, brand));
player.setClientBrand(brand);
backendConn.write(PluginMessageUtil backendConn.write(PluginMessageUtil
.rewriteMinecraftBrand(packet, server.getVersion(), player.getProtocolVersion())); .rewriteMinecraftBrand(packet, server.getVersion(), player.getProtocolVersion()));
} else if (BungeeCordMessageResponder.isBungeeCordMessage(packet)) { } else if (BungeeCordMessageResponder.isBungeeCordMessage(packet)) {