Skip to content

Commit

Permalink
1.0.4 release
Browse files Browse the repository at this point in the history
  • Loading branch information
hevav committed Dec 25, 2023
1 parent 9381bd9 commit 2126fbf
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 85 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.3
1.0.4
27 changes: 17 additions & 10 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ plugins {
}

setGroup("net.elytrium")
setVersion("1.0.4-SNAPSHOT")
setVersion("1.0.4")

java {
setSourceCompatibility(JavaVersion.VERSION_11)
setTargetCompatibility(JavaVersion.VERSION_11)
setSourceCompatibility(JavaVersion.VERSION_17)
setTargetCompatibility(JavaVersion.VERSION_17)
}

compileJava {
Expand All @@ -31,15 +31,22 @@ repositories {
setName("papermc-repo")
setUrl("https://papermc.io/repo/repository/maven-public/")
}
maven() {
setName("sonatype-snapshots-repo")
setUrl("https://s01.oss.sonatype.org/content/repositories/snapshots/")
}
}

dependencies {
implementation("net.elytrium:java-commons:1.1.0")
implementation("net.elytrium:fastprepare:1.0.4")
implementation("net.elytrium.commons:kyori:1.3.0")
implementation("net.elytrium.commons:velocity:1.3.0")
implementation("net.elytrium.commons:utils:1.3.0")
implementation("net.elytrium:fastprepare:1.0.8")
implementation("net.elytrium:serializer:1.1.1")
implementation('it.unimi.dsi:fastutil-core:8.5.11')
compileOnly("com.velocitypowered:velocity-api:3.2.0-SNAPSHOT")
annotationProcessor("com.velocitypowered:velocity-api:3.2.0-SNAPSHOT")
compileOnly("com.velocitypowered:velocity-proxy:3.2.0-SNAPSHOT")
compileOnly("com.velocitypowered:velocity-api:3.3.0-SNAPSHOT")
annotationProcessor("com.velocitypowered:velocity-api:3.3.0-SNAPSHOT")
compileOnly("com.velocitypowered:velocity-proxy:3.3.0-SNAPSHOT")
compileOnly('com.github.spotbugs:spotbugs-annotations:4.7.3')
// Needs for some velocity methods.
compileOnly('io.netty:netty-codec:4.1.86.Final')
Expand Down Expand Up @@ -100,8 +107,8 @@ shadowJar {

relocate("org.bstats", "net.elytrium.fastmotd.thirdparty.org.bstats")
relocate("net.elytrium.fastprepare", "net.elytrium.fastmotd.thirdparty.fastprepare")
relocate("net.elytrium.java.commons", "net.elytrium.fastmotd.thirdparty.commons")
relocate("it.unimi.dsi.fastutil", "net.elytrium.fastmotd.thirdparty.it.unimi.dsi.fastutil")
relocate("net.elytrium.commons", "net.elytrium.fastmotd.thirdparty.commons")
relocate("net.elytrium.serializer", "net.elytrium.fastmotd.thirdparty.serializer")
}

license {
Expand Down
33 changes: 13 additions & 20 deletions src/main/java/net/elytrium/fastmotd/FastMOTD.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
import it.unimi.dsi.fastutil.ints.IntSet;
import java.io.File;
import java.lang.reflect.Field;
import java.net.InetAddress;
import java.net.UnknownHostException;
Expand All @@ -58,6 +57,8 @@
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import net.elytrium.commons.utils.reflection.ReflectionException;
import net.elytrium.commons.utils.updates.UpdatesChecker;
import net.elytrium.fastmotd.command.MaintenanceCommand;
import net.elytrium.fastmotd.command.ReloadCommand;
import net.elytrium.fastmotd.dummy.DummyPlayer;
Expand All @@ -67,8 +68,6 @@
import net.elytrium.fastmotd.utils.MOTDGenerator;
import net.elytrium.fastprepare.PreparedPacket;
import net.elytrium.fastprepare.PreparedPacketFactory;
import net.elytrium.java.commons.reflection.ReflectionException;
import net.elytrium.java.commons.updates.UpdatesChecker;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.serializer.ComponentSerializer;
import org.bstats.velocity.Metrics;
Expand All @@ -92,7 +91,7 @@ public class FastMOTD {
private final Logger logger;
private final VelocityServer server;
private final Metrics.Factory metricsFactory;
private final File configFile;
private final Path configPath;
private final List<MOTDGenerator> motdGenerators = new ArrayList<>();
private final List<MOTDGenerator> maintenanceMOTDGenerators = new ArrayList<>();
private final Int2IntMap protocolPointers = new Int2IntOpenHashMap();
Expand Down Expand Up @@ -121,7 +120,7 @@ public FastMOTD(Logger logger, ProxyServer server, Metrics.Factory metricsFactor
this.logger = logger;
this.server = (VelocityServer) server;
this.metricsFactory = metricsFactory;
this.configFile = dataDirectory.resolve("config.yml").toFile();
this.configPath = dataDirectory.resolve("config.yml");
}

@Subscribe
Expand All @@ -137,13 +136,13 @@ public void onProxyInitialization(ProxyInitializeEvent event) {
}

this.preparedPacketFactory =
new PreparedPacketFactory(PreparedPacket::new, StateRegistry.LOGIN, false, 1, 1, false);
new PreparedPacketFactory(PreparedPacket::new, StateRegistry.LOGIN, false, 1, 1, false, true);

this.reload();
}

public void reload() {
Settings.IMP.reload(this.configFile, Settings.IMP.PREFIX);
Settings.IMP.reload(this.configPath);

if (!UpdatesChecker.checkVersionByURL("https://raw.githubusercontent.com/Elytrium/FastMOTD/master/VERSION", Settings.IMP.VERSION)) {
this.logger.error("****************************************");
Expand Down Expand Up @@ -199,7 +198,7 @@ public void reload() {
Component kickReasonComponent = serializer.deserialize(Settings.IMP.MAINTENANCE.KICK_MESSAGE);
this.kickReason = this.preparedPacketFactory
.createPreparedPacket(ProtocolVersion.MINIMUM_VERSION, ProtocolVersion.MAXIMUM_VERSION)
.prepare(version -> Disconnect.create(kickReasonComponent, version))
.prepare(version -> Disconnect.create(kickReasonComponent, version, true))
.build();

this.kickWhitelist = Settings.IMP.MAINTENANCE.KICK_WHITELIST.stream().map((String host) -> {
Expand Down Expand Up @@ -339,16 +338,10 @@ private int getOnline() {
private int getMax(int online) {
int max;
MaxCountType type = Settings.IMP.MAIN.MAX_COUNT_TYPE;
switch (type) {
case ADD_SOME:
max = online + Settings.IMP.MAIN.MAX_COUNT;
break;
case VARIABLE:
max = Settings.IMP.MAIN.MAX_COUNT;
break;
default:
throw new IllegalStateException("Unexpected value: " + type);
}
max = switch (type) {
case ADD_SOME -> online + Settings.IMP.MAIN.MAX_COUNT;
case VARIABLE -> Settings.IMP.MAIN.MAX_COUNT;
};

return max;
}
Expand Down Expand Up @@ -397,8 +390,8 @@ public PreparedPacket getKickReason() {
return this.kickReason;
}

public File getConfigFile() {
return this.configFile;
public Path getConfigPath() {
return this.configPath;
}

public enum MaxCountType {
Expand Down
88 changes: 41 additions & 47 deletions src/main/java/net/elytrium/fastmotd/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,75 +19,73 @@

import java.util.List;
import java.util.Map;
import net.elytrium.java.commons.config.YamlConfig;
import net.elytrium.java.commons.mc.serialization.Serializers;
import net.elytrium.commons.kyori.serialization.Serializers;
import net.elytrium.serializer.annotations.Comment;
import net.elytrium.serializer.annotations.CommentValue;
import net.elytrium.serializer.annotations.Final;
import net.elytrium.serializer.language.object.YamlSerializable;

public class Settings extends YamlConfig {
public class Settings extends YamlSerializable {

@Ignore
public static final Settings IMP = new Settings();

@Final
public String VERSION = BuildConstants.VERSION;

@Comment({
"Available serializers:",
"LEGACY_AMPERSAND - \"&c&lExample &c&9Text\".",
"LEGACY_SECTION - \"§c§lExample §c§9Text\".",
"MINIMESSAGE - \"<bold><red>Example</red> <blue>Text</blue></bold>\". (https://webui.adventure.kyori.net/)",
"GSON - \"[{\"text\":\"Example\",\"bold\":true,\"color\":\"red\"},{\"text\":\" \",\"bold\":true},{\"text\":\"Text\",\"bold\":true,\"color\":\"blue\"}]\". (https://minecraft.tools/en/json_text.php/)",
"GSON_COLOR_DOWNSAMPLING - Same as GSON, but uses downsampling."
@CommentValue("Available serializers:"),
@CommentValue("LEGACY_AMPERSAND - \"&c&lExample &c&9Text\"."),
@CommentValue("LEGACY_SECTION - \"§c§lExample §c§9Text\"."),
@CommentValue("MINIMESSAGE - \"<bold><red>Example</red> <blue>Text</blue></bold>\". (https://webui.adventure.kyori.net/)"),
@CommentValue("GSON - \"[{\"text\":\"Example\",\"bold\":true,\"color\":\"red\"},{\"text\":\" \",\"bold\":true},{\"text\":\"Text\",\"bold\":true,\"color\":\"blue\"}]\". (https://minecraft.tools/en/json_text.php/)"),
@CommentValue("GSON_COLOR_DOWNSAMPLING - Same as GSON, but uses downsampling."),
})
public Serializers SERIALIZER = Serializers.MINIMESSAGE;
public String PREFIX = "FastMOTD <gold>>></gold>";

@Create
public MAIN MAIN;
public MAIN MAIN = new MAIN();

public static class MAIN {
public String VERSION_NAME = "Elytrium";
public List<String> DESCRIPTIONS = List.of("<bold><red>FastMOTD</red></bold>{NL} -> Really fast.");
public List<String> FAVICONS = List.of("server-icon.png");
public List<String> INFORMATION = List.of("This is the", "<bold>best server</bold>", "<gradient:green:red>made ever</gradient>", "trust me");
@Comment("How frequently online player count will be updated (in ms)")
@Comment(@CommentValue("How frequently online player count will be updated (in ms)"))
public long UPDATE_RATE = 3000;
@Comment({
"VARIABLE - from max-count parameter",
"ADD_SOME - will add up the number from max-count parameter to current online players amount"
@CommentValue("VARIABLE - from max-count parameter"),
@CommentValue("ADD_SOME - will add up the number from max-count parameter to current online players amount")
})
public FastMOTD.MaxCountType MAX_COUNT_TYPE = FastMOTD.MaxCountType.VARIABLE;
public int MAX_COUNT = 4444;
public int FAKE_ONLINE_ADD_SINGLE = 5;
public int FAKE_ONLINE_ADD_PERCENT = 20;
@Comment({
"Accepted values: from 0.0 to 1.0.",
"Keep this value as low as possible",
"Set -1 to disable PNG recompression"
@CommentValue("Accepted values: from 0.0 to 1.0."),
@CommentValue("Keep this value as low as possible"),
@CommentValue("Set -1 to disable PNG recompression")
})
public double PNG_QUALITY = 0.0;
public boolean LOG_PINGS = false;

@Create
public VERSIONS VERSIONS;
public VERSIONS VERSIONS = new VERSIONS();

@Comment({
"Separate MOTDs/favicons/information for different protocol versions",
"See https://wiki.vg/Protocol_version_numbers",
@CommentValue("Separate MOTDs/favicons/information for different protocol versions"),
@CommentValue("See https://wiki.vg/Protocol_version_numbers"),
})
public static class VERSIONS {
@Comment("null = disabled")
@Comment(@CommentValue("null = disabled"))
public Map<String, List<String>> DESCRIPTIONS = Map.of("757-759", List.of("<bold><red>FastMOTD</red></bold>{NL} -> Supports separate MOTDs for different versions."));
@Comment("null = disabled")
@Comment(@CommentValue("null = disabled"))
public Map<String, List<String>> FAVICONS = Map.of("756-758", List.of("second-server-icon.png"));
@Comment("null = disabled")
@Comment(@CommentValue("null = disabled"))
public Map<String, List<String>> INFORMATION = Map.of("757-758", List.of("Your", "protocol", "version", "is 757 or 758"));
}

public Map<String, DOMAIN_MOTD_NODE> DOMAINS = Map.of("example.com:25565", YamlConfig.createNodeSequence(DOMAIN_MOTD_NODE.class));
public Map<String, DOMAIN_MOTD_NODE> DOMAINS = Map.of("example.com:25565", new DOMAIN_MOTD_NODE());
}

@Create
public MAINTENANCE MAINTENANCE;
public MAINTENANCE MAINTENANCE = new MAINTENANCE();

public static class MAINTENANCE {
public boolean MAINTENANCE_ENABLED = false;
Expand All @@ -99,49 +97,45 @@ public static class MAINTENANCE {
public List<String> DESCRIPTIONS = List.of("<bold><red>FastMOTD</red></bold>{NL} -> Really fast. (in maintenance mode too)");
public List<String> FAVICONS = List.of("server-icon.png");
public List<String> INFORMATION = List.of("Contact support: https://elytrium.net/discord");
@Comment("-1 = disabled")
@Comment(@CommentValue("-1 = disabled"))
public int OVERRIDE_ONLINE = -1;
@Comment("-1 = disabled")
@Comment(@CommentValue("-1 = disabled"))
public int OVERRIDE_MAX_ONLINE = -1;

@Create
public VERSIONS VERSIONS;
public VERSIONS VERSIONS = new VERSIONS();

@Comment({
"Separate MOTDs/favicons/information for different protocol versions",
"See https://wiki.vg/Protocol_version_numbers",
@CommentValue("Separate MOTDs/favicons/information for different protocol versions"),
@CommentValue("See https://wiki.vg/Protocol_version_numbers"),
})
public static class VERSIONS {
@Comment("null = disabled")
@Comment(@CommentValue("null = disabled"))
public Map<String, List<String>> DESCRIPTIONS = Map.of("757-759", List.of("<bold><red>FastMOTD</red></bold>{NL} -> Really Fast."));
@Comment("null = disabled")
@Comment(@CommentValue("null = disabled"))
public Map<String, List<String>> FAVICONS = Map.of("758-758", List.of("second-server-icon.png"));
@Comment("null = disabled")
@Comment(@CommentValue("null = disabled"))
public Map<String, List<String>> INFORMATION = Map.of("756-759", List.of("Server is", "under", "maintenance"));
}

public Map<String, DOMAIN_MOTD_NODE> DOMAINS = Map.of("example.com:25565", YamlConfig.createNodeSequence(DOMAIN_MOTD_NODE.class));
public Map<String, DOMAIN_MOTD_NODE> DOMAINS = Map.of("example.com:25565", new DOMAIN_MOTD_NODE());

@Create
public COMMAND COMMAND;
public COMMAND COMMAND = new COMMAND();

public static class COMMAND {
public String USAGE = "{PRFX} Usage: <gold>/maintenance <off|on|toggle></gold>";
public String USAGE = "FastMOTD <gold>>></gold> Usage: <gold>/maintenance <off|on|toggle></gold>";
}
}

@Create
public SHUTDOWN_SCHEDULER SHUTDOWN_SCHEDULER;
public SHUTDOWN_SCHEDULER SHUTDOWN_SCHEDULER = new SHUTDOWN_SCHEDULER();

public static class SHUTDOWN_SCHEDULER {
@Comment("Server will stop accepting new connections")
@Comment(@CommentValue("Server will stop accepting new connections"))
public boolean SHUTDOWN_SCHEDULER_ENABLED = false;
@Comment("Server will shut down after everyone has left the server")
@Comment(@CommentValue("Server will shut down after everyone has left the server"))
public boolean SHUTDOWN_ON_ZERO_PLAYERS = false;
public List<String> WHITELIST = List.of("127.0.0.1");
}

@NodeSequence
public static class DOMAIN_MOTD_NODE {

public List<String> DESCRIPTION = List.of("Description for example.com");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void execute(Invocation invocation) {
return;
}

Settings.IMP.save(this.plugin.getConfigFile());
Settings.IMP.save(this.plugin.getConfigPath());
}

@Override
Expand Down
16 changes: 11 additions & 5 deletions src/main/java/net/elytrium/fastmotd/dummy/DummyPlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import com.velocitypowered.api.util.GameProfile;
import com.velocitypowered.api.util.ModInfo;
import java.net.InetSocketAddress;
import java.util.Collection;
import java.util.List;
import java.util.Locale;
import java.util.Optional;
Expand Down Expand Up @@ -114,11 +115,6 @@ public GameProfile getGameProfile() {
return null;
}

@Override
public void clearHeaderAndFooter() {

}

@Override
public void clearPlayerListHeaderAndFooter() {

Expand Down Expand Up @@ -174,6 +170,16 @@ public void sendResourcePackOffer(ResourcePackInfo packInfo) {
return null;
}

@Override
public Collection<ResourcePackInfo> getAppliedResourcePacks() {
return null;
}

@Override
public Collection<ResourcePackInfo> getPendingResourcePacks() {
return null;
}

@Override
public boolean sendPluginMessage(ChannelIdentifier identifier, byte[] data) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
import java.net.InetSocketAddress;
import net.elytrium.commons.utils.reflection.ReflectionException;
import net.elytrium.fastmotd.FastMOTD;
import net.elytrium.fastmotd.Settings;
import net.elytrium.java.commons.reflection.ReflectionException;
import org.jetbrains.annotations.NotNull;

public class ServerChannelInitializerHook extends ChannelInitializer<Channel> {
Expand Down

0 comments on commit 2126fbf

Please sign in to comment.