Skip to content

Commit

Permalink
Requested Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
UnderscoreTud committed Nov 6, 2023
1 parent de310d2 commit 8365f67
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,7 @@ public class StructImport extends Structure {
Skript.registerExpression(ImportHandler.class, JavaType.class, ExpressionType.SIMPLE);
thisInfo = StreamSupport.stream(Spliterators.spliteratorUnknownSize(Skript.getExpressions(), Spliterator.ORDERED), false)
.filter(expressionInfo -> ImportHandler.class.equals(expressionInfo.getElementClass()))
.findFirst().orElseGet(() -> {
Skript.warning("Could not find custom import class. Custom imports will not work.");
return null;
});
.findFirst().orElseThrow(RuntimeException::new); // Should never be null
}

private Script script;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,7 @@ public boolean init(Literal<?>[] args, int matchedPattern, SkriptParser.ParseRes
})
.collect(Collectors.joining("/"));
register(ConditionSyntaxInfo.create(script, "%" + type + "% (is|are) " + property, 1, false, true));
register(
ConditionSyntaxInfo.create(script, "%" + type + "% (isn't|is not|aren't|are not) " + property, 1, true, true));
register(ConditionSyntaxInfo.create(script, "%" + type + "% (isn't|is not|aren't|are not) " + property, 1, true, true));
break;
}

Expand Down Expand Up @@ -155,7 +154,8 @@ public boolean load() {
getParser().setCurrentEvent("custom condition check", ConditionCheckEvent.class);
List<TriggerItem> items = SkriptUtil.getItemsFromNode(checkNode);
whichInfo.forEach(which -> conditionHandlers.put(which,
new Trigger(getParser().getCurrentScript(), "condition " + which, new SimpleEvent(), items)));
new Trigger(getParser().getCurrentScript(), "condition " + which, new SimpleEvent(), items))
);
SkriptLogger.setNode(null);

