TDXDevelopment
TDX Welcome RaffleConfiguration

rewards

The prizes in rewards.yml, their chances, commands and messages.

rewards.yml lists the prizes. The winner of every raffle gets exactly one, picked at random by chance.

Quick example

plugins/TDXWelcomeRaffle/rewards.yml
rewards:

  flytime:
    chance: 10%
    display: "2 minutes of flytime"
    commands:
      - "voucher give %player% fly2min 1"
    message: "&eYou have won &a2 minutes of flytime&e from the welcome raffle!"

  powerkey:
    chance: 10%
    display: "a Power Key"
    commands:
      - "crate key give %player% power_key 1"
    message: "&eYou have won a &aPOWER KEY&e from the welcome raffle!"

  diamonds:
    chance: 30%
    display: "3 diamonds"
    commands:
      - "give %player% diamond 3"
    message: "&eYou have won &a3 diamonds&e from the welcome raffle!"

The key under rewards (flytime, powerkey) is the prize's id. It is used by /welcomeraffle testreward and in console logs.

Reference

KeyTypeDefaultNotes
chancenumber110, 10% and 2.5 all work. Compared with the other prizes, see below.
displaystringthe idThe name used for %reward% in messages, for example the winner announcement.
commandslistConsole commands to run, without the slash.
commandstringOne command, as a shorter way to write commands. Both can be used together.
messagestringSent to the winner. Leave it out to send you-won from messages.yml.

How the chances work

Chances are compared with each other, they do not need to add up to 100, and there is always a prize. In the example above the three chances add up to 50, so:

PrizeChanceReal odds
flytime10%20%
powerkey10%20%
diamonds30%60%

Run /welcomeraffle rewards to see the real odds of your own file. A prize with a chance of 0 or less, or a chance that is not a number, is skipped with a warning in console.

Placeholders

In commands and message:

TokenReplaced with
%player%The winner's name
%uuid%The winner's UUID (commands only)
%newcomer%The new player the raffle was for
%reward%This prize's display name
%prefix%The prefix from messages.yml (message only)

Colours and quotes

Messages accept everything messages.yml does: &e codes, &#rrggbb hex and MiniMessage tags.

Always put a message in quotes. Without them, YAML reads a value that starts with & as something else and the first word of your message disappears:

message: &eYou won!      # loses "You"
message: "&eYou won!"    # works

The layout from the original concept

This layout, with numbered entries and a single command, is read just the same:

plugins/TDXWelcomeRaffle/rewards.yml
RaffleRewards:
  '1':
    flytime:
      command: 'voucher give %player% fly2min 1'
      chance: 10%
      message: '&eYou have won &a2 minutes of flytime&e from the welcome raffle!'
  '2':
    powerkey:
      command: 'crate key give %player% power_key 1'
      chance: 10%
      message: '&eYou have won a &aPOWER KEY &e from the welcome raffle!'

Testing a prize

/welcomeraffle testreward <player> [prize]

Gives the prize to an online player right now: its commands really run and the player gets its message and the win sound. Leave out the prize to roll a random one.

Plugin updates never touch rewards.yml, so prizes you delete stay deleted.