From 4f432c23e8e36917f2ad9829e8f48bcccdc6919e Mon Sep 17 00:00:00 2001 From: Dave Date: Thu, 25 Apr 2024 16:36:33 +0200 Subject: [PATCH] Release v3.9.7+fabric File explorer crash fix for Java 21, general tweaks and bug fixes, and port to 1.20.5. --- tcdcommons-3-fabric-1.20.1/gradle.properties | 1 - .../gui/panel/explorer/FileListPanel.java | 11 ++++++--- .../main/resources/assets/tcdcommons/icon.png | Bin 192 -> 1200 bytes .../src/main/resources/fabric.mod.json | 1 - tcdcommons-3-fabric-1.20.2/gradle.properties | 1 - .../gui/panel/explorer/FileListPanel.java | 11 ++++++--- .../main/resources/assets/tcdcommons/icon.png | Bin 192 -> 1200 bytes .../src/main/resources/fabric.mod.json | 1 - tcdcommons-3-fabric-1.20.4/gradle.properties | 1 - .../gui/panel/explorer/FileListPanel.java | 11 ++++++--- .../main/resources/assets/tcdcommons/icon.png | Bin 192 -> 1200 bytes .../src/main/resources/fabric.mod.json | 1 - .../buildsc.resources.gradle | 2 +- tcdcommons-3-fabric-1.20.5/gradle.properties | 1 - .../gui/panel/explorer/FileListPanel.java | 11 ++++++--- .../api/network/CustomPayloadNetwork.java | 10 ++++---- .../api/network/TCustomPayload.java | 22 ++++++++++++------ .../network/TCDCommonsNetworkHandler.java | 3 +-- .../resources/assets/tcdcommons/icon.aseprite | Bin 0 -> 1046 bytes .../main/resources/assets/tcdcommons/icon.png | Bin 192 -> 1200 bytes .../src/main/resources/fabric.mod.json | 4 ++-- 21 files changed, 56 insertions(+), 36 deletions(-) create mode 100644 tcdcommons-3-fabric-1.20.5/src/main/resources/assets/tcdcommons/icon.aseprite diff --git a/tcdcommons-3-fabric-1.20.1/gradle.properties b/tcdcommons-3-fabric-1.20.1/gradle.properties index a7367c7d..6f191c50 100644 --- a/tcdcommons-3-fabric-1.20.1/gradle.properties +++ b/tcdcommons-3-fabric-1.20.1/gradle.properties @@ -27,7 +27,6 @@ org.gradle.jvmargs=-Xmx1G modmenu_link_curseforge = https://www.curseforge.com/projects/711539 modmenu_link_modrinth = https://modrinth.com/mod/Eldc1g37 - modmenu_link_kofi = https://ko-fi.com/TheCSDev modmenu_link_youtube = https://www.youtube.com/@TheCSDev mod_license = LGPL-3.0-or-later diff --git a/tcdcommons-3-fabric-1.20.1/src/main/java/io/github/thecsdev/tcdcommons/api/client/gui/panel/explorer/FileListPanel.java b/tcdcommons-3-fabric-1.20.1/src/main/java/io/github/thecsdev/tcdcommons/api/client/gui/panel/explorer/FileListPanel.java index 876889aa..5d713e12 100644 --- a/tcdcommons-3-fabric-1.20.1/src/main/java/io/github/thecsdev/tcdcommons/api/client/gui/panel/explorer/FileListPanel.java +++ b/tcdcommons-3-fabric-1.20.1/src/main/java/io/github/thecsdev/tcdcommons/api/client/gui/panel/explorer/FileListPanel.java @@ -83,17 +83,22 @@ currPath.toFile() : currPath.getParent().toFile(); + final @Nullable var childDirectories = currFile.listFiles(File::isDirectory); + final @Nullable var childFiles = currFile.listFiles(File::isFile); + if(childDirectories == null || childFiles == null) + throw new SecurityException("Access denied."); + //add a "go back" list entry, allowing the user to navigate to the previous folder final var currFileParent = currFile.getParentFile(); if(currFileParent != null) addGoBackFileListItem(currFileParent); //iterate all child directories, and list them - for(final File childDir : currFile.listFiles(File::isDirectory)) + for(final File childDir : childDirectories) addFileListItem(childDir); //iterate all child non-directory files, and list them - for(final File childDir : currFile.listFiles(File::isFile)) - addFileListItem(childDir); + for(final File childFile : childFiles) + addFileListItem(childFile); } catch(SecurityException se) { diff --git a/tcdcommons-3-fabric-1.20.1/src/main/resources/assets/tcdcommons/icon.png b/tcdcommons-3-fabric-1.20.1/src/main/resources/assets/tcdcommons/icon.png index 88d8bc27fab08458fcaf984020816bf459208e5e..99cb3a84326f111dfceb90170604885f88f5b085 100644 GIT binary patch literal 1200 zcmeAS@N?(olHy`uVBq!ia0vp^4Is?H1SEZ8zRdwrjKx9jP7LeL$-HD>V9D}yaSW-L z^LCD-he)8r@%wFZ(+>2+ym&NAVdBHH4z@Z;?9Zj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arjar").toString(), include: '*.jar') .each { jarFile -> fmj_jars.add(rssDirPath.relativize(jarFile.toPath()).toString().replace('\\', '/')) }; fmj_jars = fmj_jars.collect { jarFile -> "{ \"file\": \"${jarFile}\" }" }; fmj_jars = "\", \"jars\": [" + fmj_jars.join(', ') + "], \"\": \""; diff --git a/tcdcommons-3-fabric-1.20.5/gradle.properties b/tcdcommons-3-fabric-1.20.5/gradle.properties index 44ceb972..f3e6b5d0 100644 --- a/tcdcommons-3-fabric-1.20.5/gradle.properties +++ b/tcdcommons-3-fabric-1.20.5/gradle.properties @@ -38,7 +38,6 @@ org.gradle.jvmargs=-Xmx1G modmenu_link_curseforge = https://www.curseforge.com/projects/711539 modmenu_link_modrinth = https://modrinth.com/mod/Eldc1g37 - modmenu_link_kofi = https://ko-fi.com/TheCSDev modmenu_link_youtube = https://www.youtube.com/@TheCSDev # The name of the license that applies to this project. diff --git a/tcdcommons-3-fabric-1.20.5/src/main/java/io/github/thecsdev/tcdcommons/api/client/gui/panel/explorer/FileListPanel.java b/tcdcommons-3-fabric-1.20.5/src/main/java/io/github/thecsdev/tcdcommons/api/client/gui/panel/explorer/FileListPanel.java index 876889aa..5d713e12 100644 --- a/tcdcommons-3-fabric-1.20.5/src/main/java/io/github/thecsdev/tcdcommons/api/client/gui/panel/explorer/FileListPanel.java +++ b/tcdcommons-3-fabric-1.20.5/src/main/java/io/github/thecsdev/tcdcommons/api/client/gui/panel/explorer/FileListPanel.java @@ -83,17 +83,22 @@ currPath.toFile() : currPath.getParent().toFile(); + final @Nullable var childDirectories = currFile.listFiles(File::isDirectory); + final @Nullable var childFiles = currFile.listFiles(File::isFile); + if(childDirectories == null || childFiles == null) + throw new SecurityException("Access denied."); + //add a "go back" list entry, allowing the user to navigate to the previous folder final var currFileParent = currFile.getParentFile(); if(currFileParent != null) addGoBackFileListItem(currFileParent); //iterate all child directories, and list them - for(final File childDir : currFile.listFiles(File::isDirectory)) + for(final File childDir : childDirectories) addFileListItem(childDir); //iterate all child non-directory files, and list them - for(final File childDir : currFile.listFiles(File::isFile)) - addFileListItem(childDir); + for(final File childFile : childFiles) + addFileListItem(childFile); } catch(SecurityException se) { diff --git a/tcdcommons-3-fabric-1.20.5/src/main/java/io/github/thecsdev/tcdcommons/api/network/CustomPayloadNetwork.java b/tcdcommons-3-fabric-1.20.5/src/main/java/io/github/thecsdev/tcdcommons/api/network/CustomPayloadNetwork.java index 657e4767..24f35311 100644 --- a/tcdcommons-3-fabric-1.20.5/src/main/java/io/github/thecsdev/tcdcommons/api/network/CustomPayloadNetwork.java +++ b/tcdcommons-3-fabric-1.20.5/src/main/java/io/github/thecsdev/tcdcommons/api/network/CustomPayloadNetwork.java @@ -76,12 +76,12 @@ private CustomPayloadNetwork() {} public static boolean unregisterReceiver(NetworkSide side, Identifier packetId) { Objects.requireNonNull(packetId); - switch(Objects.requireNonNull(side)) + return switch (Objects.requireNonNull(side)) { - case SERVERBOUND: return (C2S.remove(packetId) != null); - case CLIENTBOUND: return (S2C.remove(packetId) != null); - default: return false; - } + case SERVERBOUND -> (C2S.remove(packetId) != null); + case CLIENTBOUND -> (S2C.remove(packetId) != null); + default -> false; + }; } // -------------------------------------------------- /** diff --git a/tcdcommons-3-fabric-1.20.5/src/main/java/io/github/thecsdev/tcdcommons/api/network/TCustomPayload.java b/tcdcommons-3-fabric-1.20.5/src/main/java/io/github/thecsdev/tcdcommons/api/network/TCustomPayload.java index 9df73974..63950a91 100644 --- a/tcdcommons-3-fabric-1.20.5/src/main/java/io/github/thecsdev/tcdcommons/api/network/TCustomPayload.java +++ b/tcdcommons-3-fabric-1.20.5/src/main/java/io/github/thecsdev/tcdcommons/api/network/TCustomPayload.java @@ -2,12 +2,14 @@ import io.github.thecsdev.tcdcommons.TCDCommons; import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; import net.minecraft.network.PacketByteBuf; import net.minecraft.network.codec.PacketCodec; import net.minecraft.network.packet.CustomPayload; import net.minecraft.util.Identifier; import org.jetbrains.annotations.ApiStatus; +import java.util.List; import java.util.Objects; import static io.github.thecsdev.tcdcommons.api.network.CustomPayloadNetwork.CPN_PACKET_ID; @@ -21,26 +23,27 @@ public final class TCustomPayload implements CustomPayload { // ================================================== public static final Id ID = new Id<>(CPN_PACKET_ID); - public static final PacketCodec CODEC = - PacketCodec.of(TCustomPayload::encode, TCustomPayload::decode); + public static final PacketCodec CODEC; // -------------------------------------------------- private final Identifier packetId; private final ByteBuf packetPayload; // ================================================== + static + { + CODEC = PacketCodec.of(TCustomPayload::encode, TCustomPayload::decode); + } + // -------------------------------------------------- public TCustomPayload(Identifier packetId, ByteBuf packetPayload) { this.packetId = Objects.requireNonNull(packetId); this.packetPayload = Objects.requireNonNull(packetPayload); } - // -------------------------------------------------- + // ================================================== public final @Override Id getId() { return ID; } // -------------------------------------------------- @SuppressWarnings("removal") protected final @Override void finalize() throws Throwable { - //finialize super - super.finalize(); - //finalize this try { @@ -49,6 +52,7 @@ public TCustomPayload(Identifier packetId, ByteBuf packetPayload) this.packetPayload.release(); } catch (Exception e) {} + finally { super.finalize(); } //finialize super } // ================================================== public final Identifier getPacketId() { return this.packetId; } @@ -82,7 +86,11 @@ private static void encode(TCustomPayload value, PacketByteBuf buffer) */ private static TCustomPayload decode(PacketByteBuf buffer) { - return null; + final var packetId = buffer.readIdentifier(); + final var packetDataLen = buffer.readIntLE(); + final var packetDataBytes = new byte[packetDataLen]; + buffer.readBytes(packetDataBytes); + return new TCustomPayload(packetId, Unpooled.wrappedBuffer(packetDataBytes)); } // ================================================== } \ No newline at end of file diff --git a/tcdcommons-3-fabric-1.20.5/src/main/java/io/github/thecsdev/tcdcommons/network/TCDCommonsNetworkHandler.java b/tcdcommons-3-fabric-1.20.5/src/main/java/io/github/thecsdev/tcdcommons/network/TCDCommonsNetworkHandler.java index 38490a90..ceb7ecdd 100644 --- a/tcdcommons-3-fabric-1.20.5/src/main/java/io/github/thecsdev/tcdcommons/network/TCDCommonsNetworkHandler.java +++ b/tcdcommons-3-fabric-1.20.5/src/main/java/io/github/thecsdev/tcdcommons/network/TCDCommonsNetworkHandler.java @@ -22,7 +22,6 @@ public final class TCDCommonsNetworkHandler extends Object { - // ================================================== /** * The unique {@link Identifier} of the {@link CustomPayloadS2CPacket} @@ -41,7 +40,7 @@ private TCDCommonsNetworkHandler() {} PayloadTypeRegistry.playS2C().register(TCustomPayload.ID, TCustomPayload.CODEC); //obtain CPN packet ID - final var cpnPacketId = AccessorCustomPayloadNetwork.getCpnPacketId(); + //final var cpnPacketId = AccessorCustomPayloadNetwork.getCpnPacketId(); final var c2s = AccessorCustomPayloadNetwork.getC2S(); final var s2c = AccessorCustomPayloadNetwork.getS2C(); diff --git a/tcdcommons-3-fabric-1.20.5/src/main/resources/assets/tcdcommons/icon.aseprite b/tcdcommons-3-fabric-1.20.5/src/main/resources/assets/tcdcommons/icon.aseprite new file mode 100644 index 0000000000000000000000000000000000000000..3aebd3dab8ae14e12aeae0a3a3721c74648a674a GIT binary patch literal 1046 zcmWe*VPJT$l#!tU2o)F@85kH+fEWRo7#Kl<3<5w%3ownDf#KIj4zR5pKnuixm|X#E zC6aX@yIDZ4V~U7~`2YXE5{R$BkEG&1kj=&5l$e~IUX)*&m!b$(0W=&AKq@#Hd@_@Y z5{oiZiw%HW76o(#5)7Uxso4tU8HptdB^jB;3P6;cn3I#5vKeSQs{+Kd|4a~?0UT@< zbKc(A?R&&Qpy8p|idMG?dP`ZN6cqM~ojB2Z|&dt@8WhU{rzk`*KdB^?Q<9E_st8- z{#AS>FZliEu!*mD-G5m zJ%2CG-}QHU%hELe7wh-`GyHo|9*VxN`d+^9 z-{V`4?l=59=%slU<}?f>`d_4@ki z|M$+9{(bziesA`PYxcr_v%l|uX8Ym#$FJ*kqyNX9|9|hx_4xYNV6~{k|E>F98bbpM zH7FhIgEx_+XIO}65DQ@4wjrAH^8wygiYvircA?!WcB>vKd@c9gglNtSNRuUXBY z`6{+@c1m7sj$Uk+UeBjZ21mh`GBH>%L?T(r54QB|B||TjDgDg+B=vFYF=_{Up!g76{!UF-#rJLS;HBfAsTI!Z{U=dr= zd+QDJ>z1(BSle8aOIrGUpVtV9D}yaSW-L z^LCD-he)8r@%wFZ(+>2+ym&NAVdBHH4z@Z;?9Zj%E!2DHDI63aV5)yr)wpFz*tHGa zHx}}_v2%XDaI~3g-E<9Amh5jzITKhOZaq9XGa^+s{oa}Sd*}X_7s@=}Tf66e&HeB9 zoXxI<+G=w26~AC~k>z4=W=zmv;9+f8$Y3DC(8hEifI)&}L7&#?$GZ2shx9sUUlO0c zGw(D9$XJ`D3MU^&zu!~7NR!|G&bJ%P$_F%$Ma(q}EB|v#nM-K_hr06bFJG2_Zufty z;t_IocPkTP>mT{w>)YGg&&{@|yz%h)ud}m%$6pHO{bVKAzxvX75f-;vt|*y%UtcEb zTzjo=cJwWvIe5ws&3oV%QLVwy z^J{K_h{u(%m9M%4QT^HT>+p`0DRN{vu4e@6x`a^*Z1$4<#XP%HE|q@kEZ{X2;H>ol6Uc3mNRAR zQ;U49t*tvX__ncSH64wnoH5eY_@3X#EB(c4Av_{v}T`O z7PRtGzpQSfUD+>lq07<5x~yPRY+IcYOG`~{OV@r8uT(^q*3ssFb>-7MNLmuC@^ zx0J8>PQT?MD(Ur0iaq!JEBh7o?03|&*0xBG*&Gw@WN2?)w7=@_(eL?|zvu4BVGHmHagB(G z`2YXE^Sy0A0fr1u7srr_Id88Raxp0IusHtxzx*w$V4&xPn^pzEOGP{=${project.properties.loader_version}", "minecraft": "${project.properties.mod_depends_minecraft}", - "java": ">=17" + "java": ">=17", + "fabric-api": "*" }, "custom": @@ -43,7 +44,6 @@ { "modmenu.curseforge": "${project.properties.modmenu_link_curseforge}", "modmenu.modrinth": "${project.properties.modmenu_link_modrinth}", - "modmenu.kofi": "${project.properties.modmenu_link_kofi}", "modmenu.youtube": "${project.properties.modmenu_link_youtube}" } }