Oziach / spec-dialogue

Add custom overhead text for all special attacks!
BSD 2-Clause "Simplified" License
0 stars 1 forks source link

Can't use colour codes or pattern codes #1

Open VenomousInc opened 4 months ago

VenomousInc commented 4 months ago

You can't use any of the Chat Interface colour coding as entries aren't sanitized properly: https://oldschool.runescape.wiki/w/Chat_Interface

Example: Dorgeshuun crossbow : pattern2k1b1b:Uh oh, it's the Dorgeshuun Crossbow! ; Prints: pattern2k1b1b

VenomousInc commented 4 months ago

If we go to SpecDialoguePlugin and edit the ComputeMap method by changing the split on ":" to 2, so we only get a length of 2 on pair will fix this:

https://github.com/Oziach/spec-dialogue/blob/master/src/main/java/com/specdialogue/SpecDialoguePlugin.java

    void computeMap(){
        weaponsToDialoguesMap.clear();
        String[] wholePairs = config.weapsAndDialogue().split(";");
        for(String wholePair : wholePairs){

            // Set the limit to 1 so we only get the weapon name split away
            String[] pair = wholePair.split(":", 2);

            if(pair.length < 2){continue;} //if invalid pair

            String weapon = pair[0].trim();
            String dialogue = pair[1].trim();
            weaponsToDialoguesMap.put(weapon.toLowerCase(),dialogue); //map keys lowercase
        }

    }
Oziach commented 4 months ago

Good catch!

However, I tried testing after making the changes, and the chat effects don't actually apply :c

Expected result would be the player saying "Uh oh, its the Dorgeshunn Crossbow!" with the text effects you mentioned.

Instead, the player instead just says "pattern2k1b1b:Uh oh, it's the Dorgeshuun Crossbow!"

If you did test it and it worked for you, send me a screenshot or video of it if you can. If you didn't, I'd assume its a thing with the setOverheadText method in Runelite itself.

VenomousInc commented 4 months ago

I'm sorry, I assumed this was the same as normal chat! I will look into it, but this should still be fine to add as a sanitary measure.

I've never made or used a custom runelite plugin, I haven't looked into it before so I couldn't test it, thanks for trying!