TrajCakeWars

A complete, production-ready Cake Wars 1v1 minigame engine for Spigot, Paper, Purpur, and all Spigot-based forks. Built for performance, customization, and seamless integration.

🏟️

Multi-Arena

Unlimited concurrent games. Each match runs in its own temporary cloned world.

βš™οΈ

Fully Configurable

Shop items, rewards, messages, generators β€” all in one config.yml.

πŸ”Œ

Plugin Agnostic

Works with Citizens, FancyNpcs, ZNPCsPlus, Vault, LuckPerms, TAB, or a simple renamed villager.

πŸ”’

Private Sessions

Create invite-only matches with a 6-character code. Challenge your friends.

πŸ’€

No Death Screen

Custom death system. No vanilla death screen ever. Smooth spectator respawn with countdown.

🧱

Protected Map

TNT only destroys player-placed blocks. Original terrain is untouchable.

πŸŽ’

Inventory Save

Full inventory backup and restore for SMP servers. No item loss. New

πŸ”¨

Unbreakable Items

All game items have no durability. No tool or armor breaking mid-fight. New

Requirements

ComponentMinimumRecommended
ServerSpigot 1.21.xPaper 1.21.x
Java2121
RAM2 GB4 GB+
No dependencies required. TrajCakeWars is fully standalone. Compatible with Spigot, Paper, Purpur, Pufferfish, and all Spigot-based forks. Not compatible with Folia, Fabric, Forge, or Sponge.

Installation

1

Drop the JAR

TrajCakeWars.jar into plugins/

2

Start the server

Generates config.yml and arenas.yml

3

Create a template

Copy your CakeWars map to cw_templates/

4

Configure the arena

In-game setup commands

5

Set the lobby point

/cw setlobby at the exact return location

Quick Start

1. Prepare the template

# Manual copy or in-game:
/cw savetemplate desert

2. Configure the arena

/cw create desert
/cw tp desert                   # TP into the template
/cw set desert spawn1            # Stand at player 1 spawn
/cw set desert spawn2            # Stand at player 2 spawn
/cw set desert cake1             # Stand on cake block 1
/cw set desert cake2             # Stand on cake block 2
/cw set desert gen1              # Iron generator island 1
/cw set desert gen2              # Iron generator island 2
/cw set desert diamond           # Diamond gen (repeat for each)
/cw set desert lobby             # In-arena spectator point
/cw setname desert Β§6Β§lDesert
/cw settemplate desert desert
/cw back                         # Return to lobby
/cw setlobby                     # Set exact lobby return point
/cw enable desert
/cw save

Creating a Template

A template is a world folder in cw_templates/ at the server root. Each game clones it into a temporary world. The original is never modified.

Method 1: Manual copy

server/cw_templates/desert/   ← full world folder

Method 2: In-game

/cw savetemplate desert
Important: The template must include shop NPCs (entities are cloned with the terrain). Place your villagers before saving the template.

Configuring an Arena

Use /cw tp <arena> to teleport into the template world. Use /cw back to return.

PointCommandStatusDescription
spawn1/cw set <a> spawn1RequiredPlayer 1 spawn point
spawn2/cw set <a> spawn2RequiredPlayer 2 spawn point
cake1/cw set <a> cake1RequiredPlayer 1 cake block
cake2/cw set <a> cake2RequiredPlayer 2 cake block
gen1/cw set <a> gen1RequiredIron generator, island 1
gen2/cw set <a> gen2RequiredIron generator, island 2
lobby/cw set <a> lobbyRequiredArena spectator/waiting point
diamond/cw set <a> diamondOptionalDiamond gen (stackable, repeat for each)

Additional settings

/cw setname <arena> <name>          # Display name (supports Β§)
/cw seticon <arena> <MATERIAL>     # GUI icon
/cw settemplate <arena> <name>     # Link to cw_templates/ folder
/cw set <arena> diamond clear     # Remove all diamond gens

Shop NPCs

The plugin detects interactions with existing entities via configurable name keywords. Works with any NPC plugin or vanilla renamed mobs.

Setup

  1. Place NPCs in your template world using any method
  2. Name them with a keyword (e.g. "Items Shop", "Blocks Shop")
  3. Save the template β€” NPCs are cloned with the world for every game

Default keywords

ShopTriggers when name contains
Items ShopItems, Item, Combat, Weapons
Blocks ShopBlocks, Block, Build, Construction
Case-insensitive, substring matching. Color codes are stripped before comparison. A villager named "Items Shop" triggers the Items Shop because it contains "Items".

Using vanilla villagers

# Spawn a villager
/summon villager ~ ~ ~

# Rename with a name tag at an anvil ("Items Shop" or "Blocks Shop")

# Make it stay still and invincible
/data merge entity @e[type=villager,sort=nearest,limit=1] {NoAI:1b,Invulnerable:1b,Silent:1b}

# Rotate it (0=South, 90=West, 180=North, 270=East)
/data merge entity @e[type=villager,sort=nearest,limit=1] {Rotation:[180f,0f]}

Generators

