Skip to content

Commit

Permalink
V7 update
Browse files Browse the repository at this point in the history
Added ExprChatRecipients
Fixed Mirreski/Skript#10
Fixed Mirreski/Skript#9
  • Loading branch information
Mirreski committed Jun 15, 2015
1 parent 68fbcd3 commit 4dc285a
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/main/java/ch/njol/skript/Skript.java
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public final class Skript extends JavaPlugin implements Listener {

// ================ PLUGIN ================

public static String MIRRE = "V6";
public static String MIRRE = "V7";

@Nullable
private static Skript instance = null;
Expand Down
28 changes: 23 additions & 5 deletions src/main/java/ch/njol/skript/conditions/CondCompare.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

package ch.njol.skript.conditions;

import org.bukkit.entity.Entity;
import org.bukkit.event.Event;
import org.eclipse.jdt.annotation.Nullable;

Expand All @@ -31,9 +32,12 @@
import ch.njol.skript.doc.Examples;
import ch.njol.skript.doc.Name;
import ch.njol.skript.doc.Since;
import ch.njol.skript.entity.EntityData;
import ch.njol.skript.lang.Condition;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.ExpressionList;
import ch.njol.skript.lang.ParseContext;
import ch.njol.skript.lang.SkriptParser;
import ch.njol.skript.lang.SkriptParser.ParseResult;
import ch.njol.skript.log.ErrorQuality;
import ch.njol.skript.log.RetainingLogHandler;
Expand Down Expand Up @@ -108,6 +112,10 @@ public class CondCompare extends Condition {
@SuppressWarnings("null")
@Override
public boolean init(final Expression<?>[] vars, final int matchedPattern, final Kleenean isDelayed, final ParseResult parser) {

if(!parser.regexes.isEmpty())
System.out.println(parser.regexes.get(0));
System.out.println(parser.expr);
first = vars[0];
second = vars[1];
if (vars.length == 3)
Expand All @@ -123,7 +131,7 @@ public boolean init(final Expression<?>[] vars, final int matchedPattern, final
if (third instanceof ExpressionList)
((ExpressionList<?>) third).invertAnd();
}
final boolean b = init();
final boolean b = init(parser.expr);
final Expression<?> third = this.third;
if (!b) {
if (third == null && first.getReturnType() == Object.class && second.getReturnType() == Object.class) {
Expand Down Expand Up @@ -157,8 +165,8 @@ public final static String f(final Expression<?> e) {
return Classes.getSuperClassInfo(e.getReturnType()).getName().withIndefiniteArticle();
}

@SuppressWarnings("unchecked")
private boolean init() {
@SuppressWarnings({"unchecked", "null"})
private boolean init(String expr) {
final RetainingLogHandler log = SkriptLogger.startRetainingLog();
Expression<?> third = this.third;
try {
Expand Down Expand Up @@ -190,11 +198,21 @@ private boolean init() {
} finally {
log.stop();
}

final Class<?> f = first.getReturnType(), s = third == null ? second.getReturnType() : Utils.getSuperType(second.getReturnType(), third.getReturnType());
if (f == Object.class || s == Object.class)
return true;
comp = Comparators.getComparator(f, s);
//Mirre
if(Entity.class.isAssignableFrom(s)){
String[] split = expr.split(" ");
if(EntityData.parseWithoutIndefiniteArticle(split[split.length - 1]) != null){
comp = Comparators.getComparator(f, EntityData.class);
second = SkriptParser.parseLiteral(split[split.length - 1], EntityData.class, ParseContext.DEFAULT);
}
}
//Mirre

else
comp = Comparators.getComparator(f, s);

return comp != null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public Class<? extends Player> getReturnType() {
@Override
public Class<?>[] acceptChange(final ChangeMode mode) {
if (mode == ChangeMode.ADD || mode == ChangeMode.SET || mode == ChangeMode.DELETE || mode == ChangeMode.REMOVE)
return CollectionUtils.array(Player.class);
return CollectionUtils.array(Player.class, Player[].class);
return null;
}

Expand Down
21 changes: 20 additions & 1 deletion src/main/java/ch/njol/skript/lang/SkriptParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,19 @@
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;

import org.bukkit.inventory.ItemStack;
import org.eclipse.jdt.annotation.Nullable;

import ch.njol.skript.ScriptLoader;
import ch.njol.skript.Skript;
import ch.njol.skript.SkriptAPIException;
import ch.njol.skript.aliases.ItemType;
import ch.njol.skript.classes.ClassInfo;
import ch.njol.skript.command.Argument;
import ch.njol.skript.command.Commands;
import ch.njol.skript.command.ScriptCommand;
import ch.njol.skript.command.ScriptCommandEvent;
import ch.njol.skript.entity.EntityData;
import ch.njol.skript.expressions.ExprParse;
import ch.njol.skript.lang.function.ExprFunctionCall;
import ch.njol.skript.lang.function.Function;
Expand All @@ -56,6 +59,7 @@
import ch.njol.skript.log.RetainingLogHandler;
import ch.njol.skript.log.SkriptLogger;
import ch.njol.skript.registrations.Classes;
import ch.njol.skript.util.Time;
import ch.njol.skript.util.Utils;
import ch.njol.util.Kleenean;
import ch.njol.util.NonNullPair;
Expand Down Expand Up @@ -392,9 +396,24 @@ public final <T> Expression<? extends T> parseExpression(final Class<? extends T
assert types.length == 1 || !CollectionUtils.contains(types, Object.class);

final boolean isObject = types.length == 1 && types[0] == Object.class;

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(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();
}
}
}
//Mirre
final Expression<? extends T> r = parseSingleExpr(false, null, types);
if (r != null) {
log.printLog();
Expand Down

0 comments on commit 4dc285a

Please sign in to comment.