Skip to content

Commit

Permalink
Requested Changes, except async sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
sovdeeth committed Jun 3, 2024
1 parent ba922bc commit d42b8a1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/main/java/ch/njol/skript/effects/EffSort.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import ch.njol.util.Pair;
import org.bukkit.event.Event;
import org.eclipse.jdt.annotation.Nullable;
import org.jetbrains.annotations.UnknownNullability;

import java.util.HashSet;
import java.util.Iterator;
Expand Down Expand Up @@ -77,7 +78,7 @@ public class EffSort extends Effect implements InputSource {

@Nullable
private Object currentValue;
@Nullable
@UnknownNullability
private String currentIndex;

@Override
Expand Down Expand Up @@ -153,8 +154,7 @@ public boolean hasIndices() {
}

@Override
public String getCurrentIndex() {
assert currentIndex != null;
public @UnknownNullability String getCurrentIndex() {
return currentIndex;
}

Expand Down
12 changes: 9 additions & 3 deletions src/main/java/ch/njol/skript/expressions/ExprInput.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
import ch.njol.skript.lang.Literal;
import ch.njol.skript.lang.SkriptParser;
import ch.njol.skript.lang.util.SimpleExpression;
import ch.njol.skript.registrations.Classes;
import ch.njol.skript.registrations.DefaultClasses;
import ch.njol.skript.util.ClassInfoReference;
import ch.njol.skript.util.Utils;
import ch.njol.util.Kleenean;
import org.bukkit.event.Event;
Expand Down Expand Up @@ -99,14 +100,19 @@ public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelaye
return false;
switch (matchedPattern) {
case 1:
specifiedType = ((Literal<ClassInfo<?>>) exprs[0]).getSingle();
ClassInfoReference classInfoReference = ((Literal<ClassInfoReference>) ClassInfoReference.wrap((Expression<ClassInfo<?>>) exprs[0])).getSingle();
if (classInfoReference.isPlural().isTrue()) {
Skript.error("An input can only be a single value! Please use a singular type (for example: players input -> player input).");
return false;
}
specifiedType = classInfoReference.getClassInfo();
break;
case 2:
if (!inputSource.hasIndices()) {
Skript.error("You cannot use 'input index' on lists without indices!");
return false;
}
specifiedType = Classes.getExactClassInfo(String.class);
specifiedType = DefaultClasses.STRING;
isIndex = true;
break;
default:
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/ch/njol/skript/lang/InputSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import ch.njol.skript.expressions.ExprInput;
import ch.njol.skript.lang.parser.ParserInstance;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.UnknownNullability;

import java.util.Set;

Expand Down Expand Up @@ -58,7 +59,7 @@ default boolean hasIndices() {
*
* @return The current value's index.
*/
default String getCurrentIndex() {
default @UnknownNullability String getCurrentIndex() {
return null;
}

Expand Down

0 comments on commit d42b8a1

Please sign in to comment.