Beispiel #1
0
def getclaim(args="", user=None, hostmask=None, extra={}):
    dynmap.update()
    try:
        player = dynmap.getPlayerData(args)
        x = player["x"]
        z = player["z"]
        claims = dynmap.getClaims()
        for key in claims:
            claim2 = claims[key]
            if type(claim2) == dict: claim = claim2
            else: claim = claim2[0]

            if isBetween(x, z, claim['corners'][0], claim['corners'][1],
                         claim['corners'][2], claim['corners'][3]):
                return "{0} is currently in a {1}x{2} ({3}) claim by {4}. \x02Permission trust:\x0f {5} | \x02Build:\x0f {6} | \x02Container:\x0f {7}".format(
                    player["name"],
                    int(abs(claim["corners"][0] - claim["corners"][2])),
                    int(abs(claim["corners"][1] - claim["corners"][3])),
                    int(
                        abs(claim["corners"][0] - claim["corners"][2]) *
                        abs(claim["corners"][1] - claim["corners"][3])),
                    key.split("_")[0],
                    ", ".join(claim["permTrust"]),
                    ", ".join(claim["trust"]),
                    ", ".join(claim["containerTrust"]),
                )
        return "{0} is currently not standing inside a claim.".format(
            player["name"])
    except:
        return "Could not find player {0}.".format(args)
Beispiel #2
0
def online(args="", user=None, hostmask=None, extra={}):
    """online - Get online users
    {"category":"mc"}"""
    dynmap.update()
    names = [x["name"] for x in dynmap.getPlayers()]
    if len(names) == 0:
        return "There are no players online on dynmap right now."
    return "\x02Online:\x0f " + " ".join(names)
Beispiel #3
0
def get_time(args="", user=None, hostmask=None, extra={}):
    """get_time - Get server time
    {"category":"mc","alias":["gettime"]}"""
    dynmap.update()
    returned = dynmap.getServerTime()["time"]
    if dynmap.getServerTime()["canSleep"]:
        returned = returned + " (You can sleep)"
    return "\x02Server Time: \x0f" + returned
Beispiel #4
0
def get_player(args="", user=None, hostmask=None, extra={}):
    dynmap.update()
    players = dynmap.getPlayers()
    try:
        data = dynmap.getPlayerData(args)
        returned = data["name"] + " is at " + "{0},{1},{2}".format(
            data["x"], data["y"], data["z"])
        world = {
            "world": "overworld",
            "world_nether": "nether",
            "world_the_end": "end"
        }[data["world"]]
        returned = returned + " in the {0} and has {1} health and {2} armour.".format(
            world, data["health"], data["armor"])
        return returned
    except:
        return "Could not find user, possibly hidden on dynmap?"