TypeResourceDefault IntervalMax on Ground
Iron (per island)Iron Ingot2s (40 ticks)32
Diamond (shared)Diamond30s (600 ticks)4

Generators stop spawning when the ground cap is reached within a 3-block radius.

Lobby Point

The lobby point is where players are teleported after every game. Independent of world spawn.

/cw setlobby   # Saves your exact position (x, y, z, yaw, pitch, world)
Always set this. Without it, the plugin falls back to the world spawn which may not be at the correct Y level, causing players to fall into the void.

Game Flow

/cw β†’ GUI Menu β†’ Play / Private
β†’ 2 players matched β†’ Clone template world
β†’ Save inventories β†’ TP players β†’ Freeze 5s
β†’ GO! Generators active, shops open
β†’ PvP + Eat enemy cake (7 slices, 1s cooldown)
β†’ Cake destroyed β†’ next death = eliminated
β†’ Winner β†’ Rewards executed
β†’ Restore inventories β†’ TP to lobby β†’ Delete temp world

Matchmaking

TypeAccessBehavior
PublicGUI Play / /cw joinRandom map, any opponent
Map-SpecificGUI Choose MapMatch on the same map
Private/cw private <arena>Invite code, specific map

Cross-queue matching: a random-queue player can be matched with a map-specific player if the arena is available.

Private Sessions

/cw private desert     # Creates session β†’ Code: K4HN7P
/cw join K4HN7P        # Friend joins β†’ Game starts

The host stays in the main lobby while waiting. Open sessions are visible in the GUI.

Cake Mechanic

PropertyValue
Slices to destroy7 (vanilla cake)
Cooldown1 second between bites
InteractionRight-click only (left-click blocked)
ProtectionCannot eat your own cake

When a cake is fully eaten, the owner can no longer respawn. Next death is permanent elimination.

Shops

Fully driven by config.yml. Two default shops: Items and Blocks.

TypeBehavior
swordAuto-replaces lower tier sword. Always slot 0.
armor-setAuto-equips chestplate + leggings. Replaces lower tier.
armor-pieceAuto-equips single piece. Replaces lower tier.
normalAdded to inventory. Supports amount field.

Tier hierarchy: Leather (0) β†’ Chainmail (1) β†’ Iron (2) β†’ Diamond (3)

Death System

TNT & Explosions

Explosions (TNT, fireballs) only destroy blocks placed by players during the game. The original template terrain is always protected and never modified.

Freeze Phase

During the pre-game countdown (default 5 seconds), players are frozen in place via continuous teleportation. They can look around but cannot move, break blocks, place blocks, or take damage. Game mode is set to Adventure during freeze.

Inventory Save & Restore New in v2.2

Critical for SMP and survival servers. When enabled, the plugin saves the player's complete state before each game and restores it after.

What is saved:

game:
  save-inventory: true   # Enable inventory save/restore
Recommended for any server where players have persistent inventories. Without this, player items are lost when entering a game.

Command Blocking New in v2.2

During a game, all commands are blocked except those in the whitelist. This prevents players from using /rtp, /tpa, /spawn, /home, or any other command that could break the game flow.

game:
  allowed-commands:    # Only these commands work during a game
    - "cw"
    - "cakewars"
    - "cake"
    - "msg"
    - "r"
    - "reply"

Players with the cakewars.admin permission bypass this restriction.

Unbreakable Items New in v2.2

All items given during a game (swords, armor, pickaxes, bows, shears, etc.) are flagged as Unbreakable. No durability loss, no tool breaking mid-fight. Applies to shop purchases and the starter wooden sword on respawn.

game:
  unbreakable-items: true

Configuration β€” General

settings:
  prefix: "&d&lCakeWars &r&7Β» &r"   # Chat message prefix
  lobby-world: "world"               # Lobby world name (fallback)
  lobby-location:                     # Set by /cw setlobby
    world: "world"
    x/y/z/yaw/pitch: ...

Configuration β€” Game Settings

game:
  countdown: 5              # Pre-game freeze duration (seconds)
  respawn-time: 5            # Respawn countdown when cake is alive
  max-duration: 600          # Max game length in seconds (0 = infinite)
  save-inventory: true       # Save/restore player inventory
  unbreakable-items: true    # All game items are unbreakable
  allowed-commands:          # Whitelisted commands during games
    - "cw"
    - "cakewars"
    - "msg"
    - "r"
    - "reply"

Configuration β€” Generators

generators:
  iron:
    interval: 40     # Ticks between spawns (20 = 1 second)
    max: 32          # Max items on ground per generator
  diamond:
    interval: 600
    max: 4

Configuration β€” Rewards

rewards:
  enabled: true
  winner:
    commands:                   # Console commands on win
      - "give %winner% diamond 5"
      - "eco give %winner% 100"    # Works with Vault
    message: "&6⭐ VICTORY! &a+5 Diamonds"
  loser:
    commands: []
    message: "&cDefeat. Try again!"

Variables: %winner%, %loser%, %arena%

Configuration β€” Shop Items

Both shops are fully defined in config.yml.

