mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-22 08:29:21 +00:00
向外
This commit is contained in:
@@ -79,7 +79,7 @@ warning.config.image.lack_char: "<yellow>Issue found in file <arg:0> - The image
|
|||||||
warning.config.image.codepoint_in_use: "<yellow>Issue found in file <arg:0> - The image '<arg:1>' is using a character[<arg:3>(<arg:4>)] in font <arg:2> that has been used by another image '<arg:5>'.</yellow>"
|
warning.config.image.codepoint_in_use: "<yellow>Issue found in file <arg:0> - The image '<arg:1>' is using a character[<arg:3>(<arg:4>)] in font <arg:2> that has been used by another image '<arg:5>'.</yellow>"
|
||||||
warning.config.image.invalid_codepoint_grid: "<yellow>Issue found in file <arg:0> - Image '<arg:1>' has an invalid 'chars' codepoint grind.</yellow>"
|
warning.config.image.invalid_codepoint_grid: "<yellow>Issue found in file <arg:0> - Image '<arg:1>' has an invalid 'chars' codepoint grind.</yellow>"
|
||||||
warning.config.image.file_not_exist: "<yellow>Issue found in file <arg:0> - PNG file '<arg:2>' not found for image '<arg:1>'.</yellow>"
|
warning.config.image.file_not_exist: "<yellow>Issue found in file <arg:0> - PNG file '<arg:2>' not found for image '<arg:1>'.</yellow>"
|
||||||
warning.config.image.invalid_hex: "<yellow>Issue found in file <arg:0> - The image '<arg:1>' is using an unicode character '<arg:2>' that is not a valid hexadecimal (radix 16) value.</yellow>"
|
warning.config.image.invalid_hex: "<yellow>Issue found in file <arg:0> - The image '<arg:1>' is using a unicode character '<arg:2>' that is not a valid hexadecimal (radix 16) value.</yellow>"
|
||||||
warning.config.recipe.duplicated: "<yellow>Issue found in file <arg:0> - Duplicated recipe '<arg:1>'.</yellow>"
|
warning.config.recipe.duplicated: "<yellow>Issue found in file <arg:0> - Duplicated recipe '<arg:1>'.</yellow>"
|
||||||
warning.config.recipe.lack_type: "<yellow>Issue found in file <arg:0> - The recipe '<arg:1>' is missing the required argument 'type'.</yellow>"
|
warning.config.recipe.lack_type: "<yellow>Issue found in file <arg:0> - The recipe '<arg:1>' is missing the required argument 'type'.</yellow>"
|
||||||
warning.config.recipe.invalid_type: "<yellow>Issue found in file <arg:0> - The recipe '<arg:1>' is using an invalid recipe type '<arg:2>'.</yellow>"
|
warning.config.recipe.invalid_type: "<yellow>Issue found in file <arg:0> - The recipe '<arg:1>' is using an invalid recipe type '<arg:2>'.</yellow>"
|
||||||
|
|||||||
@@ -335,24 +335,10 @@ public class BukkitBlockManager extends AbstractBlockManager {
|
|||||||
throw new LocalizedResourceConfigException("warning.config.block.duplicated", path, id);
|
throw new LocalizedResourceConfigException("warning.config.block.duplicated", path, id);
|
||||||
}
|
}
|
||||||
// read block settings
|
// read block settings
|
||||||
BlockSettings settings;
|
BlockSettings settings = BlockSettings.fromMap(MiscUtils.castToMap(section.getOrDefault("settings", Map.of()), false));
|
||||||
try {
|
|
||||||
settings = BlockSettings.fromMap(MiscUtils.castToMap(section.getOrDefault("settings", Map.of()), false));
|
|
||||||
} catch (LocalizedResourceConfigException e) {
|
|
||||||
e.setPath(path);
|
|
||||||
e.setId(id);
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
|
|
||||||
// read loot table
|
// read loot table
|
||||||
LootTable<ItemStack> lootTable;
|
LootTable<ItemStack> lootTable = LootTable.fromMap(MiscUtils.castToMap(section.getOrDefault("loot", Map.of()), false));
|
||||||
try {
|
|
||||||
lootTable = LootTable.fromMap(MiscUtils.castToMap(section.getOrDefault("loot", Map.of()), false));
|
|
||||||
} catch (LocalizedResourceConfigException e) {
|
|
||||||
e.setPath(path);
|
|
||||||
e.setId(id);
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
|
|
||||||
// read states
|
// read states
|
||||||
Map<String, Property<?>> properties;
|
Map<String, Property<?>> properties;
|
||||||
@@ -440,9 +426,7 @@ public class BukkitBlockManager extends AbstractBlockManager {
|
|||||||
|
|
||||||
Map<String, Object> behaviors = MiscUtils.castToMap(section.getOrDefault("behavior", Map.of()), false);
|
Map<String, Object> behaviors = MiscUtils.castToMap(section.getOrDefault("behavior", Map.of()), false);
|
||||||
|
|
||||||
CustomBlock block;
|
CustomBlock block = BukkitCustomBlock.builder(id)
|
||||||
try {
|
|
||||||
block = BukkitCustomBlock.builder(id)
|
|
||||||
.appearances(appearances)
|
.appearances(appearances)
|
||||||
.variantMapper(variants)
|
.variantMapper(variants)
|
||||||
.lootTable(lootTable)
|
.lootTable(lootTable)
|
||||||
@@ -450,11 +434,6 @@ public class BukkitBlockManager extends AbstractBlockManager {
|
|||||||
.settings(settings)
|
.settings(settings)
|
||||||
.behavior(behaviors)
|
.behavior(behaviors)
|
||||||
.build();
|
.build();
|
||||||
} catch (LocalizedResourceConfigException e) {
|
|
||||||
e.setPath(path);
|
|
||||||
e.setId(id);
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
|
|
||||||
// bind appearance and real state
|
// bind appearance and real state
|
||||||
for (ImmutableBlockState state : block.variantProvider().states()) {
|
for (ImmutableBlockState state : block.variantProvider().states()) {
|
||||||
|
|||||||
@@ -157,14 +157,8 @@ public class BukkitFurnitureManager extends AbstractFurnitureManager {
|
|||||||
List<Map<String, Object>> hitboxConfigs = (List<Map<String, Object>>) placementArguments.getOrDefault("hitboxes", List.of());
|
List<Map<String, Object>> hitboxConfigs = (List<Map<String, Object>>) placementArguments.getOrDefault("hitboxes", List.of());
|
||||||
List<HitBox> hitboxes = new ArrayList<>();
|
List<HitBox> hitboxes = new ArrayList<>();
|
||||||
for (Map<String, Object> config : hitboxConfigs) {
|
for (Map<String, Object> config : hitboxConfigs) {
|
||||||
try {
|
|
||||||
HitBox hitBox = HitBoxTypes.fromMap(config);
|
HitBox hitBox = HitBoxTypes.fromMap(config);
|
||||||
hitboxes.add(hitBox);
|
hitboxes.add(hitBox);
|
||||||
} catch (LocalizedResourceConfigException e) {
|
|
||||||
e.setPath(path);
|
|
||||||
e.setId(id);
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (hitboxes.isEmpty() && externalModel.isEmpty()) {
|
if (hitboxes.isEmpty() && externalModel.isEmpty()) {
|
||||||
hitboxes.add(InteractionHitBox.DEFAULT);
|
hitboxes.add(InteractionHitBox.DEFAULT);
|
||||||
@@ -198,24 +192,10 @@ public class BukkitFurnitureManager extends AbstractFurnitureManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// get furniture settings
|
// get furniture settings
|
||||||
FurnitureSettings settings;
|
FurnitureSettings settings = FurnitureSettings.fromMap(settingsMap);
|
||||||
try {
|
|
||||||
settings = FurnitureSettings.fromMap(settingsMap);
|
|
||||||
} catch (LocalizedResourceConfigException e) {
|
|
||||||
e.setPath(path);
|
|
||||||
e.setId(id);
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
|
|
||||||
// get loot table
|
// get loot table
|
||||||
LootTable<ItemStack> lootTable;
|
LootTable<ItemStack> lootTable = lootMap == null ? null : LootTable.fromMap(lootMap);
|
||||||
try {
|
|
||||||
lootTable = lootMap == null ? null : LootTable.fromMap(lootMap);
|
|
||||||
} catch (LocalizedResourceConfigException e) {
|
|
||||||
e.setPath(path);
|
|
||||||
e.setId(id);
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
CustomFurniture furniture = new CustomFurniture(id, settings, placements, lootTable);
|
CustomFurniture furniture = new CustomFurniture(id, settings, placements, lootTable);
|
||||||
byId.put(id, furniture);
|
byId.put(id, furniture);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -339,15 +339,7 @@ public class BukkitItemManager extends AbstractItemManager<ItemStack> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemSettings itemSettings;
|
ItemSettings itemSettings = ItemSettings.fromMap(MiscUtils.castToMap(section.get("settings"), true));
|
||||||
try {
|
|
||||||
itemSettings = ItemSettings.fromMap(MiscUtils.castToMap(section.get("settings"), true));
|
|
||||||
} catch (LocalizedResourceConfigException e) {
|
|
||||||
e.setPath(path);
|
|
||||||
e.setId(id);
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isVanillaItem) {
|
if (isVanillaItem) {
|
||||||
itemSettings.canPlaceRelatedVanillaBlock(true);
|
itemSettings.canPlaceRelatedVanillaBlock(true);
|
||||||
}
|
}
|
||||||
@@ -391,15 +383,7 @@ public class BukkitItemManager extends AbstractItemManager<ItemStack> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemModel model;
|
ItemModel model = ItemModels.fromMap(modelSection);
|
||||||
try {
|
|
||||||
model = ItemModels.fromMap(modelSection);
|
|
||||||
} catch (LocalizedResourceConfigException e) {
|
|
||||||
e.setPath(path);
|
|
||||||
e.setId(id);
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean hasModel = false;
|
boolean hasModel = false;
|
||||||
if (customModelData != 0) {
|
if (customModelData != 0) {
|
||||||
hasModel= true;
|
hasModel= true;
|
||||||
|
|||||||
@@ -159,14 +159,7 @@ public abstract class AbstractRecipeManager<T> implements RecipeManager<T> {
|
|||||||
if (AbstractRecipeManager.this.byId.containsKey(id)) {
|
if (AbstractRecipeManager.this.byId.containsKey(id)) {
|
||||||
throw new LocalizedResourceConfigException("warning.config.recipe.duplicated", path, id);
|
throw new LocalizedResourceConfigException("warning.config.recipe.duplicated", path, id);
|
||||||
}
|
}
|
||||||
Recipe<T> recipe;
|
Recipe<T> recipe = RecipeTypes.fromMap(id, section);
|
||||||
try {
|
|
||||||
recipe = RecipeTypes.fromMap(id, section);
|
|
||||||
} catch (LocalizedResourceConfigException e) {
|
|
||||||
e.setPath(path);
|
|
||||||
e.setId(id);
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
markAsCustomRecipe(id);
|
markAsCustomRecipe(id);
|
||||||
registerInternalRecipe(id, recipe);
|
registerInternalRecipe(id, recipe);
|
||||||
|
|||||||
@@ -450,6 +450,7 @@ public abstract class AbstractPackManager implements PackManager {
|
|||||||
String key = configEntry.getKey();
|
String key = configEntry.getKey();
|
||||||
try {
|
try {
|
||||||
Key id = Key.withDefaultNamespace(key, cached.pack().namespace());
|
Key id = Key.withDefaultNamespace(key, cached.pack().namespace());
|
||||||
|
try {
|
||||||
if (parser.isTemplate()) {
|
if (parser.isTemplate()) {
|
||||||
this.plugin.templateManager().addTemplate(cached.pack(), cached.filePath(), id, configEntry.getValue());
|
this.plugin.templateManager().addTemplate(cached.pack(), cached.filePath(), id, configEntry.getValue());
|
||||||
} else if (predicate.test(parser)) {
|
} else if (predicate.test(parser)) {
|
||||||
@@ -463,7 +464,13 @@ public abstract class AbstractPackManager implements PackManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (LocalizedException e) {
|
} catch (LocalizedException e) {
|
||||||
|
if (e instanceof LocalizedResourceConfigException exception) {
|
||||||
|
exception.setPath(cached.filePath());
|
||||||
|
exception.setId(cached.prefix() + "." + key);
|
||||||
|
}
|
||||||
TranslationManager.instance().log(e.node(), e.arguments());
|
TranslationManager.instance().log(e.node(), e.arguments());
|
||||||
|
this.plugin.debug(e::node);
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
this.plugin.logger().warn("Unexpected error loading file " + cached.filePath() + " - '" + parser.sectionId()[0] + "." + key + "'. Please find the cause according to the stacktrace or seek developer help.", e);
|
this.plugin.logger().warn("Unexpected error loading file " + cached.filePath() + " - '" + parser.sectionId()[0] + "." + key + "'. Please find the cause according to the stacktrace or seek developer help.", e);
|
||||||
}
|
}
|
||||||
@@ -482,7 +489,7 @@ public abstract class AbstractPackManager implements PackManager {
|
|||||||
String configType = hashIndex != -1 ? key.substring(0, hashIndex) : key;
|
String configType = hashIndex != -1 ? key.substring(0, hashIndex) : key;
|
||||||
Optional.ofNullable(this.sectionParsers.get(configType))
|
Optional.ofNullable(this.sectionParsers.get(configType))
|
||||||
.ifPresent(parser -> this.cachedConfigs.computeIfAbsent(parser, k -> new ArrayList<>())
|
.ifPresent(parser -> this.cachedConfigs.computeIfAbsent(parser, k -> new ArrayList<>())
|
||||||
.add(new CachedConfig(castToMap(typeSections0, false), path, pack)));
|
.add(new CachedConfig(key, castToMap(typeSections0, false), path, pack)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,12 +6,14 @@ import java.util.Map;
|
|||||||
public class CachedConfig {
|
public class CachedConfig {
|
||||||
private final Pack pack;
|
private final Pack pack;
|
||||||
private final Path filePath;
|
private final Path filePath;
|
||||||
|
private final String prefix;
|
||||||
private final Map<String, Object> config;
|
private final Map<String, Object> config;
|
||||||
|
|
||||||
public CachedConfig(Map<String, Object> config, Path filePath, Pack pack) {
|
public CachedConfig(String prefix, Map<String, Object> config, Path filePath, Pack pack) {
|
||||||
this.config = config;
|
this.config = config;
|
||||||
this.filePath = filePath;
|
this.filePath = filePath;
|
||||||
this.pack = pack;
|
this.pack = pack;
|
||||||
|
this.prefix = prefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, Object> config() {
|
public Map<String, Object> config() {
|
||||||
@@ -25,4 +27,8 @@ public class CachedConfig {
|
|||||||
public Pack pack() {
|
public Pack pack() {
|
||||||
return pack;
|
return pack;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String prefix() {
|
||||||
|
return prefix;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public class LocalizedResourceConfigException extends LocalizedException {
|
|||||||
super.setArgument(0, path.toString());
|
super.setArgument(0, path.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(Key id) {
|
public void setId(String id) {
|
||||||
super.setArgument(1, id.toString());
|
super.setArgument(1, id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ public class CharacterUtils {
|
|||||||
chars[i] = (char) codePoint;
|
chars[i] = (char) codePoint;
|
||||||
}
|
}
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
throw new LocalizedResourceConfigException("");
|
throw new LocalizedResourceConfigException("warning.config.image.invalid_hex", e, hex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return chars;
|
return chars;
|
||||||
|
|||||||
Reference in New Issue
Block a user