9
0
mirror of https://github.com/Xiao-MoMi/Custom-Crops.git synced 2025-12-19 15:09:25 +00:00
This commit is contained in:
XiaoMoMi
2025-01-18 22:49:20 +08:00
parent 3eb778e687
commit 93d83ac467
6 changed files with 26 additions and 4 deletions

View File

@@ -21,7 +21,6 @@ import net.momirealms.customcrops.api.BukkitCustomCropsPlugin;
import net.momirealms.customcrops.api.action.Action;
import net.momirealms.customcrops.api.context.Context;
import net.momirealms.customcrops.api.misc.value.MathValue;
import org.bukkit.entity.Player;
public abstract class AbstractBuiltInAction<T> implements Action<T> {

View File

@@ -33,6 +33,9 @@ import static java.util.Objects.requireNonNull;
public class ActionSpawnEntity<T> extends AbstractBuiltInAction<T> {
private final String id;
private MathValue<T> x;
private MathValue<T> y;
private MathValue<T> z;
private final Map<String, Object> properties;
public ActionSpawnEntity(
@@ -42,6 +45,9 @@ public class ActionSpawnEntity<T> extends AbstractBuiltInAction<T> {
) {
super(plugin, chance);
this.id = section.getString("id");
this.x = MathValue.auto(section.get("x", 0));
this.y = MathValue.auto(section.get("y", 0));
this.z = MathValue.auto(section.get("z", 0));
Section proeprtySection = section.getSection("properties");
this.properties = proeprtySection == null ? new HashMap<>() : proeprtySection.getStringRouteMappedValues(false);
}
@@ -49,6 +55,7 @@ public class ActionSpawnEntity<T> extends AbstractBuiltInAction<T> {
@Override
protected void triggerAction(Context<T> context) {
Location location = requireNonNull(context.arg(ContextKeys.LOCATION));
location = location.clone().add(this.x.evaluate(context), this.y.evaluate(context), this.z.evaluate(context));
String finalID;
EntityProvider provider;
if (id.contains(":")) {

View File

@@ -20,7 +20,6 @@ package net.momirealms.customcrops.api.core.world;
import com.flowpowered.nbt.CompoundMap;
import com.flowpowered.nbt.CompoundTag;
import com.flowpowered.nbt.Tag;
import com.flowpowered.nbt.stream.NBTInputStream;
import net.momirealms.customcrops.api.core.SynchronizedCompoundMap;
import net.momirealms.customcrops.api.core.block.CustomCropsBlock;
import net.momirealms.customcrops.api.util.TagUtils;

View File

@@ -26,7 +26,6 @@ import io.th0rgal.oraxen.api.events.custom_block.stringblock.OraxenStringBlockPl
import io.th0rgal.oraxen.api.events.furniture.OraxenFurnitureBreakEvent;
import io.th0rgal.oraxen.api.events.furniture.OraxenFurnitureInteractEvent;
import io.th0rgal.oraxen.api.events.furniture.OraxenFurniturePlaceEvent;
import io.th0rgal.oraxen.font.Glyph;
import net.momirealms.customcrops.api.core.AbstractCustomEventListener;
import net.momirealms.customcrops.api.core.AbstractItemManager;
import org.bukkit.Material;

View File

@@ -1,6 +1,6 @@
# Project settings
# Rule: [major update].[feature update].[bug fix]
project_version=3.6.27.1
project_version=3.6.28
config_version=42
project_group=net.momirealms

View File

@@ -54,6 +54,7 @@ public class PlayerRequirementManager extends AbstractRequirementManager<Player>
this.registerPotionEffectRequirement();
this.registerSneakRequirement();
this.registerGameModeRequirement();
this.registerHandRequirement();
}
@Override
@@ -345,4 +346,21 @@ public class PlayerRequirementManager extends AbstractRequirementManager<Player>
};
}, "gamemode");
}
private void registerHandRequirement() {
registerRequirement((args, actions, advanced) -> {
String hand = ((String) args).toLowerCase(Locale.ENGLISH);
return context -> {
if (context.holder() == null) return true;
EquipmentSlot slot = context.arg(ContextKeys.SLOT);
if (slot != null) {
if (slot.name().toLowerCase(Locale.ENGLISH).equals(hand)) {
return true;
}
}
if (advanced) ActionManager.trigger(context, actions);
return false;
};
}, "hand");
}
}