geforkt von Mirrors/Velocity
Merge branch 'dev/1.1.0' into decode-multiple
Dieser Commit ist enthalten in:
Commit
b04b43954f
@ -20,7 +20,7 @@ allprojects {
|
|||||||
|
|
||||||
ext {
|
ext {
|
||||||
// dependency versions
|
// dependency versions
|
||||||
textVersion = '3.0.2'
|
textVersion = '3.0.3'
|
||||||
junitVersion = '5.3.0-M1'
|
junitVersion = '5.3.0-M1'
|
||||||
slf4jVersion = '1.7.25'
|
slf4jVersion = '1.7.25'
|
||||||
log4jVersion = '2.11.2'
|
log4jVersion = '2.11.2'
|
||||||
|
@ -3,5 +3,6 @@ package com.velocitypowered.proxy.config;
|
|||||||
public enum PingPassthroughMode {
|
public enum PingPassthroughMode {
|
||||||
DISABLED,
|
DISABLED,
|
||||||
MODS,
|
MODS,
|
||||||
|
DESCRIPTION,
|
||||||
ALL
|
ALL
|
||||||
}
|
}
|
||||||
|
@ -90,14 +90,17 @@ public class VelocityConfiguration extends AnnotatedConfig implements ProxyConfi
|
|||||||
@Comment({
|
@Comment({
|
||||||
"Should Velocity pass server list ping requests to a backend server?",
|
"Should Velocity pass server list ping requests to a backend server?",
|
||||||
"Available options:",
|
"Available options:",
|
||||||
"- \"disabled\": No pass-through will be done. The velocity.toml and server-icon.png",
|
"- \"disabled\": No pass-through will be done. The velocity.toml and server-icon.png",
|
||||||
" will determine the initial server list ping response.",
|
" will determine the initial server list ping response.",
|
||||||
"- \"mods\": Passes only the mod list from your backend server into the response.",
|
"- \"mods\": Passes only the mod list from your backend server into the response.",
|
||||||
" The first server in your try list (or forced host) with a mod list will be",
|
" The first server in your try list (or forced host) with a mod list will be",
|
||||||
" used. If no backend servers can be contacted, Velocity will not display any",
|
" used. If no backend servers can be contacted, Velocity won't display any",
|
||||||
" mod information.",
|
" mod information.",
|
||||||
"- \"all\": Passes everything from the backend server into the response. The Velocity",
|
"- \"description\": Uses the description and mod list from the backend server. The first",
|
||||||
" configuration is used if no servers could be contacted."
|
" server in the try (or forced host) list that responds is used for the",
|
||||||
|
" description and mod list.",
|
||||||
|
"- \"all\": Uses the backend server's response as the proxy response. The Velocity",
|
||||||
|
" configuration is used if no servers could be contacted."
|
||||||
})
|
})
|
||||||
@ConfigKey("ping-passthrough")
|
@ConfigKey("ping-passthrough")
|
||||||
private PingPassthroughMode pingPassthrough = PingPassthroughMode.DISABLED;
|
private PingPassthroughMode pingPassthrough = PingPassthroughMode.DISABLED;
|
||||||
@ -505,7 +508,7 @@ public class VelocityConfiguration extends AnnotatedConfig implements ProxyConfi
|
|||||||
Map<String, String> servers = new HashMap<>();
|
Map<String, String> servers = new HashMap<>();
|
||||||
for (Map.Entry<String, Object> entry : toml.entrySet()) {
|
for (Map.Entry<String, Object> entry : toml.entrySet()) {
|
||||||
if (entry.getValue() instanceof String) {
|
if (entry.getValue() instanceof String) {
|
||||||
servers.put(entry.getKey(), (String) entry.getValue());
|
servers.put(cleanServerName(entry.getKey()), (String) entry.getValue());
|
||||||
} else {
|
} else {
|
||||||
if (!entry.getKey().equalsIgnoreCase("try")) {
|
if (!entry.getKey().equalsIgnoreCase("try")) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
@ -539,6 +542,19 @@ public class VelocityConfiguration extends AnnotatedConfig implements ProxyConfi
|
|||||||
this.attemptConnectionOrder = attemptConnectionOrder;
|
this.attemptConnectionOrder = attemptConnectionOrder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TOML requires keys to match a regex of {@code [A-Za-z0-9_-]} unless it is wrapped in
|
||||||
|
* quotes; however, the TOML parser returns the key with the quotes so we need to clean the
|
||||||
|
* server name before we pass it onto server registration to keep proper server name behavior.
|
||||||
|
*
|
||||||
|
* @param name the server name to clean
|
||||||
|
*
|
||||||
|
* @return the cleaned server name
|
||||||
|
*/
|
||||||
|
private String cleanServerName(String name) {
|
||||||
|
return name.replace("\"", "");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Servers{"
|
return "Servers{"
|
||||||
|
@ -97,6 +97,24 @@ public class StatusSessionHandler implements MinecraftSessionHandler {
|
|||||||
}
|
}
|
||||||
return fallback;
|
return fallback;
|
||||||
});
|
});
|
||||||
|
case DESCRIPTION:
|
||||||
|
return pingResponses.thenApply(responses -> {
|
||||||
|
// Find the first non-fallback. If it includes a modlist, add it too.
|
||||||
|
for (ServerPing response : responses) {
|
||||||
|
if (response == fallback) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new ServerPing(
|
||||||
|
fallback.getVersion(),
|
||||||
|
fallback.getPlayers().orElse(null),
|
||||||
|
response.getDescription(),
|
||||||
|
fallback.getFavicon().orElse(null),
|
||||||
|
response.getModinfo().orElse(null)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return fallback;
|
||||||
|
});
|
||||||
default:
|
default:
|
||||||
// Not possible, but covered for completeness.
|
// Not possible, but covered for completeness.
|
||||||
return CompletableFuture.completedFuture(fallback);
|
return CompletableFuture.completedFuture(fallback);
|
||||||
|
@ -2,17 +2,14 @@ package com.velocitypowered.proxy.protocol.netty;
|
|||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import com.velocitypowered.api.network.ProtocolVersion;
|
import com.velocitypowered.api.network.ProtocolVersion;
|
||||||
import com.velocitypowered.proxy.network.Connections;
|
|
||||||
import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
||||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
||||||
import com.velocitypowered.proxy.protocol.StateRegistry;
|
import com.velocitypowered.proxy.protocol.StateRegistry;
|
||||||
import com.velocitypowered.proxy.util.except.QuietException;
|
import com.velocitypowered.proxy.util.except.QuietException;
|
||||||
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.handler.codec.CorruptedFrameException;
|
import io.netty.handler.codec.CorruptedFrameException;
|
||||||
import io.netty.handler.codec.MessageToMessageDecoder;
|
import io.netty.handler.codec.MessageToMessageDecoder;
|
||||||
import io.netty.util.ReferenceCountUtil;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class MinecraftDecoder extends MessageToMessageDecoder<ByteBuf> {
|
public class MinecraftDecoder extends MessageToMessageDecoder<ByteBuf> {
|
||||||
|
@ -3,7 +3,6 @@ package com.velocitypowered.proxy.scheduler;
|
|||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.Multimap;
|
import com.google.common.collect.Multimap;
|
||||||
import com.google.common.collect.Multimaps;
|
import com.google.common.collect.Multimaps;
|
||||||
@ -187,6 +186,9 @@ public class VelocityScheduler implements Scheduler {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.logger.error("Exception in task {} by plugin {}", runnable, plugin, e);
|
Log.logger.error("Exception in task {} by plugin {}", runnable, plugin, e);
|
||||||
} finally {
|
} finally {
|
||||||
|
if (repeat == 0) {
|
||||||
|
onFinish();
|
||||||
|
}
|
||||||
currentTaskThread = null;
|
currentTaskThread = null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -60,29 +60,25 @@ public class VelocityTabListLegacy extends VelocityTabList {
|
|||||||
|
|
||||||
Item item = packet.getItems().get(0); // Only one item per packet in 1.7
|
Item item = packet.getItems().get(0); // Only one item per packet in 1.7
|
||||||
|
|
||||||
Component displayName = LegacyComponentSerializer.legacy().deserialize(item.getName());
|
|
||||||
String strippedName = PlainComponentSerializer.INSTANCE.serialize(displayName);
|
|
||||||
|
|
||||||
switch (packet.getAction()) {
|
switch (packet.getAction()) {
|
||||||
case PlayerListItem.ADD_PLAYER:
|
case PlayerListItem.ADD_PLAYER:
|
||||||
if (nameMapping.containsKey(strippedName)) { // ADD_PLAYER also used for updating ping
|
if (nameMapping.containsKey(item.getName())) { // ADD_PLAYER also used for updating ping
|
||||||
VelocityTabListEntry entry = entries.get(nameMapping.get(strippedName));
|
VelocityTabListEntry entry = entries.get(nameMapping.get(item.getName()));
|
||||||
if (entry != null) {
|
if (entry != null) {
|
||||||
entry.setLatency(item.getLatency());
|
entry.setLatencyInternal(item.getLatency());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
UUID uuid = UUID.randomUUID(); // Use a fake uuid to preserve function of custom entries
|
UUID uuid = UUID.randomUUID(); // Use a fake uuid to preserve function of custom entries
|
||||||
nameMapping.put(strippedName, uuid);
|
nameMapping.put(item.getName(), uuid);
|
||||||
entries.put(uuid, (VelocityTabListEntry) TabListEntry.builder()
|
entries.put(uuid, (VelocityTabListEntry) TabListEntry.builder()
|
||||||
.tabList(this)
|
.tabList(this)
|
||||||
.profile(new GameProfile(uuid, strippedName, ImmutableList.of()))
|
.profile(new GameProfile(uuid, item.getName(), ImmutableList.of()))
|
||||||
.displayName(displayName)
|
|
||||||
.latency(item.getLatency())
|
.latency(item.getLatency())
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PlayerListItem.REMOVE_PLAYER:
|
case PlayerListItem.REMOVE_PLAYER:
|
||||||
UUID removedUuid = nameMapping.remove(strippedName);
|
UUID removedUuid = nameMapping.remove(item.getName());
|
||||||
if (removedUuid != null) {
|
if (removedUuid != null) {
|
||||||
entries.remove(removedUuid);
|
entries.remove(removedUuid);
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren