From 17ed07ddf09e376a0fbaea28a3fc33e30d662d8f Mon Sep 17 00:00:00 2001 From: Sh-wayz Date: Fri, 5 Feb 2021 18:31:09 -0500 Subject: [PATCH 01/17] test [skip ci] --- pymine/logic/query.py | 1 + 1 file changed, 1 insertion(+) create mode 100644 pymine/logic/query.py diff --git a/pymine/logic/query.py b/pymine/logic/query.py new file mode 100644 index 000000000..d8b9b98fc --- /dev/null +++ b/pymine/logic/query.py @@ -0,0 +1 @@ +# help From 4f6ee6a5ff6bd2b7c35e12da982fe0ddb9fab1a2 Mon Sep 17 00:00:00 2001 From: Sh-wayz Date: Sat, 6 Feb 2021 19:34:04 -0500 Subject: [PATCH 02/17] add fileioleioleil --- pymine/types/query.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 pymine/types/query.py diff --git a/pymine/types/query.py b/pymine/types/query.py new file mode 100644 index 000000000..e69de29bb From fad042732abf195f4e8531e3044e2a82c2ddf8e1 Mon Sep 17 00:00:00 2001 From: Sh-wayz Date: Sat, 6 Feb 2021 20:30:41 -0500 Subject: [PATCH 03/17] update cfg to add query thingos --- pymine/logic/config.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pymine/logic/config.py b/pymine/logic/config.py index 274cf2ddf..ab5709e7c 100644 --- a/pymine/logic/config.py +++ b/pymine/logic/config.py @@ -25,6 +25,8 @@ "spawn_animals": True, "spawn_monsters": True, "generate_structures": True, + "enable_query": True, + "query_port": 25565, } From 9abef0a76bbb7550da6b402d144721a6f97e4a6c Mon Sep 17 00:00:00 2001 From: Sh-wayz Date: Sun, 7 Feb 2021 14:35:55 -0500 Subject: [PATCH 04/17] create QueryBuffer shit --- pymine/logic/query.py | 57 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) diff --git a/pymine/logic/query.py b/pymine/logic/query.py index d8b9b98fc..fad992826 100644 --- a/pymine/logic/query.py +++ b/pymine/logic/query.py @@ -1 +1,56 @@ -# help +from __future__ import annotations +from pymine.server import server +import struct + + +class QueryBuffer: + """Buffer for the query protocol, will contain most relevant methods.""" + + def __init__(self, buf: bytes = None) -> None: + self.buf = b"" if buf is None else buf + self.pos = 0 + + def write(self, data: bytes) -> None: + """Writes data to the buffer.""" + + self.buf += data + + def read(self, length: int = None) -> bytes: + """ + Reads n bytes from the buffer, if the length is None + then all remaining data from the buffer is sent. + """ + + try: + if length is None: + length = len(self.buf) + return self.buf[self.pos :] + + return self.buf[self.pos : self.pos + length] + finally: + self.pos += length + + def reset(self) -> None: + """Resets the position in the buffer.""" + + self.pos = 0 + + @staticmethod + def pack_short(short: int): + return struct.pack("i", num) + + @staticmethod + def pack_byte(char: int): + return struct.pack(">c", char) From e84653631ffd7f8209a9969ed9f78b22180595d1 Mon Sep 17 00:00:00 2001 From: Milo Weinberg Date: Sun, 7 Feb 2021 17:16:09 -0500 Subject: [PATCH 05/17] organize imports --- pymine/logic/query.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pymine/logic/query.py b/pymine/logic/query.py index fad992826..10fb32761 100644 --- a/pymine/logic/query.py +++ b/pymine/logic/query.py @@ -1,7 +1,8 @@ from __future__ import annotations -from pymine.server import server import struct +from pymine.server import server + class QueryBuffer: """Buffer for the query protocol, will contain most relevant methods.""" From cd2b9ba4c8f62df6a499d48fe6f1ebed1b130cf1 Mon Sep 17 00:00:00 2001 From: Milo Weinberg Date: Sun, 7 Feb 2021 17:17:44 -0500 Subject: [PATCH 06/17] add missing return typehints --- pymine/logic/query.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pymine/logic/query.py b/pymine/logic/query.py index 10fb32761..628940bd2 100644 --- a/pymine/logic/query.py +++ b/pymine/logic/query.py @@ -37,21 +37,21 @@ def reset(self) -> None: self.pos = 0 @staticmethod - def pack_short(short: int): + def pack_short(short: int) -> bytes: return struct.pack(" bytes: return b"\xFE\xFD" @staticmethod - def pack_string(string: str): + def pack_string(string: str) -> bytes: return bytes(string, "latin-1") + b"\x00" @staticmethod - def pack_int32(num: int): + def pack_int32(num: int) -> bytes: return struct.pack(">i", num) @staticmethod - def pack_byte(char: int): + def pack_byte(char: int) -> bytes: return struct.pack(">c", char) From b6abb14afbc6260995cd9b652bb3949374b7ecd9 Mon Sep 17 00:00:00 2001 From: Milo Weinberg Date: Sun, 7 Feb 2021 17:19:04 -0500 Subject: [PATCH 07/17] fix pack_byte --- pymine/logic/query.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pymine/logic/query.py b/pymine/logic/query.py index 628940bd2..4041f57c7 100644 --- a/pymine/logic/query.py +++ b/pymine/logic/query.py @@ -53,5 +53,5 @@ def pack_int32(num: int) -> bytes: return struct.pack(">i", num) @staticmethod - def pack_byte(char: int) -> bytes: - return struct.pack(">c", char) + def pack_byte(byte: int) -> bytes: + return struct.pack(">b", byte) From ca22ce80f1de3a635e3caeadfeb4186b194702d6 Mon Sep 17 00:00:00 2001 From: Sh-wayz Date: Wed, 10 Feb 2021 17:07:45 -0500 Subject: [PATCH 08/17] add unpack_short --- pymine/logic/query.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pymine/logic/query.py b/pymine/logic/query.py index 4041f57c7..1dd207de2 100644 --- a/pymine/logic/query.py +++ b/pymine/logic/query.py @@ -40,6 +40,10 @@ def reset(self) -> None: def pack_short(short: int) -> bytes: return struct.pack(" int: + return struct.unpack(" bytes: return b"\xFE\xFD" From 3f1792f86b6da8f6225c74e12344dc989b18e169 Mon Sep 17 00:00:00 2001 From: Sh-wayz Date: Wed, 10 Feb 2021 17:11:08 -0500 Subject: [PATCH 09/17] add unpack_int32 --- pymine/logic/query.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pymine/logic/query.py b/pymine/logic/query.py index 1dd207de2..44d646a69 100644 --- a/pymine/logic/query.py +++ b/pymine/logic/query.py @@ -56,6 +56,10 @@ def pack_string(string: str) -> bytes: def pack_int32(num: int) -> bytes: return struct.pack(">i", num) + @staticmethod + def unpack_int32(num: int): + return struct.unpack(">i", num) + @staticmethod def pack_byte(byte: int) -> bytes: return struct.pack(">b", byte) From 2d3103b33aebdd37738644970d743402d73c74e1 Mon Sep 17 00:00:00 2001 From: Sh-wayz Date: Wed, 10 Feb 2021 17:12:34 -0500 Subject: [PATCH 10/17] add unpack_magic --- pymine/logic/query.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pymine/logic/query.py b/pymine/logic/query.py index 44d646a69..cd59acf91 100644 --- a/pymine/logic/query.py +++ b/pymine/logic/query.py @@ -48,6 +48,10 @@ def unpack_short(short: int) -> int: def pack_magic() -> bytes: return b"\xFE\xFD" + @staticmethod + def unpack_magic(): + return 65277 # big brain moment + @staticmethod def pack_string(string: str) -> bytes: return bytes(string, "latin-1") + b"\x00" From 02db3d07c13797a88c15e45f73f5a5b21c248ada Mon Sep 17 00:00:00 2001 From: Sh-wayz Date: Wed, 10 Feb 2021 17:13:23 -0500 Subject: [PATCH 11/17] add typehint --- pymine/logic/query.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pymine/logic/query.py b/pymine/logic/query.py index cd59acf91..007cc1d7c 100644 --- a/pymine/logic/query.py +++ b/pymine/logic/query.py @@ -49,7 +49,7 @@ def pack_magic() -> bytes: return b"\xFE\xFD" @staticmethod - def unpack_magic(): + def unpack_magic() -> int: return 65277 # big brain moment @staticmethod From 8d398ceaec686a39e8d916320701e630cfdae9c2 Mon Sep 17 00:00:00 2001 From: Sh-wayz Date: Wed, 10 Feb 2021 17:13:55 -0500 Subject: [PATCH 12/17] update comment --- pymine/logic/query.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pymine/logic/query.py b/pymine/logic/query.py index 007cc1d7c..492d2f1e2 100644 --- a/pymine/logic/query.py +++ b/pymine/logic/query.py @@ -50,7 +50,7 @@ def pack_magic() -> bytes: @staticmethod def unpack_magic() -> int: - return 65277 # big brain moment + return 65277 # I hate myself @staticmethod def pack_string(string: str) -> bytes: From 7f48481a40a476b65d3a01446f6dd44aed79f2f2 Mon Sep 17 00:00:00 2001 From: Sh-wayz Date: Wed, 10 Feb 2021 17:14:25 -0500 Subject: [PATCH 13/17] update comment --- pymine/logic/query.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pymine/logic/query.py b/pymine/logic/query.py index 492d2f1e2..3e39d904a 100644 --- a/pymine/logic/query.py +++ b/pymine/logic/query.py @@ -50,7 +50,7 @@ def pack_magic() -> bytes: @staticmethod def unpack_magic() -> int: - return 65277 # I hate myself + return 65277 # I hate myself. @staticmethod def pack_string(string: str) -> bytes: From 18277ca5c5c33a6edaa5781d4659dc773a1c4f08 Mon Sep 17 00:00:00 2001 From: Sh-wayz Date: Wed, 10 Feb 2021 17:15:03 -0500 Subject: [PATCH 14/17] add typehint --- pymine/logic/query.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pymine/logic/query.py b/pymine/logic/query.py index 3e39d904a..b002bc03e 100644 --- a/pymine/logic/query.py +++ b/pymine/logic/query.py @@ -61,7 +61,7 @@ def pack_int32(num: int) -> bytes: return struct.pack(">i", num) @staticmethod - def unpack_int32(num: int): + def unpack_int32(num: int) -> int: # I think return struct.unpack(">i", num) @staticmethod From 1d6c10f14b67b4d3d1e9797c212983c5f8a0c82b Mon Sep 17 00:00:00 2001 From: Sh-wayz Date: Wed, 10 Feb 2021 17:23:17 -0500 Subject: [PATCH 15/17] =?UTF-8?q?periodt=20sis=F0=9F=92=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pymine/logic/query.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pymine/logic/query.py b/pymine/logic/query.py index b002bc03e..f2af8b167 100644 --- a/pymine/logic/query.py +++ b/pymine/logic/query.py @@ -61,7 +61,7 @@ def pack_int32(num: int) -> bytes: return struct.pack(">i", num) @staticmethod - def unpack_int32(num: int) -> int: # I think + def unpack_int32(num: int) -> int: # I think. return struct.unpack(">i", num) @staticmethod From 1375b8d3869eb04cb07167c2eb6d1a7cf3684572 Mon Sep 17 00:00:00 2001 From: Sh-wayz Date: Wed, 10 Feb 2021 18:07:53 -0500 Subject: [PATCH 16/17] comment import that isn't in use rn to make myself feel better --- pymine/logic/query.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pymine/logic/query.py b/pymine/logic/query.py index f2af8b167..263b876fa 100644 --- a/pymine/logic/query.py +++ b/pymine/logic/query.py @@ -1,7 +1,7 @@ from __future__ import annotations import struct -from pymine.server import server +# from pymine.server import server # not yet ferb class QueryBuffer: From c0610195c71653cc66b9d82b8c40267dfc618c53 Mon Sep 17 00:00:00 2001 From: Sh-wayz Date: Thu, 11 Feb 2021 09:09:32 -0500 Subject: [PATCH 17/17] add metadata illegally --- plugins/example-plugin/plugin.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/plugins/example-plugin/plugin.yml b/plugins/example-plugin/plugin.yml index db46478bd..d5aab483d 100644 --- a/plugins/example-plugin/plugin.yml +++ b/plugins/example-plugin/plugin.yml @@ -1,2 +1,8 @@ -git_url: https://github.com/py-mine/example-plugin.git -module_folder: example_plugin +git_url: "https://github.com/py-mine/example-plugin.git" +module_folder: "example_plugin" +name: "example_plugin" +description: "This is an example plugin bada bing bada boom." +version: 1 +author: "PyMine Devs" +license: "GPLv3.0" +website: "https://www.youtube.com/watch?v=dQw4w9WgXcQ"