mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-29 11:59:11 +00:00
feat(network): 补充聊天命令拦截
This commit is contained in:
@@ -12,7 +12,7 @@ import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
public class ImageManagerImpl implements ImageManager {
|
||||
public abstract class AbstractImageManager implements ImageManager {
|
||||
private final CraftEngine plugin;
|
||||
// namespace:font font
|
||||
private final HashMap<Key, Font> fonts = new HashMap<>();
|
||||
@@ -22,7 +22,7 @@ public class ImageManagerImpl implements ImageManager {
|
||||
|
||||
private OffsetFont offsetFont;
|
||||
|
||||
public ImageManagerImpl(CraftEngine plugin) {
|
||||
public AbstractImageManager(CraftEngine plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@@ -68,4 +68,6 @@ public interface ImageManager extends Reloadable, ConfigSectionParser {
|
||||
default int loadingSequence() {
|
||||
return LoadingSequence.FONT;
|
||||
}
|
||||
|
||||
void delayedInit();
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package net.momirealms.craftengine.core.plugin;
|
||||
import net.momirealms.craftengine.core.block.BlockManager;
|
||||
import net.momirealms.craftengine.core.entity.furniture.FurnitureManager;
|
||||
import net.momirealms.craftengine.core.font.ImageManager;
|
||||
import net.momirealms.craftengine.core.font.ImageManagerImpl;
|
||||
import net.momirealms.craftengine.core.font.AbstractImageManager;
|
||||
import net.momirealms.craftengine.core.item.ItemManager;
|
||||
import net.momirealms.craftengine.core.item.recipe.RecipeManager;
|
||||
import net.momirealms.craftengine.core.loot.VanillaLootManager;
|
||||
@@ -120,7 +120,6 @@ public abstract class CraftEngine implements Plugin {
|
||||
@Override
|
||||
public void enable() {
|
||||
this.networkManager.enable();
|
||||
this.imageManager = new ImageManagerImpl(this);
|
||||
this.templateManager = new TemplateManagerImpl(this);
|
||||
this.itemBrowserManager = new ItemBrowserManagerImpl(this);
|
||||
this.commandManager.registerDefaultFeatures();
|
||||
@@ -135,6 +134,7 @@ public abstract class CraftEngine implements Plugin {
|
||||
this.worldManager.delayedInit();
|
||||
this.packManager.delayedInit();
|
||||
this.furnitureManager.delayedInit();
|
||||
this.imageManager.delayedInit();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package net.momirealms.craftengine.core.util;
|
||||
|
||||
import com.github.benmanes.caffeine.cache.Cache;
|
||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||
import com.google.gson.JsonElement;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import net.kyori.adventure.sound.Sound;
|
||||
@@ -182,6 +183,24 @@ public class AdventureHelper {
|
||||
return getGson().serialize(component);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a JsonElement to a Component.
|
||||
* @param gson the JsonElement to convert
|
||||
* @return the resulting Component
|
||||
*/
|
||||
public static Component jsonElementToComponent(JsonElement gson) {
|
||||
return GsonComponentSerializer.gson().deserializeFromTree(gson);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a JsonElement to a JSON string.
|
||||
* @param gson the JsonElement to convert
|
||||
* @return the JSON string representation
|
||||
*/
|
||||
public static String jsonElementToStringJson(JsonElement gson) {
|
||||
return componentToJson(jsonElementToComponent(gson));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a character is a legacy color code.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user