-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 9a9186c
Showing
10 changed files
with
1,812 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# json data storage | ||
*.json | ||
|
||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
env/ | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*,cover | ||
.hypothesis/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
target/ | ||
|
||
#Ipython Notebook | ||
.ipynb_checkpoints |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
from nbt import nbt | ||
import os | ||
import urllib.request | ||
import json | ||
import string | ||
|
||
playerdatafolder = "/home/minecraft/minecraft/Boskrill/playerdata" | ||
|
||
|
||
|
||
allowed = frozenset(string.ascii_letters + string.digits + '_') | ||
|
||
def MCCheckName(name): | ||
return (frozenset(name) <= allowed) | ||
|
||
|
||
class MojangAPIException(Exception): | ||
pass | ||
|
||
class UnknownPlayerException(Exception): | ||
pass | ||
|
||
dimensions = {-1 : 'Nether', 0 : 'Overworld', 1 : 'End'} | ||
|
||
def MCGetPlayerPos(player): | ||
r = urllib.request.Request("https://api.mojang.com/profiles/minecraft",bytes(json.dumps([player]), "utf-8"),{"Content-Type": "application/json"}) | ||
try: | ||
response = json.loads(urllib.request.urlopen(r).read().decode('utf8')) | ||
except: | ||
raise MojangAPIException | ||
try: | ||
if (len(response) > 0): | ||
filename = response[0]["id"][:8] + "-" + response[0]["id"][8:12] + "-" + response[0]["id"][12:16] + "-" + response[0]["id"][16:20] + "-" + response[0]["id"][20:] + ".dat" | ||
print(filename) | ||
nbtfile = nbt.NBTFile(os.path.join(playerdatafolder,filename),'rb') | ||
dim = dimensions[nbtfile['Dimension'].value] | ||
return(nbtfile['Pos'][0].value, nbtfile['Pos'][1].value, nbtfile['Pos'][2].value, dim) | ||
else: | ||
raise UnknownPlayerException | ||
except: | ||
raise UnknownPlayerException | ||
|
||
|
||
if __name__ == "__main__": | ||
print(MCGetPlayerPos("FreakusGeekus")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Theriah |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
def is_owner_check(message): | ||
return message.author.id == '112311949416488960' | ||
|
||
|
||
def check_permissions(ctx, **perms): | ||
msg = ctx.message | ||
if is_owner_check(msg): | ||
return True | ||
|
||
ch = msg.channel | ||
author = msg.author | ||
resolved = ch.permissions_for(author) | ||
return all(getattr(resolved, name, None) == value for name, value in perms.items()) | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import json | ||
import asyncio | ||
|
||
class Config: | ||
"""The "database" object. Internally based on ``json``.""" | ||
|
||
def __init__(self, name, **options): | ||
self.name = name | ||
self.object_hook = options.pop('object_hook', None) | ||
self.encoder = options.pop('encoder', None) | ||
self.loop = options.pop('loop', asyncio.get_event_loop()) | ||
if options.pop('load_later', False): | ||
self.loop.create_task(self.load()) | ||
else: | ||
self.load_from_file() | ||
|
||
def load_from_file(self): | ||
try: | ||
with open(self.name, 'r') as f: | ||
self._db = json.load(f, object_hook=self.object_hook) | ||
except FileNotFoundError: | ||
self._db = {} | ||
|
||
async def load(self): | ||
await self.loop.run_in_executor(None, self.load_from_file) | ||
|
||
def _dump(self): | ||
with open(self.name, 'w') as f: | ||
json.dump(self._db, f, ensure_ascii=True, cls=self.encoder) | ||
|
||
async def save(self): | ||
await self.loop.run_in_executor(None, self._dump) | ||
|
||
def get(self, key, *args): | ||
"""Retrieves a config entry.""" | ||
return self._db.get(key, *args) | ||
|
||
async def put(self, key, value, *args): | ||
"""Edits a config entry.""" | ||
self._db[key] = value | ||
await self.save() | ||
|
||
async def remove(self, key): | ||
"""Removes a config entry.""" | ||
del self._db[key] | ||
await self.save() | ||
|
||
def __contains__(self, item): | ||
return self._db.__contains__(item) | ||
|
||
def __len__(self): | ||
return self._db.__len__() | ||
|
||
def all(self): | ||
return self._db | ||
|
Oops, something went wrong.