Skip to content

StringHandler

NATroutter edited this page Apr 29, 2022 · 3 revisions

StringHandler

public class Example extends JavaPlugin {


    public void someMethod() {
        StringHandler msg = new StringHandler("Your message with or without placeholders example %this%");
        msg.replaceAll("%this%", "this is the replacement"); //replace all placeholders from message
        msg.replace("%var2%", "replaced!"); //replace only 1 placeholder from message
        msg.setPrefix("Prefix > "); //Set prefix for this message
        msg.setSuffix("< Suffix"); //Set suffix for this message
        msg.compine(new StringHandler("Secondary message")); //Compine message with other stringHandler message
        msg.addToStart("test"); //adds text to start after prefix
        msg.addToEnd("test2"); //adds text to end before suffix
        msg.broadcast(); //Broadcasts message to all players
        msg.stripColors(); //Remove all color codes!
        msg.send(p); //Send message to palyer
        
        List<String> list = msg.split('_'); //Splits message to list of strings at _
        String finalMsg = msg.build(); // Build message to string

    }

}

Clone this wiki locally