RA-StoreSync

Polls the store_orders table of a top-up website and runs RA-CoinsEconomy commands to give coins for paid orders and take them back for refunds, with safe retry and processed flags.

Author: RajaAditya Website: rajaaditya.my.id Version: 1.0.0 API: Paper 1.21.x (Java 17+)


Features

Website Top-Ups to In-Game Coins

  • Your coin store website writes orders into a store_orders table
  • This plugin checks that table on a timer and delivers the coins in game
  • Paid orders run coins give <player> <amount>, refunded orders run coins take <player> <amount>
  • Other statuses (pending, failed, cancelled, expired) never trigger anything

Reliable Delivery

  • Once a command has run successfully, the order is marked processed = true
  • If the command fails (for example RA-CoinsEconomy had crashed), the order stays unprocessed and is tried again on the next poll
  • The plugin never writes the balance table directly. It goes through RA-CoinsEconomy's own command, so validation, caching, and multi-server sync stay on one tested path

Flexible Commands

  • The give and take commands are configurable, so another economy plugin can be used later if its format differs

Dependencies

ComponentRequiredPurpose
RA-CoinsEconomyYes (hard dependency)Provides the /coins command. It must be installed on the same server
MySQLYesThe same database as the website and RA-CoinsEconomy

The plugin refuses to enable if RA-CoinsEconomy is not on the same server. The lobby is a good place, as long as the lobby also has RA-CoinsEconomy.


Installation

  1. Place RA-StoreSync.jar into the plugins/ folder of the server that has RA-CoinsEconomy
  2. Restart the server to generate config.yml
  3. Put the same database details as the website and RA-CoinsEconomy into config.yml
  4. Restart and run /storesync status

File Structure

text
1
plugins/RA-StoreSync/
└── config.yml       # Database, polling interval, commands

Configuration

config.yml

yaml
1
database:
  host: localhost
  port: 3306
  database: ra_coins      # same as the website DATABASE_URL and RA-CoinsEconomy
  username: your_user
  password: "YOUR_PASSWORD"
  pool-size: 5
  connection-timeout-ms: 5000

polling:
  interval-seconds: 10

commands:
  give-command: "coins give {player} {amount}"
  take-command: "coins take {player} {amount}"

messages:
  console-prefix: "[RA-StoreSync] "

Command placeholders: {player} and {amount}.

The database connection and polling interval need a full restart to change. /storesync reload only refreshes the values kept in memory.


How Polling Works

Every polling.interval-seconds seconds the plugin looks for orders it has not handled yet:

sql
1
SELECT * FROM store_orders WHERE status = 'PAID'     AND processed = false;
SELECT * FROM store_orders WHERE status = 'REFUNDED' AND processed = false;

Commands

CommandDescriptionAccess
/storesync statusShow the database connection, RA-CoinsEconomy status, and polling intervalAdmin
/storesync forcepollPoll right now instead of waitingAdmin
/storesync reloadReload the config values in memoryAdmin

Permissions

PermissionDefaultDescription
rastoresync.adminopManage RA-StoreSync

License

Developed by RajaAditya — rajaaditya.my.id