Skip to content

Commit b41c375

Browse files
committed
Improve handling of 26.1 world clock changes
1 parent caffcb0 commit b41c375

2 files changed

Lines changed: 20 additions & 17 deletions

File tree

src/main/java/com/laytonsmith/abstraction/bukkit/BukkitMCWorld.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,12 @@ public MCChunk[] getForceLoadedChunks() {
471471

472472
@Override
473473
public void setTime(long time) {
474-
w.setTime(time);
474+
try {
475+
w.setTime(time);
476+
} catch(IllegalArgumentException ignored) {
477+
// Probably after Paper 26.1 for worlds without a world clock (nether by default).
478+
// Ignored for consistency across versions and implementations.
479+
}
475480
}
476481

477482
@Override
@@ -481,7 +486,12 @@ public long getTime() {
481486

482487
@Override
483488
public void setFullTime(long time) {
484-
w.setFullTime(time);
489+
try {
490+
w.setFullTime(time);
491+
} catch(IllegalArgumentException ignored) {
492+
// Probably after Paper 26.1 for worlds without a world clock (nether by default).
493+
// Ignored for consistency across versions and implementations.
494+
}
485495
}
486496

487497
@Override

src/main/java/com/laytonsmith/core/functions/World.java

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -896,10 +896,10 @@ public String docs() {
896896
StringBuilder doc = new StringBuilder();
897897
synchronized(World.class) {
898898
doc.append("void {[world], time} Sets the time of a given world."
899-
+ " As of MC 26.1 all overworld dimensions share a world clock and other dimensions will throw"
900-
+ " an InvalidWorldException. The time should be a number in ticks from 0 to 24000."
901-
+ " If not, it is modulo scaled. Alternatively, common time notation (9:30pm, 4:00 am) is"
902-
+ " acceptable, and convenient english mappings also exist:");
899+
+ " As of MC 26.1 some dimensions may not have a world clock. (e.g. nether)"
900+
+ " The time should be a number in ticks from 0 to 23999."
901+
+ " If not, it is modulo scaled. Common time notation (9:30pm, 4:00 am) is also"
902+
+ " accepted, and convenient english mappings also exist: ----");
903903
doc.append("<ul>");
904904
for(String key : TIME_LOOKUP.keySet()) {
905905
doc.append("<li>").append(key).append(" = ").append(TIME_LOOKUP.get(key)).append("</li>");
@@ -977,8 +977,6 @@ public Mixed exec(Target t, Environment environment, Mixed... args) throws Confi
977977
w.setTime(Long.parseLong(stime));
978978
} catch (NumberFormatException e) {
979979
throw new CREFormatException("Invalid time provided", t);
980-
} catch(IllegalArgumentException ex) {
981-
throw new CREInvalidWorldException(ex.getMessage(), t);
982980
}
983981
return CVoid.VOID;
984982
}
@@ -1000,7 +998,7 @@ public Integer[] numArgs() {
1000998
@Override
1001999
public String docs() {
10021000
return "int {[world]} Returns the time of the specified world, as an integer in ticks from 0 to 23999."
1003-
+ " As of MC 26.1 non-overworld dimensions do not have a world clock and will return 0.";
1001+
+ " As of MC 26.1 dimensions without a world clock will return 0. (e.g. nether)";
10041002
}
10051003

10061004
@Override
@@ -1055,8 +1053,7 @@ public Integer[] numArgs() {
10551053
@Override
10561054
public String docs() {
10571055
return "void {[world], day} Set the current day number of a given world."
1058-
+ " As of MC 26.1 all overworld dimensions share the same world clock and other dimensions will"
1059-
+ " throw an InvalidWorldException.";
1056+
+ " As of MC 26.1 some dimensions may not have a world clock. (e.g. nether)";
10601057
}
10611058

10621059
@Override
@@ -1097,11 +1094,7 @@ public Mixed exec(Target t, Environment environment, Mixed... args) throws Confi
10971094
throw new CRERangeException("Day cannot be negative.", t);
10981095
}
10991096

1100-
try {
1101-
w.setFullTime(((long) day * 24000) + w.getTime());
1102-
} catch(IllegalArgumentException ex) {
1103-
throw new CREInvalidWorldException(ex.getMessage(), t);
1104-
}
1097+
w.setFullTime(((long) day * 24000) + w.getTime());
11051098
return CVoid.VOID;
11061099
}
11071100
}
@@ -1122,7 +1115,7 @@ public Integer[] numArgs() {
11221115
@Override
11231116
public String docs() {
11241117
return "int {[world]} Returns the current day number of the specified world."
1125-
+ " As of MC 26.1 non-overworld dimensions do not have a world clock and will return 0.";
1118+
+ " As of MC 26.1 dimensions without a world clock will return 0. (e.g. nether)";
11261119
}
11271120

11281121
@Override

0 commit comments

Comments
 (0)