Gambling System
The Gambling System adds a fully-featured casino to EliteMobs. Players can wager their Elite Coins across four different minigames, go into debt when they run out of money, and face the consequences when the Debt Collector comes knocking. Server administrators can configure much of the system, including the payout multipliers for Blackjack, Coin Flip and Higher/Lower — though slot machine payouts and the maximum debt are hardcoded.
Setup
Players access the games through specially configured NPCs and need elitemobs.gambling.npc, which is granted by default. The four games have their own interaction types; the house-earnings display is selected by NPC filename.
To set up a gambling NPC, create an NPC configuration file and set the interactionType to one of the following values:
| Interaction Type | Description |
|---|---|
GAMBLING_BLACKJACK | Opens the betting menu for Blackjack |
GAMBLING_COINFLIP | Opens the betting menu for Coin Flip |
GAMBLING_SLOTS | Opens the betting menu for Slot Machine |
GAMBLING_HIGHERLOWER | Opens the betting menu for Higher or Lower |
The Gambling Den Owner NPC does not use a special interaction type. To set it up, create an NPC with the filename gambling_den_owner.yml. The house earnings display will appear above the NPC automatically based on this filename.
EliteMobs ships premade NPC configs for all five roles, so you normally just place them:
| File | Role |
|---|---|
blackjack_dealer.yml | Blackjack (Vincent, the Blackjack Dealer) |
coin_flipper.yml | Coin Flip (Lucky Pete) |
slot_machine_operator.yml | Slot Machine (Spinner Sam) |
card_shark.yml | Higher or Lower (Ace Morgan, the Card Shark) |
gambling_den_owner.yml | House earnings display |
Games
Blackjack
The goal is to get as close to 21 as possible without going over. This implementation has the following rules.
Rules
- Both the player and dealer are dealt two cards.
- The dealer's second card is hidden until the player stands.
- Aces count as 11 or 1 (automatically adjusted to prevent busting when possible).
- Face cards (Jack, Queen, King) count as 10.
- The dealer stands on 17.
- Cards are drawn independently with replacement; there is no finite deck to count. Reaching 21 after a Hit automatically stands.
- The menu displays five card slots per hand. Extra draws still count toward the total even when their cards no longer fit in those slots.
- A player who is dealt a natural Blackjack receives its payout immediately, including when the dealer also has a natural Blackjack.
Actions
| Action | Description |
|---|---|
| Hit | Draw another card. |
| Stand | Keep your current hand; the dealer then plays. |
| Double Down | Pay another stake, double your bet, draw exactly one card, then stand unless you bust. Only available on your first action with 2 cards, if your remaining balance plus credit covers the extra stake. |
Payouts
| Outcome | Default Multiplier |
|---|---|
| Normal Win (player's total beats dealer, or dealer busts) | 2.0x |
| Blackjack (21 with the first two cards) | 2.5x |
| Push (tie) | 1.0x (bet returned) |
| Loss (player busts or dealer's total is higher) | 0x (bet lost) |
Closing the Menu
If a player closes the menu during the dealer's turn, the dealer's hand is played out automatically and the result is resolved. If a player closes the menu before standing, the bet is forfeited.
Coin Flip
A simple 50/50 game. Pick Heads or Tails, and the coin decides your fate.
How to Play
- The game opens with a Heads button and a Tails button.
- Click one to make your choice.
- A coin flip animation plays.
- The result is shown.
Payouts
| Outcome | Default Multiplier |
|---|---|
| Correct guess | 1.9x |
| Edge (coin lands on its edge) | 5.0x |
| Wrong guess | 0x (bet lost) |
The Edge Outcome
There is a 1% chance the coin lands on its edge instead of Heads or Tails. When this happens, the player always wins regardless of their choice, and receives a 5x payout on their bet. A special chat message and visual display are shown for this rare event.
With these defaults, Heads and Tails each occur 49.5% of the time. The expected payout is 0.495 × 1.9 + 0.01 × 5 = 0.9905 times the stake, so the combined house edge is 0.95%. The 5% edge of a plain 1.9x coin flip applies only when the edge outcome is disabled. Multipliers include the original stake.
Closing the Menu
If a player closes the menu before making a choice, the bet is forfeited.
Slot Machine
Spin three reels and match symbols to win. Rarer symbols pay more.
How to Play
- The game opens with a 3x3 reel grid and a Spin button.
- Click Spin to start the reels.
- Each reel stops in sequence with an animation.
- The middle row (payline) determines the result.
Symbols and Payouts
Each reel independently draws a symbol using the weights below. The payout multiplier for three matching symbols is 100 / weight. Exactly two matching symbols anywhere on the middle row, including the first and third positions, pay 25% of that symbol's three-match payout. These are total returns including the stake: a Cherry or Lemon pair returns less than the original bet even though the menu presents a win.
| Symbol | Weight | Chance | 3-Match Payout | 2-Match Payout |
|---|---|---|---|---|
| Cherry | 35 | 35% | 2.86x | 0.71x |
| Lemon | 28 | 28% | 3.57x | 0.89x |
| Orange | 20 | 20% | 5.0x | 1.25x |
| Golden Bell | 10 | 10% | 10.0x | 2.5x |
| Silver Bar | 5 | 5% | 20.0x | 5.0x |
| Lucky 7 | 2 | 2% | 50.0x | 12.5x |
Three Lucky 7s is the Jackpot and receives a special visual and sound effect.
Closing the Menu
If a player closes the menu before spinning, the bet is forfeited.
After a result, Spin Again charges another bet of the same amount and returns to the ready screen. The player must then click Spin; closing in between forfeits that newly charged bet.
Higher or Lower
A streak-based card game. Guess whether the next card is higher or lower than the current one, and build up a multiplier. Cash out at any time or risk it all.
How to Play
- A card is drawn and shown (values range from 2 to 14, where Ace = 14).
- Guess whether the next card will be Higher or Lower than the current card.
- If you guess correctly, your multiplier increases and the revealed card becomes the new current card.
- You can Cash Out at any time after at least one correct guess.
- If you guess wrong, you lose your entire bet.
- If the next card is equal to the current card, it counts as a loss.
Streak Multiplier
Each correct guess multiplies your winnings by the configured multiplier (default 1.3x). The multiplier stacks:
| Streak | Multiplier (default) | Payout on 100 Coin Bet |
|---|---|---|
| 1 | 1.3x | 130 |
| 2 | 1.69x | 169 |
| 3 | 2.197x | 219.7 |
| 4 | 2.856x | 285.6 |
| 5 | 3.713x | 371.3 |
| ... | ... | ... |
| 12 | ~23.3x | ~2,330 |
Max Streak and Auto-Cashout
The maximum streak is 12. When a player reaches 12 correct guesses, they are automatically cashed out and their winnings are awarded. This prevents runaway multipliers.
Closing the Menu
If a player closes the menu while they have a winning streak, they are automatically cashed out and receive their current winnings. If they close before making any guess, the bet is forfeited.
Betting
Before any game starts, the player is presented with a betting menu to select their wager.
Bet Limits
| Setting | Default Value |
|---|---|
| Minimum Bet | 10 |
There is no configurable maximum bet. The menu uses whole-coin integer bets; All In discards any fractional coins when taking the balance plus available credit.
minBet sets Reset and the lower bound on decrease buttons. The initial amount is max(minBet, 10). It is not a universal transaction guard: All In can set a positive amount below minBet, and Play currently accepts it if affordable. Do not rely on this setting as an enforced minimum for every path.
Betting Menu Controls
The betting menu provides several controls:
- Increment Buttons -- Three sizes of increase and decrease buttons. With at least 100 coins and no debt, the increments are 5%, 10%, and 25% of balance, truncated to whole coins with a minimum increment of 1. Otherwise they are fixed at 10, 50, and 100.
- All In -- Sets the bet to the maximum the player can afford (including available credit).
- Reset -- Resets the bet to the minimum.
- Play -- Starts the game with the current bet. Only active if the player can afford the bet.
- Cancel -- Closes the menu without betting.
The menu shows the current balance. Debt and available-credit lines appear when debt is positive, even though debt-free players can also use credit.
Debt System
Players can bet beyond their balance by going into debt. The casino extends credit up to a fixed limit.
How Debt Works
- When a player places a bet that exceeds their balance, the remaining amount is added as gambling debt.
- The maximum debt a player can accumulate is 500 coins. This is hardcoded and not configurable.
- Players cannot place bets that would push their debt beyond the maximum.
- When a player wins, their winnings are first applied to pay off debt before being added to their balance. Other currency earned through EliteMobs also pays this debt first, including when Vault integration is enabled. Refunded enchantment purchases bypass debt collection.
Available Credit
A player's available credit is max(0, maxDebt - currentDebt) for finite debt values. The betting menu displays it when the player has debt.
Debt Warning
When a player goes into debt, they receive a warning message. The Debt Collector may come for them while they carry outstanding debt.
Debt Collector Boss
The Debt Collector is a custom boss that spawns to hunt down players who are in gambling debt.
Spawn Conditions
- The player must have outstanding gambling debt.
- A periodic check runs every 60 minutes (configurable) for all online players.
- The first check waits a full interval after initialization. An eligible player must also be at least one interval past their last spawn attempt; this timer resets on plugin shutdown.
- Each check has a 50% chance (configurable) to spawn the Debt Collector for an eligible player.
- Only one Debt Collector can be active per player at a time.
- The Debt Collector uses the custom boss file
debt_collector.yml.
The periodic eligibility check has no world or game-mode exclusion of its own; the normal custom-boss spawn can still fail. Paying off debt prevents future periodic spawns but does not automatically remove a collector already present.
Level Scaling
The shipped debt_collector.yml uses a dynamic level and scaledCombat: true, so its combat calculations adapt to each player. Its health and damage multipliers come from that boss file. The spawn routine does not assign the pursued player's combat level directly; changing the boss configuration changes its scaling behavior.
Behavior
- The Debt Collector tries ten surface positions 5 to 10 horizontal blocks away. If none qualifies, it falls back to an offset within 5 blocks on each horizontal axis at the player's height.
- It immediately targets the player it was spawned for.
- It has a timeout of 600 seconds (10 minutes) by default. If not killed within that time, it despawns and warns the player it will return.
Outcomes
| Outcome | Effect |
|---|---|
| Debt Collector is killed | Its tracked target receives the return message if online, even if another player killed it. Debt is not reduced. |
| Player dies from a direct Debt Collector hit | The victim's debt is reduced by 50 coins (configurable). If this clears the debt, they are notified. The collector is removed after 5 seconds. The death handler requires the last damaging entity itself to be a debt_collector.yml boss; it does not trace projectile shooters or later environmental deaths. |
| Manager timeout | The collector is removed and sends a warning. A future periodic check may spawn another one if the player remains eligible and the chance succeeds. |
Gambling Den Owner
The Gambling Den Owner displays House Earnings above its head as floating text. This shows recorded stakes minus payouts, including stakes financed by debt. It is not a separate bank balance or a tally of cash already collected from debtors.
- Positive earnings are shown in green (e.g.,
+1234.56). - Negative earnings (players winning more than losing) are shown in red (e.g.,
-567.89). - The display updates every second.
- House earnings are persisted to
house_earnings.ymland survive server restarts.
Configuration
All gambling settings are stored in GamblingSettings.yml. Below are the key gameplay-affecting settings.
General Settings
| Key | Description | Default |
|---|---|---|
gamblingEnabled | Enables or disables the entire gambling system. When disabled, gambling NPCs will not work and the Debt Collector will not spawn. | true |
minBet | Reset amount and lower bound for decrease buttons; see the All In limitation above. | 10 |
Note: The maximum debt (500.0) is hardcoded and not configurable.
The loader requires positive integers for minBet, the collector check interval and the timeout; probabilities must be finite and between 0 and 1. Payout multipliers and the death-related debt reduction must be finite and non-negative. Invalid values log a warning and are replaced with their defaults in the loaded configuration.
Payout Multipliers
| Key | Description | Default |
|---|---|---|
payouts.blackjack.normal | Payout multiplier for a normal Blackjack win. | 2.0 |
payouts.blackjack.blackjack | Payout multiplier for getting a natural Blackjack (21 with first two cards). | 2.5 |
payouts.coinFlip.normal | Payout multiplier for a correct Heads/Tails guess. A 1.9x payout has a 5% house edge only when the edge outcome is disabled. | 1.9 |
payouts.coinFlip.edgeChance | Chance (0.0 to 1.0) for the coin to land on its edge (bonus win). Set to 0.0 to disable. | 0.01 |
payouts.coinFlip.edgePayout | Payout multiplier when the coin lands on its edge. | 5.0 |
payouts.higherLower.multiplierV2 | Multiplier applied per correct guess in Higher/Lower. Stacks multiplicatively. | 1.3 |
Coin-flip settings share one YAML section:
payouts:
coinFlip:
normal: 1.9
edgeChance: 0.01
edgePayout: 5.0
If your existing file stores a number directly at payouts.coinFlip, move that value under normal and add the two edge settings. EliteMobs disables gambling and reports this correction without rewriting the file. Reload after correcting it.
Slot Machine Payouts
Slot machine payouts are not configurable. They are calculated automatically from symbol weights using the formula 100 / weight:
| Symbol | Weight | 3-Match Payout | 2-Match Payout |
|---|---|---|---|
| Cherry | 35 | 2.86x | 0.71x |
| Lemon | 28 | 3.57x | 0.89x |
| Orange | 20 | 5.0x | 1.25x |
| Bell | 10 | 10.0x | 2.50x |
| Bar | 5 | 20.0x | 5.00x |
| Lucky 7 | 2 | 50.0x | 12.50x |
There are no payouts.slots.* keys in GamblingSettings.yml at all — the only slot-machine entries in the file are the slots.* UI strings (button names, labels, result titles). Payouts are always derived from the hardcoded symbol weights.
Debt Collector Settings
| Key | Description | Default |
|---|---|---|
debtCollector.spawnChance | Chance (0.0 to 1.0) that the Debt Collector spawns on each check. | 0.5 |
debtCollector.checkIntervalMinutes | How often (in minutes) to check if the Debt Collector should spawn for players in debt. | 60 |
debtCollector.timeoutSeconds | How long (in seconds) before the Debt Collector despawns if not killed. | 600 |
debtCollector.debtReductionOnPlayerDeath | Amount of debt reduced when the Debt Collector kills the player. | 50.0 |
Economy Safety
Bets are charged before a game opens. Coin Flip and Slots settle their result before the result animation; Higher/Lower records each guess before its animation and pays when the player cashes out. Blackjack resolves after the dealer finishes drawing, or immediately plays out that hand when its menu closes during the dealer turn. Payouts are rounded to two decimal places and include the original stake. The shared outcome handler prevents the same pending payout from being awarded twice.
The menu-close rules above also apply when a player's inventory closes on disconnect. These guards do not make an unfinished session recoverable after a server crash or plugin shutdown; avoid restarting during active games.