Skip to content

Commit

Permalink
Merge branch 'LabyMod:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
BarukoT authored Jan 8, 2025
2 parents 958a6dd + 8e9f02d commit 8a4d70e
Show file tree
Hide file tree
Showing 126 changed files with 764 additions and 260 deletions.
116 changes: 85 additions & 31 deletions .github/actions/validate-manifest/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def main():
wildcard_stop = False

create_comment = comment_needed()
if create_comment:
if not create_comment:
print('No manifest file changed, comment will be skipped.')

manifest_files = get_changed_manifest_files()
Expand Down Expand Up @@ -45,16 +45,22 @@ def main():
error += '- One of the **required values** is missing\n'
continue

if data['direct_ip'] in ['', '-']:
error += f'- Direct IP is required\n'
if data['nice_name'] in ['', '-']:
error += f'- Nice name is required and cannot be empty!\n'

server_directory = manifest_file.replace('minecraft_servers/', '').replace('/manifest.json', '')
if server_directory != data['server_name']:
error += '**Servername has to be directory name!**\n'
error += '**Servername has to be directory name!** (all lowercase)\n'

# Validate wildcards
if 'server_wildcards' in data:
for wildcard in data['server_wildcards']:
if not wildcard.startswith('%.'):
wildcard_stop = True
error += '- Invalid wildcard entry. Each entry must start with **%.**. Further information here: https://en.wikipedia.org/wiki/Wildcard_DNS_record (`server_wildcards`)\n'
print(f'Found valid wildcard entry: {wildcard}')

