Skip to content

Commit

Permalink
Update to 1.16.x (#83)
Browse files Browse the repository at this point in the history
* Fix PlayerInteractEvent firing on inventory click
* Translate BungeeCord format RGB colors
* Update newest Minecraft version
* Make Gui open delay 1.16+ exclusive
* Fix typo
  • Loading branch information
calumari authored Aug 22, 2020
1 parent c4835fd commit d684db8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
17 changes: 16 additions & 1 deletion helper/src/main/java/me/lucko/helper/menu/Gui.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
import me.lucko.helper.metadata.Metadata;
import me.lucko.helper.metadata.MetadataKey;
import me.lucko.helper.metadata.MetadataMap;
import me.lucko.helper.reflect.MinecraftVersion;
import me.lucko.helper.reflect.MinecraftVersions;
import me.lucko.helper.terminable.TerminableConsumer;
import me.lucko.helper.terminable.composite.CompositeTerminable;
import me.lucko.helper.text.Text;
Expand Down Expand Up @@ -256,10 +258,23 @@ public void clearItems() {
}

public void open() {
if (MinecraftVersion.getRuntimeVersion().isAfterOrEq(MinecraftVersions.v1_16)) {
// delay by a tick in 1.16+ to prevent an unwanted PlayerInteractEvent interfering with inventory clicks
Schedulers.sync().runLater(() -> {
if (!this.player.isOnline()) {
return;
}
handleOpen();
}, 1);
} else {
handleOpen();
}
}

private void handleOpen() {
if (this.valid) {
throw new IllegalStateException("Gui is already opened.");
}

this.firstDraw = true;
this.invalidated = false;
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ public final class MinecraftVersion implements Comparable<MinecraftVersion> {
/**
* The newest known version of Minecraft
*/
private static final String NEWEST_MINECRAFT_VERSION = "1.13.1";
private static final String NEWEST_MINECRAFT_VERSION = "1.16.2";

/**
* The date (with ISO 8601 or YYYY-MM-DD) when the most recent version was released.
*/
private static final String MINECRAFT_LAST_RELEASE_DATE = "2018-08-22";
private static final String MINECRAFT_LAST_RELEASE_DATE = "2020-08-11";

/**
* Gets the {@link MinecraftVersion} of the runtime server.
Expand Down
2 changes: 1 addition & 1 deletion helper/src/main/java/me/lucko/helper/text3/Text.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public static String decolorize(String s) {
public static String translateAlternateColorCodes(char from, char to, String textToTranslate) {
char[] b = textToTranslate.toCharArray();
for (int i = 0; i < b.length - 1; i++) {
if (b[i] == from && "0123456789AaBbCcDdEeFfKkLlMmNnOoRr".indexOf(b[i+1]) > -1) {
if (b[i] == from && "0123456789AaBbCcDdEeFfKkLlMmNnOoRrXx".indexOf(b[i+1]) > -1) {
b[i] = to;
b[i+1] = Character.toLowerCase(b[i+1]);
}
Expand Down

0 comments on commit d684db8

Please sign in to comment.