New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues with \n #63

Closed
EvilOlaf opened this Issue Feb 22, 2016 · 12 comments

Comments

Projects
None yet
2 participants
@EvilOlaf

EvilOlaf commented Feb 22, 2016

I have a bit of an issue with using new line in the chat.txt

This is what I tried:

match 12345
then warn "1\n2"
then deny

As well as then warn '1\n2'.

The debug output:

[18:07:31 INFO]: [ChatControl Debug] Checking 7 rules for CHAT (chat.txt)
[18:07:31 INFO]: *--------- ChatControl rule match on Olaf --------- ID UNSET
[18:07:31 INFO]: MATCH: Rule{
    Match = '12345',
    Warn Message = '"1\n2"',
    Deny = true
}
[18:07:31 INFO]: CATCH: 12345
[18:07:31 INFO]: [ChatControl Debug] Checking Packet rules against: "1\n2"
[18:07:31 INFO]: Original message cancelled.

The chat output ingame:

"1\n2"

Had a look at your tips and you wrote there:
Use \n to make a new line in a message. You have to put the message in quotes then (see the tip above). If it doesn't work then try saving the file with Notepad++ and try switching the encoding to ANSI or UNICODE (Top menu->Encoding->Convert to <encodingType>->Save).

I usually edit all config files directly per SSH using nano or vi which usually works well but I gave it a shot.
First I converted to utf-8 which resulted that the chat.txt were not loaded at all. Here is the output for this error:

