Skip to content

Commit

Permalink
Merge pull request #142 from gilesknap/fix-for-1.21
Browse files Browse the repository at this point in the history
use 1.21 block_entity_data for signs
  • Loading branch information
gilesknap authored Jul 21, 2024
2 parents 33f98d6 + 8f66204 commit 5f9e054
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 17 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@
"[python]": {
"editor.defaultFormatter": "charliermarsh.ruff",
},
"python.testing.pytestArgs": [
"tests"
],
}
9 changes: 5 additions & 4 deletions src/mciwb/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ class Monitor:

def __init__(
self,
func: None | CallbackFunction = None,
# maybe this type is a bit loose, pyright not happy, lets just roll with it.
func: None | CallbackFunction = None, # type: ignore
params: tuple[Any, ...] = (),
once=False,
name=None,
Expand All @@ -54,7 +55,7 @@ def __init__(

# pollers is a list of functions, param tuples. It may be initialized
# with a single function passed in func, params
self.pollers: list[tuple[CallbackFunction, tuple[Any, ...]]] = (
self.pollers: list[tuple[CallbackFunction, tuple[Any, ...]]] = ( # type: ignore
[] if func is None else [(func, params)]
)

Expand Down Expand Up @@ -112,7 +113,7 @@ def _poller(self):
if not self.once:
log.info(f"Monitor {self.name} stopped")

def add_poller_func(self, func: CallbackFunction, params: tuple[Any, ...] = ()):
def add_poller_func(self, func: CallbackFunction, params: tuple[Any, ...] = ()): # type: ignore
"""
Add a function to the pollers list
Expand All @@ -123,7 +124,7 @@ def add_poller_func(self, func: CallbackFunction, params: tuple[Any, ...] = ()):

# TODO: consider using a dict or indexing pollers in some fashion
# currently this does not support 2 calls to same function
def remove_poller_func(self, func: CallbackFunction):
def remove_poller_func(self, func: CallbackFunction): # type: ignore
"""
Remove a function from the pollers list
Expand Down
4 changes: 2 additions & 2 deletions src/mciwb/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,13 @@ def create(self, world_zip=None, force=False) -> None:
if not self.backup_folder.exists():
self.backup_folder.mkdir(parents=True)

container = docker_client.containers.run(
container = docker_client.containers.run( # type: ignore
"docker.io/itzg/minecraft-server",
detach=True,
environment=env,
ports={f"{self.rcon}/tcp": self.rcon, f"{self.port}": self.port},
restart_policy={"Name": "unless-stopped" if self.keep else "no"},
volumes={
volumes={ # type: ignore
str(self.server_folder): {"bind": "/data", "mode": "rw"},
str(self.backup_folder): {
"bind": str(self.backup_folder),
Expand Down
10 changes: 6 additions & 4 deletions src/mciwb/signs.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@ class Signs:

_re_sign_text = re.compile("""front_text.*messages: \\['"([^"]*)"',""")
_re_sign_entity = (
"""minecraft:oak_sign{{"""
"""BlockEntityTag:{{front_text:{{"""
"""messages:['["{0}"]','[""]','[""]','[""]']}}}},"""
"""display:{{Name:'{{"text":"{0}"}}'}}"""
"""minecraft:oak_sign["""
"""block_entity_data={{"""
"""id:oak_sign,front_text:{{"""
"""messages:['["{0}"]','[""]','[""]','[""]']"""
"""}}"""
"""}},"""
"""minecraft:item_name="{0}"]"""
)

_wall_sign = "minecraft:oak_wall_sign"
Expand Down
14 changes: 7 additions & 7 deletions tests/mockclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ def clone(
v_stop = v_start + vol.size
d_stop = dest + vol.size

self.world[
dest.x : d_stop.x, dest.y : d_stop.y, dest.z : d_stop.z
] = self.world[
v_start.x : v_stop.x,
v_start.y : v_stop.y,
v_start.z : v_stop.z,
]
self.world[dest.x : d_stop.x, dest.y : d_stop.y, dest.z : d_stop.z] = (
self.world[
v_start.x : v_stop.x,
v_start.y : v_stop.y,
v_start.z : v_stop.z,
]
)
return f"cloned {v_start} : {v_stop} to {dest}"

@property
Expand Down

0 comments on commit 5f9e054

Please sign in to comment.