Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ classes/
# eclipse

*.launch
.factorypath

# idea

Expand Down Expand Up @@ -42,3 +43,7 @@ replay_*.log
# node

node_modules/

# scripts

build.sh
12 changes: 6 additions & 6 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
ext {
// Fabric Properties
// check these on https://fabricmc.net/develop
minecraft_version = '1.21.8'
yarn_mappings = '1.21.8+build.1'
loader_version = '0.16.14'
minecraft_version = '1.21.9'
yarn_mappings = '1.21.9+build.1'
loader_version = '0.17.2'

// Mod Properties
mod_version = '1.4.0'
maven_group = 'dev.creesch'
archives_base_name = 'web-chat'

// Dependencies
fabric_version = '0.129.0+1.21.8'
yacl_version = '3.7.1+1.21.6-fabric'
mod_menu_version = '11.0.3'
fabric_version = '0.134.0+1.21.9'
yacl_version = '3.8.0+1.21.9-fabric'
mod_menu_version = '16.0.0-rc.1'

// Generic java dependencies
javalin_version = '6.7.0'
Expand Down
13 changes: 12 additions & 1 deletion src/client/java/dev/creesch/WebchatClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import dev.creesch.storage.ChatMessageRepository;
import dev.creesch.util.NamedLogger;
import java.net.URI;
import java.util.concurrent.atomic.AtomicBoolean;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
Expand All @@ -25,6 +26,7 @@ public class WebchatClient implements ClientModInitializer {
private int tickCounter = 0;
private static WebchatClient INSTANCE;
private static String MOD_VERSION = "unknown";
private static AtomicBoolean hasJoined = new AtomicBoolean(false);

@Override
public void onInitializeClient() {
Expand Down Expand Up @@ -57,7 +59,7 @@ public void onInitializeClient() {

boolean fromSelf = sender == null
? false
: sender.getName().equals(selfName);
: sender.name().equals(selfName);
try {
WebsocketJsonMessage chatMessage =
WebsocketMessageBuilder.createLiveChatMessage(
Expand Down Expand Up @@ -120,12 +122,21 @@ public void onInitializeClient() {
WebsocketMessageBuilder.createPlayerList(client)
);

boolean wasJoined = hasJoined.getAndSet(true);
if (wasJoined) {
// JOIN event can occur multiple times per server connection.
// Ensure the web address is only shown once per connection.
return;
}

showWebAddress(client);
});
});

// Send state to client
ClientPlayConnectionEvents.DISCONNECT.register((handler, client) -> {
hasJoined.set(false);

webInterface.broadcastMessage(
WebsocketMessageBuilder.createConnectionStateMessage(
WebsocketJsonMessage.ServerConnectionStates.DISCONNECT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ public static WebsocketJsonMessage createHistoryMetaDataMessage(
Pattern.compile("^https?://textures\\.minecraft\\.net/texture/.+");

private static String getPlayerTextureUrl(GameProfile profile) {
Collection<Property> textures = profile.getProperties().get("textures");
Collection<Property> textures = profile.properties().get("textures");
if (textures.isEmpty()) {
return "unknown";
}
Expand Down Expand Up @@ -332,7 +332,7 @@ private static String getPlayerTextureUrl(GameProfile profile) {
} catch (Exception e) {
LOGGER.error(
"Error decoding skin texture for player {}",
profile.getName(),
profile.name(),
e
);
}
Expand Down Expand Up @@ -360,8 +360,8 @@ public static WebsocketJsonMessage createPlayerList(
.getPlayerList()
.forEach(player -> {
GameProfile profile = player.getProfile(); // Contains UUID and name
String playerId = profile.getId().toString();
String playerName = profile.getName();
String playerId = profile.id().toString();
String playerName = profile.name();

Text playerDisplayName = player.getDisplayName() != null
? player.getDisplayName()
Expand Down
8 changes: 4 additions & 4 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
"modmenu": ["dev.creesch.config.ModMenuIntegration"]
},
"depends": {
"fabricloader": ">=0.16.14",
"minecraft": "~1.21.8",
"fabricloader": ">=0.17.2",
"minecraft": "~1.21.9",
"java": ">=21",
"fabric-api": "*",
"yet_another_config_lib_v3": ">=3.7.1+1.21.6-fabric"
"yet_another_config_lib_v3": ">=3.8.0+1.21.9-fabric"
},
"recommends": {
"modmenu": ">=11.0.3"
"modmenu": ">=16.0.0-rc.1"
}
}