I realise that this is posted in the wrong section, but I could not post it in the guides section. I would kindly ask the administration to move it to the appropriate section and remove this sentence.
Greetings, folks!
Today I'll present to you a way to optimise the HTML length by up to 30%, depending on the nesting. The examples I give are taken from an old Mobius core, but the general idea is applicable to all java-based cores.
Proof of concept: The two important bits are the (1)
Original HTML size row and the (4)
No Tabs/Rows size row, which represent the before and after, respectively.
Посмотреть вложение 55946
STEPS:
1. locate the `
setHtml(String text)` method inside `
NpcHtmlMessage.java`.
2. add the following bit of code as a standalone method:
Java:
/**
* Replaces all occurrences of New Rows and Tab spaces in the string.
* @param text the string that may contain invalid characters
* @return the string with invalid characters removed
*/
public static String removeTabSpacesAndNewRows(String text)
{
return text.replaceAll("[\\t\\n]", "");
}
3. find the last ocurence of the `
text` String variable in the `
setHtml()` method, and push it through this newly created method like so: `
removeTabSpacesAndNewRows(text);`.
4. example of the final result.
Посмотреть вложение 55945
5. You could further refine it by processing the `
text` variable between the two IF clauses by creating a new local variable, assigning it a value of `
text` and then replacing the subsequent `
text` mentions in the `
setHtml()` method with this
new local var. Here's what it could look like:
Посмотреть вложение 55947