Beispiel #5
0
def phraseInput(text, username=""):
    #Returns requirements
    for i in [
            "how long", "time it take", "length of trip", "length of journey"
    ]:
        if probFind(
                text, i
        ) > 0.85:  #Check if it's a question regarding the length of the trip
            #Config variables
            travel_type = "walk"  #Default travel type
            vert_type = "jump"
            potion = ""
            nether = False

            if "nether" in text or "hell" in text:
                nether = True

            #Horiziontal transporation methods
            if probFind(text, "walk") > 0.9: travel_type = "walk"
            elif probFindArray(text, ["sprint", "run"]): travel_type = "run"
            elif probFind(text, "sneak") > 0.9: travel_type = "sneak"
            elif probFind(text, "cart") > 0.9: travel_type = "minecart"
            elif probFind(text, "boat") > 0.9: travel_type = "boat"
            elif probFind(text, "pig") > 0.9: travel_type = "pig"
            elif probFindArray(text, ["horse", "donkey", "mule"]):
                travel_type = "horse"  #Also assume donkey and mule
            elif probFind(text, "swim") > 0.9:
                travel_type = "swim"
            elif probFind(text, "fly") > 0.9:
                travel_type = "fly"  #Assume both creative and elytra
            elif probFind(text, "pearl") > 0.9:
                travel_type = "pearl"
            elif probFindArray(text, ["elytra", "wing"]):
                travel_type = "wing"

            #Vertical transporation methods
            #Swimming in lava/water is not included and so is flying in creative
            if probFind(text, "jump") > 0.9: vert_type = "jump"
            elif probFind(text, "stair") > 0.9: vert_type = "stairs"
            elif probFind(text, "ladder") > 0.9: vert_type = "ladder"

            #Obtain location
            text2 = text.replace(" ", "")

            #Locate the bases FIRST
            a = re.findall(" (.*) base", text)
            if a != []:
                for i in a:
                    for b in base.bases:
                        if i.split(" ")[-1].replace("'s", "") in b.users:
                            text = text.replace("base", "")
                            text = text.replace(
                                i.split(" ")[-1],
                                str(b.x) + "," + str(b.y) + "," + str(b.z))
            for b in base.bases:
                if b.name.lower() in text.lower():
                    text = text.lower().replace(
                        b.name.lower(),
                        str(b.x) + "," + str(b.y) + "," + str(b.z))

            #Locate the players and replace names with coordinates
            dynmap.update()
            names = []
            players = dynmap.getPlayers()
            for key in players:
                name = key["name"]  #Prob match if player is there
                if probFind(text.lower(), name.lower()) > 0.85:
                    text = text.lower().replace(
                        name.lower(),
                        str(key["x"]) + ',' + str(key["y"]) + ',' +
                        str(key["z"]))

            #Locate the coordinates
            cords = re.findall(
                "([-+]?)([:]?\d*\.\d+|\d+),([-+]?)([:]?\d*\.\d+|\d+),([-+]?)([:]?\d*\.\d+|\d+)",
                text.replace(" ", ""))
            if cords != []:
                for x in cords:
                    replace = x[0] + x[1] + "," + x[2] + x[3] + "," + x[4] + x[
                        5]
                    text2 = text2.replace(replace, "")
            cords2 = re.findall(
                "([-+]?)([:]?\d*\.\d+|\d+),([-+]?)([:]?\d*\.\d+|\d+)",
                text2.replace(" ", ""))
            cords = cords + cords2
            text3 = text.replace(" ", "")

            #Facepalm, the order of the coordinates don't matter
            if len(cords) >= 1:
                c1 = listToCord(cords[0])
                if len(cords) >= 2:
                    c2 = listToCord(cords[1])
                    if text3.index(c2) < text3.index(c1):
                        c1, c2 = c2, c1
                else:
                    c2 = c1
                    try:
                        c1 = dynmap.getPlayerData(username)
                        c1 = str(c1["x"]) + "," + str(c1["y"]) + "," + str(
                            c1["z"])
                    except:
                        return False

            #Get the actual distance
            distance = calcDis(c1, c2)
            times = []

            if travel_type == 'walk':
                times.append(
                    [distance["horz"] / 4.3, "(Assuming flat terrain)"])
            elif travel_type == 'run':
                times.append(
                    [distance["horz"] / 5.6, "(Assuming flat terrain)"])
            elif travel_type == 'sneak':
                times.append(
                    [distance["horz"] / 1.3, "(Assuming flat terrain)"])
            elif travel_type == 'minecart':
                times.append(
                    [distance["horz"] / 8, "(Assuming powered rails)"])
                times.append(
                    [distance["horz"] / 7.1, "(Assuming 1/4 slope track)"])
            elif travel_type == 'boat':
                times.append([
                    distance["horz"] / 6.2,
                    "(Assuming max speed on flat water)"
                ])
                times.append([distance["horz"] / 40, "(Assuming on ice)"])
            elif travel_type == 'pig':
                times.append([distance["horz"] / 8, "(Assuming flat terrain)"])
            elif travel_type == 'horse':
                times.append(
                    [distance["horz"] / 9.675, "(Assuming average horse)"])
                times.append(
                    [distance["horz"] / 14.57, "(Assuming best horse)"])
                times.append([distance["horz"] / 7.525, "(Assuming donkey)"])
            elif travel_type == 'swim':
                times.append(
                    [distance["horz"] / 1.97, "(Assuming still water)"])
            elif travel_type == 'fly':
                times.append([distance["horz"] / 10.9, "(Assuming creative)"])
                times.append(
                    [distance["horz"] / 30, "(Assuming elytra, at 0 pitch)"])
            elif travel_type == 'pearl':
                times.append(
                    [distance["horz"] / 23, "(Assuming thrown at 15 degrees)"])
            elif travel_type == 'wing':
                times.append(
                    [distance["horz"] / 30, "(Assuming elytra, at 0 pitch)"])

            vert_time = 0

            if travel_type == 'fly':
                vert_time = distance["vert"] / 7.5
            elif travel_type == 'swim':
                vert_time = distance["vert"] / 2
            elif vert_type == "jump":
                vert_time = distance["vert"] / 2
            elif vert_type == "stairs":
                vert_time = distance["vert"] / 3.2
            elif vert_type == "ladder":
                vert_time = distance["vert"] / 2.35

            #Add vertical values to times and divide times by 8 for nether
            for i in range(0, len(times)):
                if nether:
                    times[i][0] /= 8
                times[i][0] += vert_time

            for i in range(0, len(times)):
                times[i][0] = convertSeconds(times[i][0])
            times.insert(0, [str(round(distance["horz"])), "meters"])
            input_int = "Time to travel by {0} from {1} to {2}".format(
                travel_type, c1, c2)
            if nether: input_int += " via the nether"
            return [times, input_int]

    return False
