9
0
mirror of https://github.com/Xiao-MoMi/craft-engine.git synced 2025-12-21 07:59:19 +00:00

模板重构

This commit is contained in:
XiaoMoMi
2025-06-11 19:02:48 +08:00
parent 65852ee0a2
commit 6adf7de9a4
19 changed files with 305 additions and 293 deletions

View File

@@ -205,7 +205,7 @@ public class BukkitProjectileManager implements Listener, ProjectileManager {
private void updateProjectileUpdateInterval(int updateInterval) {
if (this.lastInjectedInterval == updateInterval) return;
try {
CoreReflections.handle$ServerEntity$updateIntervalSetter.invokeExact(this.cachedServerEntity, updateInterval);
CoreReflections.methodHandle$ServerEntity$updateIntervalSetter.invokeExact(this.cachedServerEntity, updateInterval);
this.lastInjectedInterval = updateInterval;
} catch (Throwable e) {
BukkitProjectileManager.this.plugin.logger().warn("Failed to update server entity update interval for " + this.projectile.getType().getKey() + "[" + this.projectile.getUniqueId() + "]", e);

View File

@@ -82,7 +82,7 @@ public class BukkitNetworkManager implements NetworkManager, Listener, PluginMes
private static final String CONNECTION_HANDLER_NAME = "craftengine_connection_handler";
private static final String SERVER_CHANNEL_HANDLER_NAME = "craftengine_server_channel_handler";
private static final String PLAYER_CHANNEL_HANDLER_NAME = "craftengine_player_packet_handler";
private static final String PLAYER_CHANNEL_HANDLER_NAME = "craftengine_player_channel_handler";
private static final String PACKET_ENCODER = "craftengine_encoder";
private static final String PACKET_DECODER = "craftengine_decoder";

View File

@@ -1452,11 +1452,11 @@ public class PacketConsumers {
assert CoreReflections.method$ServerGamePacketListenerImpl$tryPickItem != null;
if (VersionHelper.isOrAbove1_21_5()) {
CoreReflections.method$ServerGamePacketListenerImpl$tryPickItem.invoke(
CoreReflections.handle$ServerPlayer$connectionGetter.invokeExact(FastNMS.INSTANCE.method$CraftPlayer$getHandle(player)),
CoreReflections.methodHandle$ServerPlayer$connectionGetter.invokeExact(FastNMS.INSTANCE.method$CraftPlayer$getHandle(player)),
FastNMS.INSTANCE.method$CraftItemStack$asNMSCopy(itemStack), blockPos, entity, true);
} else {
CoreReflections.method$ServerGamePacketListenerImpl$tryPickItem.invoke(
CoreReflections.handle$ServerPlayer$connectionGetter.invokeExact(FastNMS.INSTANCE.method$CraftPlayer$getHandle(player)), FastNMS.INSTANCE.method$CraftItemStack$asNMSCopy(itemStack));
CoreReflections.methodHandle$ServerPlayer$connectionGetter.invokeExact(FastNMS.INSTANCE.method$CraftPlayer$getHandle(player)), FastNMS.INSTANCE.method$CraftItemStack$asNMSCopy(itemStack));
}
}

View File

@@ -3274,21 +3274,21 @@ public final class CoreReflections {
)
);
public static final MethodHandle handle$ServerEntity$broadcastSetter;
public static final MethodHandle handle$ServerEntity$updateIntervalSetter;
public static final MethodHandle handle$ServerPlayer$connectionGetter;
public static final MethodHandle methodHandle$ServerEntity$broadcastSetter;
public static final MethodHandle methodHandle$ServerEntity$updateIntervalSetter;
public static final MethodHandle methodHandle$ServerPlayer$connectionGetter;
static {
try {
handle$ServerEntity$broadcastSetter = requireNonNull(
methodHandle$ServerEntity$broadcastSetter = requireNonNull(
ReflectionUtils.unreflectSetter(field$ServerEntity$broadcast)
.asType(MethodType.methodType(void.class, Object.class, Consumer.class))
);
handle$ServerEntity$updateIntervalSetter = requireNonNull(
methodHandle$ServerEntity$updateIntervalSetter = requireNonNull(
ReflectionUtils.unreflectSetter(field$ServerEntity$updateInterval)
.asType(MethodType.methodType(void.class, Object.class, int.class))
);
handle$ServerPlayer$connectionGetter = requireNonNull(
methodHandle$ServerPlayer$connectionGetter = requireNonNull(
ReflectionUtils.unreflectGetter(field$ServerPlayer$connection)
.asType(MethodType.methodType(Object.class, Object.class))
);

View File

@@ -2,7 +2,7 @@ templates:
default:emoji/basic:
content: "<hover:show_text:'<i18n:emoji.tip>'><!shadow><white><arg:emoji></white></!shadow></hover>"
default:emoji/addition_info:
content: "<hover:show_text:'<i18n:emoji.tip>'><!shadow><white><arg:emoji></white></!shadow>{text}</hover>"
content: "<hover:show_text:'<i18n:emoji.tip>'><!shadow><white><arg:emoji></white></!shadow>${text}</hover>"
emoji:
default:emoji_location:

View File

@@ -229,16 +229,16 @@ items#topaz_gears:
templates:
default:armor/topaz:
material: "chainmail_{part}"
material: "chainmail_${part}"
custom-model-data: 1000
data:
item-name: "<!i><#FF8C00><i18n:item.topaz_{part}>"
item-name: "<!i><#FF8C00><i18n:item.topaz_${part}>"
tooltip-style: minecraft:topaz
settings:
tags:
- "default:topaz_tools"
equippable:
slot: "{slot}"
slot: "${slot}"
asset-id: topaz
humanoid: "minecraft:topaz"
humanoid-leggings: "minecraft:topaz"
@@ -247,111 +247,111 @@ templates:
property: minecraft:trim_material
fallback:
type: minecraft:model
path: "minecraft:item/custom/topaz_{part}"
path: "minecraft:item/custom/topaz_${part}"
generation:
parent: "minecraft:item/generated"
textures:
"layer0": "minecraft:item/custom/topaz_{part}"
"layer0": "minecraft:item/custom/topaz_${part}"
cases:
- when: minecraft:quartz
model:
type: minecraft:model
path: "minecraft:item/custom/topaz_{part}_quartz_trim"
path: "minecraft:item/custom/topaz_${part}_quartz_trim"
generation:
parent: "minecraft:item/generated"
textures:
"layer0": "minecraft:item/custom/topaz_{part}"
"layer1": "minecraft:trims/items/{part}_trim_quartz"
"layer0": "minecraft:item/custom/topaz_${part}"
"layer1": "minecraft:trims/items/${part}_trim_quartz"
- when: minecraft:iron
model:
type: minecraft:model
path: "minecraft:item/custom/topaz_{part}_iron_trim"
path: "minecraft:item/custom/topaz_${part}_iron_trim"
generation:
parent: "minecraft:item/generated"
textures:
"layer0": "minecraft:item/custom/topaz_{part}"
"layer1": "minecraft:trims/items/{part}_trim_iron"
"layer0": "minecraft:item/custom/topaz_${part}"
"layer1": "minecraft:trims/items/${part}_trim_iron"
- when: minecraft:netherite
model:
type: minecraft:model
path: "minecraft:item/custom/topaz_{part}_netherite_trim"
path: "minecraft:item/custom/topaz_${part}_netherite_trim"
generation:
parent: "minecraft:item/generated"
textures:
"layer0": "minecraft:item/custom/topaz_{part}"
"layer1": "minecraft:trims/items/{part}_trim_netherite"
"layer0": "minecraft:item/custom/topaz_${part}"
"layer1": "minecraft:trims/items/${part}_trim_netherite"
- when: minecraft:redstone
model:
type: minecraft:model
path: "minecraft:item/custom/topaz_{part}_redstone_trim"
path: "minecraft:item/custom/topaz_${part}_redstone_trim"
generation:
parent: "minecraft:item/generated"
textures:
"layer0": "minecraft:item/custom/topaz_{part}"
"layer1": "minecraft:trims/items/{part}_trim_redstone"
"layer0": "minecraft:item/custom/topaz_${part}"
"layer1": "minecraft:trims/items/${part}_trim_redstone"
- when: minecraft:copper
model:
type: minecraft:model
path: "minecraft:item/custom/topaz_{part}_copper_trim"
path: "minecraft:item/custom/topaz_${part}_copper_trim"
generation:
parent: "minecraft:item/generated"
textures:
"layer0": "minecraft:item/custom/topaz_{part}"
"layer1": "minecraft:trims/items/{part}_trim_copper"
"layer0": "minecraft:item/custom/topaz_${part}"
"layer1": "minecraft:trims/items/${part}_trim_copper"
- when: minecraft:gold
model:
type: minecraft:model
path: "minecraft:item/custom/topaz_{part}_gold_trim"
path: "minecraft:item/custom/topaz_${part}_gold_trim"
generation:
parent: "minecraft:item/generated"
textures:
"layer0": "minecraft:item/custom/topaz_{part}"
"layer1": "minecraft:trims/items/{part}_trim_gold"
"layer0": "minecraft:item/custom/topaz_${part}"
"layer1": "minecraft:trims/items/${part}_trim_gold"
- when: minecraft:emerald
model:
type: minecraft:model
path: "minecraft:item/custom/topaz_{part}_emerald_trim"
path: "minecraft:item/custom/topaz_${part}_emerald_trim"
generation:
parent: "minecraft:item/generated"
textures:
"layer0": "minecraft:item/custom/topaz_{part}"
"layer1": "minecraft:trims/items/{part}_trim_emerald"
"layer0": "minecraft:item/custom/topaz_${part}"
"layer1": "minecraft:trims/items/${part}_trim_emerald"
- when: minecraft:diamond
model:
type: minecraft:model
path: "minecraft:item/custom/topaz_{part}_diamond_trim"
path: "minecraft:item/custom/topaz_${part}_diamond_trim"
generation:
parent: "minecraft:item/generated"
textures:
"layer0": "minecraft:item/custom/topaz_{part}"
"layer1": "minecraft:trims/items/{part}_trim_diamond"
"layer0": "minecraft:item/custom/topaz_${part}"
"layer1": "minecraft:trims/items/${part}_trim_diamond"
- when: minecraft:lapis
model:
type: minecraft:model
path: "minecraft:item/custom/topaz_{part}_lapis_trim"
path: "minecraft:item/custom/topaz_${part}_lapis_trim"
generation:
parent: "minecraft:item/generated"
textures:
"layer0": "minecraft:item/custom/topaz_{part}"
"layer1": "minecraft:trims/items/{part}_trim_lapis"
"layer0": "minecraft:item/custom/topaz_${part}"
"layer1": "minecraft:trims/items/${part}_trim_lapis"
- when: minecraft:amethyst
model:
type: minecraft:model
path: "minecraft:item/custom/topaz_{part}_amethyst_trim"
path: "minecraft:item/custom/topaz_${part}_amethyst_trim"
generation:
parent: "minecraft:item/generated"
textures:
"layer0": "minecraft:item/custom/topaz_{part}"
"layer1": "minecraft:trims/items/{part}_trim_amethyst"
"layer0": "minecraft:item/custom/topaz_${part}"
"layer1": "minecraft:trims/items/${part}_trim_amethyst"
- when: minecraft:resin
model:
type: minecraft:model
path: "minecraft:item/custom/topaz_{part}_resin_trim"
path: "minecraft:item/custom/topaz_${part}_resin_trim"
generation:
parent: "minecraft:item/generated"
textures:
"layer0": "minecraft:item/custom/topaz_{part}"
"layer1": "minecraft:trims/items/{part}_trim_resin"
"layer0": "minecraft:item/custom/topaz_${part}"
"layer1": "minecraft:trims/items/${part}_trim_resin"
recipes#11:
default:topaz_shovel:

View File

@@ -7,32 +7,32 @@ templates#models#block:
# model: model_path
# texture: texture_path
default:model/cube_all:
path: "{model}"
path: "${model}"
generation:
parent: "minecraft:block/cube_all"
textures:
"all": "{texture}"
"all": "${texture}"
# template: default:model/simplified_cube_all
# arguments:
# path: [model/texture]_path
default:model/simplified_cube_all:
path: "{path}"
path: "${path}"
generation:
parent: "minecraft:block/cube_all"
textures:
"all": "{path}"
"all": "${path}"
# template: default:model/cube_column
# arguments:
# model: model_path
# end_texture: end_texture_path
# side_texture: side_texture_path
default:model/cube_column:
path: "{model}"
path: "${model}"
generation:
parent: "minecraft:block/cube_column"
textures:
"end": "{end_texture}"
"side": "{side_texture}"
"end": "${end_texture}"
"side": "${side_texture}"
# template: default:model/cube
# arguments:
# model: model_path
@@ -44,7 +44,7 @@ templates#models#block:
# south_texture: south_texture_path
# west_texture: west_texture_path
default:model/cube:
path: "{model}"
path: "${model}"
generation:
parent: "minecraft:block/cube_column"
textures:
@@ -64,21 +64,21 @@ templates#models#2d:
# texture: texture_path
default:model/generated:
type: "minecraft:model"
path: "{model}"
path: "${model}"
generation:
parent: "minecraft:item/generated"
textures:
"layer0": "{texture}"
"layer0": "${texture}"
# template: default:model/simplified_generated
# arguments:
# path: [model/texture]_path
default:model/simplified_generated:
type: "minecraft:model"
path: "{path}"
path: "${path}"
generation:
parent: "minecraft:item/generated"
textures:
"layer0": "{path}"
"layer0": "${path}"
# template: default:model/2_layer_generated
# arguments:
# model: model_path
@@ -86,33 +86,33 @@ templates#models#2d:
# layer1: texture_path
default:model/2_layer_generated:
type: "minecraft:model"
path: "{model}"
path: "${model}"
generation:
parent: "minecraft:item/generated"
textures:
"layer0": "{layer0}"
"layer1": "{layer1}"
"layer0": "${layer0}"
"layer1": "${layer1}"
# template: default:model/handheld
# arguments:
# model: model_path
# texture: texture_path
default:model/handheld:
type: "minecraft:model"
path: "{model}"
path: "${model}"
generation:
parent: "minecraft:item/handheld"
textures:
"layer0": "{texture}"
"layer0": "${texture}"
# template: default:model/simplified_handheld
# arguments:
# path: [model/texture]_path
default:model/simplified_handheld:
type: "minecraft:model"
path: "{path}"
path: "${path}"
generation:
parent: "minecraft:item/handheld"
textures:
"layer0": "{path}"
"layer0": "${path}"
# template: default:model/elytra
# arguments:
# model: model_path
@@ -123,17 +123,17 @@ templates#models#2d:
type: "minecraft:condition"
property: minecraft:broken
on-false:
path: "{model}"
path: "${model}"
generation:
parent: "minecraft:item/generated"
textures:
"layer0": "{texture}"
"layer0": "${texture}"
on-true:
path: "{broken_model}"
path: "${broken_model}"
generation:
parent: "minecraft:item/generated"
textures:
"layer0": "{broken_texture}"
"layer0": "${broken_texture}"
# template: default:model/simplified_elytra
# arguments:
# path: [model/texture]_path
@@ -141,10 +141,10 @@ templates#models#2d:
default:model/simplified_elytra:
template: default:model/elytra
arguments:
model: "{path}"
texture: "{path}"
broken_model: "{broken_path}"
broken_texture: "{broken_path}"
model: "${path}"
texture: "${path}"
broken_model: "${broken_path}"
broken_texture: "${broken_path}"
# shield
templates#models#shield:
@@ -157,10 +157,10 @@ templates#models#shield:
property: "minecraft:using_item"
on-false:
type: minecraft:model
path: "{model}"
path: "${model}"
on-true:
type: minecraft:model
path: "{block_model}"
path: "${block_model}"
# fishing rods
templates#models#fishing_rod:
@@ -173,10 +173,10 @@ templates#models#fishing_rod:
property: "minecraft:fishing_rod/cast"
on-false:
type: "minecraft:model"
path: "{model}"
path: "${model}"
on-true:
type: "minecraft:model"
path: "{cast_model}"
path: "${cast_model}"
# template: default:model/fishing_rod_2d
# arguments:
# model: rod_model_path
@@ -188,18 +188,18 @@ templates#models#fishing_rod:
property: "minecraft:fishing_rod/cast"
on-false:
type: "minecraft:model"
path: "{model}"
path: "${model}"
generation:
parent: "minecraft:item/fishing_rod"
textures:
"layer0": "{texture}"
"layer0": "${texture}"
on-true:
type: "minecraft:model"
path: "{cast_model}"
path: "${cast_model}"
generation:
parent: "minecraft:item/fishing_rod"
textures:
"layer0": "{cast_texture}"
"layer0": "${cast_texture}"
# template: default:model/simplified_fishing_rod_2d
# arguments:
# path: rod_[model/texture]_path
@@ -207,10 +207,10 @@ templates#models#fishing_rod:
default:model/simplified_fishing_rod_2d:
template: default:model/fishing_rod_2d
arguments:
texture: "{path}"
model: "{path}"
cast_texture: "{cast_path}"
cast_model: "{cast_path}"
texture: "${path}"
model: "${path}"
cast_texture: "${cast_path}"
cast_model: "${cast_path}"
# bows
templates#models#bow:
@@ -225,7 +225,7 @@ templates#models#bow:
property: "minecraft:using_item"
on-false:
type: "minecraft:model"
path: "{model}"
path: "${model}"
on-true:
type: "minecraft:range_dispatch"
property: "minecraft:use_duration"
@@ -233,15 +233,15 @@ templates#models#bow:
entries:
- model:
type: minecraft:model
path: "{pulling_1_model}"
path: "${pulling_1_model}"
threshold: 0.65
- model:
type: minecraft:model
path: "{pulling_2_model}"
path: "${pulling_2_model}"
threshold: 0.9
fallback:
type: minecraft:model
path: "{pulling_0_model}"
path: "${pulling_0_model}"
# template: default:model/bow_2d
# arguments:
# model: bow_model_path
@@ -257,11 +257,11 @@ templates#models#bow:
property: "minecraft:using_item"
on-false:
type: "minecraft:model"
path: "{model}"
path: "${model}"
generation:
parent: "minecraft:item/bow"
textures:
"layer0": "{texture}"
"layer0": "${texture}"
on-true:
type: "minecraft:range_dispatch"
property: "minecraft:use_duration"
@@ -269,27 +269,27 @@ templates#models#bow:
entries:
- model:
type: minecraft:model
path: "{pulling_1_model}"
path: "${pulling_1_model}"
generation:
parent: "minecraft:item/bow_pulling_1"
textures:
"layer0": "{pulling_1_texture}"
"layer0": "${pulling_1_texture}"
threshold: 0.65
- model:
type: minecraft:model
path: "{pulling_2_model}"
path: "${pulling_2_model}"
generation:
parent: "minecraft:item/bow_pulling_2"
textures:
"layer0": "{pulling_2_texture}"
"layer0": "${pulling_2_texture}"
threshold: 0.9
fallback:
type: minecraft:model
path: "{pulling_0_model}"
path: "${pulling_0_model}"
generation:
parent: "minecraft:item/bow_pulling_0"
textures:
"layer0": "{pulling_0_texture}"
"layer0": "${pulling_0_texture}"
# template: default:model/simplified_bow_2d
# arguments:
# path: bow_[model/texture]_path
@@ -299,14 +299,14 @@ templates#models#bow:
default:model/simplified_bow_2d:
template: default:model/bow_2d
arguments:
model: "{path}"
pulling_0_model: "{pulling_0_path}"
pulling_1_model: "{pulling_1_path}"
pulling_2_model: "{pulling_2_path}"
texture: "{path}"
pulling_0_texture: "{pulling_0_path}"
pulling_1_texture: "{pulling_1_path}"
pulling_2_texture: "{pulling_2_path}"
model: "${path}"
pulling_0_model: "${pulling_0_path}"
pulling_1_model: "${pulling_1_path}"
pulling_2_model: "${pulling_2_path}"
texture: "${path}"
pulling_0_texture: "${pulling_0_path}"
pulling_1_texture: "${pulling_1_path}"
pulling_2_texture: "${pulling_2_path}"
# crossbows
templates#models#crossbow:
@@ -328,29 +328,29 @@ templates#models#crossbow:
- when: arrow
model:
type: minecraft:model
path: "{arrow_model}"
path: "${arrow_model}"
- when: rocket
model:
type: minecraft:model
path: "{firework_model}"
path: "${firework_model}"
fallback:
type: minecraft:model
path: "{model}"
path: "${model}"
on-true:
type: "minecraft:range_dispatch"
property: "minecraft:crossbow/pull"
entries:
- model:
type: minecraft:model
path: "{pulling_1_model}"
path: "${pulling_1_model}"
threshold: 0.58
- model:
type: minecraft:model
path: "{pulling_2_model}"
path: "${pulling_2_model}"
threshold: 1.0
fallback:
type: minecraft:model
path: "{pulling_0_model}"
path: "${pulling_0_model}"
# template: default:model/crossbow_2d
# arguments:
# model: crossbow_model_path
@@ -375,53 +375,53 @@ templates#models#crossbow:
- when: arrow
model:
type: minecraft:model
path: "{arrow_model}"
path: "${arrow_model}"
generation:
parent: "minecraft:item/crossbow_arrow"
textures:
"layer0": "{arrow_texture}"
"layer0": "${arrow_texture}"
- when: rocket
model:
type: minecraft:model
path: "{firework_model}"
path: "${firework_model}"
generation:
parent: "minecraft:item/crossbow_firework"
textures:
"layer0": "{firework_texture}"
"layer0": "${firework_texture}"
fallback:
type: minecraft:model
path: "{model}"
path: "${model}"
generation:
parent: "minecraft:item/crossbow"
textures:
"layer0": "{texture}"
"layer0": "${texture}"
on-true:
type: "minecraft:range_dispatch"
property: "minecraft:crossbow/pull"
entries:
- model:
type: minecraft:model
path: "{pulling_1_model}"
path: "${pulling_1_model}"
generation:
parent: "minecraft:item/crossbow_pulling_1"
textures:
"layer0": "{pulling_1_texture}"
"layer0": "${pulling_1_texture}"
threshold: 0.58
- model:
type: minecraft:model
path: "{pulling_2_model}"
path: "${pulling_2_model}"
generation:
parent: "minecraft:item/crossbow_pulling_2"
textures:
"layer0": "{pulling_2_texture}"
"layer0": "${pulling_2_texture}"
threshold: 1.0
fallback:
type: minecraft:model
path: "{pulling_0_model}"
path: "${pulling_0_model}"
generation:
parent: "minecraft:item/crossbow_pulling_0"
textures:
"layer0": "{pulling_0_texture}"
"layer0": "${pulling_0_texture}"
# template: default:model/simplified_crossbow_2d
# arguments:
# path: crossbow_[model/texture]_path
@@ -433,28 +433,28 @@ templates#models#crossbow:
default:model/simplified_crossbow_2d:
template: default:model/crossbow_2d
arguments:
model: "{path}"
texture: "{path}"
arrow_model: "{arrow_path}"
arrow_texture: "{arrow_path}"
firework_model: "{firework_path}"
firework_texture: "{firework_path}"
pulling_0_model: "{pulling_0_path}"
pulling_0_texture: "{pulling_0_path}"
pulling_1_model: "{pulling_1_path}"
pulling_1_texture: "{pulling_1_path}"
pulling_2_model: "{pulling_2_path}"
pulling_2_texture: "{pulling_2_path}"
model: "${path}"
texture: "${path}"
arrow_model: "${arrow_path}"
arrow_texture: "${arrow_path}"
firework_model: "${firework_path}"
firework_texture: "${firework_path}"
pulling_0_model: "${pulling_0_path}"
pulling_0_texture: "${pulling_0_path}"
pulling_1_model: "${pulling_1_path}"
pulling_1_texture: "${pulling_1_path}"
pulling_2_model: "${pulling_2_path}"
pulling_2_texture: "${pulling_2_path}"
# sounds
templates#settings#sounds:
default:sound/block_template:
sounds:
break: "minecraft:block.{block_type}.break"
step: "minecraft:block.{block_type}.step"
place: "minecraft:block.{block_type}.place"
hit: "minecraft:block.{block_type}.hit"
fall: "minecraft:block.{block_type}.fall"
break: "minecraft:block.${block_type}.break"
step: "minecraft:block.${block_type}.step"
place: "minecraft:block.${block_type}.place"
hit: "minecraft:block.${block_type}.hit"
fall: "minecraft:block.${block_type}.fall"
default:sound/crop:
sounds:
break: "minecraft:block.crop.break"
@@ -614,7 +614,7 @@ templates#settings#break_level:
# block settings
templates#settings#blocks:
default:settings/middle_click_pick_itself:
item: "{__NAMESPACE__}:{__ID__}"
item: "${__NAMESPACE__}:${__ID__}"
default:settings/solid_1x1x1:
is-suffocating: true
replaceable: false
@@ -696,7 +696,7 @@ templates#settings#blocks:
default:settings/ore:
template:
- "default:sound/stone"
- "default:pickaxe_power/level_{break_power}"
- "default:pickaxe_power/level_${break_power}"
overrides:
hardness: 3.0
resistance: 3.0
@@ -712,7 +712,7 @@ templates#settings#blocks:
default:settings/deepslate_ore:
template:
- "default:sound/deepslate"
- "default:pickaxe_power/level_{break_power}"
- "default:pickaxe_power/level_${break_power}"
overrides:
hardness: 4.5
resistance: 3.0
@@ -735,45 +735,45 @@ templates#block_states:
default: y
appearances:
axisY:
state: "{base_block}:{vanilla_id}"
state: "${base_block}:${vanilla_id}"
model:
path: "{model_vertical_path}"
path: "${model_vertical_path}"
generation:
parent: "minecraft:block/cube_column"
textures:
"end": "{texture_top_path}"
"side": "{texture_side_path}"
"end": "${texture_top_path}"
"side": "${texture_side_path}"
axisX:
state: "{base_block}:{vanilla_id}"
state: "${base_block}:${vanilla_id}"
model:
x: 90
y: 90
path: "{model_horizontal_path}"
path: "${model_horizontal_path}"
generation:
parent: "minecraft:block/cube_column_horizontal"
textures:
"end": "{texture_top_path}"
"side": "{texture_side_path}"
"end": "${texture_top_path}"
"side": "${texture_side_path}"
axisZ:
state: "{base_block}:{vanilla_id}"
state: "${base_block}:${vanilla_id}"
model:
x: 90
path: "{model_horizontal_path}"
path: "${model_horizontal_path}"
generation:
parent: "minecraft:block/cube_column_horizontal"
textures:
"end": "{texture_top_path}"
"side": "{texture_side_path}"
"end": "${texture_top_path}"
"side": "${texture_side_path}"
variants:
axis=x:
appearance: axisX
id: "{internal_id}"
id: "${internal_id}"
axis=y:
appearance: axisY
id: "{internal_id}"
id: "${internal_id}"
axis=z:
appearance: axisZ
id: "{internal_id}"
id: "${internal_id}"
default:block_state/leaves:
properties:
waterlogged:
@@ -788,107 +788,107 @@ templates#block_states:
range: 1~7
appearances:
default:
state: "{default_state}"
state: "${default_state}"
model:
path: "{model_path}"
path: "${model_path}"
generation:
parent: "minecraft:block/leaves"
textures:
"all": "{texture_path}"
"all": "${texture_path}"
waterlogged:
state: "{waterlogged_state}"
state: "${waterlogged_state}"
model:
path: "{model_path}"
path: "${model_path}"
variants:
distance=1,persistent=false,waterlogged=false:
appearance: "default"
id: "{internal_id}"
id: "${internal_id}"
distance=2,persistent=false,waterlogged=false:
appearance: "default"
id: "{internal_id}"
id: "${internal_id}"
distance=3,persistent=false,waterlogged=false:
appearance: "default"
id: "{internal_id}"
id: "${internal_id}"
distance=4,persistent=false,waterlogged=false:
appearance: "default"
id: "{internal_id}"
id: "${internal_id}"
distance=5,persistent=false,waterlogged=false:
appearance: "default"
id: "{internal_id}"
id: "${internal_id}"
distance=6,persistent=false,waterlogged=false:
appearance: "default"
id: "{internal_id}"
id: "${internal_id}"
distance=7,persistent=false,waterlogged=false:
appearance: "default"
id: "{internal_id}"
id: "${internal_id}"
settings:
is-randomly-ticking: true
distance=1,persistent=true,waterlogged=false:
appearance: "default"
id: "{internal_id}"
id: "${internal_id}"
distance=2,persistent=true,waterlogged=false:
appearance: "default"
id: "{internal_id}"
id: "${internal_id}"
distance=3,persistent=true,waterlogged=false:
appearance: "default"
id: "{internal_id}"
id: "${internal_id}"
distance=4,persistent=true,waterlogged=false:
appearance: "default"
id: "{internal_id}"
id: "${internal_id}"
distance=5,persistent=true,waterlogged=false:
appearance: "default"
id: "{internal_id}"
id: "${internal_id}"
distance=6,persistent=true,waterlogged=false:
appearance: "default"
id: "{internal_id}"
id: "${internal_id}"
distance=7,persistent=true,waterlogged=false:
appearance: "default"
id: "{internal_id}"
id: "${internal_id}"
distance=1,persistent=false,waterlogged=true:
appearance: "waterlogged"
id: "{internal_id}"
id: "${internal_id}"
settings:
resistance: 1200.0
burnable: false
fluid-state: water
distance=2,persistent=false,waterlogged=true:
appearance: "waterlogged"
id: "{internal_id}"
id: "${internal_id}"
settings:
resistance: 1200.0
burnable: false
fluid-state: water
distance=3,persistent=false,waterlogged=true:
appearance: "waterlogged"
id: "{internal_id}"
id: "${internal_id}"
settings:
resistance: 1200.0
burnable: false
fluid-state: water
distance=4,persistent=false,waterlogged=true:
appearance: "waterlogged"
id: "{internal_id}"
id: "${internal_id}"
settings:
resistance: 1200.0
burnable: false
fluid-state: water
distance=5,persistent=false,waterlogged=true:
appearance: "waterlogged"
id: "{internal_id}"
id: "${internal_id}"
settings:
resistance: 1200.0
burnable: false
fluid-state: water
distance=6,persistent=false,waterlogged=true:
appearance: "waterlogged"
id: "{internal_id}"
id: "${internal_id}"
settings:
resistance: 1200.0
burnable: false
fluid-state: water
distance=7,persistent=false,waterlogged=true:
appearance: "waterlogged"
id: "{internal_id}"
id: "${internal_id}"
settings:
resistance: 1200.0
burnable: false
@@ -896,49 +896,49 @@ templates#block_states:
fluid-state: water
distance=1,persistent=true,waterlogged=true:
appearance: "waterlogged"
id: "{internal_id}"
id: "${internal_id}"
settings:
resistance: 1200.0
burnable: false
fluid-state: water
distance=2,persistent=true,waterlogged=true:
appearance: "waterlogged"
id: "{internal_id}"
id: "${internal_id}"
settings:
resistance: 1200.0
burnable: false
fluid-state: water
distance=3,persistent=true,waterlogged=true:
appearance: "waterlogged"
id: "{internal_id}"
id: "${internal_id}"
settings:
resistance: 1200.0
burnable: false
fluid-state: water
distance=4,persistent=true,waterlogged=true:
appearance: "waterlogged"
id: "{internal_id}"
id: "${internal_id}"
settings:
resistance: 1200.0
burnable: false
fluid-state: water
distance=5,persistent=true,waterlogged=true:
appearance: "waterlogged"
id: "{internal_id}"
id: "${internal_id}"
settings:
resistance: 1200.0
burnable: false
fluid-state: water
distance=6,persistent=true,waterlogged=true:
appearance: "waterlogged"
id: "{internal_id}"
id: "${internal_id}"
settings:
resistance: 1200.0
burnable: false
fluid-state: water
distance=7,persistent=true,waterlogged=true:
appearance: "waterlogged"
id: "{internal_id}"
id: "${internal_id}"
settings:
resistance: 1200.0
burnable: false
@@ -951,9 +951,9 @@ templates#recipes:
category: building
group: planks
ingredients:
A: "#default:{wood_type}_logs"
A: "#default:${wood_type}_logs"
result:
id: "default:{wood_type}_planks"
id: "default:${wood_type}_planks"
count: 4
default:recipe/log_2_wood:
type: shaped
@@ -963,29 +963,29 @@ templates#recipes:
- "AA"
- "AA"
ingredients:
A: "default:{wood_type}_log"
A: "default:${wood_type}_log"
result:
id: "default:{wood_type}_wood"
id: "default:${wood_type}_wood"
count: 3
default:recipe/smelting_ore:
type: smelting
experience: "{exp}"
experience: "${exp}"
category: misc
group: topaz
time: 200
ingredient: "{ingredient}"
ingredient: "${ingredient}"
result:
id: "{result}"
id: "${result}"
count: 1
default:recipe/blasting_ore:
type: blasting
experience: "{exp}"
experience: "${exp}"
category: misc
group: topaz
time: 100
ingredient: "{ingredient}"
ingredient: "${ingredient}"
result:
id: "{result}"
id: "${result}"
count: 1
# loot tables
@@ -1001,7 +1001,7 @@ templates#loot_tables:
- type: survives_explosion
entries:
- type: item
item: "{__NAMESPACE__}:{__ID__}"
item: "${__NAMESPACE__}:${__ID__}"
# drop one item
@@ -1015,7 +1015,7 @@ templates#loot_tables:
- type: survives_explosion
entries:
- type: item
item: "{item}"
item: "${item}"
# drop the original furniture item or a fallback item
@@ -1027,7 +1027,7 @@ templates#loot_tables:
- rolls: 1
entries:
- type: furniture_item
item: "{item}"
item: "${item}"
# drop with silk touch
@@ -1042,7 +1042,7 @@ templates#loot_tables:
predicate: minecraft:silk_touch>=1
entries:
- type: item
item: "{item}"
item: "${item}"
# crop drops
@@ -1058,21 +1058,21 @@ templates#loot_tables:
- type: alternatives
children:
- type: item
item: "{crop_item}"
item: "${crop_item}"
conditions:
- type: match_block_property
properties:
age: "{ripe_age}"
age: "${ripe_age}"
- type: item
item: "{crop_seed}"
item: "${crop_seed}"
- rolls: 1
conditions:
- type: match_block_property
properties:
age: "{ripe_age}"
age: "${ripe_age}"
entries:
- type: item
item: "{crop_seed}"
item: "${crop_seed}"
functions:
- type: apply_bonus
enchantment: minecraft:fortune
@@ -1090,15 +1090,15 @@ templates#loot_tables:
- rolls: 1
entries:
- type: item
item: "{crop_item}"
item: "${crop_item}"
- rolls: 1
conditions:
- type: match_block_property
properties:
age: "{ripe_age}"
age: "${ripe_age}"
entries:
- type: item
item: "{crop_item}"
item: "${crop_item}"
functions:
- type: apply_bonus
enchantment: minecraft:fortune
@@ -1122,12 +1122,12 @@ templates#loot_tables:
- type: alternatives
children:
- type: item
item: "{ore_block}"
item: "${ore_block}"
conditions:
- type: enchantment
predicate: minecraft:silk_touch>=1
- type: item
item: "{ore_drop}"
item: "${ore_drop}"
functions:
- type: apply_bonus
enchantment: minecraft:fortune
@@ -1137,8 +1137,8 @@ templates#loot_tables:
- type: drop_exp
count:
type: uniform
min: "{min_exp}"
max: "{max_exp}"
min: "${min_exp:-2}"
max: "${max_exp:-4}"
# template: default:loot_table/ore_no_exp
# arguments:
@@ -1151,12 +1151,12 @@ templates#loot_tables:
- type: alternatives
children:
- type: item
item: "{ore_block}"
item: "${ore_block}"
conditions:
- type: enchantment
predicate: minecraft:silk_touch>=1
- type: item
item: "{ore_drop}"
item: "${ore_drop}"
functions:
- type: apply_bonus
enchantment: minecraft:fortune
@@ -1177,7 +1177,7 @@ templates#loot_tables:
- type: alternatives
children:
- type: item
item: "{leaves}"
item: "${leaves}"
conditions:
- type: any_of
terms:
@@ -1186,7 +1186,7 @@ templates#loot_tables:
- type: enchantment
predicate: minecraft:silk_touch>=1
- type: item
item: "{sapling}"
item: "${sapling}"
conditions:
- type: survives_explosion
- type: table_bonus

View File

@@ -69,21 +69,21 @@ images:
templates:
internal:icon/2d:
material: arrow
custom-model-data: "{model_data}"
custom-model-data: "${model_data}"
data:
item-name: "{name}"
lore: "{lore}"
item-name: "${name}"
lore: "${lore}"
model:
template: "internal:model/simplified_generated"
arguments:
path: "minecraft:item/custom/gui/{texture}"
path: "minecraft:item/custom/gui/${texture}"
internal:model/simplified_generated:
type: "minecraft:model"
path: "{path}"
path: "${path}"
generation:
parent: "minecraft:item/generated"
textures:
"layer0": "{path}"
"layer0": "${path}"
items:
internal:next_page_0:

View File

@@ -37,6 +37,7 @@ public class ItemSettings {
Helmet helmet = null;
FoodData foodData = null;
Key consumeReplacement = null;
Key craftRemainder = null;
private ItemSettings() {}
@@ -74,6 +75,7 @@ public class ItemSettings {
newSettings.helmet = settings.helmet;
newSettings.foodData = settings.foodData;
newSettings.consumeReplacement = settings.consumeReplacement;
newSettings.craftRemainder = settings.craftRemainder;
return newSettings;
}
@@ -240,7 +242,10 @@ public class ItemSettings {
int intValue = ResourceConfigUtils.getAsInt(value, "fuel-time");
return settings -> settings.fuelTime(intValue);
}));
registerFactory("consume-replacement", (value -> settings -> settings.consumeReplacement(Key.of(value.toString()))));
registerFactory("consume-replacement", (value -> settings -> {
if (value == null) settings.consumeReplacement(null);
else settings.consumeReplacement(Key.of(value.toString()));
}));
registerFactory("tags", (value -> {
List<String> tags = MiscUtils.getAsStringList(value);
return settings -> settings.tags(tags.stream().map(Key::of).collect(Collectors.toSet()));
@@ -293,6 +298,9 @@ public class ItemSettings {
);
return settings -> settings.foodData(data);
}));
// registerFactory("craft-remainder", (value -> {
//
// }));
}
private static void registerFactory(String id, ItemSettings.Modifier.Factory factory) {

View File

@@ -66,16 +66,17 @@ public interface TemplateManager extends Manageable {
private final String rawText;
private final Object defaultValue;
public Placeholder(String placeholder) {
this.rawText = "{" + placeholder + "}";
int first = placeholder.indexOf(':');
if (first == -1) {
this.placeholder = placeholder;
public Placeholder(String placeholderContent) {
this.rawText = "${" + placeholderContent + "}";
int separatorIndex = placeholderContent.indexOf(":-");
if (separatorIndex == -1) {
this.placeholder = placeholderContent;
this.defaultValue = this.rawText;
} else {
this.placeholder = placeholder.substring(0, first);
this.placeholder = placeholderContent.substring(0, separatorIndex);
String defaultValueString = placeholderContent.substring(separatorIndex + 2);
try {
this.defaultValue = CraftEngine.instance().platform().nbt2Java(placeholder.substring(first + 1));
this.defaultValue = CraftEngine.instance().platform().nbt2Java(defaultValueString);
} catch (LocalizedResourceConfigException e) {
e.appendTailArgument(this.placeholder);
throw e;
@@ -220,42 +221,33 @@ public interface TemplateManager extends Manageable {
while (i < n) {
char c = input.charAt(i);
// --- 1. 处理转义字符 ---
if (c == '\\') {
// 只在'\'后面是'{'或'}'时才作为转义处理
if (i + 1 < n && (input.charAt(i + 1) == '{' || input.charAt(i + 1) == '}')) {
currentLiteral.append(input.charAt(i + 1)); // 添加花括号
i += 2; // 跳过'\'和花括号
} else {
// 对于所有其他情况 (如 \\, \n), 将'\'视为普通字符
currentLiteral.append(c);
i++;
}
continue;
}
// --- 1. 优先检测占位符触发器 ---
if (c == '$' && i + 1 < n && input.charAt(i + 1) == '{') {
// --- 2. 处理占位符 {key} ---
if (c == '{') {
// 如果在占位符之前有普通文本,先提交它
// a. 提交之前的普通文本
if (!currentLiteral.isEmpty()) {
arguments.add(Literal.literal(currentLiteral.toString()));
currentLiteral.setLength(0); // 清空
currentLiteral.setLength(0);
}
// 开始解析占位符内部
// b. 解析占位符内部,此处的逻辑拥有自己的转义规则
int contentStartIndex = i + 2;
StringBuilder keyBuilder = new StringBuilder();
int depth = 1;
int j = i + 1;
int j = contentStartIndex;
boolean foundMatch = false;
while (j < n) {
char innerChar = input.charAt(j);
if (innerChar == '\\') { // 处理占位符内部的转义
// --- 占位符内部的转义逻辑 ---
if (innerChar == '\\') {
if (j + 1 < n && (input.charAt(j + 1) == '{' || input.charAt(j + 1) == '}')) {
keyBuilder.append(input.charAt(j + 1));
j += 2;
} else {
keyBuilder.append(innerChar); // 将'\'视为普通字符
// 在占位符内部,一个无法识别的转义\依旧被当作普通\处理
keyBuilder.append(innerChar);
j++;
}
} else if (innerChar == '{') {
@@ -266,11 +258,11 @@ public interface TemplateManager extends Manageable {
depth--;
if (depth == 0) { // 找到匹配的闭合括号
arguments.add(Placeholder.placeholder(keyBuilder.toString()));
i = j + 1; // 将主循环的索引跳到占位符之后
i = j + 1;
foundMatch = true;
break;
}
keyBuilder.append(innerChar); // 嵌套的 '}'
keyBuilder.append(innerChar);
j++;
} else {
keyBuilder.append(innerChar);
@@ -279,27 +271,31 @@ public interface TemplateManager extends Manageable {
}
if (foundMatch) {
continue; // 成功解析占位符,继续主循环
continue;
} else {
// 没有找到匹配的 '}',将起始的 '{' 视为普通文本
// 未找到闭合括号,将 '$' 视为普通字符
currentLiteral.append(c);
i++;
}
} else {
// --- 3. 处理普通字符 ---
}
// --- 2. 其次,只处理对触发器'$'的转义 ---
else if (c == '\\' && i + 1 < n && input.charAt(i + 1) == '$') {
currentLiteral.append('$'); // 直接添加 '$'
i += 2; // 跳过 '\' 和 '$'
}
// --- 3. 处理所有其他字符(包括独立的'\'和'{')为普通文本 ---
else {
currentLiteral.append(c);
i++;
}
}
// 添加循环结束后剩余的任何普通文本
if (!currentLiteral.isEmpty()) {
arguments.add(Literal.literal(currentLiteral.toString()));
}
// 根据解析出的参数数量返回最终结果
return switch (arguments.size()) {
case 0 -> Literal.literal(""); // 处理 input = "{}" 等情况
case 0 -> Literal.literal("");
case 1 -> arguments.getFirst();
case 2 -> new Complex2(input, arguments.get(0), arguments.get(1));
default -> new Complex(input, arguments);

View File

@@ -33,7 +33,7 @@ public abstract class AbstractCommonContext implements Context {
public TagResolver[] tagResolvers() {
if (this.tagResolvers == null) {
this.tagResolvers = new TagResolver[]{ShiftTag.INSTANCE, ImageTag.INSTANCE, new I18NTag(this), new NamedArgumentTag(this),
new PlaceholderTag(null), new ExpressionTag(this), new GlobalVariableTag(this)};
new PlaceholderTag(this), new ExpressionTag(this), new GlobalVariableTag(this)};
}
return this.tagResolvers;
}

View File

@@ -57,7 +57,7 @@ public class PlayerOptionalContext extends AbstractChainParameterContext impleme
@NotNull
public TagResolver[] tagResolvers() {
if (this.tagResolvers == null) {
this.tagResolvers = new TagResolver[]{ShiftTag.INSTANCE, ImageTag.INSTANCE, new PlaceholderTag(this.player), new I18NTag(this),
this.tagResolvers = new TagResolver[]{ShiftTag.INSTANCE, ImageTag.INSTANCE, new PlaceholderTag(this), new I18NTag(this),
new NamedArgumentTag(this), new ExpressionTag(this), new GlobalVariableTag(this)};
}
return this.tagResolvers;

View File

@@ -53,19 +53,15 @@ public class ViewerContext implements RelationalContext {
@Override
public TagResolver[] tagResolvers() {
if (this.tagResolvers == null) {
Player optionalOwner = null;
if (this.owner instanceof PlayerOptionalContext context) {
optionalOwner = context.player();
}
if (optionalOwner != null && this.viewer.player != null) {
this.tagResolvers = new TagResolver[]{new RelationalPlaceholderTag(optionalOwner, this.viewer.player),
if (this.owner instanceof PlayerOptionalContext context && context.player != null && this.viewer.player != null) {
this.tagResolvers = new TagResolver[]{new RelationalPlaceholderTag(context.player, this.viewer.player, this),
ShiftTag.INSTANCE, ImageTag.INSTANCE,
new PlaceholderTag(optionalOwner), new ViewerPlaceholderTag(this.viewer.player()),
new PlaceholderTag(this.owner), new ViewerPlaceholderTag(this.viewer),
new NamedArgumentTag(this.owner), new ViewerNamedArgumentTag(this.viewer),
new I18NTag(this), new ExpressionTag(this), new GlobalVariableTag(this)};
} else {
this.tagResolvers = new TagResolver[]{ShiftTag.INSTANCE, ImageTag.INSTANCE,
new PlaceholderTag(optionalOwner), new ViewerPlaceholderTag(this.viewer.player()),
new PlaceholderTag(this.owner), new ViewerPlaceholderTag(this.viewer),
new NamedArgumentTag(this.owner), new ViewerNamedArgumentTag(this.viewer),
new I18NTag(this), new ExpressionTag(this), new GlobalVariableTag(this)};
}

View File

@@ -5,17 +5,17 @@ import net.kyori.adventure.text.minimessage.ParsingException;
import net.kyori.adventure.text.minimessage.tag.Tag;
import net.kyori.adventure.text.minimessage.tag.resolver.ArgumentQueue;
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
import net.momirealms.craftengine.core.entity.player.Player;
import net.momirealms.craftengine.core.plugin.CraftEngine;
import net.momirealms.craftengine.core.plugin.context.PlayerOptionalContext;
import net.momirealms.craftengine.core.util.AdventureHelper;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class PlaceholderTag implements TagResolver {
private final Player player;
private final net.momirealms.craftengine.core.plugin.context.Context context;
public PlaceholderTag(@Nullable Player player) {
this.player = player;
public PlaceholderTag(@NotNull net.momirealms.craftengine.core.plugin.context.Context context) {
this.context = context;
}
@Override
@@ -23,8 +23,10 @@ public class PlaceholderTag implements TagResolver {
if (!this.has(name) || !CraftEngine.instance().compatibilityManager().hasPlaceholderAPI()) {
return null;
}
String placeholder = "%" + arguments.popOr("No argument placeholder provided") + "%";
String parsed = CraftEngine.instance().compatibilityManager().parse(player, placeholder);
String rawArgument = arguments.popOr("No argument relational placeholder provided").toString();
if (rawArgument.contains("<")) rawArgument = AdventureHelper.resolvePlainStringTags(rawArgument, this.context.tagResolvers());
String placeholder = "%" + rawArgument + "%";
String parsed = this.context instanceof PlayerOptionalContext playerOptionalContext ? CraftEngine.instance().compatibilityManager().parse(playerOptionalContext.player(), placeholder) : CraftEngine.instance().compatibilityManager().parse(null, placeholder);
if (parsed.equals(placeholder)) {
parsed = arguments.popOr("No default papi value provided").toString();
}

View File

@@ -7,6 +7,8 @@ import net.kyori.adventure.text.minimessage.tag.resolver.ArgumentQueue;
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
import net.momirealms.craftengine.core.entity.player.Player;
import net.momirealms.craftengine.core.plugin.CraftEngine;
import net.momirealms.craftengine.core.plugin.context.PlayerOptionalContext;
import net.momirealms.craftengine.core.plugin.context.RelationalContext;
import net.momirealms.craftengine.core.util.AdventureHelper;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -14,10 +16,12 @@ import org.jetbrains.annotations.Nullable;
public class RelationalPlaceholderTag implements TagResolver {
private final Player player1;
private final Player player2;
private final RelationalContext context;
public RelationalPlaceholderTag(@NotNull Player player1, @NotNull Player player2) {
public RelationalPlaceholderTag(@NotNull Player player1, @NotNull Player player2, RelationalContext context) {
this.player1 = player1;
this.player2 = player2;
this.context = context;
}
@Override
@@ -25,8 +29,10 @@ public class RelationalPlaceholderTag implements TagResolver {
if (!this.has(name) || !CraftEngine.instance().compatibilityManager().hasPlaceholderAPI()) {
return null;
}
String placeholder = "%" + arguments.popOr("No argument placeholder provided") + "%";
String parsed = CraftEngine.instance().compatibilityManager().parse(player1, player2, placeholder);
String rawArgument = arguments.popOr("No argument placeholder provided").toString();
if (rawArgument.contains("<")) rawArgument = AdventureHelper.resolvePlainStringTags(rawArgument, this.context.tagResolvers());
String placeholder = "%" + rawArgument + "%";
String parsed = CraftEngine.instance().compatibilityManager().parse(this.player1, this.player2, placeholder);
if (parsed.equals(placeholder)) {
parsed = arguments.popOr("No default papi value provided").toString();
}

View File

@@ -1,12 +1,11 @@
package net.momirealms.craftengine.core.plugin.text.minimessage;
import net.momirealms.craftengine.core.entity.player.Player;
import net.momirealms.craftengine.core.plugin.context.Context;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class ViewerPlaceholderTag extends PlaceholderTag {
public ViewerPlaceholderTag(@Nullable Player player) {
public ViewerPlaceholderTag(@NotNull Context player) {
super(player);
}

View File

@@ -316,6 +316,11 @@ public class AdventureHelper {
return true;
}
public static String resolvePlainStringTags(String raw, TagResolver... resolvers) {
Component resultComponent = AdventureHelper.customMiniMessage().deserialize(raw, resolvers);
return AdventureHelper.plainTextContent(resultComponent);
}
public static Component replaceText(Component text, Map<String, Component> replacements) {
String patternString = replacements.keySet().stream()
.map(Pattern::quote)

View File

@@ -104,7 +104,7 @@ public class MiscUtils {
public static void deepMergeMaps(Map<String, Object> baseMap, Map<String, Object> mapToMerge) {
for (Map.Entry<String, Object> entry : mapToMerge.entrySet()) {
String key = entry.getKey();
if (!key.isEmpty() && key.charAt(0) == '$') {
if (key.length() > 2 && key.charAt(0) == '$' && key.charAt(1) == '$') {
Object value = entry.getValue();
baseMap.put(key.substring(1), value);
} else {

View File

@@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx1G
# Project settings
# Rule: [major update].[feature update].[bug fix]
project_version=0.0.56.5
project_version=0.0.56.6
config_version=36
lang_version=15
project_group=net.momirealms
@@ -51,7 +51,7 @@ byte_buddy_version=1.17.5
ahocorasick_version=0.6.3
snake_yaml_version=2.4
anti_grief_version=0.17
nms_helper_version=0.67.3
nms_helper_version=0.67.7
evalex_version=3.5.0
reactive_streams_version=1.0.4
amazon_awssdk_version=2.31.23