Skip to content

Commit

Permalink
Merge branch 'master' into fix/visual-effects-expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
TPGamesNL authored Jun 27, 2021
2 parents e4bc1df + 55a376b commit 726b82f
Show file tree
Hide file tree
Showing 13 changed files with 38 additions and 18 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ void createTestTask(String name, String environments, boolean devMode) {
}

// Register different Skript testing tasks
createTestTask('quickTest', 'src/test/skript/environments/main/paper-1.17.json', false)
createTestTask('quickTest', 'src/test/skript/environments/main/paper-1.16.5.json', false)
createTestTask('skriptTest', 'src/test/skript/environments/main', false)
createTestTask('skriptTestFull', 'src/test/skript/environments/', false)
createTestTask('skriptTestDev', 'src/test/skript/environments/main/' + (project.property('testEnv') == null
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/ch/njol/skript/SkriptUpdater.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public class SkriptUpdater extends Updater {
public final static ArgsMessage m_downloaded = new ArgsMessage("updater.downloaded");
public final static Message m_internal_error = new Message("updater.internal error");
public final static Message m_custom_version = new Message("updater.custom version");
public final static Message m_nightly = new Message("updater.nightly build");

SkriptUpdater() {
super(loadManifest());
Expand Down Expand Up @@ -87,6 +88,9 @@ public CompletableFuture<Void> updateCheck(CommandSender sender) {
case CUSTOM:
Skript.info(sender, "" + m_custom_version);
break;
case DEVELOPMENT:
Skript.info(sender, "" + m_nightly);
break;
case LATEST:
Skript.info(sender, "" + m_running_latest_version);
break;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ch/njol/skript/command/ScriptCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ boolean execute2(final ScriptCommandEvent event, final CommandSender sender, fin
if (e != null)
sender.sendMessage(ChatColor.DARK_RED + e.getMessage());
sender.sendMessage(usage);
log.clearAll();
log.clear();
return false;
}
log.clearError();
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/ch/njol/skript/conditions/CondIsSlimeChunk.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import java.util.Random;

import ch.njol.skript.Skript;
import org.bukkit.Chunk;

import ch.njol.skript.conditions.base.PropertyCondition;
Expand All @@ -43,13 +44,18 @@
"\t\t\tsend \"Nope, it isn't\""})
@Since("2.3")
public class CondIsSlimeChunk extends PropertyCondition<Chunk> {

private static final boolean CHUNK_METHOD_EXISTS = Skript.methodExists(Chunk.class, "isSlimeChunk");

static {
register(CondIsSlimeChunk.class, "([a] slime chunk|slime chunks|slimey)", "chunk");
}

@Override
public boolean check(Chunk chunk) {
if (CHUNK_METHOD_EXISTS)
return chunk.isSlimeChunk();

Random random = new Random(chunk.getWorld().getSeed() +
(0x4c1906L * chunk.getX() * chunk.getX()) +
(0x5ac0dbL * chunk.getX()) +
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ch/njol/skript/effects/EffChange.java
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ public boolean init(final Expression<?>[] exprs, final int matchedPattern, final
log.printError();
return false;
}
log.clearAll();
log.clear();
final Class<?>[] r = new Class[rs.length];
for (int i = 0; i < rs.length; i++)
r[i] = rs[i].isArray() ? rs[i].getComponentType() : rs[i];
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/ch/njol/skript/effects/EffContinue.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ protected void execute(Event e) {
@Nullable
@Override
protected TriggerItem walk(Event e) {
TriggerItem.walk(loop, e);
return null;
return loop;
}

@Override
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/ch/njol/skript/lang/SkriptParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ private final <T> Expression<? extends T> parseSingleExpr(final boolean allowUnp
log.printError();
return null;
}
log.clearAll();
log.clear();
final LogEntry e = log.getError();
return (Literal<? extends T>) new UnparsedLiteral(expr, e != null && (error == null || e.quality > error.quality) ? e : error);
}
Expand Down Expand Up @@ -561,7 +561,7 @@ else if (!hasSingular && hasPlural)
log.printError();
return null;
}
log.clearAll();
log.clear();
final LogEntry e = log.getError();
return new UnparsedLiteral(expr, e != null && (error == null || e.quality > error.quality) ? e : error);
}
Expand Down Expand Up @@ -667,11 +667,11 @@ public final <T> Expression<? extends T> parseExpression(final Class<? extends T

if (pieces.size() == 1) { // not a list of expressions, and a single one has failed to parse above
if (expr.startsWith("(") && expr.endsWith(")") && next(expr, 0, context) == expr.length()) {
log.clearAll();
log.clear();
return new SkriptParser(this, "" + expr.substring(1, expr.length() - 1)).parseExpression(types);
}
if (isObject && (flags & PARSE_LITERALS) != 0) { // single expression - can return an UnparsedLiteral now
log.clearAll();
log.clear();
return (Expression<? extends T>) new UnparsedLiteral(expr, log.getError());
}
// results in useless errors most of the time
Expand Down Expand Up @@ -816,11 +816,11 @@ public final Expression<?> parseExpression(final ExprInfo vi) {

if (pieces.size() == 1) { // not a list of expressions, and a single one has failed to parse above
if (expr.startsWith("(") && expr.endsWith(")") && next(expr, 0, context) == expr.length()) {
log.clearAll();
log.clear();
return new SkriptParser(this, "" + expr.substring(1, expr.length() - 1)).parseExpression(vi);
}
if (isObject && (flags & PARSE_LITERALS) != 0) { // single expression - can return an UnparsedLiteral now
log.clearAll();
log.clear();
return new UnparsedLiteral(expr, log.getError());
}
// results in useless errors most of the time
Expand Down
5 changes: 0 additions & 5 deletions src/main/java/ch/njol/skript/log/ParseLogHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,6 @@ public void clearError() {
error = null;
}

public void clearAll() {
clear();
clearError();
}

/**
* Prints the retained log
*/
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/ch/njol/skript/sections/SecLoop.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import ch.njol.skript.lang.util.ContainerExpression;
import ch.njol.skript.util.Container;
import ch.njol.skript.util.Container.ContainerType;
import ch.njol.skript.util.LiteralUtils;
import ch.njol.util.Kleenean;
import org.bukkit.event.Event;
import org.eclipse.jdt.annotation.Nullable;
Expand Down Expand Up @@ -60,7 +61,11 @@ public boolean init(Expression<?>[] exprs,
ParseResult parseResult,
SectionNode sectionNode,
List<TriggerItem> triggerItems) {
expr = exprs[0];
expr = LiteralUtils.defendExpression(exprs[0]);
if (!LiteralUtils.canInitSafely(expr)) {
Skript.error("Can't understand this loop: '" + parseResult.expr.substring(5) + "'");
return false;
}

if (Container.class.isAssignableFrom(expr.getReturnType())) {
ContainerType type = expr.getReturnType().getAnnotation(ContainerType.class);
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/ch/njol/skript/update/ReleaseStatus.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,10 @@ public enum ReleaseStatus {
* Updates have been checked, but this release was not found at all.
* It might be not yet published.
*/
CUSTOM
CUSTOM,

/**
* Running a developer/nightly build, updates will not be checked.
*/
DEVELOPMENT
}
5 changes: 5 additions & 0 deletions src/main/java/ch/njol/skript/update/Updater.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@ public CompletableFuture<Void> checkUpdates() {
CompletableFuture<Void> future = CompletableFuture.completedFuture(null);
assert future != null;
return future;
} else if (currentRelease.flavor.contains("nightly")) {
releaseStatus = ReleaseStatus.DEVELOPMENT;
CompletableFuture<Void> future = CompletableFuture.completedFuture(null);
assert future != null;
return future;
}

state = UpdaterState.CHECKING; // We started checking for updates
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/lang/english.lang
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ updater:
downloaded: The latest version of Skript has been downloaded! Restart the server or use /reload to apply the changes.
internal error: An internal error occurred while checking for the latest version of Skript. Please refer to the server log for details.
custom version: You're currently running a custom Skript version. No updates will be automatically installed.
nightly build: You're currently running a development build of Skript. No updates will be automatically installed.

# -- Commands --
commands:
Expand Down

0 comments on commit 726b82f

Please sign in to comment.