return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,9 @@ public boolean load() {
SkriptLogger.setNode(triggerNode);
getParser().setCurrentEvent("custom effect trigger", EffectTriggerEvent.class);
List<TriggerItem> items = SkriptUtil.getItemsFromNode(triggerNode);
whichInfo.forEach(which ->
effectHandlers.put(which,
new Trigger(getParser().getCurrentScript(), "effect " + which, new SimpleEvent(), items)));
whichInfo.forEach(which -> effectHandlers.put(which,
new Trigger(getParser().getCurrentScript(), "effect " + which, new SimpleEvent(), items))
);
SkriptLogger.setNode(null);

return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ public class StructCustomEvent extends CustomSyntaxStructure<EventSyntaxInfo> {
public static boolean customEventsUsed = false;

static {
String[] syntax = {
"[:local] [custom] event %string%"
};
Skript.registerStructure(StructCustomEvent.class, customSyntaxValidator()
.addEntry("pattern", null, true)
.addEntryData(new EventValuesEntryData("event values", null, true) {
Expand All @@ -41,7 +38,7 @@ public boolean canCreateWith(String node) {
})
.addSection("check", true)
.build(),
syntax
"[:local] [custom] event %string%"
);
}

Expand Down Expand Up @@ -149,9 +146,9 @@ public boolean load() {
CustomEvent.setLastWhich(whichInfo.get(0));
List<TriggerItem> items = SkriptUtil.getItemsFromNode(checkNode);
CustomEvent.setLastWhich(null);
whichInfo.forEach(which ->
eventHandlers.put(which,
new Trigger(getParser().getCurrentScript(), "event " + which, new SimpleEvent(), items)));
whichInfo.forEach(which -> eventHandlers.put(which,
new Trigger(getParser().getCurrentScript(), "event " + which, new SimpleEvent(), items))
);
}
SkriptLogger.setNode(null);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package org.skriptlang.reflect.syntax.expression.elements;

import ch.njol.skript.Skript;
import ch.njol.skript.classes.Changer;
import ch.njol.skript.classes.Changer.ChangeMode;
import ch.njol.skript.classes.ClassInfo;
import ch.njol.skript.config.Node;
import ch.njol.skript.config.SectionNode;
import ch.njol.skript.lang.ExpressionInfo;
import ch.njol.skript.lang.ExpressionType;
Expand Down Expand Up @@ -66,7 +65,7 @@ protected Class<?> getValue(String value) {
})
.addEntry("loop of", null, true)
.addSection("get", false);
Arrays.stream(Changer.ChangeMode.values())
Arrays.stream(ChangeMode.values())
.sorted((mode1, mode2) -> {
long words1 = StringUtils.count(mode1.toString(), '_');
long words2 = StringUtils.count(mode2.toString(), '_');
Expand All @@ -82,9 +81,9 @@ protected Class<?> getValue(String value) {
static final Map<ExpressionSyntaxInfo, Class<?>> returnTypes = new HashMap<>();
static final Map<ExpressionSyntaxInfo, Trigger> expressionHandlers = new HashMap<>();
static final Map<ExpressionSyntaxInfo, Trigger> parserHandlers = new HashMap<>();
static final Map<ExpressionSyntaxInfo, List<Changer.ChangeMode>> hasChanger = new HashMap<>();
static final Map<ExpressionSyntaxInfo, Map<Changer.ChangeMode, Trigger>> changerHandlers = new HashMap<>();
static final Map<ExpressionSyntaxInfo, Map<Changer.ChangeMode, Class<?>[]>> changerTypes = new HashMap<>();
static final Map<ExpressionSyntaxInfo, List<ChangeMode>> hasChanger = new HashMap<>();
static final Map<ExpressionSyntaxInfo, Map<ChangeMode, Trigger>> changerHandlers = new HashMap<>();
static final Map<ExpressionSyntaxInfo, Map<ChangeMode, Class<?>[]>> changerTypes = new HashMap<>();
static final Map<ExpressionSyntaxInfo, String> loopOfs = new HashMap<>();
static final Map<ExpressionSyntaxInfo, List<Supplier<Boolean>>> usableSuppliers = new HashMap<>();
static final Map<ExpressionSyntaxInfo, Boolean> parseSectionLoaded = new HashMap<>();
Expand All @@ -109,7 +108,7 @@ protected Class<?> getValue(String value) {
dataTracker.addManaged(parseSectionLoaded);
}

private final Map<Changer.ChangeMode, SectionNode> changerNodes = new HashMap<>();
private final Map<ChangeMode, SectionNode> changerNodes = new HashMap<>();
private SectionNode parseNode;

@Override
Expand Down Expand Up @@ -199,15 +198,15 @@ public boolean preLoad() {
if (usableInNode != null && !handleUsableEntry(usableInNode, usableSuppliers))
return false;

for (Changer.ChangeMode mode : Changer.ChangeMode.values()) {
for (ChangeMode mode : ChangeMode.values()) {
String name = mode.toString().replace('_', ' ').toLowerCase(Locale.ENGLISH);
NonNullPair<SectionNode, Class<?>[]> pair = entryContainer.getOptional(name, NonNullPair.class, false);
if (pair == null)
continue;
changerNodes.put(mode, pair.getFirst());

whichInfo.forEach(which -> {
List<Changer.ChangeMode> hasChangerList =
List<ChangeMode> hasChangerList =
hasChanger.computeIfAbsent(which, k -> new ArrayList<>());

hasChangerList.add(mode);
Expand Down Expand Up @@ -238,23 +237,22 @@ public boolean load() {
{
getParser().setCurrentEvent("custom expression getter", ExpressionGetEvent.class);
List<TriggerItem> items = SkriptUtil.getItemsFromNode(getNode);
whichInfo.forEach(which ->
expressionHandlers.put(which,
new Trigger(getParser().getCurrentScript(), "get " + which.getPattern(), new SimpleEvent(), items)));
whichInfo.forEach(which -> expressionHandlers.put(which,
new Trigger(getParser().getCurrentScript(), "get " + which.getPattern(), new SimpleEvent(), items))
);
}

changerNodes.forEach((changeMode, node) -> {
SkriptLogger.setNode(node);
getParser().setCurrentEvent("custom expression changer", ExpressionChangeEvent.class);
List<TriggerItem> items = SkriptUtil.getItemsFromNode(node);
whichInfo.forEach(which -> {
Map<Changer.ChangeMode, Trigger> changerMap =
changerHandlers.computeIfAbsent(which, k -> new HashMap<>());
Map<ChangeMode, Trigger> changerMap = changerHandlers.computeIfAbsent(which, k -> new HashMap<>());

String name = changeMode.toString().toLowerCase(Locale.ENGLISH).replace('_', ' ');
changerMap.put(changeMode,
new Trigger(getParser().getCurrentScript(),
String.format("%s %s", name, which.getPattern()), new SimpleEvent(), items));
changerMap.put(changeMode, new Trigger(
getParser().getCurrentScript(), String.format("%s %s", name, which.getPattern()), new SimpleEvent(), items
));
});
});

Expand Down

0 comments on commit 8365f67

Please sign in to comment.