https://github.com/grandmoff100/mcserverapi
A framework for making events triggered by events in the Minecraft Server Console.
https://github.com/grandmoff100/mcserverapi
framework hacktoberfest hacktoberfest2020 minecraft minecraft-api python python3
Last synced: 3 months ago
JSON representation
A framework for making events triggered by events in the Minecraft Server Console.
- Host: GitHub
- URL: https://github.com/grandmoff100/mcserverapi
- Owner: GrandMoff100
- Created: 2020-09-08T01:08:26.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2020-10-29T22:02:33.000Z (almost 5 years ago)
- Last Synced: 2025-01-23T12:15:29.482Z (9 months ago)
- Topics: framework, hacktoberfest, hacktoberfest2020, minecraft, minecraft-api, python, python3
- Language: Python
- Homepage:
- Size: 45.1 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# MCServerAPI
MCServerAPI is a python framework for running and creating events triggered by minecraft events in the server-console.## Example
```py
from mcserverapi import Server, Parser
server = Server('') # Can either relative or absolute
class MyParser(Parser):
def on_player_message(self, ctx):
player, message = ctx
server.run_cmd('say', player, 'has said', message)
def on_ready(self, ctx):
print('Server took', ctx[0], 'to start.')parser = MyParser(server)
java_flags = {
'-Xmx': '3G',
'-Xms': '1G'
}server.start(**java_flags)
parser.watch_for_events() # This is a blocking call. If you don't want it to block it, run it in a thread like so... threading.Thread(target=parser.watch_for_events).start()
```# Changelog
- 1.3.1:
You can now pass arguments and flags to .start() like so...
> (Note that init has been modified so you have to include any flags or arguments besides -jar and nogui)
```py
server.start('', '',**{'-Xmx':'3g', '-Xms':'1g'})
```