Initial commit.
This commit is contained in:
commit
20d77c8e31
18 changed files with 54473 additions and 0 deletions
12
.editorconfig
Normal file
12
.editorconfig
Normal file
|
@ -0,0 +1,12 @@
|
|||
# EditorConfig is awesome: https://EditorConfig.org
|
||||
|
||||
# top-most EditorConfig file
|
||||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = tab
|
||||
indent_size = 4
|
||||
end_of_line = crlf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = false
|
0
__init__.py
Normal file
0
__init__.py
Normal file
17
config.ini
Executable file
17
config.ini
Executable file
|
@ -0,0 +1,17 @@
|
|||
[redis]
|
||||
host = localhost
|
||||
port = 6379
|
||||
db = 0
|
||||
|
||||
[minecraft]
|
||||
serverdir = /home/wyatt/mcserver/plugin-dev/
|
||||
servercommand = /home/wyatt/mcserver/plugin-dev/run.sh # Plain java command line also works
|
||||
|
||||
[authserver]
|
||||
address = http://192.168.4.250:5000/
|
||||
secret = 8a99237b-8df4-4602-9ebb-4539add9f6a3
|
||||
|
||||
[oidc]
|
||||
issuer = https://auth.arsrobotics.org/application/o/test/
|
||||
client = 291ccc718932aac39fb66b1f3659f036c7a049a5
|
||||
secret = 23acd5ef8cff26461fbb4da1c9ec6dda1ed56bbfbeaf12f68a1682990d2cf68955681ab4e447d0a3aa9796d36bbd04c950d91a2a17e8bc50bf2d3892a2c32ed3
|
22
config.json
Normal file
22
config.json
Normal file
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"gravel": {
|
||||
"data_dir": "/home/wyatt/.local/var/gravel"
|
||||
},
|
||||
"valkey": {
|
||||
"host": "localhost",
|
||||
"port": 6379,
|
||||
"db": 0,
|
||||
"enabled": true
|
||||
},
|
||||
"minecraft": {
|
||||
"servers": [
|
||||
{
|
||||
"name": "Default",
|
||||
"uuid": "eb8b13b9-dde9-46e1-adf8-9e0d63fa47a7",
|
||||
"dir": "/home/wyatt/mcserver/plugin-dev/",
|
||||
"cmd": "/home/wyatt/mcserver/plugin-dev/run.sh",
|
||||
"version": "paper_1.21.1"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
0
lib/__init__.py
Normal file
0
lib/__init__.py
Normal file
17
lib/commands.py
Normal file
17
lib/commands.py
Normal file
|
@ -0,0 +1,17 @@
|
|||
from dataclasses import dataclass
|
||||
import os
|
||||
|
||||
import lib.globalData
|
||||
|
||||
@dataclass
|
||||
class Command:
|
||||
Usage: str
|
||||
Description: str
|
||||
Method: callable
|
||||
|
||||
commands = []
|
||||
|
||||
def Parse(globalData: globalData, line: str):
|
||||
args = str(line).split()
|
||||
command = args[0]
|
||||
|
31
lib/config.py
Normal file
31
lib/config.py
Normal file
|
@ -0,0 +1,31 @@
|
|||
|
||||
import json
|
||||
|
||||
class ValkeyConfig:
|
||||
def __init__(self, configJSON):
|
||||
|
||||
self.host = configJSON.get("host", "localhost")
|
||||
|
||||
try:
|
||||
self.port = int(configJSON.get("port", 6379))
|
||||
except ValueError:
|
||||
Logger.error("Unable to parse config value 'valkey.port'.")
|
||||
Logger.error("Ensure 'valkey.port' is a interger")
|
||||
Logger.warn("Defaulting 'valkey.port' to 6379")
|
||||
|
||||
try:
|
||||
self.db = int(configJSON.get("db", 0))
|
||||
except ValueError:
|
||||
Logging.error("Unable to parse config value 'valkey.db'")
|
||||
Logger.error("Ensure 'valkey.db' is a number")
|
||||
Logger.warn("Defaulting 'valkey.db' to 0")
|
||||
|
||||
self.enabled = configJSON.get("enabled", False if isinstance(configJSON.get("enabled"), bool) else False)
|
||||
|
||||
class Config:
|
||||
|
||||
def __init__(self, _configFilePath):
|
||||
with open(_configFilePath) as _configFile:
|
||||
_configJSON = json.load(_configFile)
|
||||
_ValkeyJson = _configJSON.get("valkey", {})
|
||||
self.valkeyConf = ValkeyConfig(_ValkeyJson)
|
2
lib/globalData.py
Normal file
2
lib/globalData.py
Normal file
|
@ -0,0 +1,2 @@
|
|||
class globalData:
|
||||
commands: list = []
|
8
lib/pluginLoader.py
Normal file
8
lib/pluginLoader.py
Normal file
|
@ -0,0 +1,8 @@
|
|||
import importlib
|
||||
|
||||
import lib.globalData
|
||||
|
||||
def LoadPlugins(globalData: globalData):
|
||||
pluginName = "plugins.core"
|
||||
importlib.import_module(pluginName)
|
||||
|
34
logging.json
Normal file
34
logging.json
Normal file
|
@ -0,0 +1,34 @@
|
|||
{
|
||||
"version": 1,
|
||||
"disable_existing_loggers": true,
|
||||
"formatters": {
|
||||
"file": {
|
||||
"format": "%(asctime)s: [%(module)s]: [%(levelname)s]: %(message)s",
|
||||
"validate": true
|
||||
},
|
||||
"console": {
|
||||
"format": "[%(module)s]: [%(levelname)s]: %(message)s",
|
||||
"validate": true
|
||||
}
|
||||
},
|
||||
"handlers": {
|
||||
"console": {
|
||||
"class": "logging.StreamHandler",
|
||||
"formatter": "console"
|
||||
},
|
||||
"file": {
|
||||
"class": "logging.handlers.RotatingFileHandler",
|
||||
"formatter": "file",
|
||||
"filename": "logs//GravelMC.log"
|
||||
}
|
||||
},
|
||||
"loggers": {
|
||||
"GravelMC": {
|
||||
"level": "DEBUG",
|
||||
"handlers": [
|
||||
"console",
|
||||
"file"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
54253
logs/GravelMC.log
Normal file
54253
logs/GravelMC.log
Normal file
File diff suppressed because it is too large
Load diff
61
main.py
Normal file
61
main.py
Normal file
|
@ -0,0 +1,61 @@
|
|||
import json
|
||||
from lib.config import Config as Config
|
||||
import lib.commands
|
||||
import logging, logging.config
|
||||
import select, sys
|
||||
|
||||
import valkey
|
||||
|
||||
import lib.pluginLoader
|
||||
|
||||
global GavelVersion
|
||||
GravelVersion = "0.1.0"
|
||||
|
||||
global Logger
|
||||
|
||||
with open("logging.json") as _loggingConfigFile:
|
||||
logging.config.dictConfig(json.load(_loggingConfigFile))
|
||||
Logger = logging.getLogger("GravelMC.Main")
|
||||
|
||||
def main():
|
||||
Logger.info("Starting GravelMC")
|
||||
Logger.info("Version: " + GravelVersion)
|
||||
|
||||
Logger.debug("Loading config")
|
||||
configFilePath = "config.json"
|
||||
config = Config(configFilePath)
|
||||
Logger.debug("Config Loaded")
|
||||
|
||||
Logger.debug(f"Configuring Valkey client with DB: {config.valkeyConf.db} , Host: {config.valkeyConf.host}, Port: {config.valkeyConf.port}")
|
||||
valkey.Valkey(host=config.valkeyConf.host, port=config.valkeyConf.port, db=config.valkeyConf.db)
|
||||
|
||||
Logger.debug("Loading Plugins")
|
||||
lib.pluginLoader.LoadPlugins()
|
||||
Logger.debug("Plugins Loaded")
|
||||
|
||||
Logger.debug("Beginning to loop")
|
||||
while True:
|
||||
loop()
|
||||
|
||||
Logger.debug("Ended loop")
|
||||
|
||||
bye()
|
||||
|
||||
def loop():
|
||||
#Logger.debug("Beginning of loop")
|
||||
|
||||
ready, _, _ = select.select([sys.stdin], [], [], 0)
|
||||
if ready:
|
||||
line = sys.stdin.readline().strip()
|
||||
lib.commands.Parse(line)
|
||||
|
||||
#Logger.debug("End of loop")
|
||||
|
||||
def bye():
|
||||
Logger.info("Stopping Gravel.")
|
||||
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
main()
|
||||
except KeyboardInterrupt:
|
||||
bye()
|
0
plugins/core/__init__.py
Normal file
0
plugins/core/__init__.py
Normal file
0
plugins/core/commands/__init__.py
Normal file
0
plugins/core/commands/__init__.py
Normal file
9
plugins/core/commands/help.py
Normal file
9
plugins/core/commands/help.py
Normal file
|
@ -0,0 +1,9 @@
|
|||
import lib.commands
|
||||
import lib.globalData
|
||||
|
||||
def init(globalData: globalData):
|
||||
helpCommand: lib.commands.Command = lib.commands.Command("[command]", "Prints this help message.", helpCommand)
|
||||
|
||||
|
||||
def helpCommand(command: str = None):
|
||||
print("Available Commands:")
|
2
plugins/core/main.py
Normal file
2
plugins/core/main.py
Normal file
|
@ -0,0 +1,2 @@
|
|||
print("Loaded moduel core")
|
||||
|
1
requirements.txt
Normal file
1
requirements.txt
Normal file
|
@ -0,0 +1 @@
|
|||
valkey==6.0.2
|
4
test.py
Normal file
4
test.py
Normal file
|
@ -0,0 +1,4 @@
|
|||
import select, sys
|
||||
|
||||
ready, _, _ = select.select([sys.stdin], [], [], 0.025)
|
||||
type(ready)
|
Loading…
Reference in a new issue