From 295afc6e35635fc0a6da32a814132b2412e87291 Mon Sep 17 00:00:00 2001 From: Aust1n46 Date: Sun, 11 Feb 2024 02:39:17 -0600 Subject: [PATCH] Update Edit command update VersionService inject --- .../venture/Aust1n46/chat/initators/commands/Edit.java | 8 +++++--- .../java/venture/Aust1n46/chat/xcut/VersionService.java | 7 ++----- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/main/java/venture/Aust1n46/chat/initators/commands/Edit.java b/src/main/java/venture/Aust1n46/chat/initators/commands/Edit.java index ba14e19..606f320 100644 --- a/src/main/java/venture/Aust1n46/chat/initators/commands/Edit.java +++ b/src/main/java/venture/Aust1n46/chat/initators/commands/Edit.java @@ -16,11 +16,11 @@ import com.google.inject.Inject; import venture.Aust1n46.chat.initiators.application.VentureChat; import venture.Aust1n46.chat.localization.LocalizedMessage; import venture.Aust1n46.chat.model.ChatMessage; -import venture.Aust1n46.chat.model.VentureChatPlayer; import venture.Aust1n46.chat.model.UniversalCommand; +import venture.Aust1n46.chat.model.VentureChatPlayer; +import venture.Aust1n46.chat.service.VentureChatFormatService; import venture.Aust1n46.chat.service.VentureChatPlayerApiService; import venture.Aust1n46.chat.utilities.FormatUtils; -import venture.Aust1n46.chat.service.VentureChatFormatService; public class Edit extends UniversalCommand { @Inject @@ -41,7 +41,6 @@ public class Edit extends UniversalCommand { @Inject public void postConstruct() { emptyLinePacketContainer = formatService.createPacketPlayOutChat("{\"extra\":[\" \"],\"text\":\"\"}"); - messageDeletedComponentPlayer = WrappedChatComponent.fromJson("{\"text\":\"\",\"extra\":[{\"text\":\"\",\"color\":\"red\",\"italic\":\"true\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[{\"text\":\"" + FormatUtils.FormatStringAll(plugin.getConfig().getString("messageremoverpermissions")) + "\"}]}}}]}"); } @Override @@ -111,6 +110,9 @@ public class Edit extends UniversalCommand { } public WrappedChatComponent getMessageDeletedChatComponentPlayer() { + if (messageDeletedComponentPlayer == null) { // avoid errors on startup from this non functional command on different game versions + messageDeletedComponentPlayer = WrappedChatComponent.fromJson("{\"text\":\"\",\"extra\":[{\"text\":\"\",\"color\":\"red\",\"italic\":\"true\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[{\"text\":\"" + FormatUtils.FormatStringAll(plugin.getConfig().getString("messageremoverpermissions")) + "\"}]}}}]}"); + } return this.messageDeletedComponentPlayer; } diff --git a/src/main/java/venture/Aust1n46/chat/xcut/VersionService.java b/src/main/java/venture/Aust1n46/chat/xcut/VersionService.java index 75e99c9..ca91ad4 100644 --- a/src/main/java/venture/Aust1n46/chat/xcut/VersionService.java +++ b/src/main/java/venture/Aust1n46/chat/xcut/VersionService.java @@ -4,15 +4,12 @@ import com.comphenix.protocol.utility.MinecraftVersion; import com.google.inject.Singleton; @Singleton -public final class VersionService { +public class VersionService { public static final MinecraftVersion SERVER_VERSION = MinecraftVersion.getCurrentVersion(); private static final MinecraftVersion MC1_19 = new MinecraftVersion(1, 19, 0); private static final MinecraftVersion MC1_19_1 = new MinecraftVersion(1, 19, 1); private static final MinecraftVersion MC1_20_4 = new MinecraftVersion(1, 20, 4); - private VersionService() { - } - public boolean is1_7() { return SERVER_VERSION.getMinor() == 7 && SERVER_VERSION.getMajor() == 1; } @@ -76,7 +73,7 @@ public final class VersionService { public boolean isAbove_1_19() { return SERVER_VERSION.isAtLeast(MC1_19_1); } - + public boolean isAtLeast_1_20_4() { return SERVER_VERSION.isAtLeast(MC1_20_4); }