From cd97d938f9598176694e77fd3c0007f09c0fd605 Mon Sep 17 00:00:00 2001 From: Petr Ilin Date: Wed, 8 Jun 2022 14:47:43 +0300 Subject: [PATCH] 1.19 support --- README.md | 3 +-- build.gradle | 6 +++--- .../net/elytrium/limbofilter/LimboFilter.java | 8 +++++--- .../java/net/elytrium/limbofilter/Settings.java | 5 ++++- .../limbofilter/cache/CachedPackets.java | 16 ++++++++++------ 5 files changed, 23 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index dbb7155..8f7a579 100644 --- a/README.md +++ b/README.md @@ -54,5 +54,4 @@ Your donations are really appreciated. Donations wallets/links/cards: - MasterCard Debit Card (Tinkoff Bank): ``5536 9140 0599 1975`` - Qiwi Wallet: ``PFORG`` or [this link](https://my.qiwi.com/form/Petr-YSpyiLt9c6) -- YooMoney Wallet: ``4100 1721 8467 044`` or [this link](https://yoomoney.ru/quickpay/shop-widget?writer=seller&targets=Donation&targets-hint=&default-sum=&button-text=11&payment-type-choice=on&mobile-payment-type-choice=on&hint=&successURL=&quickpay=shop&account=410017218467044) -- PayPal: ``ogurec332@mail.ru`` +- YooMoney Wallet: ``4100 1721 8467 044`` or [this link](https://yoomoney.ru/quickpay/shop-widget?writer=seller&targets=Donation&targets-hint=&default-sum=&button-text=11&payment-type-choice=on&mobile-payment-type-choice=on&hint=&successURL=&quickpay=shop&account=410017218467044) \ No newline at end of file diff --git a/build.gradle b/build.gradle index 31139b6..b5cd0e0 100644 --- a/build.gradle +++ b/build.gradle @@ -9,7 +9,7 @@ plugins { } setGroup("net.elytrium") -setVersion("1.0.4") +setVersion("1.0.5") compileJava { getOptions().setEncoding("UTF-8") @@ -34,14 +34,14 @@ repositories { } dependencies { - compileOnly("net.elytrium:limboapi-api:1.0.4-SNAPSHOT") + compileOnly("net.elytrium:limboapi-api:1.0.5") compileOnly("com.velocitypowered:velocity-api:3.1.2-SNAPSHOT") annotationProcessor("com.velocitypowered:velocity-api:3.1.2-SNAPSHOT") compileOnly("com.velocitypowered:velocity-proxy:3.1.2-SNAPSHOT") // From Elytrium Repo. // Needs for some velocity methods. - compileOnly("io.netty:netty-codec:4.1.76.Final") + compileOnly("io.netty:netty-codec:4.1.77.Final") implementation("org.bstats:bstats-velocity:3.0.0") diff --git a/src/main/java/net/elytrium/limbofilter/LimboFilter.java b/src/main/java/net/elytrium/limbofilter/LimboFilter.java index f528c0b..5a8f9ec 100644 --- a/src/main/java/net/elytrium/limbofilter/LimboFilter.java +++ b/src/main/java/net/elytrium/limbofilter/LimboFilter.java @@ -128,8 +128,9 @@ public void onProxyInitialization(ProxyInitializeEvent event) { metrics.addCustomChart(new SimplePie("load_world", () -> String.valueOf(Settings.IMP.MAIN.LOAD_WORLD))); metrics.addCustomChart(new SimplePie("check_brand", () -> String.valueOf(Settings.IMP.MAIN.CHECK_CLIENT_BRAND))); metrics.addCustomChart(new SimplePie("check_settings", () -> String.valueOf(Settings.IMP.MAIN.CHECK_CLIENT_SETTINGS))); - System.out.println(Settings.IMP.MAIN.CAPTCHA_GENERATOR.BACKPLATE_PATHS.isEmpty()); - metrics.addCustomChart(new SimplePie("has_backplate", () -> String.valueOf(!Settings.IMP.MAIN.CAPTCHA_GENERATOR.BACKPLATE_PATHS.isEmpty()))); + metrics.addCustomChart(new SimplePie("has_backplate", + () -> String.valueOf(!Settings.IMP.MAIN.CAPTCHA_GENERATOR.BACKPLATE_PATHS.isEmpty() + && !Settings.IMP.MAIN.CAPTCHA_GENERATOR.BACKPLATE_PATHS.get(0).isEmpty()))); metrics.addCustomChart(new SingleLineChart("pings", () -> Math.toIntExact(this.statistics.getPings()))); // Total pings metrics.addCustomChart(new SingleLineChart("connections", () -> Math.toIntExact(this.statistics.getConnections()))); @@ -208,7 +209,8 @@ public void reload() { this.filterServer = this.factory.createLimbo(this.filterWorld) .setName("LimboFilter") - .setReadTimeout(Settings.IMP.MAIN.MAX_PING); + .setReadTimeout(Settings.IMP.MAIN.MAX_PING) + .setWorldTime(Settings.IMP.MAIN.WORLD_TICKS); CommandManager manager = this.server.getCommandManager(); manager.unregister("limbofilter"); diff --git a/src/main/java/net/elytrium/limbofilter/Settings.java b/src/main/java/net/elytrium/limbofilter/Settings.java index 325aa11..b88b5b6 100644 --- a/src/main/java/net/elytrium/limbofilter/Settings.java +++ b/src/main/java/net/elytrium/limbofilter/Settings.java @@ -85,10 +85,13 @@ public static class MAIN { public String CHECK_STATE_NON_TOGGLED = "CAPTCHA_ON_POSITION_FAILED"; public boolean LOAD_WORLD = false; - @Comment("World file type: \"schematic\" (1.12.2 and lower), \"structure\" block .nbt (saved in the latest version).") + @Comment("World file type: \"schematic\" (1.12.2 and lower, not recommended), \"structure\" block .nbt (saved in 1.17 - 1.18.2).") public String WORLD_FILE_TYPE = "structure"; public String WORLD_FILE_PATH = "world.nbt"; + @Comment("World time in ticks (24000 ticks == 1 in-game day)") + public long WORLD_TICKS = 1000L; + @Comment("Unit of time in seconds for the Auto Toggles the Statistics.") public int UNIT_OF_TIME_CPS = 300; diff --git a/src/main/java/net/elytrium/limbofilter/cache/CachedPackets.java b/src/main/java/net/elytrium/limbofilter/cache/CachedPackets.java index 0f2d8bb..4ff165b 100644 --- a/src/main/java/net/elytrium/limbofilter/cache/CachedPackets.java +++ b/src/main/java/net/elytrium/limbofilter/cache/CachedPackets.java @@ -20,8 +20,9 @@ import com.velocitypowered.api.network.ProtocolVersion; import com.velocitypowered.proxy.protocol.MinecraftPacket; import com.velocitypowered.proxy.protocol.ProtocolUtils; -import com.velocitypowered.proxy.protocol.packet.Chat; import com.velocitypowered.proxy.protocol.packet.Disconnect; +import com.velocitypowered.proxy.protocol.packet.chat.LegacyChat; +import com.velocitypowered.proxy.protocol.packet.chat.SystemChat; import com.velocitypowered.proxy.protocol.packet.title.GenericTitlePacket; import java.util.ArrayList; import java.util.List; @@ -107,16 +108,19 @@ private MinecraftPacket createSetSlotPacket(LimboFactory factory, VirtualItem it public PreparedPacket createChatPacket(LimboFactory factory, String text) { return factory.createPreparedPacket() - .prepare(new Chat( + .prepare(new LegacyChat( ProtocolUtils.getJsonChatSerializer(ProtocolVersion.MINIMUM_VERSION).serialize( LimboFilter.getSerializer().deserialize(text) - ), Chat.CHAT_TYPE, null + ), LegacyChat.CHAT_TYPE, null ), ProtocolVersion.MINIMUM_VERSION, ProtocolVersion.MINECRAFT_1_15_2) - .prepare(new Chat( + .prepare(new LegacyChat( ProtocolUtils.getJsonChatSerializer(ProtocolVersion.MINECRAFT_1_16).serialize( LimboFilter.getSerializer().deserialize(text) - ), Chat.CHAT_TYPE, null - ), ProtocolVersion.MINECRAFT_1_16); + ), LegacyChat.CHAT_TYPE, null + ), ProtocolVersion.MINECRAFT_1_16, ProtocolVersion.MINECRAFT_1_18_2) + .prepare(new SystemChat( + LimboFilter.getSerializer().deserialize(text), 0 + ), ProtocolVersion.MINECRAFT_1_19); } private PreparedPacket createDisconnectPacket(LimboFactory factory, String message) {