Modules

Editor integration

Override the setters and players can move, scale and reset your module in the HUD editor. Save every value to your own mod's config, never to SimpleCPSConfig.

The setters

MyCustomModule.java
// Inside your MyCustomModule class:

@Override
public void setPositionType(SimpleCPSConfig.Position pos) {
    MyAddonConfig.anchor = pos; // save to YOUR config
}

@Override
public void setXOffset(int x) { MyAddonConfig.xOffset = x; }

@Override
public void setYOffset(int y) { MyAddonConfig.yOffset = y; }

@Override
public void setScale(int scale) { MyAddonConfig.scale = scale; }

@Override
public int getScale() { return MyAddonConfig.scale; }

@Override
public void resetToDefaults() {
    // Called by Reset Position in the context menu
    MyAddonConfig.anchor  = SimpleCPSConfig.Position.TOP_LEFT;
    MyAddonConfig.xOffset = 0;
    MyAddonConfig.yOffset = 0;
    MyAddonConfig.scale   = 100;
}

They are optional. Skip these overrides and your module still renders correctly, but players cannot move or scale it in the editor.

Saving when a move ends

When the editor finishes moving your module it calls onPositionUpdated(). Override it to write the new position to your own config.

MyCustomModule.java
@Override
public void onPositionUpdated() {
    // Called after a drag is released, after an arrow-key nudge,
    // and after the align and distribute tools move the module
    MyAddonConfig.save();
}

The default saves simplecps.json, which holds nothing of yours unless you use plugin state.

Grid and smooth snapping need nothing from you. Both are applied by the editor before it calls your setters. setXOffset() and setYOffset() are called once per frame with the position the module should be at right now, including while a snap animation plays, so write them straight through and let onPositionUpdated() decide when to persist.