[18:05:38] [Server thread/WARN]: java.lang.NullPointerException: Cannot define an operator when no rule is being created! File: 'chat.txt' Line: '# -------------------------------------------------------------------------------' Previous rule: 'null'
[18:05:38] [Server thread/WARN]:        at java.util.Objects.requireNonNull(Objects.java:228)
[18:05:38] [Server thread/WARN]:        at kangarko.chatcontrol.rules.ChatCeaser.loadRules(ChatCeaser.java:96)
[18:05:38] [Server thread/WARN]:        at kangarko.chatcontrol.rules.ChatCeaser.load(ChatCeaser.java:60)
[18:05:38] [Server thread/WARN]:        at kangarko.chatcontrol.ChatControl.onReload(ChatControl.java:171)
[18:05:38] [Server thread/WARN]:        at kangarko.chatcontrol.CommandsHandler.handleCommand(CommandsHandler.java:199)
[18:05:38] [Server thread/WARN]:        at kangarko.chatcontrol.CommandsHandler.onCommand(CommandsHandler.java:25)
[18:05:38] [Server thread/WARN]:        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44)
[18:05:38] [Server thread/WARN]:        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141)
[18:05:38] [Server thread/WARN]:        at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchCommand(CraftServer.java:641)
[18:05:38] [Server thread/WARN]:        at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchServerCommand(CraftServer.java:627)
[18:05:38] [Server thread/WARN]:        at net.minecraft.server.v1_8_R3.DedicatedServer.aO(DedicatedServer.java:412)
[18:05:38] [Server thread/WARN]:        at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:375)
[18:05:38] [Server thread/WARN]:        at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654)
[18:05:38] [Server thread/WARN]:        at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557)
[18:05:38] [Server thread/WARN]:        at java.lang.Thread.run(Thread.java:745)
[18:05:38] [Server thread/INFO]: ^[[0;33;1m[^[[0;36;1mServer^[[0;33;1m]^[[0;32;1m ^[[0;31;1mNeu laden der Konfiguration ist fehlgeschlagen. Der Fehler war: ^[[0;31;22mCannot define an operator when no rule is being created! File: 'chat.txt' Line: '# -------------------------------------------------------------------------------' Previous rule: 'null'^[[m

Next I converted to ANSI. This one loaded but did not change the output behavior.

As a side note: There is no need to put quotes around a message when using color codes. They will work anyways.

CHC 5.2.7

Thanks for reading..

@kangarko

This comment has been minimized.

Show comment
Hide comment
@kangarko

kangarko Feb 23, 2016

Owner

Hey,

unfortunately the behaviour of \n has, since the changes in 1.7x regarding encoding, a mystery to me, too. The code itself has the instruction to split the text, and it did just fine around one-two years before.
In most places in the plugin, there are .yml files which accept |- characters that supplies newlines:

Here are two ways of splitting a message in .yml files:

Example: "Hello\nWorld"
Another_Example: |-
  Hello
  World

The first one is problematic, and I have try to do a lot about this, but did not find a solution, so you'll have to stick with the |-
Unfortunately the custom reader in rules does not accept |-

You can try using just | but if it won't work then I am sorry.

Owner

kangarko commented Feb 23, 2016

Hey,

unfortunately the behaviour of \n has, since the changes in 1.7x regarding encoding, a mystery to me, too. The code itself has the instruction to split the text, and it did just fine around one-two years before.
In most places in the plugin, there are .yml files which accept |- characters that supplies newlines:

Here are two ways of splitting a message in .yml files:

Example: "Hello\nWorld"
Another_Example: |-
  Hello
  World

The first one is problematic, and I have try to do a lot about this, but did not find a solution, so you'll have to stick with the |-
Unfortunately the custom reader in rules does not accept |-

You can try using just | but if it won't work then I am sorry.

@kangarko kangarko added the issue label Feb 23, 2016

@EvilOlaf

This comment has been minimized.

Show comment
Hide comment
@EvilOlaf

EvilOlaf Feb 23, 2016

Thanks again for the reply.
I'll try some testing with |-
For now I use some kind a nasty workaround and fill up the rest of the line with &f to create whitespace till I reach the forced linebreak. The problem here is when a texture pack replaces the default font of Minecraft....

EvilOlaf commented Feb 23, 2016

Thanks again for the reply.
I'll try some testing with |-
For now I use some kind a nasty workaround and fill up the rest of the line with &f to create whitespace till I reach the forced linebreak. The problem here is when a texture pack replaces the default font of Minecraft....

@kangarko

This comment has been minimized.

Show comment
Hide comment
@kangarko

kangarko Feb 23, 2016

Owner

I see. They have changed things around encoding in 1.9 again, I hope in a way that make it working again. I will keep looking for a solution though.

Owner

kangarko commented Feb 23, 2016

I see. They have changed things around encoding in 1.9 again, I hope in a way that make it working again. I will keep looking for a solution though.

@kangarko kangarko changed the title from Issue with new line at "then warn" action to Issues with \n Feb 25, 2016

@kangarko kangarko added won't fix and removed issue labels Feb 25, 2016

@EvilOlaf EvilOlaf referenced this issue Mar 3, 2016

Closed

AntiCAP #73

@EvilOlaf

This comment has been minimized.

Show comment
Hide comment
@EvilOlaf

EvilOlaf Mar 7, 2016

Still hoping this can be fixed, also in 1.8 in any way.

Well I have another idea.
What if the same action is allowed multiple times?

Using the example at the top:

match 12345
then warn "1\n2"
then deny

Will not work obviously.

So what if we use warn twice?

match 12345
then warn 1
then warn 2
then deny

This could be also be extremely useful (at least for me xD) at packet rewriting.

EvilOlaf commented Mar 7, 2016

Still hoping this can be fixed, also in 1.8 in any way.

Well I have another idea.
What if the same action is allowed multiple times?

Using the example at the top:

match 12345
then warn "1\n2"
then deny

Will not work obviously.

So what if we use warn twice?

match 12345
then warn 1
then warn 2
then deny

This could be also be extremely useful (at least for me xD) at packet rewriting.

@kangarko

This comment has been minimized.

Show comment
Hide comment
@kangarko

kangarko Mar 7, 2016

Owner

Hey, operators are supported only once, this is from the basics of the system - something I cannot change easily.

i'll recheck the new line character's behaviour in 1.9

** Mon, 07 Mar 2016 09:03:40 -0800 - "kangarko/ChatControl" chatcontrol@noreply.github.com, "kangarko/ChatControl" reply@reply.github.com **

Still hoping this can be fixed, also in 1.8 in any way.

Well I have another idea.
What if the same action is allowed multiple times?

Using the example at the top:

match 12345
then warn "1\n2"
then deny

Will not work obviously.

So what if we use warn twice?

match 12345
then warn 1
then warn 2
then deny

This could be also be extremely useful (at least for me xD) at packet rewriting.


Reply to this email directly or view it on GitHub:
#63 (comment)

Owner

kangarko commented Mar 7, 2016

Hey, operators are supported only once, this is from the basics of the system - something I cannot change easily.

i'll recheck the new line character's behaviour in 1.9

** Mon, 07 Mar 2016 09:03:40 -0800 - "kangarko/ChatControl" chatcontrol@noreply.github.com, "kangarko/ChatControl" reply@reply.github.com **

Still hoping this can be fixed, also in 1.8 in any way.

Well I have another idea.
What if the same action is allowed multiple times?

Using the example at the top:

match 12345
then warn "1\n2"
then deny

Will not work obviously.

So what if we use warn twice?

match 12345
then warn 1
then warn 2
then deny

This could be also be extremely useful (at least for me xD) at packet rewriting.


Reply to this email directly or view it on GitHub:
#63 (comment)

@EvilOlaf

This comment has been minimized.

Show comment
Hide comment
@EvilOlaf

EvilOlaf Mar 7, 2016

Hm what about creating a custom line break which not depends on YML?
Like [:NEWLINE:]
If this was found inside an action it will split the string here an put everything behind in a new line.

No clue if this would work, I just try to deliver some ideas.

EvilOlaf commented Mar 7, 2016

Hm what about creating a custom line break which not depends on YML?
Like [:NEWLINE:]
If this was found inside an action it will split the string here an put everything behind in a new line.

No clue if this would work, I just try to deliver some ideas.

@kangarko

This comment has been minimized.

Show comment
Hide comment
@kangarko

kangarko Mar 7, 2016

Owner

Yeah that would work. I can add that actually (in some free time) :)

** Mon, 07 Mar 2016 09:28:05 -0800 - "kangarko/ChatControl" chatcontrol@noreply.github.com, "kangarko/ChatControl" reply@reply.github.com **

Hm what about creating a custom line break which not depends on YML?
Like [:NEWLINE:]
If this was found inside an action it will split the string here an put everything behind in a new line.


Reply to this email directly or view it on GitHub:
#63 (comment)

Owner

kangarko commented Mar 7, 2016

Yeah that would work. I can add that actually (in some free time) :)

** Mon, 07 Mar 2016 09:28:05 -0800 - "kangarko/ChatControl" chatcontrol@noreply.github.com, "kangarko/ChatControl" reply@reply.github.com **

Hm what about creating a custom line break which not depends on YML?
Like [:NEWLINE:]
If this was found inside an action it will split the string here an put everything behind in a new line.


Reply to this email directly or view it on GitHub:
#63 (comment)

@EvilOlaf

This comment has been minimized.

Show comment
Hide comment
@EvilOlaf

EvilOlaf Mar 7, 2016

👍 Looking straight forward to it :)

EvilOlaf commented Mar 7, 2016

👍 Looking straight forward to it :)

@kangarko

This comment has been minimized.

Show comment
Hide comment
@kangarko

kangarko Mar 12, 2016

Owner

I did not found any workable solution, it got me frustrated and I decided to implement my own one ;)

Seems like it cannot display blank lines after the last string, but otherwise it works.

Edit:
Blank lines at the end can be workarounded by doing:

then warn \n&cAttention!\n\n&bYou have now tested the plugin.\n\n\n&cEnd of the attention \n \n \n

Owner

kangarko commented Mar 12, 2016

I did not found any workable solution, it got me frustrated and I decided to implement my own one ;)

Seems like it cannot display blank lines after the last string, but otherwise it works.

Edit:
Blank lines at the end can be workarounded by doing:

then warn \n&cAttention!\n\n&bYou have now tested the plugin.\n\n\n&cEnd of the attention \n \n \n

@kangarko

This comment has been minimized.

Show comment
Hide comment
@kangarko

kangarko Mar 12, 2016

Owner

Will be pushed into the pro version..

Owner

kangarko commented Mar 12, 2016

Will be pushed into the pro version..

@kangarko kangarko closed this Mar 12, 2016

@EvilOlaf

This comment has been minimized.

Show comment
Hide comment
@EvilOlaf

EvilOlaf Mar 16, 2016

Works well within the rules.txt but unfortunately not in the packets.txt

I rewrote an existing rule in packets.txt which was known to work before and edited the action to then rewrite 1\n2. Well, 1\n2 is exactly what I got in chat instead of

1
2

EvilOlaf commented Mar 16, 2016

Works well within the rules.txt but unfortunately not in the packets.txt

I rewrote an existing rule in packets.txt which was known to work before and edited the action to then rewrite 1\n2. Well, 1\n2 is exactly what I got in chat instead of

1
2
@kangarko

This comment has been minimized.

Show comment
Hide comment
@kangarko

kangarko Mar 20, 2016

Owner

Packet rules have different implementation. The message to be rewritten is packed to JSON using net.md_5.bungee.chat.ComponentSerializer (API from bungee which is compiled with spigot since 1.7.10) which I am out of control of, sorry.

Owner

kangarko commented Mar 20, 2016

Packet rules have different implementation. The message to be rewritten is packed to JSON using net.md_5.bungee.chat.ComponentSerializer (API from bungee which is compiled with spigot since 1.7.10) which I am out of control of, sorry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment