Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-11-17 05:20:14 +01:00
Mostly brought 2.0.0 up to update with Velocity 1.1.5-SNAPSHOT changes.
I have not verified that this actually works.
Dieser Commit ist enthalten in:
Ursprung
699147c916
Commit
0e05f5f308
@ -1,7 +1,7 @@
|
|||||||
package com.velocitypowered.api.event.player;
|
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.connection.Player;
|
||||||
import com.velocitypowered.api.proxy.messages.ChannelIdentifier;
|
import com.velocitypowered.api.proxy.messages.ChannelIdentifier;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -71,8 +71,8 @@ public class BackendPlaySessionHandler implements MinecraftSessionHandler {
|
|||||||
if (server.getConfiguration().isBungeePluginChannelEnabled()) {
|
if (server.getConfiguration().isBungeePluginChannelEnabled()) {
|
||||||
MinecraftConnection serverMc = serverConn.ensureConnected();
|
MinecraftConnection serverMc = serverConn.ensureConnected();
|
||||||
serverMc.write(PluginMessageUtil.constructChannelsPacket(serverMc.getProtocolVersion(),
|
serverMc.write(PluginMessageUtil.constructChannelsPacket(serverMc.getProtocolVersion(),
|
||||||
ImmutableList.of(getBungeeCordChannel(serverMc.getProtocolVersion()))
|
ImmutableList.of(getBungeeCordChannel(serverMc.getProtocolVersion())),
|
||||||
));
|
ServerboundPluginMessagePacket.FACTORY));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,7 +88,7 @@ public class BackendPlaySessionHandler implements MinecraftSessionHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle(ClientboundKeepAlivePacket packet) {
|
public boolean handle(ClientboundKeepAlivePacket packet) {
|
||||||
serverConn.setLastPingId(packet.getRandomId());
|
serverConn.getPendingPings().put(packet.getRandomId(), System.currentTimeMillis());
|
||||||
return false; // forwards on
|
return false; // forwards on
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ public class VelocityServerConnection implements MinecraftConnectionAssociation,
|
|||||||
return getHandshakeRemoteAddress();
|
return getHandshakeRemoteAddress();
|
||||||
}
|
}
|
||||||
StringBuilder data = new StringBuilder()
|
StringBuilder data = new StringBuilder()
|
||||||
.append(registeredServer.getServerInfo().getAddress().getHostString())
|
.append(getHandshakeRemoteAddress())
|
||||||
.append('\0')
|
.append('\0')
|
||||||
.append(((InetSocketAddress) proxyPlayer.getRemoteAddress()).getHostString())
|
.append(((InetSocketAddress) proxyPlayer.getRemoteAddress()).getHostString())
|
||||||
.append('\0')
|
.append('\0')
|
||||||
|
@ -42,6 +42,7 @@ import com.velocitypowered.proxy.network.StateRegistry;
|
|||||||
import com.velocitypowered.proxy.network.packet.AbstractPluginMessagePacket;
|
import com.velocitypowered.proxy.network.packet.AbstractPluginMessagePacket;
|
||||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundChatPacket;
|
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundChatPacket;
|
||||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundDisconnectPacket;
|
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundDisconnectPacket;
|
||||||
|
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundHeaderAndFooterPacket;
|
||||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundKeepAlivePacket;
|
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundKeepAlivePacket;
|
||||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundPluginMessagePacket;
|
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundPluginMessagePacket;
|
||||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundResourcePackRequestPacket;
|
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundResourcePackRequestPacket;
|
||||||
@ -268,16 +269,6 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Component getPlayerListHeader() {
|
|
||||||
return this.playerListHeader;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Component getPlayerListFooter() {
|
|
||||||
return this.playerListFooter;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendPlayerListHeader(@NonNull final Component header) {
|
public void sendPlayerListHeader(@NonNull final Component header) {
|
||||||
this.sendPlayerListHeaderAndFooter(header, this.playerListFooter);
|
this.sendPlayerListHeaderAndFooter(header, this.playerListFooter);
|
||||||
@ -292,9 +283,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
|||||||
public void sendPlayerListHeaderAndFooter(final Component header, final Component footer) {
|
public void sendPlayerListHeaderAndFooter(final Component header, final Component footer) {
|
||||||
this.playerListHeader = Objects.requireNonNull(header, "header");
|
this.playerListHeader = Objects.requireNonNull(header, "header");
|
||||||
this.playerListFooter = Objects.requireNonNull(footer, "footer");
|
this.playerListFooter = Objects.requireNonNull(footer, "footer");
|
||||||
if (this.getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_8) >= 0) {
|
this.tabList.setHeaderAndFooter(header, footer);
|
||||||
this.connection.write(HeaderAndFooter.create(header, footer, this.getProtocolVersion()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -360,11 +349,6 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
|||||||
this.profile = profile.withProperties(properties);
|
this.profile = profile.withProperties(properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void clearHeaderAndFooter() {
|
|
||||||
tabList.clearHeaderAndFooter();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VelocityTabList getTabList() {
|
public VelocityTabList getTabList() {
|
||||||
return tabList;
|
return tabList;
|
||||||
|
@ -15,4 +15,12 @@ public interface Packet {
|
|||||||
|
|
||||||
boolean handle(PacketHandler handler);
|
boolean handle(PacketHandler handler);
|
||||||
|
|
||||||
|
// TODO: Move this into decoder
|
||||||
|
default int expectedMinLength(ByteBuf buf, PacketDirection direction, ProtocolVersion version) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
default int expectedMaxLength(ByteBuf buf, PacketDirection direction, ProtocolVersion version) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@ import com.velocitypowered.proxy.network.packet.PacketDirection;
|
|||||||
import com.velocitypowered.proxy.network.packet.PacketHandler;
|
import com.velocitypowered.proxy.network.packet.PacketHandler;
|
||||||
import com.velocitypowered.proxy.network.packet.PacketReader;
|
import com.velocitypowered.proxy.network.packet.PacketReader;
|
||||||
import com.velocitypowered.proxy.network.serialization.brigadier.ArgumentPropertyRegistry;
|
import com.velocitypowered.proxy.network.serialization.brigadier.ArgumentPropertyRegistry;
|
||||||
|
import com.velocitypowered.proxy.util.collect.IdentityHashStrategy;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import it.unimi.dsi.fastutil.objects.Object2IntLinkedOpenCustomHashMap;
|
import it.unimi.dsi.fastutil.objects.Object2IntLinkedOpenCustomHashMap;
|
||||||
import it.unimi.dsi.fastutil.objects.Object2IntLinkedOpenHashMap;
|
import it.unimi.dsi.fastutil.objects.Object2IntLinkedOpenHashMap;
|
||||||
|
@ -314,26 +314,4 @@ public class ClientboundJoinGamePacket implements Packet {
|
|||||||
public boolean handle(PacketHandler handler) {
|
public boolean handle(PacketHandler handler) {
|
||||||
return handler.handle(this);
|
return handler.handle(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return MoreObjects.toStringHelper(this)
|
|
||||||
.add("entityId", this.entityId)
|
|
||||||
.add("gamemode", this.gamemode)
|
|
||||||
.add("dimension", this.dimension)
|
|
||||||
.add("partialHashedSeed", this.partialHashedSeed)
|
|
||||||
.add("difficulty", this.difficulty)
|
|
||||||
.add("isHardcore", this.isHardcore)
|
|
||||||
.add("maxPlayers", this.maxPlayers)
|
|
||||||
.add("levelType", this.levelType)
|
|
||||||
.add("viewDistance", this.viewDistance)
|
|
||||||
.add("reducedDebugInfo", this.reducedDebugInfo)
|
|
||||||
.add("showRespawnScreen", this.showRespawnScreen)
|
|
||||||
.add("dimensionRegistry", this.dimensionRegistry)
|
|
||||||
.add("dimensionInfo", this.dimensionInfo)
|
|
||||||
.add("currentDimensionData", this.currentDimensionData)
|
|
||||||
.add("previousGamemode", this.previousGamemode)
|
|
||||||
.add("biomeRegistry", this.biomeRegistry)
|
|
||||||
.toString();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ import com.velocitypowered.proxy.network.StateRegistry;
|
|||||||
import com.velocitypowered.proxy.network.packet.Packet;
|
import com.velocitypowered.proxy.network.packet.Packet;
|
||||||
import com.velocitypowered.proxy.network.packet.PacketDirection;
|
import com.velocitypowered.proxy.network.packet.PacketDirection;
|
||||||
import com.velocitypowered.proxy.util.except.QuietDecoderException;
|
import com.velocitypowered.proxy.util.except.QuietDecoderException;
|
||||||
|
import com.velocitypowered.proxy.util.except.QuietRuntimeException;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
import io.netty.channel.ChannelInboundHandlerAdapter;
|
import io.netty.channel.ChannelInboundHandlerAdapter;
|
||||||
|
@ -1,24 +0,0 @@
|
|||||||
package com.velocitypowered.proxy.protocol;
|
|
||||||
|
|
||||||
import com.velocitypowered.api.network.ProtocolVersion;
|
|
||||||
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
|
||||||
import io.netty.buffer.ByteBuf;
|
|
||||||
|
|
||||||
public interface MinecraftPacket {
|
|
||||||
|
|
||||||
void decode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion protocolVersion);
|
|
||||||
|
|
||||||
void encode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion protocolVersion);
|
|
||||||
|
|
||||||
boolean handle(MinecraftSessionHandler handler);
|
|
||||||
|
|
||||||
default int expectedMaxLength(ByteBuf buf, ProtocolUtils.Direction direction,
|
|
||||||
ProtocolVersion version) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
default int expectedMinLength(ByteBuf buf, ProtocolUtils.Direction direction,
|
|
||||||
ProtocolVersion version) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,129 +0,0 @@
|
|||||||
package com.velocitypowered.proxy.protocol.packet;
|
|
||||||
|
|
||||||
import static com.velocitypowered.proxy.protocol.util.PluginMessageUtil.transformLegacyToModernChannel;
|
|
||||||
|
|
||||||
import com.velocitypowered.api.network.ProtocolVersion;
|
|
||||||
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
|
||||||
import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
|
||||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
|
||||||
import com.velocitypowered.proxy.protocol.util.DeferredByteBufHolder;
|
|
||||||
import io.netty.buffer.ByteBuf;
|
|
||||||
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
|
||||||
|
|
||||||
public class PluginMessage extends DeferredByteBufHolder implements MinecraftPacket {
|
|
||||||
|
|
||||||
private @Nullable String channel;
|
|
||||||
|
|
||||||
public PluginMessage() {
|
|
||||||
super(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public PluginMessage(String channel,
|
|
||||||
@MonotonicNonNull ByteBuf backing) {
|
|
||||||
super(backing);
|
|
||||||
this.channel = channel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getChannel() {
|
|
||||||
if (channel == null) {
|
|
||||||
throw new IllegalStateException("Channel is not specified.");
|
|
||||||
}
|
|
||||||
return channel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setChannel(String channel) {
|
|
||||||
this.channel = channel;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "PluginMessage{"
|
|
||||||
+ "channel='" + channel + '\''
|
|
||||||
+ ", data=" + super.toString()
|
|
||||||
+ '}';
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void decode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) {
|
|
||||||
this.channel = ProtocolUtils.readString(buf);
|
|
||||||
if (version.compareTo(ProtocolVersion.MINECRAFT_1_13) >= 0) {
|
|
||||||
this.channel = transformLegacyToModernChannel(this.channel);
|
|
||||||
}
|
|
||||||
if (version.compareTo(ProtocolVersion.MINECRAFT_1_8) >= 0) {
|
|
||||||
this.replace(buf.readRetainedSlice(buf.readableBytes()));
|
|
||||||
} else {
|
|
||||||
this.replace(ProtocolUtils.readRetainedByteBufSlice17(buf));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void encode(ByteBuf buf, ProtocolUtils.Direction direction, ProtocolVersion version) {
|
|
||||||
if (channel == null) {
|
|
||||||
throw new IllegalStateException("Channel is not specified.");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (refCnt() == 0) {
|
|
||||||
throw new IllegalStateException("Plugin message contents for " + this.channel
|
|
||||||
+ " freed too many times.");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (version.compareTo(ProtocolVersion.MINECRAFT_1_13) >= 0) {
|
|
||||||
ProtocolUtils.writeString(buf, transformLegacyToModernChannel(this.channel));
|
|
||||||
} else {
|
|
||||||
ProtocolUtils.writeString(buf, this.channel);
|
|
||||||
}
|
|
||||||
if (version.compareTo(ProtocolVersion.MINECRAFT_1_8) >= 0) {
|
|
||||||
buf.writeBytes(content());
|
|
||||||
} else {
|
|
||||||
ProtocolUtils.writeByteBuf17(content(), buf, true); // True for Forge support
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean handle(MinecraftSessionHandler handler) {
|
|
||||||
return handler.handle(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public PluginMessage copy() {
|
|
||||||
return (PluginMessage) super.copy();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public PluginMessage duplicate() {
|
|
||||||
return (PluginMessage) super.duplicate();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public PluginMessage retainedDuplicate() {
|
|
||||||
return (PluginMessage) super.retainedDuplicate();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public PluginMessage replace(ByteBuf content) {
|
|
||||||
return (PluginMessage) super.replace(content);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public PluginMessage retain() {
|
|
||||||
return (PluginMessage) super.retain();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public PluginMessage retain(int increment) {
|
|
||||||
return (PluginMessage) super.retain(increment);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public PluginMessage touch() {
|
|
||||||
return (PluginMessage) super.touch();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public PluginMessage touch(Object hint) {
|
|
||||||
return (PluginMessage) super.touch(hint);
|
|
||||||
}
|
|
||||||
}
|
|
@ -5,6 +5,7 @@ import com.velocitypowered.api.proxy.player.TabList;
|
|||||||
import com.velocitypowered.api.proxy.player.TabListEntry;
|
import com.velocitypowered.api.proxy.player.TabListEntry;
|
||||||
import com.velocitypowered.api.util.GameProfile;
|
import com.velocitypowered.api.util.GameProfile;
|
||||||
import com.velocitypowered.proxy.connection.MinecraftConnection;
|
import com.velocitypowered.proxy.connection.MinecraftConnection;
|
||||||
|
import com.velocitypowered.proxy.connection.client.ConnectedPlayer;
|
||||||
import com.velocitypowered.proxy.network.ProtocolUtils;
|
import com.velocitypowered.proxy.network.ProtocolUtils;
|
||||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundHeaderAndFooterPacket;
|
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundHeaderAndFooterPacket;
|
||||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundPlayerListItemPacket;
|
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundPlayerListItemPacket;
|
||||||
@ -16,6 +17,7 @@ import java.util.Map;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ package com.velocitypowered.proxy.tablist;
|
|||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.velocitypowered.api.proxy.player.TabListEntry;
|
import com.velocitypowered.api.proxy.player.TabListEntry;
|
||||||
import com.velocitypowered.api.util.GameProfile;
|
import com.velocitypowered.api.util.GameProfile;
|
||||||
import com.velocitypowered.proxy.connection.MinecraftConnection;
|
import com.velocitypowered.proxy.connection.client.ConnectedPlayer;
|
||||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundPlayerListItemPacket;
|
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundPlayerListItemPacket;
|
||||||
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundPlayerListItemPacket.Item;
|
import com.velocitypowered.proxy.network.packet.clientbound.ClientboundPlayerListItemPacket.Item;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -18,8 +18,8 @@ public class VelocityTabListLegacy extends VelocityTabList {
|
|||||||
|
|
||||||
private final Map<String, UUID> nameMapping = new ConcurrentHashMap<>();
|
private final Map<String, UUID> nameMapping = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
public VelocityTabListLegacy(MinecraftConnection connection) {
|
public VelocityTabListLegacy(ConnectedPlayer player) {
|
||||||
super(connection);
|
super(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -27,6 +27,7 @@ import java.util.List;
|
|||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
public class CommandManagerTests {
|
public class CommandManagerTests {
|
||||||
@ -444,29 +445,29 @@ public class CommandManagerTests {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
manager.register(rawCommand, "foo");
|
manager.register("foo", rawCommand);
|
||||||
|
|
||||||
assertTrue(manager.offerSuggestions(MockCommandSource.INSTANCE, "foo").get().isEmpty());
|
assertTrue(manager.offerSuggestions(MockCommandSource.INSTANCE, "foo").get().isEmpty());
|
||||||
assertFalse(manager.offerSuggestions(MockCommandSource.INSTANCE, "foo bar").get().isEmpty());
|
assertFalse(manager.offerSuggestions(MockCommandSource.INSTANCE, "foo bar").get().isEmpty());
|
||||||
|
|
||||||
Command oldCommand = new Command() {
|
SimpleCommand oldCommand = new SimpleCommand() {
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSource source, String @NonNull [] args) {
|
public void execute(Invocation invocation) {
|
||||||
fail("The Command should not be executed while testing suggestions");
|
fail("The Command should not be executed while testing suggestions");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasPermission(CommandSource source, String @NonNull [] args) {
|
public boolean hasPermission(Invocation invocation) {
|
||||||
return args.length > 0;
|
return invocation.arguments().length > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> suggest(CommandSource source, String @NonNull [] currentArgs) {
|
public List<String> suggest(Invocation invocation) {
|
||||||
return ImmutableList.of("suggestion");
|
return ImmutableList.of("suggestion");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
manager.register(oldCommand, "bar");
|
manager.register("bar", oldCommand);
|
||||||
|
|
||||||
assertTrue(manager.offerSuggestions(MockCommandSource.INSTANCE, "bar").get().isEmpty());
|
assertTrue(manager.offerSuggestions(MockCommandSource.INSTANCE, "bar").get().isEmpty());
|
||||||
assertFalse(manager.offerSuggestions(MockCommandSource.INSTANCE, "bar foo").get().isEmpty());
|
assertFalse(manager.offerSuggestions(MockCommandSource.INSTANCE, "bar foo").get().isEmpty());
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren