Example #1
0
import time

from plugin import Plugin

# You SHOULD name instance of Plugin() as plugin, otherwise it wouldn't work
# TODO: Fix it
plugin = Plugin(name="Core", description="Core plugin for server (containts all basic stuff)", version="0.1")

# You can do this to make code shorter and cleaner
event = plugin.event

plugin.log("Initialized successfully...")


@event("player_command")
def handler(player, command, args):
    if command == "stop":
        player.send_chat("Server stopping... You will be kicked in two seconds")
        time.sleep(2)
        plugin.log(player.nickname + " has stopped the server!")
        from twisted.internet import reactor  # Import reactor and call stop methods
        reactor.removeAll()
        reactor.iterate()
        reactor.stop()
    if command == "tppos":
        # If command called with 3 arguments
        if len(args) == 3:
            # Set player position
            try:
                x, y, z = [float(arg) for arg in args]  # Convert strings to floats
                player.set_position(x, y, z)