Skip to content

Instantly share code, notes, and snippets.

@AmauryCarrade
Last active October 24, 2020 19:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AmauryCarrade/ce4b5d9a0747d91e29fdc7df16d279b6 to your computer and use it in GitHub Desktop.
Save AmauryCarrade/ce4b5d9a0747d91e29fdc7df16d279b6 to your computer and use it in GitHub Desktop.
Converts ZePS stations enum to dynmap markers
lines = []
stations = []
declarations_started = False
netherroutes_started = False
with open("./Station.java") as f:
lines = f.readlines()
for line in lines:
line = line.strip()
if not line:
continue
if not declarations_started:
if line == "{":
declarations_started = True
continue
if line == ";":
break
if line.startswith("//"):
netherroutes_started = True
continue
keyword, arguments = line.split("(", maxsplit=1)
x, z, name, *arguments = arguments.split(",")
# We strip delimiters from the name, but we add back
# a parenthesis in case we removed one from the
# name itself.
name = name.strip('(") ')
if '(' in name:
name += ')'
arguments = [
arg.strip("() ")
for arg in arguments
if arg and not arg.strip().startswith("//")
]
station_type = "portal"
# First argument after coordinates and name: station type
if len(arguments) > 0:
station_type = (
"intersection" if "INTERSECTION_ONLY" in arguments[0] else "portal"
)
if station_type == "intersection" and netherroutes_started:
# We don't want to put netherroute intersections on the map (pointless).
continue
# Second argument after: hidden station (for path display only - we don't want these)
if len(arguments) > 1:
if arguments[1] == "true":
continue
# Third argument after is the danger but we don't care (?)
prefix = " " * 12
tab = " " * 4
category = "netherrail" if not netherroutes_started else "netherroutes"
print(f"{prefix}{category}_{keyword.lower()}:")
prefix += tab
print(f"{prefix}world: V5_nether")
print(f"{prefix}markup: false")
print(f"{prefix}x: {x}")
print(f"{prefix}y: 64")
print(f"{prefix}z: {z}")
print(f"{prefix}label: {name}")
print(f'{prefix}icon: {"minecart" if station_type == "intersection" else "portal"}')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment