mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-27 10:59:07 +00:00
添加禁用原版配方功能
This commit is contained in:
@@ -152,7 +152,14 @@ image:
|
||||
sign: true
|
||||
|
||||
recipe:
|
||||
# Enable the plugin's recipe system
|
||||
enable: true
|
||||
# Disable vanilla recipes
|
||||
disable-vanilla-recipes:
|
||||
# Disable all vanilla recipes
|
||||
all: false
|
||||
# Disable the recipes in list
|
||||
list: []
|
||||
|
||||
gui:
|
||||
browser:
|
||||
|
||||
@@ -297,6 +297,7 @@ public class BukkitRecipeManager extends AbstractRecipeManager<ItemStack> {
|
||||
|
||||
@Override
|
||||
public void unload() {
|
||||
if (!Config.enableRecipeSystem()) return;
|
||||
super.unload();
|
||||
try {
|
||||
if (VersionHelper.isVersionNewerThan1_21_2()) {
|
||||
@@ -310,6 +311,7 @@ public class BukkitRecipeManager extends AbstractRecipeManager<ItemStack> {
|
||||
|
||||
@Override
|
||||
public void delayedLoad() {
|
||||
if (!Config.enableRecipeSystem()) return;
|
||||
this.injectDataPackRecipes();
|
||||
}
|
||||
|
||||
@@ -368,12 +370,23 @@ public class BukkitRecipeManager extends AbstractRecipeManager<ItemStack> {
|
||||
for (Object pack : selected) {
|
||||
packResources.add(Reflections.method$Pack$open.invoke(pack));
|
||||
}
|
||||
|
||||
boolean hasDisabledAny = !Config.disabledVanillaRecipes().isEmpty();
|
||||
try (AutoCloseable resourceManager = (AutoCloseable) Reflections.constructor$MultiPackResourceManager.newInstance(Reflections.instance$PackType$SERVER_DATA, packResources)) {
|
||||
Map<Object, Object> scannedResources = (Map<Object, Object>) Reflections.method$FileToIdConverter$listMatchingResources.invoke(fileToIdConverter, resourceManager);
|
||||
for (Map.Entry<Object, Object> entry : scannedResources.entrySet()) {
|
||||
Key id = extractKeyFromResourceLocation(entry.getKey().toString());
|
||||
// Maybe it's unregistered by other plugins
|
||||
if (Bukkit.getRecipe(new NamespacedKey(id.namespace(), id.value())) == null) {
|
||||
// now CraftEngine takes over everything
|
||||
// // Maybe it's unregistered by other plugins
|
||||
// if (Bukkit.getRecipe(new NamespacedKey(id.namespace(), id.value())) == null) {
|
||||
// continue;
|
||||
// }
|
||||
if (Config.disableAllVanillaRecipes()) {
|
||||
this.delayedTasksOnMainThread.add(() -> unregisterPlatformRecipe(id));
|
||||
continue;
|
||||
}
|
||||
if (hasDisabledAny && Config.disabledVanillaRecipes().contains(id)) {
|
||||
this.delayedTasksOnMainThread.add(() -> unregisterPlatformRecipe(id));
|
||||
continue;
|
||||
}
|
||||
markAsDataPackRecipe(id);
|
||||
@@ -423,6 +436,7 @@ public class BukkitRecipeManager extends AbstractRecipeManager<ItemStack> {
|
||||
|
||||
@Override
|
||||
public void runDelayedSyncTasks() {
|
||||
if (!Config.enableRecipeSystem()) return;
|
||||
try {
|
||||
// run delayed tasks
|
||||
for (Runnable r : this.delayedTasksOnMainThread) {
|
||||
|
||||
@@ -40,7 +40,6 @@ public abstract class AbstractModelGenerator implements ModelGenerator {
|
||||
if (!ResourceLocation.isValid(model.parentModelPath())) {
|
||||
TranslationManager.instance().log("warning.config.model.generation.parent.invalid_resource_location", path.toString(), id.toString(), model.parentModelPath());
|
||||
}
|
||||
|
||||
for (Map.Entry<String, String> texture : model.texturesOverride().entrySet()) {
|
||||
if (!ResourceLocation.isValid(texture.getValue())) {
|
||||
TranslationManager.instance().log("warning.config.model.generation.texture.invalid_resource_location", path.toString(), id.toString(), texture.getKey(), texture.getValue());
|
||||
|
||||
@@ -17,6 +17,7 @@ import net.momirealms.craftengine.core.plugin.PluginProperties;
|
||||
import net.momirealms.craftengine.core.plugin.locale.TranslationManager;
|
||||
import net.momirealms.craftengine.core.plugin.logger.filter.DisconnectLogFilter;
|
||||
import net.momirealms.craftengine.core.util.AdventureHelper;
|
||||
import net.momirealms.craftengine.core.util.Key;
|
||||
import net.momirealms.craftengine.core.util.MiscUtils;
|
||||
import net.momirealms.craftengine.core.util.ReflectionUtils;
|
||||
|
||||
@@ -30,6 +31,7 @@ import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Config {
|
||||
private static Config instance;
|
||||
@@ -105,7 +107,10 @@ public class Config {
|
||||
protected boolean furniture$hide_base_entity;
|
||||
|
||||
protected boolean block$sound_system$enable;
|
||||
|
||||
protected boolean recipe$enable;
|
||||
protected boolean recipe$disable_vanilla_recipes$all;
|
||||
protected Set<Key> recipe$disable_vanilla_recipes$list;
|
||||
|
||||
protected boolean item$non_italic_tag;
|
||||
|
||||
@@ -259,6 +264,8 @@ public class Config {
|
||||
|
||||
// recipe
|
||||
recipe$enable = config.getBoolean("recipe.enable", true);
|
||||
recipe$disable_vanilla_recipes$all = config.getBoolean("recipe.disable-vanilla-recipes.all", false);
|
||||
recipe$disable_vanilla_recipes$list = config.getStringList("recipe.disable-vanilla-recipes.list").stream().map(Key::of).collect(Collectors.toSet());
|
||||
|
||||
// image
|
||||
image$illegal_characters_filter$anvil = config.getBoolean("image.illegal-characters-filter.anvil", true);
|
||||
@@ -350,6 +357,14 @@ public class Config {
|
||||
return instance.recipe$enable;
|
||||
}
|
||||
|
||||
public static boolean disableAllVanillaRecipes() {
|
||||
return instance.recipe$disable_vanilla_recipes$all;
|
||||
}
|
||||
|
||||
public static Set<Key> disabledVanillaRecipes() {
|
||||
return instance.recipe$disable_vanilla_recipes$list;
|
||||
}
|
||||
|
||||
public static boolean nonItalic() {
|
||||
return instance.item$non_italic_tag;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user