Expression<? extends T> d = null;
if (def != null) {
if (def.startsWith("%") && def.endsWith("%")) {
final RetainingLogHandler log = SkriptLogger.startRetainingLog();
try {
d = new SkriptParser("" + def.substring(1, def.length() - 1), SkriptParser.PARSE_EXPRESSIONS, ParseContext.COMMAND).parseExpression(type.getC());
if (d == null) {
log.printErrors("Can't understand this expression: " + def + "");
return null;
}
log.printLog();
} finally {
log.stop();
}
} else {
final RetainingLogHandler log = SkriptLogger.startRetainingLog();
try {
if (type.getC() == String.class) {
if (def.startsWith("\"") && def.endsWith("\""))
d = (Expression<? extends T>) VariableString.newInstance("" + def.substring(1, def.length() - 1));
else
d = (Expression<? extends T>) new SimpleLiteral<String>(def, false);
} else {
d = new SkriptParser(def, SkriptParser.PARSE_LITERALS, ParseContext.DEFAULT).parseExpression(type.getC());
}
if (d == null) {
log.printErrors("Can't understand this expression: '" + def + "'");
return null;
}