check_server_online_state(
data['direct_ip'],
Expand Down Expand Up @@ -90,6 +96,8 @@ def main():
for key in USERNAME_SOCIAL_KEYS:
if key in social and (social[key].startswith('http') or 'www' in social[key]):
error += f'- Please use a **username**, not a link (`social.{key}`)\n'
if key in social and social[key] in ('', '-'):
error += f'- Please remove the empty key **{key}** or fill in information.\n'

# Check facebook, because it works :)
if 'facebook' in social:
Expand All @@ -105,19 +113,22 @@ def main():
int(data['discord']['server_id'])
except ValueError:
error += f'- Please use a **numeric** value for your server id (`discord.server_id`)\n'
if 'rename_to_minecraft_name' in 'discord' in data == True:
comment += f'- `discord.rename_to_minecraft_name` is reserved for LabyMod Partners. Change it to `false`. If you are a partner, please ignore this message.\n'
if 'rename_to_minecraft_name' in data['discord'] and data['discord']['rename_to_minecraft_name'] == True:
comment += f'- `discord.rename_to_minecraft_name` is reserved for LabyMod Partners. Change it to `false`.' \
'If you are a partner, please ignore this message.\n'


if 'user_stats' in data and ('{userName}' not in data['user_stats'] and '{uuid}' not in data['user_stats']):
error += '- Please use {userName} or {uuid} in your stats url (`user_stats`)\n'
if 'location' in data:
if 'city' in data['location'] and data['location']['city'] in ['', '-']:
error += f'- Please remove the empty key **city** or fill in information.\n'

if 'location' in data and 'country_code' in data['location']:
country_code = data['location']['country_code']
if len(country_code) > 2 or len(country_code) <= 1:
error += '- Use valid format (ISO 3166-1 alpha-2) for country code. (`location.country_code`)\n'
if 'country_code' in data['location']:
country_code = data['location']['country_code']
if len(country_code) > 2 or len(country_code) <= 1:
error += '- Use valid format (ISO 3166-1 alpha-2) for country code. (`location.country_code`)\n'

if not country_code.isupper():
error += '- Use upper-case for country code. (`location.country_code`)\n'
if not country_code.isupper():
error += '- Use upper-case for country code. (`location.country_code`)\n'

# check hex codes
if 'brand' in data:
Expand All @@ -129,13 +140,53 @@ def main():
stats_url = data['user_stats']
if not stats_url.startswith('https://'):
error += f'- Invalid url. URL has to start with **https://** (`user_stats`)\n'
if '{userName}' not in data['user_stats'] and '{uuid}' not in data['user_stats']:
error += '- Please use {userName} or {uuid} in your stats url (`user_stats`)\n'

if '://laby.net/' in stats_url:
error += f'- Please use **your own page**, not LABY.net (`user_stats`)\n'

if 'chat' in data and 'message_formats' in data['chat']:
message_format = data['chat']['message_formats']
if isinstance(message_format, list):
if len(message_format) == 1:
message_format = message_format[0]
else:
error += f'**message_format** has the wrong format. Please recheck the [example manifest](https://github.com/LabyMod/server-media/blob/master/docs/Manifest.md#chat-object).'

template_regex = '^§[a-f0-9](?<level>\\d+)( \\||§8 \\|) §[a-f0-9](?<sender>[a-zA-Z0-9_]{2,16})§r§7: §f(?<message>.*)$'
if template_regex == message_format:
comment += f'- It seems you\'re using the **template regex** for chat message! Please make sure it is the right regex for **your server**!'
if message_format in ('', '-'):
error += f'- Please remove the empty key **message_formats** or fill in information.\n'


if 'gamemodes' in data:
gamemodes = data['gamemodes']
for key, gamemode in gamemodes.items():
if 'name' not in gamemode or 'color' not in gamemode or gamemode['name'] in ('', '-') or '#' not in gamemode['color']:
error += f"- Please add a name or a color to the gamemode {key}\n"
if 'url' in gamemode and gamemode['url'] in ('', '-'):
error += f"- Please remove the empty url key in gamemode **{key}** or fill in information.\n"
if 'versions' in gamemode and gamemode['versions'] in ('', '-'):
error += f"- Please remove the empty version key in gamemode **{key}** or fill in information.\n"
if 'command' in gamemode and gamemode['command'] in ('', '-'):
error += f"- Please remove the empty command key in gamemode **{key}** or fill in information.\n"



if create_comment:
post_comment(error)
post_comment(comment)
if error != '':
post_comment(error)
if comment != '':
temp_comment = comment
comment = '*Just as an information*:\n\n'
comment += temp_comment
post_comment(comment, 'comments')

if error != '':
# Make job fail
sys_exit('Invalid data in manifest.json. See comments above or review in PR for more information.')

for error in error.split('\n'):
# Print error comments, so that the user can relate the issues even if there is no comment
Expand All @@ -144,10 +195,6 @@ def main():
for comment in comment.split('\n'):
print(comment)

if error != '':
# Make job fail
sys_exit('Invalid data in manifest.json. See comments above or review in PR for more information.')


def get_changed_manifest_files():
print('Getting changed files from json')
Expand All @@ -163,10 +210,6 @@ def get_changed_manifest_files():


def post_comment(comment: str, request_type: str = 'reviews'):
if comment == '':
print('No issues found.')
return

if request_type == 'reviews':
comment += '\nPlease fix the issues by pushing **one** commit to the pull ' \
'request to prevent too many automatic reviews.'
Expand All @@ -178,10 +221,11 @@ def post_comment(comment: str, request_type: str = 'reviews'):
headers={'Accept': 'application/vnd.github.v3+json', 'Authorization': f"Token {os.getenv('GH_TOKEN')}"}
)

print(f'Github request returned {request.status_code}')
print(f'Github request returned {request.status_code}, posted into {request_type}.')


def check_server_online_state(ip: str, wildcards: list):
offline_text = 'In general, we only accept pull requests from servers, **that are online**.\nPlease change this, otherwise we cannot review your server correctly and have to deny the pull request.\n\n'
print(f'Check server status for {ip}')

url = f'https://api.mcsrvstat.us/2/{ip}'
Expand Down Expand Up @@ -210,17 +254,15 @@ def check_server_online_state(ip: str, wildcards: list):
server_ip = response['ip_address']
print(f"Checked server status successfully: {response['online']}")

offline_text = "In general, we only accept pull requests from servers, **that are online**. " \
"Please change this, otherwise we cannot review your server correctly and have to deny the pull request.\n\n" \
"If your server is currently online, then our api returned a wrong status, we will have a look at it :)\n\n" \
f"Reference: [API URL ({url})]({url})"
offline_text += f"Reference: [API URL ({url})]({url})"

