Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-11-17 05:20:14 +01:00
Apply initial requested changes
Dieser Commit ist enthalten in:
Ursprung
d47b339908
Commit
fb879cb498
@ -2,6 +2,7 @@ package com.velocitypowered.api.event.player;
|
|||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import com.velocitypowered.api.proxy.Player;
|
import com.velocitypowered.api.proxy.Player;
|
||||||
|
import com.velocitypowered.api.proxy.messages.ChannelIdentifier;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -9,12 +10,12 @@ import java.util.List;
|
|||||||
* This event is fired when a client ({@link Player}) sends a plugin message through the
|
* This event is fired when a client ({@link Player}) sends a plugin message through the
|
||||||
* register channel.
|
* register channel.
|
||||||
*/
|
*/
|
||||||
public final class PlayerPluginMessageRegisterEvent {
|
public final class PlayerChannelRegisterEvent {
|
||||||
|
|
||||||
private final Player player;
|
private final Player player;
|
||||||
private final List<String> channels;
|
private final List<ChannelIdentifier> channels;
|
||||||
|
|
||||||
public PlayerPluginMessageRegisterEvent(Player player, List<String> channels) {
|
public PlayerChannelRegisterEvent(Player player, List<ChannelIdentifier> channels) {
|
||||||
this.player = Preconditions.checkNotNull(player, "player");
|
this.player = Preconditions.checkNotNull(player, "player");
|
||||||
this.channels = Preconditions.checkNotNull(channels, "channels");
|
this.channels = Preconditions.checkNotNull(channels, "channels");
|
||||||
}
|
}
|
||||||
@ -23,13 +24,13 @@ public final class PlayerPluginMessageRegisterEvent {
|
|||||||
return player;
|
return player;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getChannels() {
|
public List<ChannelIdentifier> getChannels() {
|
||||||
return channels;
|
return channels;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "PlayerPluginMessageRegisterEvent{"
|
return "PlayerChannelRegisterEvent{"
|
||||||
+ "player=" + player
|
+ "player=" + player
|
||||||
+ ", channels=" + channels
|
+ ", channels=" + channels
|
||||||
+ '}';
|
+ '}';
|
@ -5,14 +5,17 @@ import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_16;
|
|||||||
import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_8;
|
import static com.velocitypowered.api.network.ProtocolVersion.MINECRAFT_1_8;
|
||||||
import static com.velocitypowered.proxy.protocol.util.PluginMessageUtil.constructChannelsPacket;
|
import static com.velocitypowered.proxy.protocol.util.PluginMessageUtil.constructChannelsPacket;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.velocitypowered.api.event.command.CommandExecuteEvent.CommandResult;
|
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.PlayerChatEvent;
|
import com.velocitypowered.api.event.player.PlayerChatEvent;
|
||||||
import com.velocitypowered.api.event.player.PlayerPluginMessageRegisterEvent;
|
|
||||||
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;
|
||||||
import com.velocitypowered.api.proxy.messages.ChannelIdentifier;
|
import com.velocitypowered.api.proxy.messages.ChannelIdentifier;
|
||||||
|
import com.velocitypowered.api.proxy.messages.LegacyChannelIdentifier;
|
||||||
|
import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier;
|
||||||
import com.velocitypowered.proxy.VelocityServer;
|
import com.velocitypowered.proxy.VelocityServer;
|
||||||
import com.velocitypowered.proxy.connection.ConnectionTypes;
|
import com.velocitypowered.proxy.connection.ConnectionTypes;
|
||||||
import com.velocitypowered.proxy.connection.MinecraftConnection;
|
import com.velocitypowered.proxy.connection.MinecraftConnection;
|
||||||
@ -193,8 +196,16 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
|||||||
} else if (PluginMessageUtil.isRegister(packet)) {
|
} else if (PluginMessageUtil.isRegister(packet)) {
|
||||||
List<String> channels = PluginMessageUtil.getChannels(packet);
|
List<String> channels = PluginMessageUtil.getChannels(packet);
|
||||||
player.getKnownChannels().addAll(channels);
|
player.getKnownChannels().addAll(channels);
|
||||||
server.getEventManager().fireAndForget(new PlayerPluginMessageRegisterEvent(player,
|
List<ChannelIdentifier> channelIdentifiers = new ArrayList<>();
|
||||||
channels));
|
for (String channel : channels) {
|
||||||
|
try {
|
||||||
|
channelIdentifiers.add(MinecraftChannelIdentifier.from(channel));
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
channelIdentifiers.add(new LegacyChannelIdentifier(channel));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
server.getEventManager().fireAndForget(new PlayerChannelRegisterEvent(player,
|
||||||
|
ImmutableList.copyOf(channelIdentifiers)));
|
||||||
backendConn.write(packet.retain());
|
backendConn.write(packet.retain());
|
||||||
} else if (PluginMessageUtil.isUnregister(packet)) {
|
} else if (PluginMessageUtil.isUnregister(packet)) {
|
||||||
player.getKnownChannels().removeAll(PluginMessageUtil.getChannels(packet));
|
player.getKnownChannels().removeAll(PluginMessageUtil.getChannels(packet));
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren