diff --git a/build.gradle b/build.gradle index 94e2880..a989430 100644 --- a/build.gradle +++ b/build.gradle @@ -1,8 +1,8 @@ plugins { - id 'com.github.johnrengelman.shadow' version '7.1.2' + id 'com.github.johnrengelman.shadow' version '8.1.1' id 'java' - id 'fabric-loom' version '1.1-SNAPSHOT' - id 'io.github.juuxel.loom-quiltflower' version '1.8.0' + id 'fabric-loom' version '1.2-SNAPSHOT' + id 'io.github.juuxel.loom-quiltflower' version '1.10.0' id 'maven-publish' } @@ -10,7 +10,7 @@ sourceCompatibility = JavaVersion.VERSION_17 targetCompatibility = JavaVersion.VERSION_17 archivesBaseName = project.archives_base_name -version = project.mod_version + "+" + project.minecraft_version +version = "${project.mod_version}+${rootProject.minecraft_base_version}" group = project.maven_group configurations { @@ -53,7 +53,7 @@ dependencies { modImplementation include('me.lucko:fabric-permissions-api:0.2-SNAPSHOT') shadow implementation("blue.endless:jankson:1.2.0") - modImplementation include('me.basiqueevangelist:onedatastore:0.1.2+1.19') { + modImplementation include("me.basiqueevangelist:onedatastore:${project.onedatastore_version}") { transitive = false } // PSA: Some older mods, compiled on Loom 0.2.1, might have outdated Maven POMs. diff --git a/gradle.properties b/gradle.properties index 5f3f196..fbefc10 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,9 +3,10 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://fabricmc.net/develop - minecraft_version=1.19.3 - yarn_mappings=1.19.3+build.5 - loader_version=0.14.13 + minecraft_base_version=1.20 + minecraft_version=1.20.1 + yarn_mappings=1.20.1+build.5 + loader_version=0.14.21 # Mod Properties mod_version = 1.3.1 @@ -13,5 +14,6 @@ org.gradle.jvmargs=-Xmx1G archives_base_name = pingspam # Dependencies - fabric_version=0.73.0+1.19.3 - modmenu_version=5.0.2 \ No newline at end of file + fabric_version=0.84.0+1.20.1 + modmenu_version=7.1.0 + onedatastore_version=0.1.3-pre.1+1.20 \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 41dfb87..fae0804 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/java/me/basiqueevangelist/pingspam/PingSpamConfig.java b/src/main/java/me/basiqueevangelist/pingspam/PingSpamConfig.java index a7e6dd7..f33a9d7 100644 --- a/src/main/java/me/basiqueevangelist/pingspam/PingSpamConfig.java +++ b/src/main/java/me/basiqueevangelist/pingspam/PingSpamConfig.java @@ -11,4 +11,11 @@ public class PingSpamConfig { @Comment("Process pings from messages with nil UUIDs. Disabling this will disallow pings from command blocks and the server console, but will also disallow random unprivileged discord users from pinging @everyone with a discord link.") public boolean processPingsFromUnknownPlayers = true; + + @Comment(""" + Makes Pingspam send all important packets to all clients, regardless of whether that client registered Pingspam + channels as receivable. + Can be important if your proxy somehow blocks these registrations. + """) + public boolean ignoreCanSend = false; } diff --git a/src/main/java/me/basiqueevangelist/pingspam/commands/AliasCommand.java b/src/main/java/me/basiqueevangelist/pingspam/commands/AliasCommand.java index c7275d0..c49ebb1 100644 --- a/src/main/java/me/basiqueevangelist/pingspam/commands/AliasCommand.java +++ b/src/main/java/me/basiqueevangelist/pingspam/commands/AliasCommand.java @@ -115,7 +115,7 @@ private static int removePlayerAlias(CommandContext ctx) th ServerNetworkLogic.removePossibleName(src.getServer().getPlayerManager(), alias); src.sendFeedback( - Text.literal("Removed alias ") + () -> Text.literal("Removed alias ") .formatted(Formatting.GREEN) .append(Text.literal('"' + alias + '"') .formatted(Formatting.YELLOW)) @@ -149,7 +149,7 @@ private static int addPlayerAlias(CommandContext ctx) throw ServerNetworkLogic.addPossibleName(src.getServer().getPlayerManager(), newAlias); src.sendFeedback( - Text.literal("Added alias ") + () -> Text.literal("Added alias ") .formatted(Formatting.GREEN) .append(Text.literal('"' + newAlias + '"') .formatted(Formatting.YELLOW)) @@ -188,7 +188,7 @@ private static int listPlayerAliases(CommandContext ctx) th headerBuilder.append('.'); } - src.sendFeedback(Text.literal(player.getName()) + src.sendFeedback(() -> Text.literal(player.getName()) .formatted(Formatting.AQUA) .append( Text.literal(headerBuilder.toString()) @@ -219,7 +219,7 @@ private static int removeAlias(CommandContext ctx) throws C if (!NameLogic.isValidName(src.getServer(), alias, false)) ServerNetworkLogic.removePossibleName(src.getServer().getPlayerManager(), alias); - src.sendFeedback(Text.literal("Removed alias ") + src.sendFeedback(() -> Text.literal("Removed alias ") .formatted(Formatting.GREEN) .append(Text.literal('"' + alias + '"') .formatted(Formatting.YELLOW)) @@ -249,7 +249,7 @@ private static int addAliases(CommandContext ctx) throws Co data.aliases().add(newAlias); ServerNetworkLogic.addPossibleName(src.getServer().getPlayerManager(), newAlias); - src.sendFeedback(Text.literal("Added alias ") + src.sendFeedback(() -> Text.literal("Added alias ") .formatted(Formatting.GREEN) .append(Text.literal('"' + newAlias + '"') .formatted(Formatting.YELLOW)) @@ -287,7 +287,7 @@ private static int listAliases(CommandContext ctx) throws C } src.sendFeedback( - Text.literal(headerBuilder.toString()) + () -> Text.literal(headerBuilder.toString()) .formatted(Formatting.GREEN) .append(Text.literal(contentBuilder.toString()) .formatted(Formatting.YELLOW)), false); diff --git a/src/main/java/me/basiqueevangelist/pingspam/commands/GroupCommand.java b/src/main/java/me/basiqueevangelist/pingspam/commands/GroupCommand.java index b1ad8ef..3212bbb 100644 --- a/src/main/java/me/basiqueevangelist/pingspam/commands/GroupCommand.java +++ b/src/main/java/me/basiqueevangelist/pingspam/commands/GroupCommand.java @@ -102,7 +102,7 @@ private static int listPlayersInGroup(CommandContext ctx) t headerBuilder.append('.'); } - src.sendFeedback(Text.literal("Group ") + src.sendFeedback(() -> Text.literal("Group ") .formatted(Formatting.GREEN) .append(Text.literal("@" + groupName) .formatted(Formatting.YELLOW)) @@ -132,7 +132,7 @@ private static int removePlayerFromGroup(CommandContext ctx ServerNetworkLogic.removePossibleName(src.getServer().getPlayerManager(), group); src.sendFeedback( - Text.literal("Removed player ") + () -> Text.literal("Removed player ") .formatted(Formatting.GREEN) .append(Text.literal(player.getName()) .formatted(Formatting.AQUA)) @@ -164,7 +164,7 @@ private static int addPlayerToGroup(CommandContext ctx) thr ServerNetworkLogic.addPossibleName(src.getServer().getPlayerManager(), group); src.sendFeedback( - Text.literal("Added player ") + () -> Text.literal("Added player ") .formatted(Formatting.GREEN) .append(Text.literal(player.getName()) .formatted(Formatting.AQUA)) diff --git a/src/main/java/me/basiqueevangelist/pingspam/commands/NotificationsCommand.java b/src/main/java/me/basiqueevangelist/pingspam/commands/NotificationsCommand.java index 1fc7d92..e57c808 100644 --- a/src/main/java/me/basiqueevangelist/pingspam/commands/NotificationsCommand.java +++ b/src/main/java/me/basiqueevangelist/pingspam/commands/NotificationsCommand.java @@ -31,21 +31,23 @@ public static int showNotifications(CommandContext ctx) thr PingspamPlayerData data = DataStore.getFor(src.getServer()).getPlayer(src.getPlayerOrThrow().getUuid(), PingSpam.PLAYER_DATA); if (!data.unreadPings().isEmpty()) { - MutableText response = Text.literal("You have " + data.unreadPings().size() + " unread message" + (data.unreadPings().size() != 1 ? "s" : "") + ":") - .formatted(Formatting.GREEN); - - for (Text notif : data.unreadPings()) { - response.append(Text.literal("\n- ") - .formatted(Formatting.WHITE) - .append(notif)); - } - - src.sendFeedback(response, false); + src.sendFeedback(() -> { + MutableText response = Text.literal("You have " + data.unreadPings().size() + " unread message" + (data.unreadPings().size() != 1 ? "s" : "") + ":") + .formatted(Formatting.GREEN); + + for (Text notif : data.unreadPings()) { + response.append(Text.literal("\n- ") + .formatted(Formatting.WHITE) + .append(notif)); + } + + return response; + }, false); data.unreadPings().clear(); return 1; } else { - src.sendFeedback(Text.literal("You have no unread messages.") + src.sendFeedback(() -> Text.literal("You have no unread messages.") .formatted(Formatting.GREEN), false); return 0; diff --git a/src/main/java/me/basiqueevangelist/pingspam/commands/PingIgnoreCommand.java b/src/main/java/me/basiqueevangelist/pingspam/commands/PingIgnoreCommand.java index b919cbd..8c1c97a 100644 --- a/src/main/java/me/basiqueevangelist/pingspam/commands/PingIgnoreCommand.java +++ b/src/main/java/me/basiqueevangelist/pingspam/commands/PingIgnoreCommand.java @@ -69,7 +69,7 @@ private static int addIgnoredPlayer(CommandContext ctx) thr data.ignoredPlayers().add(offender.getId()); - src.sendFeedback(Text.literal("You are now ignoring ") + src.sendFeedback(() -> Text.literal("You are now ignoring ") .formatted(Formatting.GREEN) .append(Text.literal(offender.getName()) .formatted(Formatting.AQUA)) @@ -89,7 +89,7 @@ private static int removeIgnoredPlayer(CommandContext ctx) data.ignoredPlayers().remove(pardonee.getId()); - src.sendFeedback(Text.literal("You are no longer ignoring ") + src.sendFeedback(() -> Text.literal("You are no longer ignoring ") .formatted(Formatting.GREEN) .append(Text.literal(pardonee.getName()) .formatted(Formatting.AQUA)) @@ -104,7 +104,7 @@ private static int listIgnoredPlayers(CommandContext ctx) t PingspamPlayerData data = DataStore.getFor(src.getServer()).getPlayer(player.getUuid(), PingSpam.PLAYER_DATA); if (data.ignoredPlayers().isEmpty()) { - src.sendFeedback(Text.literal("You are not ignoring any players.") + src.sendFeedback(() -> Text.literal("You are not ignoring any players.") .formatted(Formatting.GREEN), false); return 0; } @@ -114,7 +114,7 @@ private static int listIgnoredPlayers(CommandContext ctx) t contentBuilder.append("\n - ").append(NameUtil.getNameFromUUID(ignoredPlayerUuid)); } - src.sendFeedback(Text.literal("You are ignoring " + data.ignoredPlayers().size() + " player(s):") + src.sendFeedback(() -> Text.literal("You are ignoring " + data.ignoredPlayers().size() + " player(s):") .formatted(Formatting.GREEN) .append(Text.literal(contentBuilder.toString()) .formatted(Formatting.AQUA)), false); diff --git a/src/main/java/me/basiqueevangelist/pingspam/commands/PingSoundCommand.java b/src/main/java/me/basiqueevangelist/pingspam/commands/PingSoundCommand.java index 9de4041..b6abc66 100644 --- a/src/main/java/me/basiqueevangelist/pingspam/commands/PingSoundCommand.java +++ b/src/main/java/me/basiqueevangelist/pingspam/commands/PingSoundCommand.java @@ -45,7 +45,7 @@ private static int setPingSound(CommandContext ctx) throws data.setPingSound(event); - src.sendFeedback(Text.literal("Set ping sound to ") + src.sendFeedback(() -> Text.literal("Set ping sound to ") .formatted(Formatting.GREEN) .append(Text.literal(soundId.toString()) .formatted(Formatting.YELLOW)) @@ -61,7 +61,7 @@ private static int removePingSound(CommandContext ctx) thro data.setPingSound(null); - src.sendFeedback(Text.literal("Disabled ping sound.") + src.sendFeedback(() -> Text.literal("Disabled ping sound.") .formatted(Formatting.GREEN), false); return 0; @@ -73,13 +73,13 @@ private static int getPingSound(CommandContext ctx) throws PingspamPlayerData data = DataStore.getFor(src.getServer()).getPlayer(player.getUuid(), PingSpam.PLAYER_DATA); if (data.pingSound() != null) { - src.sendFeedback(Text.literal("Your current ping sound is ") + src.sendFeedback(() -> Text.literal("Your current ping sound is ") .formatted(Formatting.GREEN) .append(Text.literal(data.pingSound().getId().toString()) .formatted(Formatting.YELLOW)) .append(Text.literal(".")), false); } else { - src.sendFeedback(Text.literal("You have disabled ping sounds.") + src.sendFeedback(() -> Text.literal("You have disabled ping sounds.") .formatted(Formatting.GREEN), false); } diff --git a/src/main/java/me/basiqueevangelist/pingspam/mixin/ServerPlayerEntityMixin.java b/src/main/java/me/basiqueevangelist/pingspam/mixin/ServerPlayerEntityMixin.java index ab0275b..1c585c8 100644 --- a/src/main/java/me/basiqueevangelist/pingspam/mixin/ServerPlayerEntityMixin.java +++ b/src/main/java/me/basiqueevangelist/pingspam/mixin/ServerPlayerEntityMixin.java @@ -35,6 +35,7 @@ public ServerPlayerEntityMixin(World world, BlockPos pos, float yaw, GameProfile @Unique private PingspamPlayerData pingspamData; @Unique private int actionbarTime = 0; + @Unique private int prevPingsCount = -1; @Inject(method = "", at = @At("RETURN")) private void loadPingspamData(MinecraftServer server, ServerWorld world, GameProfile profile, CallbackInfo ci) { @@ -49,6 +50,11 @@ private void tick(CallbackInfo ci) { var pings = pingspamData.unreadPings(); + if (prevPingsCount != pings.size()) { + prevPingsCount = pings.size(); + actionbarTime = 0; + } + if (pings.size() > 0 && PingSpam.CONFIG.getConfig().showUnreadMessagesInActionbar) { actionbarTime--; diff --git a/src/main/java/me/basiqueevangelist/pingspam/network/ServerNetworkLogic.java b/src/main/java/me/basiqueevangelist/pingspam/network/ServerNetworkLogic.java index 89182ef..03c45ae 100644 --- a/src/main/java/me/basiqueevangelist/pingspam/network/ServerNetworkLogic.java +++ b/src/main/java/me/basiqueevangelist/pingspam/network/ServerNetworkLogic.java @@ -1,12 +1,13 @@ package me.basiqueevangelist.pingspam.network; +import me.basiqueevangelist.pingspam.PingSpam; import me.basiqueevangelist.pingspam.utils.NameLogic; import me.lucko.fabric.api.permissions.v0.Permissions; import net.fabricmc.fabric.api.networking.v1.PacketByteBufs; import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking; import net.minecraft.network.ClientConnection; -import net.minecraft.network.Packet; import net.minecraft.network.PacketByteBuf; +import net.minecraft.network.packet.Packet; import net.minecraft.server.PlayerManager; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.util.Identifier; @@ -53,7 +54,7 @@ public static void addPossibleName(PlayerManager manager, String possibleName) { public static void sendToAll(PlayerManager manager, Identifier channel, PacketByteBuf buf) { Packet packet = ServerPlayNetworking.createS2CPacket(channel, buf); for (ServerPlayerEntity player : manager.getPlayerList()) { - if (ServerPlayNetworking.canSend(player, channel)) + if (ServerPlayNetworking.canSend(player, channel) || PingSpam.CONFIG.getConfig().ignoreCanSend) player.networkHandler.sendPacket(packet); } } diff --git a/src/main/java/me/basiqueevangelist/pingspam/utils/OfflineUtil.java b/src/main/java/me/basiqueevangelist/pingspam/utils/OfflineUtil.java index f14ea46..9d52b3c 100644 --- a/src/main/java/me/basiqueevangelist/pingspam/utils/OfflineUtil.java +++ b/src/main/java/me/basiqueevangelist/pingspam/utils/OfflineUtil.java @@ -2,7 +2,6 @@ import me.basiqueevangelist.pingspam.PingSpam; import net.minecraft.datafixer.DataFixTypes; -import net.minecraft.datafixer.Schemas; import net.minecraft.nbt.NbtCompound; import net.minecraft.nbt.NbtHelper; import net.minecraft.nbt.NbtIo; @@ -31,8 +30,11 @@ public static NbtCompound get(UUID player) throws IOException { Path savedPlayersPath = PingSpam.SERVER.getSavePath(WorldSavePath.PLAYERDATA); Path savedDataPath = savedPlayersPath.resolve(player.toString() + ".dat"); NbtCompound rawTag = NbtIo.readCompressed(savedDataPath.toFile()); - int dataVersion = rawTag.contains("DataVersion", 3) ? rawTag.getInt("DataVersion") : -1; - return NbtHelper.update(Schemas.getFixer(), DataFixTypes.PLAYER, rawTag, dataVersion); + return DataFixTypes.PLAYER.update( + PingSpam.SERVER.getDataFixer(), + rawTag, + NbtHelper.getDataVersion(rawTag, -1) + ); } public static List listSavedPlayers() { diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 8076fde..aa9bb6d 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -46,8 +46,8 @@ "depends": { "fabricloader": ">=0.7.4", "fabric": "*", - "minecraft": "1.19.3", + "minecraft": "1.20.x", "fabric-permissions-api-v0": "*", - "onedatastore": ">=0.1.2" + "onedatastore": ">=0.1.3-pre.1" } }