Skip to content

Commit c29c6e3

Browse files
committed
Add welcome message
1 parent 5c0fe3a commit c29c6e3

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/main/java/io/github/mattidragon/demobox/DemoBoxGame.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import net.minecraft.server.world.ServerWorld;
1212
import net.minecraft.structure.StructurePlacementData;
1313
import net.minecraft.text.Text;
14+
import net.minecraft.util.Formatting;
1415
import net.minecraft.util.Identifier;
1516
import net.minecraft.util.math.BlockPos;
1617
import net.minecraft.util.math.Vec2f;
@@ -60,6 +61,7 @@ private static GameOpenProcedure open(GameOpenContext<Settings> context) {
6061
instance.setup();
6162
activity.listen(GamePlayerEvents.OFFER, instance::onPlayerOffered);
6263
activity.listen(GamePlayerEvents.LEAVE, instance::onPlayerLeave);
64+
activity.listen(GamePlayerEvents.JOIN, instance::onPlayerJoin);
6365
});
6466
}
6567

@@ -85,6 +87,13 @@ private void onPlayerLeave(ServerPlayerEntity player) {
8587
}
8688
}
8789

90+
private void onPlayerJoin(ServerPlayerEntity player) {
91+
player.sendMessage(Text.translatable("demobox.info.1").formatted(Formatting.GREEN, Formatting.BOLD));
92+
player.sendMessage(Text.translatable("demobox.info.2").formatted(Formatting.WHITE));
93+
player.sendMessage(Text.translatable("demobox.info.3").formatted(Formatting.WHITE));
94+
player.sendMessage(Text.translatable("demobox.info.4").formatted(Formatting.WHITE));
95+
}
96+
8897
@NotNull
8998
private PlayerOfferResult onPlayerOffered(PlayerOffer offer) {
9099
return offer.accept(world, settings.playerPos);
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
{
22
"command.demobox.open.fail": "Failed to open demo box",
33
"demobox.demo.join": "%s joined the demo",
4-
"gameType.demobox.demo_box": "Demo Box"
4+
"gameType.demobox.demo_box": "Demo Box",
5+
6+
"demobox.info.1": "Welcome to the DemoBox!",
7+
"demobox.info.2": "Here you can experiment with mods in by yourself.",
8+
"demobox.info.3": "You might have noticed that you don't have any of your items.\nDon't worry. They'll be returned to you once you leave.",
9+
"demobox.info.4": "You can leave using the /demobox leave command.\nYou can also use the /game command to leave and join active demos."
510
}

0 commit comments

Comments
 (0)