mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-27 10:59:07 +00:00
修复bug
This commit is contained in:
@@ -65,11 +65,7 @@ resource-pack:
|
||||
- BetterModel/build
|
||||
merge-external-zip-files:
|
||||
- CustomNameplates/resourcepack.zip
|
||||
exclude-file-suffixes:
|
||||
- "md"
|
||||
- "psd"
|
||||
- "bbmodel"
|
||||
- "db"
|
||||
exclude-file-extensions: ["md", "psd", "bbmodel", "db", "ini"]
|
||||
delivery:
|
||||
# Send the resource pack on joining the server
|
||||
send-on-join: true
|
||||
|
||||
@@ -10,6 +10,7 @@ public class BukkitItemBehaviors extends ItemBehaviors {
|
||||
public static final Key FURNITURE_ITEM = Key.from("craftengine:furniture_item");
|
||||
public static final Key WATER_BUCKET_ITEM = Key.from("craftengine:water_bucket_item");
|
||||
public static final Key BUCKET_ITEM = Key.from("craftengine:bucket_item");
|
||||
public static final Key HAT_ITEM = Key.from("craftengine:hat_item");
|
||||
|
||||
public static void init() {
|
||||
register(EMPTY, EmptyItemBehavior.FACTORY);
|
||||
|
||||
@@ -1,14 +1,23 @@
|
||||
package net.momirealms.craftengine.bukkit.util;
|
||||
|
||||
import net.momirealms.craftengine.bukkit.nms.FastNMS;
|
||||
import net.momirealms.craftengine.core.plugin.CraftEngine;
|
||||
import net.momirealms.craftengine.core.plugin.context.Context;
|
||||
import net.momirealms.craftengine.core.util.Key;
|
||||
import net.momirealms.craftengine.core.util.VersionHelper;
|
||||
import net.momirealms.craftengine.core.world.particle.*;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.Vibration;
|
||||
import org.bukkit.World;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public final class ParticleUtils {
|
||||
private static final Map<Key, Particle> CACHE = new HashMap<>();
|
||||
|
||||
private ParticleUtils() {}
|
||||
|
||||
public static Particle getParticle(String particle) {
|
||||
@@ -24,6 +33,20 @@ public final class ParticleUtils {
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Particle getParticle(Key particle) {
|
||||
return CACHE.computeIfAbsent(particle, k -> {
|
||||
try {
|
||||
Object nmsParticle = Reflections.method$Registry$get.invoke(Reflections.instance$BuiltInRegistries$PARTICLE_TYPE, KeyUtils.toResourceLocation(particle));
|
||||
if (nmsParticle == null) return null;
|
||||
return FastNMS.INSTANCE.method$CraftParticle$toBukkit(nmsParticle);
|
||||
} catch (ReflectiveOperationException e) {
|
||||
CraftEngine.instance().logger().warn("Failed to get particle: " + particle, e);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static final Particle HAPPY_VILLAGER = getParticle("HAPPY_VILLAGER");
|
||||
public static final Particle BUBBLE = getParticle("BUBBLE");
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ public class BukkitWorld implements World {
|
||||
|
||||
@Override
|
||||
public void spawnParticle(Position location, Key particle, int count, double xOffset, double yOffset, double zOffset, double speed, @Nullable ParticleData extraData, @NotNull Context context) {
|
||||
Particle particleType = Registry.PARTICLE_TYPE.get(KeyUtils.toNamespacedKey(particle));
|
||||
Particle particleType = ParticleUtils.getParticle(particle);
|
||||
if (particleType == null) return;
|
||||
org.bukkit.World platformWorld = platformWorld();
|
||||
platformWorld.spawnParticle(particleType, location.x(), location.y(), location.z(), count, xOffset, yOffset, zOffset, speed, extraData == null ? null : ParticleUtils.toBukkitParticleData(extraData, context, platformWorld, location.x(), location.y(), location.z()));
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package net.momirealms.craftengine.core.item;
|
||||
|
||||
import net.momirealms.craftengine.core.sound.SoundData;
|
||||
|
||||
public class Helmet {
|
||||
private final SoundData equipSound;
|
||||
|
||||
public Helmet(SoundData equipSound) {
|
||||
this.equipSound = equipSound;
|
||||
}
|
||||
|
||||
public SoundData equipSound() {
|
||||
return equipSound;
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import net.momirealms.craftengine.core.item.modifier.EquippableModifier;
|
||||
import net.momirealms.craftengine.core.item.modifier.ItemDataModifier;
|
||||
import net.momirealms.craftengine.core.pack.misc.EquipmentGeneration;
|
||||
import net.momirealms.craftengine.core.plugin.locale.LocalizedResourceConfigException;
|
||||
import net.momirealms.craftengine.core.sound.SoundData;
|
||||
import net.momirealms.craftengine.core.util.Key;
|
||||
import net.momirealms.craftengine.core.util.MiscUtils;
|
||||
import net.momirealms.craftengine.core.util.ResourceConfigUtils;
|
||||
@@ -28,6 +29,7 @@ public class ItemSettings {
|
||||
boolean canPlaceRelatedVanillaBlock = false;
|
||||
ProjectileMeta projectileMeta;
|
||||
boolean dyeable = true;
|
||||
Helmet helmet = null;
|
||||
|
||||
private ItemSettings() {}
|
||||
|
||||
@@ -105,6 +107,11 @@ public class ItemSettings {
|
||||
return anvilRepairItems;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Helmet helmet() {
|
||||
return helmet;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public EquipmentGeneration equipment() {
|
||||
return equipment;
|
||||
@@ -155,6 +162,11 @@ public class ItemSettings {
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemSettings helmet(Helmet helmet) {
|
||||
this.helmet = helmet;
|
||||
return this;
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
public interface Modifier {
|
||||
|
||||
@@ -229,6 +241,10 @@ public class ItemSettings {
|
||||
String type = args.getOrDefault("type", "none").toString();
|
||||
return settings -> settings.projectileMeta(new ProjectileMeta(customTridentItemId, displayType, scale, translation, rotation, type));
|
||||
}));
|
||||
registerFactory("helmet", (value -> {
|
||||
Map<String, Object> args = MiscUtils.castToMap(value, false);
|
||||
return settings -> settings.helmet(new Helmet(SoundData.create(args.getOrDefault("equip-sound", "minecraft:intentionally_empty"), 1f, 1f)));
|
||||
}));
|
||||
registerFactory("dyeable", (value -> {
|
||||
boolean bool = (boolean) value;
|
||||
return settings -> settings.dyeable(bool);
|
||||
|
||||
@@ -15,4 +15,9 @@ public abstract class ItemBehavior {
|
||||
public InteractionResult use(World world, Player player, InteractionHand hand) {
|
||||
return InteractionResult.PASS;
|
||||
}
|
||||
|
||||
// TODO
|
||||
public InteractionResult useOnEntity() {
|
||||
return InteractionResult.PASS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1208,7 +1208,7 @@ public abstract class AbstractPackManager implements PackManager {
|
||||
|
||||
private void processRegularFile(Path file, BasicFileAttributes attrs, Path sourceFolder, @Nullable FileSystem fs,
|
||||
Map<String, List<Path>> conflictChecker, Map<Path, CachedAssetFile> previousFiles) throws IOException {
|
||||
if (Config.excludeFileSuffixes().contains(FileUtils.getExtension(file))) {
|
||||
if (Config.excludeFileExtensions().contains(FileUtils.getExtension(file))) {
|
||||
return;
|
||||
}
|
||||
CachedAssetFile cachedAsset = previousFiles.get(file);
|
||||
@@ -1237,7 +1237,7 @@ public abstract class AbstractPackManager implements PackManager {
|
||||
if (entryAttrs.isDirectory()) {
|
||||
return FileVisitResult.CONTINUE;
|
||||
}
|
||||
if (Config.excludeFileSuffixes().contains(FileUtils.getExtension(entry))) {
|
||||
if (Config.excludeFileExtensions().contains(FileUtils.getExtension(entry))) {
|
||||
return FileVisitResult.CONTINUE;
|
||||
}
|
||||
Path entryPathInZip = zipRoot.relativize(entry);
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package net.momirealms.craftengine.core.pack;
|
||||
|
||||
public class LoadingSequence {
|
||||
public final class LoadingSequence {
|
||||
private LoadingSequence() {}
|
||||
|
||||
public static final int TEMPLATE = 0;
|
||||
public static final int GLOBAL_VAR = 10;
|
||||
public static final int LANG = 20;
|
||||
|
||||
@@ -12,7 +12,7 @@ import java.nio.file.Path;
|
||||
* This class provides access to the resource pack folder
|
||||
* and configuration folder within the specified directory.
|
||||
*/
|
||||
public class Pack {
|
||||
public final class Pack {
|
||||
private final Path folder;
|
||||
private final PackMeta meta;
|
||||
private final boolean enabled;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package net.momirealms.craftengine.core.pack;
|
||||
|
||||
public class ResourceLocation {
|
||||
public final class ResourceLocation {
|
||||
|
||||
public static boolean isValid(final String resourceLocation) {
|
||||
int index = resourceLocation.indexOf(":");
|
||||
|
||||
@@ -56,7 +56,7 @@ public class Config {
|
||||
protected List<ResolutionConditional> resource_pack$duplicated_files_handler;
|
||||
protected List<String> resource_pack$merge_external_folders;
|
||||
protected List<String> resource_pack$merge_external_zips;
|
||||
protected Set<String> resource_pack$exclude_file_suffixes;
|
||||
protected Set<String> resource_pack$exclude_file_extensions;
|
||||
|
||||
protected boolean resource_pack$protection$crash_tools$method_1;
|
||||
protected boolean resource_pack$protection$crash_tools$method_2;
|
||||
@@ -218,7 +218,7 @@ public class Config {
|
||||
resource_pack$supported_version$max = getVersion(config.get("resource-pack.supported-version.max", "LATEST").toString());
|
||||
resource_pack$merge_external_folders = config.getStringList("resource-pack.merge-external-folders");
|
||||
resource_pack$merge_external_zips = config.getStringList("resource-pack.merge-external-zip-files");
|
||||
resource_pack$exclude_file_suffixes = new HashSet<>(config.getStringList("resource-pack.exclude-file-suffixes", List.of("md", "psd", "bbmodel", "db")));
|
||||
resource_pack$exclude_file_extensions = new HashSet<>(config.getStringList("resource-pack.exclude-file-extensions"));
|
||||
resource_pack$delivery$send_on_join = config.getBoolean("resource-pack.delivery.send-on-join", true);
|
||||
resource_pack$delivery$resend_on_upload = config.getBoolean("resource-pack.delivery.resend-on-upload", true);
|
||||
resource_pack$delivery$kick_if_declined = config.getBoolean("resource-pack.delivery.kick-if-declined", true);
|
||||
@@ -468,8 +468,8 @@ public class Config {
|
||||
return instance.resource_pack$merge_external_zips;
|
||||
}
|
||||
|
||||
public static Set<String> excludeFileSuffixes() {
|
||||
return instance.resource_pack$exclude_file_suffixes;
|
||||
public static Set<String> excludeFileExtensions() {
|
||||
return instance.resource_pack$exclude_file_extensions;
|
||||
}
|
||||
|
||||
public static boolean kickOnDeclined() {
|
||||
|
||||
@@ -56,8 +56,8 @@ public class LevelerExpFunction<CTX extends Context> extends AbstractConditional
|
||||
@Override
|
||||
public Function<CTX> create(Map<String, Object> arguments) {
|
||||
Object count = ResourceConfigUtils.requireNonNullOrThrow(arguments.get("count"), "warning.config.function.leveler_exp.missing_count");
|
||||
String leveler = ResourceConfigUtils.requireNonEmptyStringOrThrow("leveler", "warning.config.function.leveler_exp.missing_leveler");
|
||||
String plugin = ResourceConfigUtils.requireNonEmptyStringOrThrow("plugin", "warning.config.function.leveler_exp.missing_plugin");
|
||||
String leveler = ResourceConfigUtils.requireNonEmptyStringOrThrow(arguments.get("leveler"), "warning.config.function.leveler_exp.missing_leveler");
|
||||
String plugin = ResourceConfigUtils.requireNonEmptyStringOrThrow(arguments.get("plugin"), "warning.config.function.leveler_exp.missing_plugin");
|
||||
return new LevelerExpFunction<>(NumberProviders.fromObject(count), leveler, plugin, PlayerSelectors.fromObject(arguments.get("target"), conditionFactory()), getPredicates(arguments));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +50,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.65.25
|
||||
nms_helper_version=0.65.26
|
||||
evalex_version=3.5.0
|
||||
reactive_streams_version=1.0.4
|
||||
amazon_awssdk_version=2.31.23
|
||||
|
||||
Reference in New Issue
Block a user