Пример #1
0
def launch_plugin(plug):
    import importlib
    if "." not in sys.path:
        sys.path = ["."] + sys.path  # use plugins in the folder, instead of library.zip - if accidentally included
    Plugin = importlib.import_module("plugins." + plug[0], "omnitool")

    if plug[2] == "receiver":
        worlds = list(get_worlds())
        from . import plugingui

        w = plugingui.run(worlds, Plugin, "rec")
        if w:
            with w.open("rb") as f:
                Plug = Plugin.Receiver()
                f.buffer = [0]
                header = get_header(f)[0]
                print("sending header")
                if Plug.rec_header(header) != False:
                    get_tile = iter_get_tile(select_tile_getter(header["version"]))(f)
                    tiles = []
                    for xi in range(header["width"]):  # for each slice
                        tiles.append([next(get_tile) for _ in range(header["height"])])
                    print("sending tiles")
                    if Plug.rec_tiles(tiles) != False:
                        if Plug.rec_chests(chests=[get_chest(f) for x in range(1000)]) != False:
                            if Plug.rec_signs(signs=[get_sign(f) for x in range(1000)]) != False:
                                npcs = []
                                while 1:
                                    npc = get_npc(f)
                                    if not npc:
                                        break
                                    else:
                                        npcs.append(npc)
                                names = get_npc_names(f)
                                trail = get_trail(f)
                                if trail[1] != header["name"] or trail[2] != header["ID"]:
                                    print("Warning, World signature test not passed")
                                Plug.rec_npcs(npcs, names)
                                Plug.run()
        else:
            print("No world selected, aborting execution")

    elif plug[2] == "generator":
        Plug = Plugin.Generator()
        Plug.run()
        plug_save(Plug)

    elif plug[2] == "program":
        Plug = Plugin.Program()
        Plug.run()

    elif plug[2] == "transplant":
        worlds = list(get_worlds())
        import plugingui

        w1, w2 = plugingui.run(worlds, Plugin, "trans")
        with w2.open("rb") as f:
            Plug = Plugin.Transplant()
            f.buffer = [0]
            header = get_header(f)[0]
            Plug.rec_header(header)
            get_tile = iter_get_tile(select_tile_getter(header["version"]))(f)
            tiles = []
            for xi in range(header["width"]):  # for each slice
                tiles.append([next(get_tile) for _ in range(header["height"])])
            Plug.rec_tiles(tiles)
            Plug.rec_chests(chests=[get_chest(f) for x in range(1000)])
            Plug.rec_signs(signs=[get_sign(f) for x in range(1000)])
            npcs = []
            while 1:
                npc = get_npc(f)
                if not npc:
                    break
                else:
                    npcs.append(npc)
            names = get_npc_names(f)
            trail = get_trail(f)
            if trail[1] != header["name"] or trail[2] != header["ID"]:
                print("Warning, World signature test not passed")
            Plug.rec_npcs(npcs, names)
            Plug.run()

        with w1.open("rb") as f:
            # Plug = Plugin.Transplant()
            f.buffer = [0]
            header = get_header(f)[0]
            if Plug.rec_header(header) != False:
                tiles = []
                for xi in range(header["width"]):  # for each slice
                    tiles.append([get_tile(f) for tile in range(header["height"])])
                if Plug.rec_tiles(tiles) != False:
                    if Plug.rec_chests(chests=[get_chest(f) for x in range(1000)]) != False:
                        if Plug.rec_signs(signs=[get_sign(f) for x in range(1000)]) != False:
                            npcs = []
                            while 1:
                                npc = get_npc(f)
                                if not npc:
                                    break
                                else:
                                    npcs.append(npc)
                            names = get_npc_names(f)
                            trail = get_trail(f)
                            if trail[1] != header["name"] or trail[2] != header["ID"]:
                                print("Warning, World signature test not passed")
                            Plug.rec_npcs(npcs, names)
                            Plug.run()
        plug_save(Plug)

    elif plug[2] == "modifier":
        worlds = list(get_worlds())
        from .plugingui import run as run_plugingui

        w = run_plugingui(worlds, Plugin, "mod")
        with w.open("rb") as f:
            Plug = Plugin.Modifier()
            f.buffer = [0]
            header = get_header(f)[0]
            Plug.rec_header(header)
            get_tile = iter_get_tile(select_tile_getter(header["version"]))(f)
            tiles = []
            for xi in range(header["width"]):  # for each slice
                tiles.append([next(get_tile) for _ in range(header["height"])])
            Plug.rec_tiles(tiles)
            Plug.rec_chests(chests=[get_chest(f) for x in range(1000)])
            Plug.rec_signs(signs=[get_sign(f) for x in range(1000)])
            npcs = []
            while 1:
                npc = get_npc(f)
                if not npc:
                    break
                else:
                    npcs.append(npc)
            names = get_npc_names(f)
            trail = get_trail(f)
            if trail[1] != header["name"] or trail[2] != header["ID"]:
                print("Warning, World signature test not passed")
            Plug.rec_npcs(npcs, names)
            Plug.run()
        plug_save(Plug)

    else:
        print("Unrecognized plugin type, aborting execution")

    print()
    print(plug[1] + " is done")
    sys.exit()
