def registerhook(hookCls, execfunc): # Use like this: # >>> from net.canarymod.hook.player import BlockDestroyHook # >>> def hookfunc(listener, hook): # ... yell(str(hook.getBlock().getType())) # >>> registerhook(BlockDestroyHook,hookfunc) Canary.hooks().registerHook(PluginEventListener(), Canary.manager().getPlugin('CanaryConsole'), hookCls, EventDispatcher(execfunc), Priority.NORMAL)
def registercommand(name, min, max, execfunc): # Use like this: # >>> def functiontest(caller, params): # ... yell(params[1]) # >>> registercommand("test", 2, 2, functiontest) Canary.commands().registerCommand(CanaryChatCommand(ChatCommand(names=[name], min=min, max=max), SERVER, execfunc), SERVER, True)
from net.canarymod import LineTracer from net.canarymod.api.world.blocks import BlockType from net.canarymod.api.world.effects import Particle from net.canarymod.api import GameMode from net.canarymod.api.world.position import Location from net.canarymod.api.world.position import Position from net.canarymod.commandsys import Command, CommandListener, CanaryCommand from net.canarymod.chat import MessageReceiver from net.canarymod.plugin import Priority, PluginListener from net.canarymod.hook import Dispatcher from time import * from random import * from math import * SERVER = Canary.getServer() WORLD = SERVER.getDefaultWorld() MORNING = 2000 NOON = 6000 EVENING = 14000 NIGHT = 18000 #full list of BlockTypes available in JavaDocs on canarymod.net AIR = BlockType.Air STONE = BlockType.Stone GRASS = BlockType.Grass DIRT = BlockType.Dirt COBBLESTONE = BlockType.Cobble WOOD_PLANKS = BlockType.OakWood SAPLING = BlockType.OakSapling BEDROCK = BlockType.Bedrock