Skip to content

Latest commit

 

History

History
56 lines (45 loc) · 2.31 KB

File metadata and controls

56 lines (45 loc) · 2.31 KB

MCPremium System

This system manages player VIP status and other custom statuses (e.g., premium, premium2).

Database Schema

-- Table for storing VIP information
-- total_spent: The single source of truth for lifetime top-up amount
-- VIP level can be calculated in code: vipLevel = floor(total_spent / 100)
CREATE TABLE IF NOT EXISTS vip_data (
    account_type VARCHAR(50) NOT NULL DEFAULT 'player',
    account_uuid VARCHAR(36) NOT NULL,
    total_spent BIGINT DEFAULT 0, 
    updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,
    PRIMARY KEY (account_type, account_uuid)
);

-- Table for managing account statuses (one active status per account)
-- time_left: Remaining duration in seconds
CREATE TABLE IF NOT EXISTS account_status (
    account_type VARCHAR(50) NOT NULL DEFAULT 'player',
    account_uuid VARCHAR(36) NOT NULL,
    status_name VARCHAR(50) NOT NULL,
    priority INTEGER DEFAULT 0,
    time_left BIGINT NOT NULL, 
    is_active INTEGER DEFAULT 1, 
    created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
    PRIMARY KEY (account_type, account_uuid)
);

-- Index for faster lookup when querying active statuses per account
CREATE INDEX IF NOT EXISTS idx_status_uuid ON account_status(account_type, account_uuid, is_active);

API Endpoints

All endpoints are prefixed with /api and require a valid Bearer token.

VIP Data

  • GET /api/vip/:uuid?account_type=player: Returns VIP data for an account.
  • POST /api/vip/topup: Increments total_spent for an account.
    • Body: { "account_type": "player", "account_uuid": "...", "amount": 100 }

Account Status

  • GET /api/status/:uuid?account_type=player: Returns the active status for an account.
  • POST /api/status/set: Sets a status for an account.
    • If an account already has an active status, it can only be overwritten if:
      1. The status_name is identical (updates duration/priority).
      2. The new status has a strictly higher priority than the existing one.
    • In case 2, the previous status will be automatically deactivated (is_active set to 0).
    • Body: { "account_type": "player", "account_uuid": "...", "status_name": "premium", "priority": 1, "time_left": 3600 }
  • POST /api/status/deactivate: Removes the active status for an account.
    • Body: { "account_type": "player", "account_uuid": "..." }