Пример #2
0
def launch_plugin(plug):
    import importlib
    if "." not in sys.path:
        sys.path = [
            "."
        ] + sys.path  # use plugins in the folder, instead of library.zip - if accidentally included
    Plugin = importlib.import_module("plugins." + plug[0], "omnitool")

    if plug[2] == "receiver":
        worlds = list(get_worlds())
        from . import plugingui

        w = plugingui.run(worlds, Plugin, "rec")
        if w:
            with w.open("rb") as f:
                Plug = Plugin.Receiver()
                f.buffer = [0]
                header = get_header(f)[0]
                print("sending header")
                if Plug.rec_header(header) != False:
                    get_tile = iter_get_tile(
                        select_tile_getter(header["version"]))(f)
                    tiles = []
                    for xi in range(header["width"]):  # for each slice
                        tiles.append(
                            [next(get_tile) for _ in range(header["height"])])
                    print("sending tiles")
                    if Plug.rec_tiles(tiles) != False:
                        if Plug.rec_chests(
                                chests=[get_chest(f)
                                        for x in range(1000)]) != False:
                            if Plug.rec_signs(
                                    signs=[get_sign(f)
                                           for x in range(1000)]) != False:
                                npcs = []
                                while 1:
                                    npc = get_npc(f)
                                    if not npc:
                                        break
                                    else:
                                        npcs.append(npc)
                                names = get_npc_names(f)
                                trail = get_trail(f)
                                if trail[1] != header["name"] or trail[
                                        2] != header["ID"]:
                                    print(
                                        "Warning, World signature test not passed"
                                    )
                                Plug.rec_npcs(npcs, names)
            if hasattr(Plug, "run"): Plug.run()
        else:
            print("No world selected, aborting execution")

    elif plug[2] == "generator":
        Plug = Plugin.Generator()
        Plug.run()
        plug_save(Plug)

    elif plug[2] == "program":
        Plug = Plugin.Program()
        Plug.run()

    elif plug[2] == "transplant":
        worlds = list(get_worlds())
        import plugingui

        w1, w2 = plugingui.run(worlds, Plugin, "trans")
        with w2.open("rb") as f:
            Plug = Plugin.Transplant()
            f.buffer = [0]
            header = get_header(f)[0]
            Plug.rec_header(header)
            get_tile = iter_get_tile(select_tile_getter(header["version"]))(f)
            tiles = []
            for xi in range(header["width"]):  # for each slice
                tiles.append([next(get_tile) for _ in range(header["height"])])
            Plug.rec_tiles(tiles)
            Plug.rec_chests(chests=[get_chest(f) for x in range(1000)])
            Plug.rec_signs(signs=[get_sign(f) for x in range(1000)])
            npcs = []
            while 1:
                npc = get_npc(f)
                if not npc:
                    break
                else:
                    npcs.append(npc)
            names = get_npc_names(f)
            trail = get_trail(f)
            if trail[1] != header["name"] or trail[2] != header["ID"]:
                print("Warning, World signature test not passed")
            Plug.rec_npcs(npcs, names)
            Plug.run()

        with w1.open("rb") as f:
            # Plug = Plugin.Transplant()
            f.buffer = [0]
            header = get_header(f)[0]
            if Plug.rec_header(header) != False:
                tiles = []
                for xi in range(header["width"]):  # for each slice
                    tiles.append(
                        [get_tile(f) for tile in range(header["height"])])
                if Plug.rec_tiles(tiles) != False:
                    if Plug.rec_chests(
                            chests=[get_chest(f)
                                    for x in range(1000)]) != False:
                        if Plug.rec_signs(
                                signs=[get_sign(f)
                                       for x in range(1000)]) != False:
                            npcs = []
                            while 1:
                                npc = get_npc(f)
                                if not npc:
                                    break
                                else:
                                    npcs.append(npc)
                            names = get_npc_names(f)
                            trail = get_trail(f)
                            if trail[1] != header["name"] or trail[
                                    2] != header["ID"]:
                                print(
                                    "Warning, World signature test not passed")
                            Plug.rec_npcs(npcs, names)
            if hasattr(Plug, "run"): Plug.run()
        plug_save(Plug)

    elif plug[2] == "modifier":
        worlds = list(get_worlds())
        from .plugingui import run as run_plugingui

        w = run_plugingui(worlds, Plugin, "mod")
        with w.open("rb") as f:
            Plug = Plugin.Modifier()
            f.buffer = [0]
            header = get_header(f)[0]
            Plug.rec_header(header)
            get_tile = iter_get_tile(select_tile_getter(header["version"]))(f)
            tiles = []
            for xi in range(header["width"]):  # for each slice
                tiles.append([next(get_tile) for _ in range(header["height"])])
            Plug.rec_tiles(tiles)
            Plug.rec_chests(chests=[get_chest(f) for x in range(1000)])
            Plug.rec_signs(signs=[get_sign(f) for x in range(1000)])
            npcs = []
            while 1:
                npc = get_npc(f)
                if not npc:
                    break
                else:
                    npcs.append(npc)
            names = get_npc_names(f)
            trail = get_trail(f)
            if trail[1] != header["name"] or trail[2] != header["ID"]:
                print("Warning, World signature test not passed")
            Plug.rec_npcs(npcs, names)
        Plug.run()
        plug_save(Plug)

    else:
        print("Unrecognized plugin type, aborting execution")

    print(plug[1] + " is done")
    sys.exit()
