kangarko / ChatControl-Pro

The ultimate chat solution. Prevent spam, ads, swears and even bots on your server. Replaced by ChatControl Red: https://mineacademy.org/chatcontrol-red
Other
65 stars 8 forks source link

1.16.5: Is it possible to auto-join channels when switching worlds? #2290

Closed yourlocalvirgo closed 3 years ago

yourlocalvirgo commented 3 years ago

I'm currently using MC version 1.16.5, and using the latest release of ChatControl Pro.

Here's what I'm trying to accomplish: when one of my minecraft users switches from our survival to our creative world, I'd like them to automatically leave the survival chat channel and join the creative chat channel. So far, I've tried to accomplish this by adding this following text to the ChatControl/rules/chat.txt file:

# Switches channel for user if in survival channel while in creative1 world
match (.*)
# ignore world creative1
ignore channel creative
then console ch set {player} creative write
then deny

# Switches channel for user if in creative channel while in survival world
match (.*)
ignore world creative1
ignore channel survival
then console ch set {player} survival write
then deny

However, I don't think it's properly identifying the "ignore channel {channel name}" operator.

Is there a way to accomplish this, or maybe use a different operator? Or maybe this is something I can configure with Essentials? I'm very new to operating a Minecraft server with plug-ins, so I don't know much and I'm still learning. Any help would be greatly appreciated!

kangarko commented 3 years ago

@gone-incognito I know you had a similar setup, did you manage to find a working solution for this please?

TheIntolerant commented 3 years ago

I personally don't actually have such a setup, since I have a global chat, with multiple servers with chat linked up to every server but I did help someone achieve a similar setup.

As this switch should happen with a world change, for this to work effectively, you would be best using an operator that checks the world the user is currently in, such as "require world (world_name)" etc, would you mind telling me the world names? And also your channel names?

Also please be as clear as possible with regards to world names and gamemode types, so I know exactly what worlds are for survival and creative, just so I can help provide a solution ASAP :P

Also note, this auto change with channels only happens when the user tries to speak. If you wish to also make it so when they run / command to go to survival/creative worlds, let me know and I'll see if I can help.

yourlocalvirgo commented 3 years ago

Thanks so much for the quick response!

I have two worlds, named "survival" (gamemode: survival) and "creative1" (gamemode: creative). The corresponding channels would be "survival" and "creative" (pretty straightforward!)

We are also using Multiverse portals for our users to switch between worlds (ex: they go through our "survival" portal and they'll join the survival world, or they'll go through the "creative" portal and join our creative world), so I'm not sure if it'd be possible to switch the channels when going through the portals as well. I'm fine with either option, though! (I hope that makes sense...)

Also, just to note: I tried the operator "require world (world name)" but was given the error that the operator wasn't recognized. I can certainly try again, but unfortunately I don't think it will work.

Thanks again for the quick response!

TheIntolerant commented 3 years ago

in chat.txt

# Switches channel for the user if not in survival channel while in the survival world
match (.*)
ignore world creative1
then console ch set {player} survival write
then command ch send survival $0
dont verbose
then deny

# Switches channel for the user if not in the creative channel while in the creative world
match (.*)
ignore world survival
then console ch set {player} creative write
then command ch send creative $0
dont verbose
then deny

Just something to note, these rules won't work for OP's unless the bypass perms for ChatControlPro have been negated for those users. Also, unlike ChatConntrolRed, since there is no ignore channel or require channel operators, this rule is actually performed on every chat message sent, for that reason the above rules should be added to the button of your chat.txt file since CC rules are processed from top to bottom and if this is at the top of that file, any rule under it won't be processed due to the then deny operator.

You may also want to go into your localization file and hide these messages by setting Channels.Join sections to '' for keys "Success", "Leave_Reading" to prevent message spam when channels are automatically switched.

TheIntolerant commented 3 years ago

oh shoot this is ChatControlPro, let me double-check the operators and edit the above message lol

I have adjusted the above message, so that it should work for ChatControlPro, also my apologies for mentioning the require world operator, as that is only available in ChatControlRed, which explains why it didn't work for you.

Also just a note, the operators ChatControlPro uses are listed in the rules.txt file, unfortunately there doesn't seem to be a list of them on the wiki for ChatControlPro, as ChatControlRed has a fair few extra operators such as ignore channel, require world etc

