Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Freakus committed Apr 29, 2016
0 parents commit 9a9186c
Show file tree
Hide file tree
Showing 10 changed files with 1,812 additions and 0 deletions.
65 changes: 65 additions & 0 deletions .gitignore
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
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

45 changes: 45 additions & 0 deletions NBTHelper.py
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"))
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Theriah
Binary file added TheriahRiptideIconTransparent.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions checks.py
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())



56 changes: 56 additions & 0 deletions config.py
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

Loading

0 comments on commit 9a9186c

Please sign in to comment.