Skip to content

Commit

Permalink
Structure API Update (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
UnderscoreTud authored Dec 27, 2023
1 parent 3d19b64 commit c73746f
Show file tree
Hide file tree
Showing 69 changed files with 1,277 additions and 1,758 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ compileJava {

dependencies {
implementation 'org.spigotmc:spigot-api:1.13.2-R0.1-SNAPSHOT'
implementation 'com.github.SkriptLang:Skript:2.7.0-beta3'
implementation 'com.github.SkriptLang:Skript:2.7.1'
implementation 'org.eclipse.jdt:org.eclipse.jdt.annotation:1.1.0'
}
12 changes: 6 additions & 6 deletions src/main/java/com/btk5h/skriptmirror/Descriptor.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.btk5h.skriptmirror;

import com.btk5h.skriptmirror.skript.custom.CustomImport;
import org.skriptlang.reflect.java.elements.structures.StructImport;
import com.btk5h.skriptmirror.util.JavaUtil;
import com.btk5h.skriptmirror.util.SkriptMirrorUtil;
import org.skriptlang.skript.lang.script.Script;

import java.io.File;
import java.util.Objects;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
Expand Down Expand Up @@ -102,7 +102,7 @@ public Descriptor orDefaultClass(Class<?> cls) {
/**
* Parses the given {@link String} as a {@link Descriptor}. The script parameter is to get the imports.
*/
public static Descriptor parse(String desc, File script) throws ImportNotFoundException {
public static Descriptor parse(String desc, Script script) throws ImportNotFoundException {
Matcher m = DESCRIPTOR.matcher(desc);

if (m.matches()) {
Expand All @@ -123,7 +123,7 @@ public static Descriptor parse(String desc, File script) throws ImportNotFoundEx
/**
* Parses a list of imported names, returning a class array containing the classes in the given string.
*/
private static Class<?>[] parseParams(String args, File script) throws ImportNotFoundException {
private static Class<?>[] parseParams(String args, Script script) throws ImportNotFoundException {
String[] rawClasses = args.split(",");

Class<?>[] parsedClasses = new Class<?>[rawClasses.length];
Expand Down Expand Up @@ -160,8 +160,8 @@ private static Class<?>[] parseParams(String args, File script) throws ImportNot
/**
* Looks up a class from its imported name in the given file.
*/
private static Class<?> lookupClass(File script, String userType) throws ImportNotFoundException {
JavaType customImport = CustomImport.lookup(script, userType);
private static Class<?> lookupClass(Script script, String userType) throws ImportNotFoundException {
JavaType customImport = StructImport.lookup(script, userType);
if (customImport == null)
throw new ImportNotFoundException(userType);

Expand Down
4 changes: 0 additions & 4 deletions src/main/java/com/btk5h/skriptmirror/FunctionWrapper.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
package com.btk5h.skriptmirror;

import ch.njol.skript.config.Config;
import ch.njol.skript.lang.function.Function;
import ch.njol.skript.lang.function.Functions;
import ch.njol.skript.lang.parser.ParserInstance;
import com.btk5h.skriptmirror.util.SkriptReflection;
import com.btk5h.skriptmirror.util.SkriptUtil;
import org.eclipse.jdt.annotation.Nullable;
import org.skriptlang.skript.lang.script.Script;

public class FunctionWrapper {

Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/btk5h/skriptmirror/JavaType.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.Objects;

public final class JavaType {

private final Class<?> javaClass;

public JavaType(Class<?> javaClass) {
Expand All @@ -25,4 +26,5 @@ public boolean equals(Object o) {
public int hashCode() {
return Objects.hash(javaClass);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
import ch.njol.skript.Skript;
import ch.njol.skript.effects.EffReturn;
import ch.njol.util.Checker;
import org.skriptlang.reflect.syntax.condition.elements.CustomCondition;
import org.skriptlang.reflect.syntax.effect.elements.CustomEffect;
import org.skriptlang.reflect.syntax.expression.elements.CustomExpression;
import com.btk5h.skriptmirror.skript.EffExpressionStatement;
import com.btk5h.skriptmirror.skript.custom.ExprMatchedPattern;
import com.btk5h.skriptmirror.skript.custom.condition.CustomCondition;
import com.btk5h.skriptmirror.skript.custom.effect.CustomEffect;
import com.btk5h.skriptmirror.skript.custom.expression.CustomExpression;
import com.btk5h.skriptmirror.util.SkriptReflection;

import java.util.Collection;
Expand Down
43 changes: 0 additions & 43 deletions src/main/java/com/btk5h/skriptmirror/ParserInstanceState.java

This file was deleted.

34 changes: 14 additions & 20 deletions src/main/java/com/btk5h/skriptmirror/SkriptMirror.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
import ch.njol.skript.SkriptAddon;
import ch.njol.skript.lang.parser.ParserInstance;
import ch.njol.skript.util.Version;
import com.btk5h.skriptmirror.skript.CondParseLater;
import com.btk5h.skriptmirror.skript.custom.condition.CustomConditionSection;
import com.btk5h.skriptmirror.skript.custom.effect.CustomEffectSection;
import com.btk5h.skriptmirror.skript.custom.event.CustomEventSection;
import com.btk5h.skriptmirror.skript.custom.expression.CustomExpressionSection;
import org.skriptlang.reflect.syntax.condition.elements.StructCustomCondition;
import org.skriptlang.reflect.syntax.effect.elements.StructCustomEffect;
import org.skriptlang.reflect.syntax.event.elements.StructCustomEvent;
import org.skriptlang.reflect.syntax.expression.elements.StructCustomExpression;
import com.btk5h.skriptmirror.skript.reflect.ExprJavaCall;
import com.btk5h.skriptmirror.skript.reflect.ExprProxy;
import com.btk5h.skriptmirror.skript.reflect.sections.SecSection;
Expand All @@ -22,6 +21,7 @@
import java.util.Map;

public class SkriptMirror extends JavaPlugin {

private static SkriptMirror instance;
private static SkriptAddon addonInstance;

Expand All @@ -41,10 +41,9 @@ public void onEnable() {
return;
}

if (!Skript.classExists("ch.njol.skript.lang.parser.ParserInstance") || !Skript.methodExists(ParserInstance.class, "get")) {
if (Skript.getVersion().isSmallerThan(new Version(2, 7))) {
getLogger().severe("");
getLogger().severe("Your version of Skript (" + Skript.getVersion() + ") is not supported, at least Skript 2.6 is required to run this version of skript-reflect.");
getLogger().severe("If you want to use a version of Skript below 2.6, use skript-reflect 2.2.3: https://github.com/TPGamesNL/skript-reflect/releases/tag/v2.2.3");
getLogger().severe("Your version of Skript (" + Skript.getVersion() + ") is not supported, at least Skript 2.7 is required to run this version of skript-reflect.");
getLogger().severe("");
Bukkit.getPluginManager().disablePlugin(this);
return;
Expand All @@ -54,10 +53,10 @@ public void onEnable() {
getLogger().warning("You shouldn't have both skript-mirror and skript-reflect enabled, it will probably cause issues");
}

saveDefaultConfig();

try {
getAddonInstance().loadClasses("com.btk5h.skriptmirror.skript");
getAddonInstance()
.loadClasses("com.btk5h.skriptmirror.skript")
.loadClasses("org.skriptlang.reflect", "syntax", "java.elements");

Path dataFolder = SkriptMirror.getInstance().getDataFolder().toPath();
LibraryLoader.loadLibraries(dataFolder);
Expand All @@ -84,25 +83,20 @@ public void onEnable() {
return map;
}));

metrics.addCustomChart(new Metrics.SimplePie("preload_enabled",
() -> "" + getConfig().getBoolean("enable-preloading")));
metrics.addCustomChart(new Metrics.SimplePie("deferred_parsing_used",
() -> "" + CondParseLater.deferredParsingUsed));

metrics.addCustomChart(new Metrics.SingleLineChart("java_calls_made", () -> {
int i = ExprJavaCall.javaCallsMade;
ExprJavaCall.javaCallsMade = 0;
return i;
}));

metrics.addCustomChart(new Metrics.SimplePie("custom_conditions_used",
() -> "" + CustomConditionSection.customConditionsUsed));
() -> "" + StructCustomCondition.customConditionsUsed));
metrics.addCustomChart(new Metrics.SimplePie("custom_effects_used",
() -> "" + CustomEffectSection.customEffectsUsed));
() -> "" + StructCustomEffect.customEffectsUsed));
metrics.addCustomChart(new Metrics.SimplePie("custom_events_used",
() -> "" + CustomEventSection.customEventsUsed));
() -> "" + StructCustomEvent.customEventsUsed));
metrics.addCustomChart(new Metrics.SimplePie("custom_expressions_used",
() -> "" + CustomExpressionSection.customExpressionsUsed));
() -> "" + StructCustomExpression.customExpressionsUsed));

metrics.addCustomChart(new Metrics.SimplePie("proxies_used",
() -> "" + ExprProxy.proxiesUsed));
Expand Down
100 changes: 0 additions & 100 deletions src/main/java/com/btk5h/skriptmirror/skript/CondParseLater.java

This file was deleted.

Loading

0 comments on commit c73746f

Please sign in to comment.