Also since you said you are new to running a minecraft server, just so you know the $0 in the example above is a RegEx thing and that will insert what the user said into that command so they run /ch send <channel> <whatever they said>

TheIntolerant commented 3 years ago

I just remembered one thing I couldn't do on ChatControlPro which was, having multiple rules with the exact same match... If you ever do decide to update to ChatControlRed, you won't have to worry about such minor details but for now you should use this instead

# Switches channel for the user if not in survival channel while in the survival world
match (.*)
ignore world creative1
then console ch set {player} survival write
then command ch send survival $0
dont verbose
then deny

# Switches channel for the user if not in the creative channel while in the creative world
match (.)*
ignore world survival
then console ch set {player} creative write
then command ch send creative $0
dont verbose
then deny

NOTE the match (.)* and match (.*) do the same thing, you just need to make the RegEx slightly different, as ChatControlPro requires you to have different and the RegEx used in the match operator for each rule. For example, if you were to add say a "mini games world" with its own chat, you could do what I have posted above but need to change the regex in match so it isn't the same as the above, such as match ((.)*)* which would work the same as match (.*), that is why I made the operator different for each rule.

yourlocalvirgo commented 3 years ago

Got it, thank you so much! I'm going to try this now and will write back to let y'all know if it worked.

yourlocalvirgo commented 3 years ago

Alrighty! I was finally able to test the info you sent, and unfortunately, it does not work. The weird thing is, I think it works to an extent, but it's not working the way it should.

I had a friend of mine join our survival world, and when he'd try to type, it would not go through and give him the error that he "did not have permission to write into a channel he wasn't in", basically saying he wasn't in the survival channel. However, when he would try the /channel join survival command, he wouldn't join -- and, in our server console, it actually said he left the survival channel. It was behaving very oddly... I'm going to try a few other things first, but please let me know if there's any other help you can offer.

yourlocalvirgo commented 3 years ago

I think what's happening, is that there's no rule for if they are in the correct channel. So, anytime they try to type, even if they're in the correct channel, it denies the permission to speak and continually joins them to the survival channel.

TheIntolerant commented 3 years ago

My only other suggestion would be to try

# Switches channel for the user if not in survival channel while in the survival world
match (.*)
ignore world creative1
then console ch set {player} survival write
dont verbose

# Switches channel for the user if not in the creative channel while in the creative world
match (.)*
ignore world survival
then console ch set {player} creative write
dont verbose

If that doesn't work, I'm afraid the only solution to this problem would be to buy ChatcontrolRed on mc-market, since that has "ignore channel", "require channel", "require world" operators which would be helpful in such cases.

kangarko commented 3 years ago

Thanks so much gone-incognito for help <3 Let me know your MCMarket username or if you prefer to do this in private email it to matej@mineacademy.org

kangarko commented 3 years ago

I'll give you Red free of charge and if it solves your problem you can donate an amount to billing@matejpacan.com later

yourlocalvirgo commented 3 years ago

I'll give you Red free of charge and if it solves your problem you can donate an amount to billing@matejpacan.com later

Oh, thanks so much!! I actually went ahead and purchased last night; I am currently configuring the files now and will let you know how it goes!

Thanks so much for the A+ support, y'all. Like I said, I'm really new to this, and I don't think I would've been able to figure it out without your help!

TheIntolerant commented 3 years ago

There should be an example in the chat.rs file telling you who to make a rule that auto switch channels based on the world the user is in, but in case you get confused, to save you time. This example will work for ChatControlRed

in chat.rs file

# Switches channel for the user if not in survival channel while in the survival world
match (.*)
require world survival
ignore channel survival
then console channel join survival write {player}|channel sendas {player} survival $0
dont verbose
then deny

# Switches channel for the user if not in the creative channel while in the creative world
match (.*)
require world creative1
ignore channel creative
then console channel join creative write {player}|channel sendas {player} creative $0
dont verbose
then deny

Worth checking this ticket out if you get stuck. https://github.com/kangarko/ChatControl-Red/issues/824

kangarko commented 3 years ago

Thanks, I am closing in good faith this has been resolved, if not just comment below and I'll still get the notification!