Пример #3
0
def launch_plugin(plug):
    import importlib

    Plugin = importlib.__import__("plugins." + plug[0], fromlist=[plug[0]])
    if plug[2] == "receiver":
        #print(dir(Plugin))
        worlds = list(get_worlds())
        import plugingui

        w = plugingui.run(worlds, Plugin, "rec")
        if w:
            with w.open("rb") as f:
                Plug = Plugin.Receiver()
                f.buffer = [0]
                header = get_header(f)[0]
                print("sending header")
                if Plug.rec_header(header) != False:
                    tiles = []
                    for xi in range(header["width"]):  # for each slice
                        tiles.append([get_tile(f) for tile in range(header["height"])])
                    print("sending tiles")
                    if Plug.rec_tiles(tiles) != False:
                        if Plug.rec_chests(chests=[get_chest(f) for x in range(1000)]) != False:
                            if Plug.rec_signs(signs=[get_sign(f) for x in range(1000)]) != False:
                                npcs = []
                                while 1:
                                    npc = get_npc(f)
                                    if not npc:
                                        break
                                    else:
                                        npcs.append(npc)
                                names = get_npc_names(f)
                                trail = get_trail(f)
                                if trail[1] != header["name"] or trail[2] != header["ID"]:
                                    print("Warning, World signature test not passed")
                                Plug.rec_npcs(npcs, names)
                                Plug.run()
        else:
            print("No world selected, aborting execution")
    elif plug[2] == "generator":
        Plug = Plugin.Generator()
        Plug.run()
        plug_save(Plug)

    elif plug[2] == "program":

        Plug = Plugin.Program()
        Plug.run()
    elif plug[2] == "transplant":

        worlds = list(get_worlds())
        import plugingui

        w1, w2 = plugingui.run(worlds, Plugin, "trans")
        with w2.open("rb") as f:
            Plug = Plugin.Transplant()
            f.buffer = [0]
            header = get_header(f)[0]
            Plug.rec_header(header)
            tiles = []
            for xi in range(header["width"]):  # for each slice
                tiles.append([get_tile(f) for tile in range(header["height"])])
            Plug.rec_tiles(tiles)
            Plug.rec_chests(chests=[get_chest(f) for x in range(1000)])
            Plug.rec_signs(signs=[get_sign(f) for x in range(1000)])
            npcs = []
            while 1:
                npc = get_npc(f)
                if not npc:
                    break
                else:
                    npcs.append(npc)
            names = get_npc_names(f)
            trail = get_trail(f)
            if trail[1] != header["name"] or trail[2] != header["ID"]:
                print("Warning, World signature test not passed")
            Plug.rec_npcs(npcs, names)
            Plug.run()

        with w1.open("rb") as f:
            #Plug = Plugin.Transplant()
            f.buffer = [0]
            header = get_header(f)[0]
            if Plug.rec_header(header) != False:
                tiles = []
                for xi in range(header["width"]):  # for each slice
                    tiles.append([get_tile(f) for tile in range(header["height"])])
                if Plug.rec_tiles(tiles) != False:
                    if Plug.rec_chests(chests=[get_chest(f) for x in range(1000)]) != False:
                        if Plug.rec_signs(signs=[get_sign(f) for x in range(1000)]) != False:
                            npcs = []
                            while 1:
                                npc = get_npc(f)
                                if not npc:
                                    break
                                else:
                                    npcs.append(npc)
                            names = get_npc_names(f)
                            trail = get_trail(f)
                            if trail[1] != header["name"] or trail[2] != header["ID"]:
                                print("Warning, World signature test not passed")
                            Plug.rec_npcs(npcs, names)
                            Plug.run()
        plug_save(Plug)
    elif plug[2] == "modifier":
        worlds = list(get_worlds())
        import plugingui

        w = plugingui.run(worlds, Plugin, "mod")
        with w.open("rb") as f:
            Plug = Plugin.Modifier()
            f.buffer = [0]
            header = get_header(f)[0]
            Plug.rec_header(header)
            tiles = []
            for xi in range(header["width"]):  # for each slice
                tiles.append([get_tile(f) for tile in range(header["height"])])
            Plug.rec_tiles(tiles)
            Plug.rec_chests(chests=[get_chest(f) for x in range(1000)])
            Plug.rec_signs(signs=[get_sign(f) for x in range(1000)])
            npcs = []
            while 1:
                npc = get_npc(f)
                if not npc:
                    break
                else:
                    npcs.append(npc)
            names = get_npc_names(f)
            trail = get_trail(f)
            if trail[1] != header["name"] or trail[2] != header["ID"]:
                print("Warning, World signature test not passed")
            Plug.rec_npcs(npcs, names)
            Plug.run()

        plug_save(Plug)

    else:
        print("Unrecognized plugin type, aborting execution")
    print()
    print(plug[1] + " is done")
    sys.exit()