""" Basic demo example """ from spock import Client from spock.plugins import DefaultPlugins from demoplugin import DemoPlugin start_settings = { 'username': '******', 'password': '******', } plugins = DefaultPlugins plugins.append(('demo', DemoPlugin)) client = Client(plugins=plugins, start=start_settings) #client.start() with no arguments will automatically connect to localhost client.start('localhost', 25565)
# Import the plugins you have created from example_plugin import ExamplePlugin from spock import Client from spock.plugins import DefaultPlugins # Set the following values: USERNAME = '' PASSWORD = '' SERVER = 'localhost' # Enter your credentials and the server information settings = { 'start': { 'username': USERNAME, 'password': PASSWORD, }, } # Load the plugins. Any functionality that you want to implement must be called # from a plugin. You can define new plugins that listen for arbitrary events # from the game. Furthermore, events can even be periodic timers that trigger a # method. plugins = DefaultPlugins plugins.append(('example', ExamplePlugin)) # Instantiate and start the client, which will then run and wait for events to # occur client = Client(plugins=plugins, settings=settings) client.start(SERVER, 25565)
from spockextras.plugins.helpers.NewMovement import NewMovementPlugin from spockextras.plugins.helpers.NewPhysics import NewPhysicsPlugin from spockextras.plugins.helpers.SpockControl import SpockControlPlugin from spockextras.plugins.helpers.Messenger import MessengerPlugin from spockextras.plugins.helpers.SendMapData import SendMapDataPlugin from spockextras.plugins.helpers.SendEntityData import SendEntityDataPlugin # connect to localhost server settings = {'start': {'username': '******',},'auth': {'authenticated': False,},} plugins = DefaultPlugins plugins.append(('Messenger', MessengerPlugin)) plugins.append(('SendMapData', SendMapDataPlugin)) plugins.append(('SendEntityData', SendEntityDataPlugin)) plugins.append(('MineAndPlace', MineAndPlacePlugin)) plugins.append(('NewMovement', NewMovementPlugin)) #plugins.append(('NewPhysics', NewPhysicsPlugin)) plugins.append(('SpockControl', SpockControlPlugin)) client = Client(plugins = plugins, settings = settings) print("connecting to localhost on port 25565") #client.start() with no arguments will automatically connect to localhost client.start('localhost', 25565)
""" Basic demo example """ from spock import Client from spock.plugins import DefaultPlugins from demoplugin import DemoPlugin #Open login.py and put in your username and password from login import username, password plugins = DefaultPlugins plugins.append(DemoPlugin) client = Client(plugins = plugins, username = username, password = password) #client.start() with no arguments will automatically connect to localhost client.start('localhost', 25565)
""" Offline connection demo """ from spock import Client from spock.plugins import DefaultPlugins from demoplugin import DemoPlugin #Open login.py and put in your username and password from login import username plugins = DefaultPlugins plugins.append(DemoPlugin) client = Client(plugins=plugins, username=username, authenticated=False) #client.start() with no arguments will automatically connect to localhost client.start('localhost', 25565)
# import rospy # from minecraft_bot.msg import controller_msg import sys from spock import Client, PluginLoader from spock.plugins import DefaultPlugins from spock.plugins.helpers.move import MovementPlugin from spock.plugins.helpers.physics import PhysicsPlugin from spock.plugins.helpers.entities import EntityPlugin from spock.plugins.helpers.clientinfo import ClientInfoPlugin from spockbot.plugins.CursesCommand import * from spockbot.plugins.BaseCommands import BaseCommandsPlugin from spockbot.plugins.ChatCommand import ChatCommandPlugin from spockbot.plugins.Chat import ChatPlugin # connect to localhost server settings = {"start": {"username": "******"}, "auth": {"authenticated": False}} plugins = DefaultPlugins plugins.append(("basecommand", BaseCommandsPlugin)) plugins.append(("chat", ChatPlugin)) plugins.append(("chatcommand", ChatCommandPlugin)) plugins.append(("Movement", MovementPlugin)) plugins.append(("Physics", PhysicsPlugin)) plugins.append(("Entities", EntityPlugin)) plugins.append(("ClientInfo", ClientInfoPlugin)) client = Client(plugins=plugins, settings=settings) # client.start() with no arguments will automatically connect to localhost client.start("localhost", 25565)
def _import_yaml(self, path, obj): temp_set = {} data = yaml.load(open(path).read()) for key, plugin in data[obj].items(): if plugin[0] == 'yaml': for key, val in self._import_yaml(plugin[1], key).items(): temp_set[key] = get_settings(temp_set.get(key, {}), val) elif plugin[0] == 'python': for key, _ in self._import_python(plugin[1], key): temp_set[key] = data.get(key, {}) else: self._import_plugin(plugin[1], plugin[0], key) temp_set[key] = data.get(key, {}) return temp_set def _import_python(self, path, obj): pylist = __import__(path, fromlist=[obj]).__dict__[obj] for plugin in pylist: self.plugin_list.append(plugin) return pylist def _import_plugin(self, path, obj, name): plugin = __import__(path, fromlist=[obj]).__dict__[obj] self.plugin_list.append((name, plugin)) if __name__ == '__main__': from spock import Client Client(settings_mixin=YamlSettings, file_path='config.yaml').start()