Skip to content

Commit

Permalink
Ok, scripts are now parsing and enabling correctly. And it is quite f…
Browse files Browse the repository at this point in the history
…ast, I think?
  • Loading branch information
bensku committed Oct 21, 2016
1 parent 03917e8 commit d6c9ceb
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 17 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
groupid=ch.njol
name=skript
version=2.2-dev20b
version=2.2-dev21
2 changes: 2 additions & 0 deletions src/main/java/ch/njol/skript/ScriptLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ public final static ScriptInfo enableScripts(final List<ParserInstance> parsed)
@SuppressWarnings("null")
private final static void enableScript(ParserInstance pi, ScriptInfo i) {
final CountingLogHandler numErrors = SkriptLogger.startLogHandler(new CountingLogHandler(SkriptLogger.SEVERE));
Skript.debug("Enabling script " + pi.config.getFileName());
try {
for (ScriptCommand cmd : pi.commands) { // Register commands
i.commands++;
Expand Down Expand Up @@ -328,6 +329,7 @@ final static ScriptInfo unloadScript(final File script) {
}

public final static ScriptInfo unloadScripts(final File[] files) {
Skript.debug("Unloading (some) scripts...");
ScriptInfo i = new ScriptInfo();
for (File f : files) {
assert f != null;
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/ch/njol/skript/conditions/CondCompare.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

package ch.njol.skript.conditions;

import java.util.Arrays;

import org.bukkit.entity.Entity;
import org.bukkit.event.Event;
import org.eclipse.jdt.annotation.Nullable;
Expand Down Expand Up @@ -112,7 +114,6 @@ public class CondCompare extends Condition {
@SuppressWarnings("null")
@Override
public boolean init(final Expression<?>[] vars, final int matchedPattern, final Kleenean isDelayed, final ParseResult parser) {

first = vars[0];
second = vars[1];
if (vars.length == 3)
Expand Down
28 changes: 14 additions & 14 deletions src/main/java/ch/njol/skript/lang/SkriptParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -408,20 +408,20 @@ public final <T> Expression<? extends T> parseExpression(final Class<? extends T
final ParseLogHandler log = SkriptLogger.startParseLogHandler();
try {
//Mirre
if (isObject){
if ((flags & PARSE_LITERALS) != 0) {
// Hack as items use '..., ... and ...' for enchantments. Numbers and times are parsed beforehand as they use the same (deprecated) id[:data] syntax.
final SkriptParser p = new SkriptParser(pi, expr, PARSE_LITERALS, context);
for (final Class<?> c : new Class[] {Number.class, Time.class, ItemType.class, ItemStack.class}) {
final Expression<?> e = p.parseExpression(c);
if (e != null) {
log.printLog();
return (Expression<? extends T>) e;
}
log.clear();
}
}
}
// if (isObject){
// if ((flags & PARSE_LITERALS) != 0) {
// // Hack as items use '..., ... and ...' for enchantments. Numbers and times are parsed beforehand as they use the same (deprecated) id[:data] syntax.
// final SkriptParser p = new SkriptParser(pi, expr, PARSE_LITERALS, context);
// for (final Class<?> c : new Class[] {Number.class, Time.class, ItemType.class, ItemStack.class}) {
// final Expression<?> e = p.parseExpression(c); // Wow this breaks stuff -bensku, 21.10.2016
// if (e != null) {
// log.printLog();
// return (Expression<? extends T>) e;
// }
// log.clear();
// }
// }
// }
//Mirre
final Expression<? extends T> r = parseSingleExpr(false, null, types);
if (r != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,8 @@ public boolean isSingle() {
@SuppressWarnings("unchecked")
public Class<? extends T> getReturnType() {
if (signature == null) {
throw new SkriptAPIException("Signature of function is null when return type is asked!");
//throw new SkriptAPIException("Signature of function is null when return type is asked!");
return (Class<? extends T>) Unknown.class;
}
assert signature != null;
@SuppressWarnings("null") // Wait what, Eclipse? Already asserted this...
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/ch/njol/skript/lang/parser/ParserInstance.java
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,8 @@ public String run(final Matcher m) {

numTriggers++;
}

manager.parseReady(this);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public void loadAndEnable(File[] files) {
public void run() {
Skript.debug("Trying to load scripts asynchronously...");
List<ParserInstance> parsed = load(files); // Parsed scripts; this is blocking operation
Skript.debug("Done parsing scripts");
new BukkitRunnable() { // This needs to be done synchronously

@Override
Expand Down

0 comments on commit d6c9ceb

Please sign in to comment.