3
0
Mirror von https://github.com/PaperMC/Velocity.git synchronisiert 2024-12-23 23:00:35 +01:00
Dieser Commit ist enthalten in:
Leymooo 2018-08-31 16:50:14 +03:00
Ursprung d743c8b5a1
Commit b201d82a31
3 geänderte Dateien mit 31 neuen und 18 gelöschten Zeilen

Datei anzeigen

@ -118,8 +118,8 @@ public class VelocityServer implements ProxyServer {
AnnotatedConfig.saveConfig(configuration.dumpConfig(), configPath); //Resave config to add new values
} catch (IOException | RuntimeException e) {
logger.error("Unable to load your velocity.toml. The server will shut down.", e);
} catch (Throwable e) {
logger.error("Unable to read/load/save your velocity.toml. The server will shut down.", e);
LogManager.shutdown();
System.exit(1);
}

Datei anzeigen

@ -18,7 +18,6 @@ import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@ -90,9 +89,7 @@ public class AnnotatedConfig {
public List<String> dumpConfig() {
List<String> lines = new ArrayList<>();
if (!dumpFields(this, lines)) {
throw new RuntimeException("can not dump config");
}
dumpFields(this, lines);
return lines;
}
@ -102,7 +99,7 @@ public class AnnotatedConfig {
* @param toSave object those we need to dump
* @param lines a list where store dumped lines
*/
private boolean dumpFields(Object toSave, List<String> lines) {
private void dumpFields(Object toSave, List<String> lines) {
try {
for (Field field : toSave.getClass().getDeclaredFields()) {
@ -140,11 +137,8 @@ public class AnnotatedConfig {
}
}
} catch (IllegalAccessException | IllegalArgumentException | SecurityException e) {
logger.log(Level.ERROR, "Unexpected error while dumping fields", e);
lines.clear();
return false;
throw new RuntimeException("Can not dump config", e);
}
return true;
}
private String toString(Object value) {

Datei anzeigen

@ -32,16 +32,22 @@ public class VelocityConfiguration extends AnnotatedConfig {
@Comment("What port should the proxy be bound to? By default, we'll bind to all addresses on port 25577.")
private String bind = "0.0.0.0:25577";
@Comment("What should be the MOTD? Legacy color codes and JSON are accepted.")
private String motd = "&3A Velocity Server";
@Comment({"What should we display for the maximum number of players? (Velocity does not support a cap",
@Comment({
"What should we display for the maximum number of players? (Velocity does not support a cap",
"on the number of players online.)"})
@ConfigKey("show-max-players")
private int showMaxPlayers = 500;
@Comment("Should we authenticate players with Mojang? By default, this is on.")
@ConfigKey("online-mode")
private boolean onlineMode = true;
@Comment({"Should we forward IP addresses and other data to backend servers?",
@Comment({
"Should we forward IP addresses and other data to backend servers?",
"Available options:",
"- \"none\": No forwarding will be done. All players will appear to be Should we forward IP addresses and other data to backend servers?connecting from the proxy",
" and will have offline-mode UUIDs.",
@ -57,6 +63,7 @@ public class VelocityConfiguration extends AnnotatedConfig {
@ConfigKey("forwarding-secret")
private byte[] forwardingSecret = new Random().ints(48, 123).filter(i -> (i < 58) || (i > 64 && i < 91) || (i > 96)).limit(12)
.collect(StringBuilder::new, (sb, i) -> sb.append((char) i), StringBuilder::append).toString().getBytes(StandardCharsets.UTF_8); //One line string generation
@Table("[servers]")
private final Servers servers;
@ -403,21 +410,26 @@ public class VelocityConfiguration extends AnnotatedConfig {
@Override
public String toString() {
return "Servers{" + "servers=" + servers + ", attemptConnectionOrder=" + attemptConnectionOrder + '}';
return "Servers{"
+ "servers=" + servers
+ ", attemptConnectionOrder=" + attemptConnectionOrder
+ '}';
}
}
private static class Advanced {
@Comment({"How large a Minecraft packet has to be before we compress it. Setting this to zero will compress all packets, and",
@Comment({
"How large a Minecraft packet has to be before we compress it. Setting this to zero will compress all packets, and",
"setting it to -1 will disable compression entirely."})
@ConfigKey("compression-threshold")
private int compressionThreshold = 1024;
@Comment("How much compression should be done (from 0-9). The default is -1, which uses zlib's default level of 6.")
@ConfigKey("compression-level")
private int compressionLevel = -1;
@Comment({"How fast (in miliseconds) are clients allowed to connect after the last connection? Default: 3000",
@Comment({
"How fast (in miliseconds) are clients allowed to connect after the last connection? Default: 3000",
"Disable by setting to 0"})
@ConfigKey("login-ratelimit")
private int loginRatelimit = 3000;
@ -465,7 +477,11 @@ public class VelocityConfiguration extends AnnotatedConfig {
@Override
public String toString() {
return "Advanced{" + "compressionThreshold=" + compressionThreshold + ", compressionLevel=" + compressionLevel + ", loginRatelimit=" + loginRatelimit + '}';
return "Advanced{"
+ "compressionThreshold=" + compressionThreshold
+ ", compressionLevel=" + compressionLevel
+ ", loginRatelimit=" + loginRatelimit
+ '}';
}
}
@ -511,7 +527,10 @@ public class VelocityConfiguration extends AnnotatedConfig {
@Override
public String toString() {
return "Query{" + "queryEnabled=" + queryEnabled + ", queryPort=" + queryPort + '}';
return "Query{"
+ "queryEnabled=" + queryEnabled
+ ", queryPort=" + queryPort
+ '}';
}
}
}