Update Edit command update VersionService inject

This commit is contained in:
Aust1n46 2024-02-11 02:39:17 -06:00
parent 7069f24f14
commit 295afc6e35
2 changed files with 7 additions and 8 deletions

View File

@ -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\":\"<message removed>\",\"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\":\"<message removed>\",\"color\":\"red\",\"italic\":\"true\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[{\"text\":\"" + FormatUtils.FormatStringAll(plugin.getConfig().getString("messageremoverpermissions")) + "\"}]}}}]}");
}
return this.messageDeletedComponentPlayer;
}

View File

@ -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);
}