Skip to content

Commit

Permalink
Merge branch 'dev/patch' into fix-time
Browse files Browse the repository at this point in the history
  • Loading branch information
sovdeeth authored Sep 22, 2024
2 parents 7486ff9 + 0a8bac3 commit 5f48eb1
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 26 deletions.
4 changes: 2 additions & 2 deletions src/main/java/ch/njol/skript/conditions/CondIsWithin.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,15 @@ public boolean check(Event event) {
Location one = loc1.getSingle(event);
Location two = loc2.getSingle(event);
if (one == null || two == null || one.getWorld() != two.getWorld())
return false;
return isNegated();
AABB box = new AABB(one, two);
return locsToCheck.check(event, box::contains, isNegated());
}

// else, within an entity/block/chunk/world
Object area = this.area.getSingle(event);
if (area == null)
return false;
return isNegated();

// Entities
if (area instanceof Entity) {
Expand Down
15 changes: 9 additions & 6 deletions src/main/java/ch/njol/skript/expressions/ExprHoverList.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public void change(Event event, @Nullable Object[] delta, ChangeMode mode) {

if (HAS_NEW_LISTED_PLAYER_INFO) {
List<PaperServerListPingEvent.ListedPlayerInfo> values = new ArrayList<>();
if (mode != ChangeMode.DELETE && mode != ChangeMode.RESET) {
if (mode != ChangeMode.DELETE && mode != ChangeMode.RESET && mode != ChangeMode.REMOVE) {
for (Object object : delta) {
if (object instanceof Player) {
Player player = (Player) object;
Expand All @@ -124,7 +124,9 @@ public void change(Event event, @Nullable Object[] delta, ChangeMode mode) {
sample.addAll(values);
break;
case REMOVE:
sample.removeAll(values);
for (Object value : delta) {
sample.removeIf(profile -> profile.name().equals(value));
}
break;
case DELETE:
case RESET:
Expand All @@ -135,7 +137,7 @@ public void change(Event event, @Nullable Object[] delta, ChangeMode mode) {
}

List<PlayerProfile> values = new ArrayList<>();
if (mode != ChangeMode.DELETE && mode != ChangeMode.RESET) {
if (mode != ChangeMode.DELETE && mode != ChangeMode.RESET && mode != ChangeMode.REMOVE) {
for (Object object : delta) {
if (object instanceof Player) {
Player player = (Player) object;
Expand All @@ -150,13 +152,14 @@ public void change(Event event, @Nullable Object[] delta, ChangeMode mode) {
switch (mode) {
case SET:
sample.clear();
sample.addAll(values);
break;
// $FALL-THROUGH$
case ADD:
sample.addAll(values);
break;
case REMOVE:
sample.removeAll(values);
for (Object value : delta) {
sample.removeIf(profile -> profile.getName() != null && profile.getName().equals(value));
}
break;
case DELETE:
case RESET:
Expand Down
10 changes: 9 additions & 1 deletion src/main/java/ch/njol/skript/lang/SkriptParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -1181,7 +1181,15 @@ public static String notOfType(Class<?>... types) {
}
Class<?> c = types[i];
assert c != null;
message.append(Classes.getSuperClassInfo(c).getName().withIndefiniteArticle());
ClassInfo<?> classInfo = Classes.getSuperClassInfo(c);
// if there's a registered class info,
if (classInfo != null) {
// use the article,
message.append(classInfo.getName().withIndefiniteArticle());
} else {
// otherwise fallback to class name
message.append(c.getName());
}
}
return message.toString();
}
Expand Down
10 changes: 6 additions & 4 deletions src/main/java/org/skriptlang/skript/bukkit/SkriptMetrics.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,14 @@ public static void setupMetrics(Metrics metrics) {

metrics.addCustomChart(new DrilldownPie("drilldownLogVerbosity", () -> {
String verbosity = SkriptConfig.verbosity.value().name().toLowerCase(Locale.ENGLISH).replace('_', ' ');
return isDefaultMap(verbosity, SkriptConfig.verbosity.defaultValue());
String defaultValue = SkriptConfig.verbosity.defaultValue().name().toLowerCase(Locale.ENGLISH).replace('_', ' ');
return isDefaultMap(verbosity, defaultValue);
}));

metrics.addCustomChart(new DrilldownPie("drilldownPluginPriority", () -> {
String priority = SkriptConfig.defaultEventPriority.value().name().toLowerCase(Locale.ENGLISH).replace('_', ' ');
return isDefaultMap(priority, SkriptConfig.defaultEventPriority.defaultValue());
String defaultValue = SkriptConfig.defaultEventPriority.defaultValue().name().toLowerCase(Locale.ENGLISH).replace('_', ' ');
return isDefaultMap(priority, defaultValue);
}));
metrics.addCustomChart(new SimplePie("cancelledByDefault", () ->
SkriptConfig.listenCancelledByDefault.value().toString()
Expand All @@ -143,10 +145,10 @@ public static void setupMetrics(Metrics metrics) {
SkriptConfig.caseSensitive.value().toString()
));
metrics.addCustomChart(new SimplePie("caseSensitiveVariables", () ->
SkriptConfig.caseInsensitiveVariables.value().toString()
String.valueOf(!SkriptConfig.caseInsensitiveVariables.value())
));
metrics.addCustomChart(new SimplePie("caseSensitiveCommands", () ->
SkriptConfig.caseInsensitiveCommands.value().toString()
String.valueOf(!SkriptConfig.caseInsensitiveCommands.value())
));

metrics.addCustomChart(new SimplePie("disableSaveWarnings", () ->
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/config.sk
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
# ==== General Options ====

language: english
# Which language to use. Currently English, German, Korean, French, Polish, Russian, Japanese, Simplified Chinese and Turkish
# Which language to use. Currently English, German, Korean, French, Polish, Russian, Japanese, Simplified Chinese, Turkish and Dutch
# are included in the download, but custom languages can be created as well. Use the name in lowercase and no spaces as the value.
# Please note that not everything can be translated yet, i.e. parts of Skript will still be english if you use another language.
# If you want to translate Skript to your language please read the readme.txt located in the /lang/ folder in the jar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ test "EffHealth item mutation fix":

set {_item1} to diamond sword with damage 100
set {_item2} to diamond with damage 10
repair {_item1}, {_item2}
repair {_item1} and {_item2}
assert {_item1} is diamond sword with damage 0 with "{_item1} was incorrectly repaired"
assert {_item2} is diamond with "{_item2} was no longer a diamond"
14 changes: 7 additions & 7 deletions src/test/skript/tests/syntaxes/conditions/CondCompare.sk
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ test "compare":
assert 1 is greater than or equal to 0 and 1 with "Number is not greater than or equal to two smaller/equal numbers"
assert 1 is less than or equal to 1 and 2 with "Number is not smaller than or equal to two greater/equal numbers"

assert 1, 2 is 1, 2 with "direct list comparison of equal numbers failed"
assert 1, 2, 3 is not 1, 2 with "direct list comparison of non-equal numbers succeeded"
assert 1, 2 is 1, 2, or 3 with "comparison between AND list of numbers and OR list of superset of numbers failed"
assert 1, 2, 3 is 1 or 2 to fail with "comparison between AND list of numbers and OR list of subset of numbers succeeded"
assert 1 and 2 is 1 and 2 with "direct list comparison of equal numbers failed"
assert 1, 2, and 3 is not 1 and 2 with "direct list comparison of non-equal numbers succeeded"
assert 1 and 2 is 1, 2, or 3 with "comparison between AND list of numbers and OR list of superset of numbers failed"
assert 1, 2, and 3 is 1 or 2 to fail with "comparison between AND list of numbers and OR list of subset of numbers succeeded"

assert 1, 2, 3 is greater than -1, -2, -3 with "Numbers are not larger than smaller numbers"
assert 1, 2, 3 is less than 5, 6, 7 with "Numbers are not smaller than larger numbers"
assert 1, 2, 3 is between -1, 1 and 3, 3.5 with "Numbers are not between smaller/equal numbers and larger/equal numbers"
assert 1, 2, and 3 is greater than -1, -2, and -3 with "Numbers are not larger than smaller numbers"
assert 1, 2, and 3 is less than 5, 6, and 7 with "Numbers are not smaller than larger numbers"
assert 1, 2, and 3 is between (-1 and 1) and (3 and 3.5) with "Numbers are not between smaller/equal numbers and larger/equal numbers"

assert 10 is between 5 and 15 with "Number isn't between smaller and larger"
assert 10 is between 9 and 11 with "Number isn't between smaller and larger"
Expand Down
2 changes: 2 additions & 0 deletions src/test/skript/tests/syntaxes/conditions/CondIsWithin.sk
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ test "within condition" when running minecraft "1.17":
set {_loc2} to location(20, 20, 20, "world")
assert location(10, 10, 10, "world") is within {_loc1} and {_loc2} with "failed within two locs"
assert location(10, -10, 10, "world") is not within {_loc1} and {_loc2} with "failed within two locs"
assert location(0, 0, 0, "world") is not within {_none} and {_none} with "failed within two locs"

# chunks
set {_chunk1} to chunk at {_loc1}
Expand Down Expand Up @@ -37,6 +38,7 @@ test "within condition" when running below minecraft "1.17":
set {_loc2} to location(20, 20, 20, "world")
assert location(10, 10, 10, "world") is within {_loc1} and {_loc2} with "failed within two locs"
assert location(10, -10, 10, "world") is not within {_loc1} and {_loc2} with "failed within two locs"
assert location(0, 0, 0, "world") is not within {_none} and {_none} with "failed within two locs"

# chunks
set {_chunk1} to chunk at {_loc1}
Expand Down
6 changes: 3 additions & 3 deletions src/test/skript/tests/syntaxes/expressions/ExprRepeat.sk
Original file line number Diff line number Diff line change
Expand Up @@ -43,23 +43,23 @@ test "repeat expression":
then:
assert false is true with "ExprRepeat Multi - 1) 'aa' and 'b' repeated 3 times is not 'aaaaaa' and 'bbb'"

set {_strings::*} to "aa", "b"
set {_strings::*} to "aa" and "b"
set {_strings::*} to {_strings::*} repeated {_repeat} times
if any:
{_strings::1} is not "aaaaaa"
{_strings::2} is not "bbb"
then:
assert false is true with "ExprRepeat Multi - 2) 'aa' and 'b' repeated 3 times is not 'aaaaaa' and 'bbb'"

set {_strings::*} to "aa", "b"
set {_strings::*} to "aa" and "b"
set {_strings::*} to {_strings::*} repeated 3 times
if any:
{_strings::1} is not "aaaaaa"
{_strings::2} is not "bbb"
then:
assert false is true with "ExprRepeat Multi - 3) 'aa' and 'b' repeated 3 times is not 'aaaaaa' and 'bbb'"

set {_strings::*} to "aa", "b" repeated {_repeat} times
set {_strings::*} to "aa" and "b" repeated {_repeat} times
if any:
{_strings::1} is not "aaaaaa"
{_strings::2} is not "bbb"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
test "string cases":
assert caseEquals("Oops!" in lowercase, "oops!") is true with "lowercase failed"
assert caseEquals("Oops!" in uppercase, "OOPS!") is true with "uppercase failed"
assert caseEquals(capitalised "Oops!", "OOPS!") is true with "capitalised failed"
assert caseEquals((capitalised "Oops!"), "OOPS!") is true with "capitalised failed"
assert caseEquals("hellO i'm steve!" in proper case, "HellO I'm Steve!") is true with "lenient proper case failed"
assert caseEquals("hellO i'm steve!" in strict proper case, "Hello I'm Steve!") is true with "strict proper case failed"
assert caseEquals("spAwn neW boSs ()" in camel case, "spAwnNeWBoSs()") is true with "lenient camel case failed"
Expand Down

0 comments on commit 5f48eb1

Please sign in to comment.