if not response['online']:
post_comment(f'*Just as an information*:\nYour server {ip} **could be offline**.\n {offline_text}', 'comments')

wildcard_string = '*Just as an information*:\n'
wildcard_string = '*Just as an information regarding your wildcards*:\n'
wildcard_comment = False
for wildcard in wildcards:
print(f'Checking wildcard "{wildcard}"')
wildcard_ip = str.replace(wildcard, '%', 'testingstringwildcard')
request = requests.get(f'https://api.mcsrvstat.us/2/{wildcard_ip}')

Expand All @@ -231,9 +273,11 @@ def check_server_online_state(ip: str, wildcards: list):
continue

if not response['online']:
print(f'Wildcard "{wildcard}" is offline')
wildcard_string += f'- Wildcard {wildcard} seems to be invalid. Server is offline with testing wildcard.\n'
wildcard_comment = True
else:
print(f'Wildcard "{wildcard}" is online')
if response['ip'] != server_ip:
wildcard_string += f'- Wildcard do not resolve the same ip address: *{wildcard}* => *{response["ip"]}*\n'
wildcard_comment = True
Expand All @@ -255,7 +299,8 @@ def check_server_online_state(ip: str, wildcards: list):


def comment_needed():
if os.getenv('PR_ACTION').endswith('opened'):
pr_action = os.getenv('PR_ACTION')
if pr_action in ['opened', 'reopened', 'synchronize']:
print('PR opened - Write comment.')
return True

Expand Down Expand Up @@ -284,13 +329,22 @@ def check_discord_invite(url: str):
request = requests.get(f'https://discord.com/api/v9/invites/{invite}')
if request.status_code == 200:
print(f'Invite for {invite} was successful.')

response_data = request.json()
guild_data = response_data.get('guild', {})
if isinstance(guild_data, dict):
guild_name = guild_data.get('name', 'Unknown Guild')
else:
guild_name = 'Unknown Guild'
print(f'Guild name: {guild_name}')

return True
else:
print(f'Invite for {invite} was invalid .')
print(f'Invite for {invite} was invalid.')
return False
except requests.exceptions.ConnectionError:
print(f'Discord seems to be down while checking. Please check manually\n')
return False

if __name__ == '__main__':
main()
main()
2 changes: 1 addition & 1 deletion docs/Files.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ characters (no URL/domain!).

> **Important**: The directory MUST match the `server_name` property in the [manifest.json](/docs/Manifest.md).
To be accepted a server should be already released and on more than ~20 concurrent players on a daily basis.
For a server to get accepted, it should already be released and publicly available! Servers in maintenance will be declined.

A folder can contain the following files (*required):

