uncovery / uncovery_me

Full source of the uncovery.me minecraft server
GNU General Public License v3.0
12 stars 3 forks source link

Shop listings have multiple angstroms in them. #257

Closed ETcodehome closed 7 years ago

ETcodehome commented 7 years ago

Shop listings have multiple angstroms in them.

uncovery commented 7 years ago

angstroms?

ETcodehome commented 7 years ago

2017-02-27_09 13 06

uncovery commented 7 years ago

Ah. that might be from the color-coding. I switched to a new message method some weeks ago because of changes in the chat plugin:

https://github.com/uncovery/uncovery_me/blob/master/websend_inc/mod.inc.php#L190

This might be related. We used to use this here:

https://github.com/uncovery/uncovery_me/blob/master/includes/websend.inc.php#L478

I am not 100% sure it's because of this, but likely related in some sense to the new chat plugin.

uncovery commented 7 years ago

the Broadcast might need a different way to do colorcodes. The issue is that the colors ARE changing, so not sure if there is anything unneedd that is creating the Angstroms.

ETcodehome commented 7 years ago

function umc_mod_broadcast($msg) { global $WS_INIT; $chat_command = $WS_INIT['mod']['broadcast']; // we can send several messages as an array. if (!is_array($msg)) { $msg = array($msg); } foreach ($msg as $line) { $str = preg_replace(color_regex() . "e", 'color_map(\'$1\')', $line); $full_command = "$chat_command $str;"; umc_exec_command($full_command, 'asConsole'); } }

ETcodehome commented 7 years ago

should probably also be using echo instead of a specialised command that prefixes with broadcast.

umc_echo("{yellow}[!]{gray} Didn't specify {yellow}request{gray} or {yellow}offer{gray}, assuming {yellow}offer", true);

ETcodehome commented 7 years ago

ah but echo doesn't psuh to all.... hrmm.

uncovery commented 7 years ago

yes exactly.

ETcodehome commented 7 years ago

/tellraw @a ["",{"text":"[!]"},{"text":" Psiber voted! Rolled ","color":"gold"},{"text":"936"},{"text":"! Recieved ","color":"gold"},{"text":"15 Potatoes!"}]

That's the right basic command to be using for this since it isnt wrapped by something else. Removes all the [Broadcast] and makes it far easier / cleaner to read. Will update to have same fields etc.

ETcodehome commented 7 years ago

function color_map($color = null) { global $UMC_COLORS; $keys = array();

foreach ($UMC_COLORS as $code => $types) {
    $keys = array_merge($keys, $types['names']);
    if (isset($color) && in_array($color, $types['names'])) {
        return "§". $code;
    }
}
if (isset($color)) { // there is an error, we should not be here, color not found
    return;
}
return $keys;

}

The unicode character added to the start of the color codes, was that specific to old chat system? return "§". $code;

ETcodehome commented 7 years ago

http://minecraft.tools/en/color-code.php

does the new system not need the unicdoe preface?

uncovery commented 7 years ago

So the tellraw is definetely the best thing we can do. We would need a function abstracting this The function above is for the way colors worked in the old code (when this whole {...} did not exist in chat. If we translate colors that are used in commands right now to the "color":"gold" stuff, we can forget about those.

uncovery commented 7 years ago

It think it's easiest to go through the code and make sure that system messages use a good format. I am afraid that the $ and § color codes are quite difficult to translate into the "color":"gold" type of text.

ETcodehome commented 7 years ago

Well, the tellraw is also the best long term solution too, since that is native functionality (best for efficiency and future proofing).

It also has some awesome options available for mouse over text, clickable buttons (like a buy now command that prefills in chat when you click a shop listing), description texts, all sorts.

While it's nice to have a 1:1 transition from the old color code formatting I'm not sure that a straight translation for the old messgaes is the best solution. We should be really looking at each usage that is a problem and seeing if the tellraw opens new ways to improve the user experience.

We should just migrate the problematic commands over for right now. Generate any feedback that we want to adapt to the new system as we need them.

http://minecraft.tools/en/tellraw.php?tellraw=%3Cspan%20style%3D%22color%3A%23000000%22%3EWelcome%20to%20Minecraft%3C%2Fspan%3E&selector=%40a

Is an awesome generator for rapidly generating the JSON chat strings.

Will start with modifying this one to use as an example.

uncovery commented 7 years ago

Is there a source code for this tool available? I wonder how much we want to have an abstraction layer for this or if we should use tellraw directly in the code.

ETcodehome commented 7 years ago

I can't imagine that they have source available for it, since their whole website is basically supplying these tools (for various useful bits and pieces)