Creating Simple Placeholder

Introduction

Simple placeholder class allows you to replace placeholder in a string directly.

Implementing the class

public class Example implements SimplePlaceholder {

    public Example() {
        // register this placeholder
        PlaceholderManager.register(this);
    }
    
    @Override
    public String replace(String string, ExtraData data) {
        Player viewer = data.get(ExtraData.DATA_VIEWER);
        if (viewer != null) {
            string = string.replace("$gamemode", viewer.getGameMode().name());
        }
        return string; // must return the string!
    }
    
}

Last updated