Skip to content
Flint
Dokumentation
Writing scripts

Paper and Velocity

Running Flint on the proxy and the backends, and sending messages between them.

Install Flint on the Velocity proxy and on every Paper server behind it. No configuration is needed: they talk over the flint:main plugin channel.

Messages between servers

On a Paper server:

import network
from text import escape

command gchat(message: text):
    line = "<dark_aqua>[{network.server()}] <white>{sender.name}<gray>: {escape(message)}"
    broadcast line
    network.broadcast("gchat", line)

on network.message "gchat":
    broadcast data

command lobby:
    network.connect(sender, "lobby")

On Velocity:

# platform: velocity
import network, proxy

command alert(message: text):
    permission "flint.alert"
    network.broadcast("alert", message)

on network.message "gchat":
    print("[{source}] {data}")
Call Does
network.send(server, channel, data) to one server by name, or "proxy"
network.proxy(channel, data) to the proxy
network.broadcast(channel, data) to every other server and the proxy
network.server() / network.servers() this server’s name / all names
network.connect(player, server) moves a player

data can be text, numbers, lists and maps (about 29 KB at most). A handler receives channel, data and source. Without a channel after on network.message, the handler gets every channel.

Things to know

  • Plugin messages travel over a player’s connection. A message to a server with nobody online is queued (up to 200) and delivered when the next player connects there.
  • The proxy drops anything on the Flint channel that comes from a game client, so players cannot forge messages. As always with Velocity, the backends must only be reachable through the proxy.
  • For data that must be shared at any time, use a common database (storage.type=database or the db module).

Proxy-only features

On Velocity scripts get the proxy module (players, servers, console commands), the events player.login, server.connect, server.connected and server.kick, and the server argument type:

# platform: velocity
import proxy

command send(target: player, destination: server):
    permission "network.send"
    target.connect(destination)

on server.kick:
    target = proxy.server("lobby")
    if target != none:
        player.connect(target)