Skip to content

Commit

Permalink
Merge pull request #226 from EquipableMC/master
Browse files Browse the repository at this point in the history
Code Cleanup & Fix a server crash!
  • Loading branch information
ItsTheSky authored Dec 18, 2024
2 parents 0f52ee9 + f102e0b commit 4423759
Show file tree
Hide file tree
Showing 97 changed files with 207 additions and 277 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import ch.njol.skript.Skript;
import ch.njol.skript.config.Config;
import ch.njol.skript.lang.*;
import ch.njol.skript.lang.SkriptParser.ParseResult;
import ch.njol.skript.log.SkriptLogger;
import info.itsthesky.disky.DiSky;
import info.itsthesky.disky.core.SkriptUtils;
Expand Down Expand Up @@ -81,7 +82,7 @@ protected Predicate<GuildAuditLogEntryCreateEvent> logChecker() {

@Override
@SuppressWarnings("unchecked")
public boolean init(Literal<?> @NotNull [] exprs, int matchedPattern, @NotNull SkriptParser.ParseResult parser) {
public boolean init(Literal<?> @NotNull [] exprs, int matchedPattern, @NotNull ParseResult parser) {
bot = (String) (exprs[0] == null ? null : exprs[0].getSingle());

bukkitClass = (Class<? extends Event>) Arrays.stream(this.getClass().getDeclaredClasses())
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/info/itsthesky/disky/api/skript/BaseScope.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import ch.njol.skript.config.Node;
import ch.njol.skript.config.SectionNode;
import ch.njol.skript.lang.*;
import ch.njol.skript.lang.SkriptParser.ParseResult;
import ch.njol.skript.lang.util.SimpleLiteral;
import ch.njol.skript.log.SkriptLogger;
import ch.njol.skript.util.StringMode;
Expand All @@ -31,7 +32,7 @@ public abstract class BaseScope<T> extends SelfRegisteringSkriptEvent {

public abstract @Nullable String validate(@Nullable T parsedEntity);

public void init(Literal<?> @NotNull [] args, int matchedPattern, @NotNull SkriptParser.ParseResult parseResult, SectionNode node) {};
public void init(Literal<?> @NotNull [] args, int matchedPattern, @NotNull ParseResult parseResult, SectionNode node) {};

public String parseEntry(SectionNode node, String key) {
return parseEntry(node, key, "");
Expand Down Expand Up @@ -91,7 +92,7 @@ public static void nukeSectionNode(SectionNode sectionNode) {
}

@Override
public boolean init(Literal<?> @NotNull [] args, int matchedPattern, @NotNull SkriptParser.ParseResult parseResult) {
public boolean init(Literal<?> @NotNull [] args, int matchedPattern, @NotNull ParseResult parseResult) {
final Node node = SkriptLogger.getNode();
if (!(node instanceof SectionNode))
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import ch.njol.skript.SkriptAPIException;
import ch.njol.skript.lang.Condition;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.SkriptParser;
import ch.njol.skript.lang.SkriptParser.ParseResult;
import ch.njol.util.Kleenean;
import org.bukkit.event.Event;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -61,7 +61,7 @@ public boolean check(@NotNull Event e) {
}

@Override
public boolean init(Expression<?> @NotNull [] exprs, int matchedPattern, @NotNull Kleenean isDelayed, @NotNull SkriptParser.ParseResult parseResult) {
public boolean init(Expression<?> @NotNull [] exprs, int matchedPattern, @NotNull Kleenean isDelayed, @NotNull ParseResult parseResult) {
expr = (Expression<? extends T>) exprs[0];
this.setNegated(matchedPattern == 1);
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@

import ch.njol.skript.Skript;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.ExpressionType;
import ch.njol.skript.lang.SkriptParser;
import ch.njol.skript.lang.SkriptParser.ParseResult;
import ch.njol.skript.lang.parser.ParserInstance;
import ch.njol.skript.lang.util.SimpleExpression;
import ch.njol.util.Kleenean;
import info.itsthesky.disky.core.SkriptUtils;
import net.dv8tion.jda.api.events.GenericEvent;
import org.bukkit.event.Event;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -38,7 +35,7 @@ public boolean isSingle() {
}

@Override
public boolean init(Expression<?> @NotNull [] exprs, int matchedPattern, @NotNull Kleenean isDelayed, @NotNull SkriptParser.ParseResult parseResult) {
public boolean init(Expression<?> @NotNull [] exprs, int matchedPattern, @NotNull Kleenean isDelayed, @NotNull ParseResult parseResult) {
if (!EasyElement.containsEvent(getEvent())) {
Skript.error(getValue() + " cannot be used in a " + ParserInstance.get().getCurrentEventName());
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import ch.njol.skript.Skript;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.ExpressionType;
import ch.njol.skript.lang.SkriptParser;
import ch.njol.skript.lang.SkriptParser.ParseResult;
import ch.njol.skript.lang.util.SimpleExpression;
import ch.njol.util.Kleenean;
import org.bukkit.event.Event;
Expand All @@ -29,7 +29,7 @@ protected static <T> void register(final Class<? extends Expression<T>> c, final

@Override
@SuppressWarnings("unchecked")
public boolean init(final Expression<?> @NotNull [] expr, final int matchedPattern, final @NotNull Kleenean isDelayed, @NotNull final SkriptParser.ParseResult parseResult) {
public boolean init(final Expression<?> @NotNull [] expr, final int matchedPattern, final @NotNull Kleenean isDelayed, @NotNull final ParseResult parseResult) {
this.expr = (Expression<? extends F>) expr[0];
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import ch.njol.skript.classes.Changer;
import ch.njol.skript.config.SectionNode;
import ch.njol.skript.lang.*;
import ch.njol.skript.lang.SkriptParser.ParseResult;
import ch.njol.skript.lang.util.SimpleExpression;
import ch.njol.util.Kleenean;
import org.bukkit.event.Event;
Expand Down Expand Up @@ -36,7 +37,7 @@ public static <T, S extends ReturningSection<T>> void register(Class<S> sectionC
private Variable<T> variable;

@Override
public boolean init(Expression<?> @NotNull [] exprs, int matchedPattern, @NotNull Kleenean isDelayed, @NotNull SkriptParser.ParseResult parseResult, @NotNull SectionNode sectionNode, @NotNull List<TriggerItem> triggerItems) {
public boolean init(Expression<?> @NotNull [] exprs, int matchedPattern, @NotNull Kleenean isDelayed, @NotNull ParseResult parseResult, @NotNull SectionNode sectionNode, @NotNull List<TriggerItem> triggerItems) {
loadOptionalCode(sectionNode);
variable = (Variable<T>) exprs[exprs.length - 1];
return true;
Expand All @@ -61,7 +62,7 @@ public abstract static class LastBuilderExpression<T, S extends ReturningSection
private S section;

@Override
public boolean init(Expression<?> @NotNull [] exprs, int matchedPattern, @NotNull Kleenean isDelayed, @NotNull SkriptParser.ParseResult parseResult) {
public boolean init(Expression<?> @NotNull [] exprs, int matchedPattern, @NotNull Kleenean isDelayed, @NotNull ParseResult parseResult) {
section = getParser().getCurrentSection(getSectionClass());
return getParser().isCurrentSection(getSectionClass());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package info.itsthesky.disky.api.skript;

import ch.njol.skript.Skript;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.SkriptParser;
import ch.njol.skript.lang.parser.ParserInstance;
import ch.njol.skript.lang.SkriptParser.ParseResult;
import ch.njol.skript.lang.util.SimpleExpression;
import ch.njol.util.Kleenean;
import org.bukkit.event.Event;
Expand Down Expand Up @@ -35,7 +33,7 @@ public boolean isSingle() {
}

@Override
public boolean init(Expression<?> @NotNull [] exprs, int matchedPattern, @NotNull Kleenean isDelayed, @NotNull SkriptParser.ParseResult parseResult) {
public boolean init(Expression<?> @NotNull [] exprs, int matchedPattern, @NotNull Kleenean isDelayed, @NotNull ParseResult parseResult) {
return getEvent() == null || EasyElement.containsEvent(getEvent());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import ch.njol.skript.Skript;
import ch.njol.skript.classes.Changer;
import ch.njol.skript.lang.*;
import ch.njol.skript.lang.SkriptParser.ParseResult;
import ch.njol.skript.lang.parser.ParserInstance;
import ch.njol.skript.timings.SkriptTimings;
import ch.njol.skript.variables.Variables;
Expand All @@ -28,9 +29,9 @@ public abstract class WaiterEffect<T> extends EasyElement {
@Nullable protected Variable<T> changedVariable = null;
private boolean isStopped;

public abstract boolean initEffect(Expression<?>[] expressions, int i, Kleenean kleenean, SkriptParser.ParseResult parseResult);
public abstract boolean initEffect(Expression<?>[] expressions, int i, Kleenean kleenean, ParseResult parseResult);

public boolean init(Expression<?> @NotNull [] expressions, int i, @NotNull Kleenean kleenean, @NotNull SkriptParser.ParseResult parseResult) {
public boolean init(Expression<?> @NotNull [] expressions, int i, @NotNull Kleenean kleenean, @NotNull ParseResult parseResult) {
ParserInstance.get().setHasDelayBefore(Kleenean.TRUE);
node = new NodeInformation();
return initEffect(expressions, i, kleenean, parseResult);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package info.itsthesky.disky.api.skript.action;

import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.SkriptParser;
import ch.njol.skript.lang.SkriptParser.ParseResult;
import ch.njol.skript.lang.util.SimpleExpression;
import ch.njol.util.Kleenean;
import info.itsthesky.disky.api.skript.EasyElement;
Expand Down Expand Up @@ -45,7 +45,7 @@ public boolean isSingle() {
}

@Override
public boolean init(Expression<?> @NotNull [] exprs, int matchedPattern, @NotNull Kleenean isDelayed, @NotNull SkriptParser.ParseResult parseResult) {
public boolean init(Expression<?> @NotNull [] exprs, int matchedPattern, @NotNull Kleenean isDelayed, @NotNull ParseResult parseResult) {
exprGuild = (Expression<E>) exprs[0];
exprBot = (Expression<Bot>) exprs[1];
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import ch.njol.skript.classes.Changer;
import ch.njol.skript.config.Node;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.SkriptParser;
import ch.njol.skript.lang.SkriptParser.ParseResult;
import ch.njol.util.Kleenean;
import info.itsthesky.disky.api.changers.ChangeablePropertyExpression;
import info.itsthesky.disky.api.skript.EasyElement;
Expand Down Expand Up @@ -72,7 +72,7 @@ public O[] getAsync(Event e) {
}

@Override
public boolean init(Expression<?> @NotNull [] exprs, int matchedPattern, @NotNull Kleenean isDelayed, @NotNull SkriptParser.ParseResult parseResult) {
public boolean init(Expression<?> @NotNull [] exprs, int matchedPattern, @NotNull Kleenean isDelayed, @NotNull ParseResult parseResult) {
setExpr(exprs[0]);
node = getParser().getNode();
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import ch.njol.skript.classes.Changer;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.SkriptParser;
import ch.njol.skript.lang.SkriptParser.ParseResult;
import ch.njol.util.Kleenean;
import info.itsthesky.disky.api.changers.ChangeablePropertyExpression;
import info.itsthesky.disky.api.skript.EasyElement;
Expand Down Expand Up @@ -45,7 +45,7 @@ public void change(Event e, Object[] delta, Bot bot, Changer.ChangeMode mode) {
}

@Override
public boolean init(Expression<?> @NotNull [] exprs, int matchedPattern, @NotNull Kleenean isDelayed, @NotNull SkriptParser.ParseResult parseResult) {
public boolean init(Expression<?> @NotNull [] exprs, int matchedPattern, @NotNull Kleenean isDelayed, @NotNull ParseResult parseResult) {
setExpr(exprs[0]);
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import ch.njol.skript.config.Node;
import ch.njol.skript.expressions.base.SimplePropertyExpression;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.SkriptParser;
import ch.njol.skript.lang.SkriptParser.ParseResult;
import ch.njol.util.Kleenean;
import info.itsthesky.disky.api.skript.INodeHolder;
import info.itsthesky.disky.elements.changers.IAsyncChangeableExpression;
Expand All @@ -18,7 +18,7 @@ public class DiSkyStateProperty extends SimplePropertyExpression<Object, Boolean
public Node node;

@Override
public boolean init(Expression<?>[] expressions, int matchedPattern, Kleenean isDelayed, SkriptParser.ParseResult parseResult) {
public boolean init(Expression<?>[] expressions, int matchedPattern, Kleenean isDelayed, ParseResult parseResult) {
node = getParser().getNode();
return super.init(expressions, matchedPattern, isDelayed, parseResult);
}
Expand Down
9 changes: 2 additions & 7 deletions src/main/java/info/itsthesky/disky/core/SkriptUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@
import ch.njol.skript.config.Node;
import ch.njol.skript.config.SectionNode;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.SkriptParser;
import ch.njol.skript.lang.SkriptParser.ParseResult;
import ch.njol.skript.lang.TriggerItem;
import ch.njol.skript.lang.VariableString;
import ch.njol.skript.lang.parser.ParserInstance;
import ch.njol.skript.lang.util.SimpleExpression;
import ch.njol.skript.lang.util.SimpleLiteral;
import ch.njol.skript.log.*;
import ch.njol.skript.registrations.EventValues;
import ch.njol.skript.util.*;
Expand All @@ -22,14 +20,12 @@
import info.itsthesky.disky.api.events.SimpleDiSkyEvent;
import info.itsthesky.disky.api.skript.EasyElement;
import info.itsthesky.disky.elements.effects.RetrieveEventValue;
import info.itsthesky.disky.elements.events.member.MemberKickEvent;
import info.itsthesky.disky.elements.sections.handler.DiSkyRuntimeHandler;
import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.Icon;
import net.dv8tion.jda.api.entities.channel.Channel;
import net.dv8tion.jda.api.entities.channel.middleman.GuildChannel;
import net.dv8tion.jda.api.events.guild.GenericGuildEvent;
import net.dv8tion.jda.api.events.message.GenericMessageEvent;
import net.dv8tion.jda.api.requests.RestAction;
import org.bukkit.Bukkit;
Expand All @@ -40,7 +36,6 @@

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.lang.reflect.Array;
import java.lang.reflect.Field;
Expand Down Expand Up @@ -133,7 +128,7 @@ public boolean isDefault() {
}

@Override
public boolean init(Expression<?> @NotNull [] exprs, int matchedPattern, @NotNull Kleenean isDelayed, @NotNull SkriptParser.ParseResult parseResult) {
public boolean init(Expression<?> @NotNull [] exprs, int matchedPattern, @NotNull Kleenean isDelayed, @NotNull ParseResult parseResult) {
return true;
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import ch.njol.skript.doc.Name;
import ch.njol.skript.lang.Effect;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.SkriptParser;
import ch.njol.skript.lang.SkriptParser.ParseResult;
import ch.njol.util.Kleenean;
import info.itsthesky.disky.DiSky;
import info.itsthesky.disky.api.skript.SpecificBotEffect;
Expand All @@ -31,7 +31,7 @@ public class BaseBotEffect extends WaiterEffect<Object> {
private SpecificBotEffect<Object> effect;

@Override
public boolean initEffect(Expression<?>[] expressions, int i, Kleenean kleenean, SkriptParser.ParseResult parseResult) {
public boolean initEffect(Expression<?>[] expressions, int i, Kleenean kleenean, ParseResult parseResult) {
exprBot = (Expression<Bot>) expressions[0];
final String rawEffect = parseResult.regexes.get(0).group();
final Effect unparsedEffect = Effect.parse(rawEffect, "Can't understand this effect: " + rawEffect);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,16 @@
import ch.njol.skript.classes.Parser;
import ch.njol.skript.config.SectionNode;
import ch.njol.skript.lang.*;
import ch.njol.skript.lang.SkriptParser.ParseResult;
import ch.njol.skript.lang.util.SimpleLiteral;
import ch.njol.skript.registrations.Classes;
import ch.njol.skript.util.StringMode;
import ch.njol.skript.util.Timespan;
import ch.njol.skript.util.Utils;
import ch.njol.util.NonNullPair;
import ch.njol.util.StringUtils;
import info.itsthesky.disky.api.DiSkyType;
import info.itsthesky.disky.core.SkriptUtils;
import net.dv8tion.jda.api.entities.channel.ChannelType;
import net.dv8tion.jda.api.requests.RestAction;
import org.bukkit.event.Event;

import java.lang.reflect.InvocationTargetException;
Expand Down Expand Up @@ -61,9 +60,9 @@ private String escape(final String s) {

public boolean parseArguments(String args, CommandObject command, Event event) {
SkriptParser parser = new SkriptParser(args, SkriptParser.PARSE_LITERALS, ParseContext.COMMAND);
SkriptParser.ParseResult res = null;
ParseResult res = null;
try {
res = (SkriptParser.ParseResult) PARSE_I.invoke(parser, command.getPattern());
res = (ParseResult) PARSE_I.invoke(parser, command.getPattern());
} catch (IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import ch.njol.skript.lang.Literal;
import ch.njol.skript.lang.SkriptEvent;
import ch.njol.skript.lang.SkriptParser;
import ch.njol.skript.lang.SkriptParser.ParseResult;
import ch.njol.skript.registrations.EventValues;
import ch.njol.skript.util.Getter;
import info.itsthesky.disky.DiSky;
Expand Down Expand Up @@ -76,7 +76,7 @@ public Bot get(@NotNull EvtDiSkyCommand event) {
}

@Override
public boolean init(Literal<?> @NotNull [] exprs, int i, @NotNull SkriptParser.ParseResult parseResult) {
public boolean init(Literal<?> @NotNull [] exprs, int i, @NotNull ParseResult parseResult) {
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import ch.njol.skript.doc.Name;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.ExpressionType;
import ch.njol.skript.lang.SkriptParser;
import ch.njol.skript.lang.SkriptParser.ParseResult;
import ch.njol.skript.lang.util.SimpleExpression;
import ch.njol.util.Kleenean;
import info.itsthesky.disky.elements.commands.CommandEvent;
Expand Down Expand Up @@ -51,7 +51,7 @@ public boolean isSingle() {
}

@Override
public boolean init(Expression<?> @NotNull [] exprs, int matchedPattern, @NotNull Kleenean isDelayed, @NotNull SkriptParser.ParseResult parseResult) {
public boolean init(Expression<?> @NotNull [] exprs, int matchedPattern, @NotNull Kleenean isDelayed, @NotNull ParseResult parseResult) {
if (!ScriptLoader.isCurrentEvent(CommandEvent.class)) {
Skript.error("The used alias can only used in a discord command trigger section.");
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import ch.njol.skript.doc.Name;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.ExpressionType;
import ch.njol.skript.lang.SkriptParser;
import ch.njol.skript.lang.SkriptParser.ParseResult;
import ch.njol.skript.lang.util.SimpleExpression;
import ch.njol.util.Kleenean;
import info.itsthesky.disky.elements.commands.CommandEvent;
Expand Down Expand Up @@ -50,7 +50,7 @@ public boolean isSingle() {
}

@Override
public boolean init(Expression<?> @NotNull [] exprs, int matchedPattern, @NotNull Kleenean isDelayed, @NotNull SkriptParser.ParseResult parseResult) {
public boolean init(Expression<?> @NotNull [] exprs, int matchedPattern, @NotNull Kleenean isDelayed, @NotNull ParseResult parseResult) {
if (!ScriptLoader.isCurrentEvent(CommandEvent.class)) {
Skript.error("The used arguments can only used in a discord command trigger section.");
return false;
Expand Down
Loading

0 comments on commit 4423759

Please sign in to comment.