Skip to content

Commit

Permalink
1.20.4 update
Browse files Browse the repository at this point in the history
  • Loading branch information
allanf181 committed Jan 12, 2024
1 parent c12ed47 commit 29fc584
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 41 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id "architectury-plugin" version "3.4-SNAPSHOT"
id "dev.architectury.loom" version "1.1-SNAPSHOT" apply false
id "dev.architectury.loom" version "1.4-SNAPSHOT" apply false
}

architectury {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,13 @@ public void onMessageReceived(@NotNull MessageReceivedEvent e) {
"```\n=============== Online Players (" + onlinePlayers.size() + ") ===============\n"
);
for (ServerPlayer player : onlinePlayers) {
playerList.append("\n").append(player.getScoreboardName()).append("\t").append(player.latency).append("ms");
playerList.append("\n").append(player.getScoreboardName()).append("\t").append(player.connection.latency()).append("ms");
}
playerList.append("```");
e.getChannel().sendMessage(playerList.toString()).queue();
} else if (e.getMessage().getContentRaw().startsWith("!tps")) {
StringBuilder tpss = new StringBuilder("Server TPS: ");
double serverTickTime = Utils.average(server.tickTimes) * 1.0E-6D;
tpss.append(Math.min(1000.0 / serverTickTime, 20));
tpss.append(Math.min(1000.0 / server.getCurrentSmoothedTickTime(), 20));
e.getChannel().sendMessage(tpss.toString()).queue();
} else if(e.getMessage().getContentRaw().startsWith("!help")){
String help = """
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import dev.architectury.event.events.common.EntityEvent;
import dev.architectury.event.events.common.PlayerEvent;
import net.dv8tion.jda.api.utils.MarkdownSanitizer;
import net.minecraft.advancements.Advancement;
import net.minecraft.network.chat.Component;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.util.Tuple;
Expand Down Expand Up @@ -52,12 +53,13 @@ public void init() {
return CompoundEventResult.pass();
});

PlayerEvent.PLAYER_ADVANCEMENT.register((playerEntity, advancement) -> {
if (DisChatBridge.config.announceAdvancements && advancement.getDisplay() != null && advancement.getDisplay().shouldAnnounceChat() && !DisChatBridge.stop) {
switch (advancement.getDisplay().getFrame()) {
case GOAL -> DisChatBridge.textChannel.sendMessage(DisChatBridge.config.texts.advancementGoal.replace("%playername%", MarkdownSanitizer.escape(playerEntity.getScoreboardName())).replace("%advancement%", MarkdownSanitizer.escape(advancement.getDisplay().getTitle().getString()))).queue();
case TASK -> DisChatBridge.textChannel.sendMessage(DisChatBridge.config.texts.advancementTask.replace("%playername%", MarkdownSanitizer.escape(playerEntity.getScoreboardName())).replace("%advancement%", MarkdownSanitizer.escape(advancement.getDisplay().getTitle().getString()))).queue();
case CHALLENGE -> DisChatBridge.textChannel.sendMessage(DisChatBridge.config.texts.advancementChallenge.replace("%playername%", MarkdownSanitizer.escape(playerEntity.getScoreboardName())).replace("%advancement%", MarkdownSanitizer.escape(advancement.getDisplay().getTitle().getString()))).queue();
PlayerEvent.PLAYER_ADVANCEMENT.register((playerEntity, advancementHolder) -> {
Advancement advancement = advancementHolder.value();
if (DisChatBridge.config.announceAdvancements && advancement.display().isPresent() && advancement.display().get().shouldAnnounceChat() && !DisChatBridge.stop) {
switch (advancement.display().get().getType()) {
case GOAL -> DisChatBridge.textChannel.sendMessage(DisChatBridge.config.texts.advancementGoal.replace("%playername%", MarkdownSanitizer.escape(playerEntity.getScoreboardName())).replace("%advancement%", MarkdownSanitizer.escape(advancement.display().get().getTitle().getString()))).queue();
case TASK -> DisChatBridge.textChannel.sendMessage(DisChatBridge.config.texts.advancementTask.replace("%playername%", MarkdownSanitizer.escape(playerEntity.getScoreboardName())).replace("%advancement%", MarkdownSanitizer.escape(advancement.display().get().getTitle().getString()))).queue();
case CHALLENGE -> DisChatBridge.textChannel.sendMessage(DisChatBridge.config.texts.advancementChallenge.replace("%playername%", MarkdownSanitizer.escape(playerEntity.getScoreboardName())).replace("%advancement%", MarkdownSanitizer.escape(advancement.display().get().getTitle().getString()))).queue();
}
}
});
Expand Down
10 changes: 0 additions & 10 deletions common/src/main/java/one/armelin/dischatbridge/utils/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,6 @@ public static Tuple<String, String> convertMentionsFromNames(String message) {
return new Tuple<>(discordString.toString(), mcString.toString());
}

public static double average(long[] values) {
long l = 0L;

for (long m : values) {
l += m;
}

return (double)l / (double)values.length;
}

public static String sanitize(String text, boolean always) {
return text
.replace("§", (DisChatBridge.config.texts.removeVanillaFormattingFromDiscord || always) ? "&" : "§")
Expand Down
4 changes: 2 additions & 2 deletions curse_upload
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ cd ../../../
FILE_LOCATION=`echo "./forge/build/libs/$FILE_NAME"`

#See https://github.com/curseforge/api for how to retrieve game version numbers
JSON=`printf '{"changelog": "%s", "gameVersions": [9639,7498,10150,9990], "releaseType": "release"}' "$CHANGE_LOG"`
JSON=`printf '{"changelog": "%s", "gameVersions": [9639,7498,10150,10407], "releaseType": "release"}' "$CHANGE_LOG"`

echo "Uploading $FILE_NAME to Curse Forge..."
echo
Expand All @@ -26,7 +26,7 @@ cd ../../../
FILE_LOCATION=`echo "./fabric/build/libs/$FILE_NAME"`

#See https://github.com/curseforge/api for how to retrieve game version numbers
JSON=`printf '{"changelog": "%s", "gameVersions": [9639,7499,9153,9990], "releaseType": "release"}' "$CHANGE_LOG"`
JSON=`printf '{"changelog": "%s", "gameVersions": [9639,7499,9153,10407], "releaseType": "release"}' "$CHANGE_LOG"`

echo "Uploading $FILE_NAME to Curse Forge..."
echo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
import net.minecraft.network.chat.ChatType;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.PlayerChatMessage;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerPlayer;
import one.armelin.dischatbridge.events.ServerChat;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import net.minecraft.server.network.ServerGamePacketListenerImpl;
import org.spongepowered.asm.mixin.Shadow;
Expand All @@ -17,16 +15,13 @@

@Mixin(ServerGamePacketListenerImpl.class)
public class MixinServerGamePacketListenerImpl {
@Final
@Shadow
private MinecraftServer server;
@Shadow public ServerPlayer player;

@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/server/players/PlayerList;broadcastChatMessage(Lnet/minecraft/network/chat/PlayerChatMessage;Lnet/minecraft/server/level/ServerPlayer;Lnet/minecraft/network/chat/ChatType$Bound;)V"), method = "broadcastChatMessage", cancellable = true)
private void broadcastChatMessage(PlayerChatMessage message, CallbackInfo ci) {
CompoundEventResult<Component> eventResult = ServerChat.RECEIVED.invoker().received(this.player, message.decoratedContent());
if (eventResult.isPresent()) {
this.server.getPlayerList().broadcastChatMessage(message.withUnsignedContent(eventResult.object()), this.player, ChatType.bind(ChatType.CHAT, player));
player.server.getPlayerList().broadcastChatMessage(message.withUnsignedContent(eventResult.object()), this.player, ChatType.bind(ChatType.CHAT, player));
ci.cancel();
}
}
Expand Down
2 changes: 2 additions & 0 deletions fabric/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ dependencies {
exclude group: 'org.slf4j'
exclude module: 'annotations'
}

shadowCommon "curse.maven:no-chat-reports-634062:4938991"
}

processResources {
Expand Down
4 changes: 2 additions & 2 deletions fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"dischatbridge.mixins.json"
],
"depends": {
"fabricloader": ">=0.14.22",
"minecraft": ">=1.20.1"
"fabricloader": ">=0.15.0",
"minecraft": ">=1.20.4"
}
}
6 changes: 3 additions & 3 deletions forge/src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# The name of the mod loader type to load - for regular FML @Mod mods it should be javafml
modLoader="javafml" #mandatory
# A version range to match for said mod loader - for regular FML @Mod it will be the forge version
loaderVersion="[47,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions.
loaderVersion="[49,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions.
# The license for you mod. This is mandatory metadata and allows for easier comprehension of your redistributive properties.
# Review your options at https://choosealicense.com/. All rights reserved is the default copyright stance, and is thus the default here.
license="All Rights Reserved"
Expand Down Expand Up @@ -51,7 +51,7 @@ A barebones Discord <-> Minecraft chat bridge.
# Does this dependency have to exist - if not, ordering below must be specified
mandatory=true #mandatory
# The version range of the dependency
versionRange="[47,)" #mandatory
versionRange="[49,)" #mandatory
# An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory
ordering="NONE"
# Side this dependency is applied on - BOTH, CLIENT or SERVER
Expand All @@ -61,6 +61,6 @@ A barebones Discord <-> Minecraft chat bridge.
modId="minecraft"
mandatory=true
# This version range declares a minimum of the current minecraft version up to but not including the next major version
versionRange="[1.20.1,1.21)"
versionRange="[1.20.4,1.21)"
ordering="NONE"
side="SERVER"
13 changes: 6 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
org.gradle.jvmargs=-Xmx4G

minecraft_version=1.20.1
minecraft_version=1.20.4

archives_base_name=DisChatBridge
mod_version=2.2.0
mod_version=2.2.1
maven_group=one.armelin.dischatbridge

architectury_version=9.1.12
cloth_config_version=11.1.106
architectury_version=11.0.11

fabric_loader_version=0.14.23
fabric_api_version=0.90.0+1.20.1
fabric_loader_version=0.15.3
fabric_api_version=0.93.1+1.20.4

forge_version=1.20.1-47.2.1
forge_version=1.20.4-49.0.19
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

0 comments on commit 29fc584

Please sign in to comment.