items-shop:
  title: "&d&lItems Shop"
  size: 45                     # 9, 18, 27, 36, 45, 54
  items:
    my-item:                   # Unique key (any name)
      slot: 10                  # Inventory position
      type: normal              # sword | armor-set | armor-piece | normal
      material: GOLDEN_APPLE
      name: "&6Golden Apple"     # Supports color codes
      amount: 1
      price: 2
      currency: DIAMOND         # IRON_INGOT or DIAMOND
      lore: ["&7Description"]

For armor-set type, use chest and legs instead of material.

Configuration β€” NPC Detection

shop-detection:
  items-keywords: ["Items", "Item", "Combat", "Weapons"]
  blocks-keywords: ["Blocks", "Block", "Build", "Construction"]

Case-insensitive, substring matching. Works on any living entity. Color codes stripped before comparison.

Player Commands

CommandDescription
/cwOpen main menu (GUI)
/cw joinJoin public matchmaking queue
/cw join <code>Join a private session by invite code
/cw leaveLeave queue, session, or game
/cw queueShow queue size
/cw private <arena>Create a private session

Admin Commands

All require cakewars.admin permission.

Arena Management

CommandDescription
/cw adminAdmin GUI panel
/cw create <id>Create a new arena
/cw delete <id>Delete an arena (type twice to confirm)
/cw enable <arena>Enable for matchmaking
/cw listList all arenas with status
/cw info <arena>Arena detail view (GUI)
/cw saveSave all configurations to disk

Setup

CommandDescription
/cw set <arena> <point>Set a configuration point at your location
/cw setname <arena> <name>Set display name
/cw seticon <arena> <MATERIAL>Set GUI icon
/cw settemplate <arena> <name>Link to template in cw_templates/
/cw savetemplate <name>Save current world as template

Teleportation

CommandDescription
/cw tp <arena>Teleport into template world for setup
/cw backReturn to lobby
/cw setlobbySet exact lobby return point at your position

Permissions

PermissionDefaultDescription
cakewars.playtruePlay CakeWars, use GUI and commands
cakewars.adminopArena management, admin GUI, bypass command blocking

Compatibility

Server Software

Compatible with Spigot, Paper, Purpur, Pufferfish, and all Spigot-based forks. Not compatible with Folia, Fabric, Forge, or Sponge.

NPC Plugins

Citizens2

Full support. /npc command add -p cw for lobby NPC.

ZNPCs

Full support. /znpcs action <id> add CMD cw

FancyNpcs

Full support. Set keywords in NPC name.

Vanilla Villagers

Rename with a name tag. Works out of the box.

Recommended Companion Plugins

PluginPurpose
TABPer-world tab list β€” isolates game tab from lobby
LuckPermsPermission management
Vault + EssentialsXEconomy for reward commands

Architecture

cw_templates/desert/     ← immutable template
    β†’ File copy β†’ cw_game_<uuid>/  ← temporary clone
    β†’ WorldCreator β†’ Game plays β†’ Unload β†’ Deleted

Auto gamerules: no mobs, no daylight cycle, no weather, fixed noon, no fire, no advancements.

Plugin Structure (~2400 lines)

fr.trajstudio.cakewars/
β”œβ”€β”€ CakeWarsPlugin          β”œβ”€β”€ gui/MainMenuGUI
β”œβ”€β”€ arena/Arena             β”œβ”€β”€ gui/MapSelectGUI
β”œβ”€β”€ arena/ArenaManager      β”œβ”€β”€ gui/AdminGUI
β”œβ”€β”€ arena/ArenaState        β”œβ”€β”€ gui/GUIListener
β”œβ”€β”€ commands/CakeWarsCmd    β”œβ”€β”€ listeners/GameListener
β”œβ”€β”€ game/GameInstance       β”œβ”€β”€ listeners/ShopListener
β”œβ”€β”€ matchmaking/Manager     β”œβ”€β”€ listeners/ConnectionListener
β”œβ”€β”€ shop/ShopGUI            β”œβ”€β”€ utils/AutoEquip
                            └── utils/WorldManager

FAQ

How many concurrent games?

10-20 with 4 GB RAM. Limited by RAM and disk speed.

Does TNT damage the map?

No. Only player-placed blocks are destroyed.

Server crash during a game?

Temporary world folders (cw_game_*) remain on disk. Delete them manually when the server is stopped.

2v2 / 4v4 support?

Current version is 1v1 only.

Empty shop?

Delete plugins/TrajCakeWars/config.yml and restart to regenerate with full shop configuration.

Players fall into void after game?

Run /cw setlobby at the correct position in your lobby.

Player lost inventory?

Enable game.save-inventory: true in config.yml. Essential for SMP servers.

How to add a new map?

Build map β†’ copy to cw_templates/ β†’ /cw create β†’ /cw tp β†’ /cw set all points β†’ /cw enable β†’ /cw save

How to update?

Replace the JAR and restart. arenas.yml is preserved. Delete config.yml to regenerate if new config sections were added.

Changelog

v2.2.2

Added

Changed

Fixed

TrajCakeWars v2.2.2 β€” Built by TrajStudio
Β© 2025 TrajStudio. All rights reserved.