#Is it possible to change the join and leave messages in KubeJS?

85 messages · Page 1 of 1 (latest)

thorny zinc
#

Hello! I need your help please, I know absolutely nothing about this mod and I cannot find any form of information about it... I have tried several bits of code to try and edit the join and leave messages but always get errors, "events" is not defined, "onEvent" is outdated, etc... Thank you for your help!

hollow scrollBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

ruby merlin
#

what is a join message and a leave message?

dense slate
#

i assume hes trying to pull a script from an older modpack that adds joining and leave messages into his newer pack

#

??code

onyx ibexBOT
# dense slate ??code

🗒️**Send the code!**🗒️
You may have an issue with a KubeJS script and you explain it to the best of your ability yet without the actual code in question we have very little to go off of in trying to assist you.

dense slate
#

also if you want a basic understanding of how to get started with using kubejs scripts then there are youtube tutorials out there for beginners

#

??tutorial

onyx ibexBOT
dense slate
#

the first one shows you the absolute basics on getting started and youll probably understand why that error is telling you onEvent is outdated too😉

thorny zinc
#

I barely have any experience with javascript too sadly 😦 The code I pulled from Bing AI but it is probably picking some info from an outdated wiki or something, so it is not working at all.

Basically, I want to change the "Player joined the game" and "Player left the game" for my roleplay server...

ruby merlin
#

which message you want? maybe a simple lang entry is enough

thorny zinc
#

Oh with a resource pack?

#

I want a simple message like "Someone joined the game" (because we hide the online player list to add surprise)

dense slate
#

do you want it to be every time a player leaves/joins the world?

#

or like a welcome message type deal on first join

thorny zinc
#

everytime, to replace those yellow messages on server when someome joins/leaves

dense slate
onyx ibexBOT
#

[Quote ➤](#1179100908534120539 message) 🗒️**Send the code!**🗒️
You may have an issue with a KubeJS script and you explain it to the best of your ability yet without the actual code in question we have very little to go off of in trying to assist you.

thorny zinc
#

Well I don't really have any code right now or it is really scuffed 😅

#
on('player.logged_in', function (event) {
    event.server.tellraw('@a', [
        {
            "text": "Someone joined the game",
            "color": "yellow"
        }
    ]);
});

on('player.logged_out', function (event) {
    event.server.tellraw('@a', [
        {
            "text": "Someone left the game",
            "color": "yellow"
        }
    ]);
});
});
#

something like this, but there were multiple versions of it, this one does not even cancel the default messages

dense slate
#

ah, good ol chat gpt code, love to see it

#

doesnt understand much of kubejs tbh unless you teach it

#

sec

thorny zinc
#

yeah 😦 I think it pulls it from older versions

#

I told it to use v6 but it didnt work really well as you can see lol

dense slate
# thorny zinc yeah 😦 I think it pulls it from older versions

heres an easy to understand way of giving player join and leave messages

// Event listener for player joining
PlayerEvents.loggedIn(event => {
    // Define the player as well as the username to the event
    const { player, server, player: { username } } = event
    //Multiple colors version
    let message = Text.of("Hello, ").green().bold()
        .append(Text.of(`${username} `).yellow())
        .append(Text.of(`and welcome to minecraft!`).green());
    player.tell(message);
    
    //Simple version
    player.tell(`Hello, ${username} and welcome to minecraft!`)

    //You can also tell the whole server the message if you wanted to
    //Multiple colors version
    let serverannouncement = Text.of(`${username} `).green().bold()
        .append(Text.of(`just joined!`).green());
    server.tell(serverannouncement);

    //Simple version
    server.tell(`${username} just joined!`)

});

// Event listener for player leaving
PlayerEvents.loggedOut(event => {
    // Define the player as well as the username to the event
    const { player, server, player: { username } } = event
    //Multiple colors version
    let message = Text.of(`${username} `).green().bold()
        .append(Text.of(`just left.`).green());
    player.tell(message);

    //Simple version
    player.tell(`${username} just left.`)

    //You can also tell the whole server the message if you wanted to
    //Multiple colors version
    let serverannouncement = Text.of(`${username} `).green().bold()
        .append(Text.of(`just left.`).green());
    server.tell(serverannouncement);
    //Simple version
    server.tell(`${username} just left.`)
});``` this goes in your server_scripts folder in a .js file
thorny zinc
#

ooh thank you! do you know how to cancel the regular messages too? so they are replaced entirely by these

dense slate
#

if its kubejs there should be a script you can just delete

ruby merlin
#

Why don't use lang entry for that? you just override the message lang entry

#

since his message is simple

#

@dense slate are you able to check lang file en_us if it have this entry about player join or left?

dense slate
ruby merlin
#

@dense slate he just need to add this entries

multiplayer.player.joined
multiplayer.player.left

#

with the msg he wants

dense slate
#

ah i see yeah he could also do that as well, he can overwrite that with the lang event right?

dense slate
thorny zinc
dense slate
#

yea

#

you could if you wanted to use the loggin/logout event set the entries to ""

#

(just deleting the text in it)

#

or input your messages with color codes

ruby merlin
#

????????? lang event

#

resource pack ????????

dense slate
thorny zinc
#

?

#

yeah thats only editable in a clientsided resourcepack no?

dense slate
#

i must be misunderstanding what uncandangos getting at

#

ill let him take it from here lol

thorny zinc
#

if only I could just use essentials lol

ruby merlin
#

@dense slate 😐 have you never used lang event?

dense slate
#

i didnt realize thats what you meant

ruby merlin
#

what? lol im syaing that since im here

dense slate
#

tho you shouldnt be explaining it to me, you should be explaining it to the ticket OP

thorny zinc
#

yeah 😄 I hve no clue what you all are talking about lol

#

plus french and 2am debuffs

dense slate
#

hes talking about something like thisjs /** Add language entries */ ClientEvents.lang('en_us', (e) => { // Effect / Radiation e.add("multiplayer.player.joined", "your welcome message"); })

thorny zinc
#

ooooh you can do that with kubejs too 😮

ruby merlin
#
ClientEvents.lang("en_us", event => {
  event.addAll({
    "multiplayer.player.joined": "Someone joined the game",
    "multiplayer.player.left": "Someone left the game"
  })
})

i think this is enough, but if people change language to something but english they will see like normal on their language.
you may want to override that at all languages, but still that is not something people can't cheat since it is client side, they can do anything

dense slate
#

yeah

#

poor uncandango speaking to a wall me

thorny zinc
dense slate
#

but yeah

thorny zinc
#

but alright i get it now tysm!

dense slate
#

np

thorny zinc
#

it says clientEvents are not defined 😦

dense slate
#

??code

onyx ibexBOT
# dense slate ??code

🗒️**Send the code!**🗒️
You may have an issue with a KubeJS script and you explain it to the best of your ability yet without the actual code in question we have very little to go off of in trying to assist you.

dense slate
#

it goes into your client scripts

#

also send logs

thorny zinc
#

oh alright! i had put on server. code was the one you just sent lol

#

ooh i can just put json file in kubejs/assets/minecraft/lang it works too 😮

dense slate
#

why not the lang event?

thorny zinc
#

its basically same i guess

#

just was curious

#

json hurts my brain less and is more minecraft friendly too lol

dense slate
#

kubejs directly does what the texture pack does so you could say it's better but its up to you lol

thorny zinc
#

yeah it kinda works as a resource pack too 😄

#

its definitely cool

#

anyway thank you so much for the help I am closing ticket!