Expand Down
10 changes: 5 additions & 5 deletions docs/Manifest.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
| `social.discord` | [Discord invite **URL**](Usages.md#social) | `"https://discord.gg/labymod"` *or* `"https://discord.gg/Wbg7rArky7"` ([Read more](#discord-url)) |
| `social.youtube` | [YouTube channel **URL**](Usages.md#social) | `"https://www.youtube.com/channel/UCSamgE1KYvC7qZn56T0J2yg"` |
| `social.teamspeak` | [TeamSpeak server address](Usages.md#social) | `"ts.labymod.net"` |
| `gamemodes` | [Gamemodes](Usages.md#gamemodes) | [gamemode object](#gamemode-object) |
| `chat` | Chat | [chat object](#chat-object) |
| `gamemodes` | [Gamemodes](Usages.md#gamemodes) | [Gamemode object](#gamemode-object) |
| `chat` | Chat | [Chat object](#chat-object) |
| `discord.server_id` | [Discord server id](Usages.md#one-click-discord-join-partner-only) | `260471731809026048` |
| `discord.rename_to_minecraft_name` | Boolean whether the user should be renamed when joining | `false` (`true` only allowed for server partners) |
| `brand.primary` | [Primary brand color](Usages.md#colorize-your-page) | `"#008FE8"` |
Expand All @@ -40,7 +40,7 @@
### Chat object
| Key | Description | Example value |
|-------------------|-----------------------------------------|---------------|
| `message_formats` | Regex for chat messages sent by players | see below |
| `message_formats` | Regex for chat messages sent by players | See below |
```json
[
"^§[a-f0-9](?<level>\\d+)(| §[a-f0-9](?<rank>\\S+)) §e(?<sender>[a-zA-Z0-9_]{2,16}) §f(?<message>.*)$"
Expand All @@ -54,7 +54,7 @@
| Any color code | `§[a-f0-9]` |
| Any formatting code | `§[k-or]` |
| Any color or formatting code | `§[a-fk-or0-9]` |
| Any color or formatting code in a row | zero or one: `(§[a-fk-or0-9])?`<br/>at least one: `(§[a-fk-or0-9])+`<br/>zero or more: `(§[a-fk-or0-9])*` |
| Any color or formatting code in a row | Zero or one: `(§[a-fk-or0-9])?`<br/>At least one: `(§[a-fk-or0-9])+`<br/>Zero or more: `(§[a-fk-or0-9])*` |
| Player name | `[a-zA-Z0-9_]{2,16}` |

### Gamemode object
Expand All @@ -64,7 +64,7 @@
| `name`* | Gamemode nice name | `"JumpWorld"` |
| `color`* | Brand color | `"#ADD8E6"` |
| `url` | Gamemode description url / website related to the gamemode | `"https://www.timolia.de/games#jumpworld"` |
| `command` | e.g. quickjoin-command | `"/quickjoin jumpworld"` |
| `command` | E.g. quickjoin-command | `"/quickjoin jumpworld"` |
| `versions` | Restrict supported Minecraft versions for the gamemode | `"1.17<1.19.1"`, `"1.8<*"` |

* Required values are: `name` & `color`
Expand Down
Binary file added minecraft_servers/blockmania/background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added minecraft_servers/blockmania/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added minecraft_servers/blockmania/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added minecraft_servers/blockmania/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions minecraft_servers/blockmania/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"server_name": "blockmania",
"nice_name": "Blockmania",
"direct_ip": "blockmania.com",
"supported_languages": [
"en"
],
"social": {
"twitter": "Block_Mania",
"discord": "https://discord.com/invite/GkqBP5J"
},
"discord": {
"server_id": 252413534951047179,
"rename_to_minecraft_name": false
},
"brand": {
"primary": "#497cb1",
"background": "#497cb1",
"text": "#ffffff"
}
}
Binary file added minecraft_servers/buildtheearth/background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added minecraft_servers/buildtheearth/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions minecraft_servers/buildtheearth/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"server_name": "buildtheearth",
"nice_name": "BuildTheEarth",
"direct_ip": "buildtheearth.net",
"supported_languages": [
"en"
],
"social": {
"twitter": "BuildTheEarth_",
"discord": "https://discord.com/invite/buildtheearth-net-690908396404080650"
},
"discord": {
"server_id": 690908396404080650,
"rename_to_minecraft_name": false
},
"brand": {
"primary": "#497cb1",
"background": "#497cb1",
"text": "#ffffff"
},
"yt_trailer": "yge606ivgls"
}
Binary file added minecraft_servers/clarrymc/background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added minecraft_servers/clarrymc/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added minecraft_servers/clarrymc/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added minecraft_servers/clarrymc/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions minecraft_servers/clarrymc/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"server_name": "clarrymc",
"nice_name": "ClarryMC",
"direct_ip": "clarrymc.de",
"supported_languages": [
"de"
],
"social": {
"discord": "https://discord.gg/QXqryx4Wcj"
},
"discord": {
"server_id": 1256979742457069658
},
"brand": {
"primary": "#e305c2",
"background": "#00182e",
"text": "#ffffff"
},
"location": {
"city": "Frankfurt",
"country": "Germany",
"country_code": "DE"
}
}
Binary file added minecraft_servers/claynation/background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added minecraft_servers/claynation/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added minecraft_servers/claynation/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added minecraft_servers/claynation/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 8a4d70e

Please sign in to comment.