Beispiel #6
0
def get_time(args="", user=None, hostmask=None, extra={}):
    dynmap.update()
    returned = dynmap.getServerTime()["time"]
    if dynmap.getServerTime()["canSleep"]:
        returned = returned + " (You can sleep)"
    return "\x02Server Time: \x0f" + returned
Beispiel #7
0
def getmap(args="", user=None, hostmask=None, extra={}):
    world = "overworld"
    view = "flat"
    worlds = {
        "overworld": "world",
        "nether": "world_nether",
        "end": "world_the_end"
    }
    views = {"flat": "flat", "3d": "surface", "cave": "cave"}
    args = args.lower()

    if "overworld" in args:
        args = args.strip('nether').strip('overworld')
    elif "nether" in args or "hell" in args:
        world = "nether"
        args = args.strip('nether').strip('hell')
    elif "end" in args:
        world = "end"
        args = args.strip('end')

    if "flat" in args: args = args.strip('flat')
    elif "3d" in args:
        args = args.strip('3d')
        view = "3d"
    elif "cave" in args:
        args = args.strip('cave')
        view = "cave"

    args = args.lstrip().rstrip()
    world = worlds[world]
    view = views[view]
    dynmap.update()

    try:  #Get the location of [player name] and return world
        if dynmap.getPlayerData(args):  #If it's a valid player return map
            data = dynmap.getPlayerData(args)
            url = "http://dynmap.starcatcher.us/?worldname={0}&mapname={1}&zoom=6&x={2}&y={3}&z={4}".format(
                data["world"], view, data["x"], data["y"], data["z"])
            try:
                return web.isgd(url)
            except:
                return url
    except:
        pass

    #Obtain the location of [location] and return map
    locations = {
        "azure": {
            "cord": [-69, -220],
            "world": "world"
        },
        "spawn": {
            "cord": [-211, 142],
            "world": "world"
        },
        "end portal": {
            "cord": [-115, -126],
            "world": "world_nether"
        },
    }

    for key in locations:
        if key in args.lower():
            url = "http://dynmap.starcatcher.us/?worldname={0}&mapname={1}&zoom=6&x={2}&y={3}&z={4}".format(
                locations[key]["world"], view, locations[key]["cord"][0], 65,
                locations[key]["cord"][1])
            try:
                return web.isgd(url)
            except:
                return url

    #Obtain coordinates
    cords = re.findall(
        "([-+]?)([:]?\d*\.\d+|\d+),([-+]?)([:]?\d*\.\d+|\d+),([-+]?)([:]?\d*\.\d+|\d+)",
        args.replace(" ", ""))
    if cords == []:
        cords = re.findall(
            "([-+]?)([:]?\d*\.\d+|\d+),([-+]?)([:]?\d*\.\d+|\d+)",
            args.replace(" ", ""))
    cords2 = []
    for i in cords[0]:
        cords2.append(i)
    x = cords2[0] + cords2[1]
    if len(cords2) == 4:
        y = "65"
        z = cords2[2] + cords2[3]
    elif len(cords2) == 6:
        y = cords2[2] + cords2[3]
        z = cords2[4] + cords2[5]
    url = "http://dynmap.starcatcher.us/?worldname={0}&mapname={1}&zoom=6&x={2}&y={3}&z={4}".format(
        world, view, x, y, z)
    try:
        return web.isgd(url)
    except:
        return url
Beispiel #8
0
def get_weather(args="", user=None, hostmask=None, extra={}):
    dynmap.update()
    return "\x02Weather:\x0f Thundering: {0} | Raining: {1}".format(
        dynmap.isThundering(), dynmap.hasStorm())
Beispiel #9
0
def get_tick(args="", user=None, hostmask=None, extra={}):
    dynmap.update()
    returned = dynmap.getServerTick()
    return "\x02Server Tick: \x0f" + str(returned)
Beispiel #10
0
def get_weather(args="", user=None, hostmask=None, extra={}):
    """get_weather - Get weather
    {"category":"mc","alias":["getweather"]}"""
    dynmap.update()
    return "\x02Weather:\x0f Thundering: {0} | Raining: {1}".format(
        dynmap.isThundering(), dynmap.hasStorm())
Beispiel #11
0
def get_tick(args="", user=None, hostmask=None, extra={}):
    """get_tick - Get raw server time
    {"category":"mc","alias":["gettick"]}"""
    dynmap.update()
    returned = dynmap.getServerTick()
    return "\x02Server Tick: \x0f" + str(returned)