9
0
mirror of https://github.com/Xiao-MoMi/craft-engine.git synced 2025-12-22 08:29:21 +00:00

清理垃圾

This commit is contained in:
XiaoMoMi
2025-04-25 23:21:45 +08:00
parent 3823e1798f
commit 72ee81d951
5 changed files with 72 additions and 23 deletions

View File

@@ -61,6 +61,7 @@ public class BukkitCompatibilityManager implements CompatibilityManager {
CondIsBlockCustomBlock.register();
ExprBlockCustomBlockID.register();
ExprBlockCustomBlockState.register();
// ExprCustomBlockProperty.register();
logHook("Skript");
Plugin skriptPlugin = getPlugin("Skript");
for (BukkitTask task : Bukkit.getScheduler().getPendingTasks()) {

View File

@@ -16,7 +16,6 @@ import java.util.List;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
import java.util.logging.Level;
public class LuckPermsEventListeners {
private final JavaPlugin plugin;

View File

@@ -68,26 +68,5 @@ public class CraftEngineClasses {
}
})
);
// Classes.registerClass(new ClassInfo<>(CustomBlock.class, "customblocks")
// .user("custom block")
// .name("Custom Block")
// .parser(new Parser<>() {
// @Override
// public String toString(CustomBlock o, int flags) {
// return o.id().toString();
// }
//
// @Override
// public String toVariableNameString(CustomBlock o) {
// return "customblock:" + o.id();
// }
//
// @Override
// public @Nullable CustomBlock parse(String s, ParseContext context) {
// return BuiltInRegistries.BLOCK.getValue(Key.of(s));
// }
// })
// );
}
}

View File

@@ -0,0 +1,71 @@
package net.momirealms.craftengine.bukkit.compatibility.skript.expression;
import ch.njol.skript.Skript;
import ch.njol.skript.expressions.base.PropertyExpression;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.ExpressionType;
import ch.njol.skript.lang.SkriptParser;
import ch.njol.util.Kleenean;
import net.momirealms.craftengine.core.block.ImmutableBlockState;
import net.momirealms.craftengine.core.block.properties.Property;
import org.bukkit.event.Event;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.List;
public class ExprCustomBlockProperty extends PropertyExpression<ImmutableBlockState, String> {
public static void register() {
Skript.registerExpression(
ExprCustomBlockProperty.class,
String.class,
ExpressionType.PROPERTY,
"[the] custom block %strings% propert(y|ies) of %customblockstates%",
"%customblockstates%'[s] custom block %strings% propert(y|ies)"
);
}
private Expression<String> properties;
@Override
public @NotNull Class<? extends String> getReturnType() {
return String.class;
}
@Override
protected String[] get(Event event, ImmutableBlockState[] source) {
String[] props = this.properties.getArray(event);
List<String> results = new ArrayList<>();
for (ImmutableBlockState state : source) {
for (String propName : props) {
Property<?> property = state.owner().value().getProperty(propName);
if (property != null) {
results.add(state.get(property).toString());
}
}
}
return results.toArray(new String[0]);
}
@SuppressWarnings("unchecked")
@Override
public boolean init(Expression<?>[] exprs, int matchedPattern, @NotNull Kleenean isDelayed, SkriptParser.@NotNull ParseResult parseResult) {
if (matchedPattern == 0) {
properties = (Expression<String>) exprs[0];
setExpr((Expression<? extends ImmutableBlockState>) exprs[1]);
} else {
properties = (Expression<String>) exprs[1];
setExpr((Expression<? extends ImmutableBlockState>) exprs[0]);
}
return true;
}
@Override
public @NotNull String toString(@Nullable Event event, boolean debug) {
return "custom block state " + getExpr().toString(event, debug) +
"'s " + properties.toString(event, debug) + " property";
}
}

View File

@@ -3,7 +3,6 @@ package net.momirealms.craftengine.core.plugin;
import net.momirealms.craftengine.core.advancement.AdvancementManager;
import net.momirealms.craftengine.core.block.BlockManager;
import net.momirealms.craftengine.core.entity.furniture.FurnitureManager;
import net.momirealms.craftengine.core.entity.player.Player;
import net.momirealms.craftengine.core.font.FontManager;
import net.momirealms.craftengine.core.item.ItemManager;
import net.momirealms.craftengine.core.item.recipe.RecipeManager;