Compare commits

..

No commits in common. "88fede563923d15cdc30b3ae7e70fc6efc5b422d" and "1598270436269eef338c117b6537bb3ad9b7d76d" have entirely different histories.

74 changed files with 0 additions and 489 deletions

16
.gitignore vendored
View file

@ -1,16 +0,0 @@
# Jetbrains IDE
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf
.idea/artifacts
.idea/compiler.xml
.idea/jarRepositories.xml
.idea/modules.xml
.idea/*.iml
.idea/modules
*.iml
*.ipr
.internal/Tools/*
.internal/Sources/config.ini

8
.idea/.gitignore vendored
View file

@ -1,8 +0,0 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

View file

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DiscordProjectSettings">
<option name="show" value="PROJECT_FILES" />
<option name="description" value="" />
</component>
</project>

View file

@ -1,19 +0,0 @@
<component name="libraryTable">
<library name="Examples-v2">
<CLASSES>
<root url="jar://$PROJECT_DIR$/Resource Packs/Examples-v2/VPExample-1.16.2-1.16.4.zip!/" />
<root url="jar://$PROJECT_DIR$/Resource Packs/Examples-v2/VPExample-1.20.2-1.20.4.zip!/" />
<root url="jar://$PROJECT_DIR$/Resource Packs/Examples-v2/VPExample-1.15.2-1.16.1.zip!/" />
<root url="jar://$PROJECT_DIR$/Resource Packs/Examples-v2/VPExample-1.17.x.zip!/" />
<root url="jar://$PROJECT_DIR$/Resource Packs/Examples-v2/VPExample-1.19.3.zip!/" />
<root url="jar://$PROJECT_DIR$/Resource Packs/Examples-v2/VPExample-1.20-1.20.1.zip!/" />
<root url="jar://$PROJECT_DIR$/Resource Packs/Examples-v2/VPExample-1.19-1.19.2.zip!/" />
<root url="jar://$PROJECT_DIR$/Resource Packs/Examples-v2/VPExample-1.12.2.zip!/" />
<root url="jar://$PROJECT_DIR$/Resource Packs/Examples-v2/VPExample-1.19.4.zip!/" />
<root url="jar://$PROJECT_DIR$/Resource Packs/Examples-v2/VPExample-1.18.x.zip!/" />
<root url="jar://$PROJECT_DIR$/Resource Packs/Examples-v2/VPExample-1.13.2-1.14.4.zip!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

View file

@ -1,18 +0,0 @@
<component name="libraryTable">
<library name="Examples-v3">
<CLASSES>
<root url="jar://$PROJECT_DIR$/Resource Packs/Examples-v3/VPExampleNew-1.17.x.zip!/" />
<root url="jar://$PROJECT_DIR$/Resource Packs/Examples-v3/VPExampleNew-1.19-1.19.2.zip!/" />
<root url="jar://$PROJECT_DIR$/Resource Packs/Examples-v3/VPExampleNew-1.16.x.zip!/" />
<root url="jar://$PROJECT_DIR$/Resource Packs/Examples-v3/VPExampleNew-1.19.4.zip!/" />
<root url="jar://$PROJECT_DIR$/Resource Packs/Examples-v3/VPExampleNew-1.19.3.zip!/" />
<root url="jar://$PROJECT_DIR$/Resource Packs/Examples-v3/VPExampleNew-1.14.x.zip!/" />
<root url="jar://$PROJECT_DIR$/Resource Packs/Examples-v3/VPExampleNew-1.15.x.zip!/" />
<root url="jar://$PROJECT_DIR$/Resource Packs/Examples-v3/VPExampleNew-1.18.x.zip!/" />
<root url="jar://$PROJECT_DIR$/Resource Packs/Examples-v3/VPExampleNew-1.20.2-1.20.4.zip!/" />
<root url="jar://$PROJECT_DIR$/Resource Packs/Examples-v3/VPExampleNew-1.20-1.20.1.zip!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

View file

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Black">
<option name="sdkName" value="Python 3.10 (VehiclesPlus-v3)" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="temurin-21" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

View file

@ -1,26 +0,0 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Build v2 packs" type="PythonConfigurationType" factoryName="Python">
<module name="VehiclesPlus" />
<option name="ENV_FILES" value="" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="SDK_NAME" value="Python 3.10 (VehiclesPlus-v3)" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/.internal/Sources" />
<option name="IS_MODULE_SDK" value="false" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/.internal/Sources/convert.py" />
<option name="PARAMETERS" value="v2" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
</component>

View file

@ -1,26 +0,0 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Build v3 packs" type="PythonConfigurationType" factoryName="Python">
<module name="VehiclesPlus" />
<option name="ENV_FILES" value="" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="SDK_NAME" value="Python 3.10 (VehiclesPlus-v3)" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/.internal/Sources" />
<option name="IS_MODULE_SDK" value="false" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/.internal/Sources/convert.py" />
<option name="PARAMETERS" value="v3" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
</component>

View file

@ -1,25 +0,0 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Refresh wiki" type="PythonConfigurationType" factoryName="Python">
<module name="VehiclesPlus" />
<option name="ENV_FILES" value="" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/.internal/Sources" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/.internal/Sources/refresh.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
</component>

View file

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

View file

@ -1,4 +0,0 @@
# Converter scripts
This directory contains scripts that are used to convert the data from the original format to the format used in the project.
The VPExample.zip files are for version 1.20, which is the source.

View file

@ -1,118 +0,0 @@
import os
import shutil
import subprocess
import requests
def parse_versions(file_path):
versions = []
with open(file_path, 'r') as file:
for line in file:
parts = line.strip().split('#')
version_description = parts[1]
versions.append(version_description)
return versions
def download_latest_jar(repo_url, jar_directory, jar_name="ResourcePackConverter.jar"):
api_url = f"https://api.github.com/repos/{repo_url}/releases"
response = requests.get(api_url)
response.raise_for_status()
releases = response.json()
jar_url = None
for release in releases:
if release['assets']:
for asset in release['assets']:
if asset['name'] == jar_name:
jar_url = asset['browser_download_url']
break
if jar_url:
break
if not jar_url:
raise FileNotFoundError(f"No JAR file named {jar_name} found in the releases.")
jar_path = os.path.join(jar_directory, jar_name)
os.makedirs(jar_directory, exist_ok=True)
response = requests.get(jar_url)
response.raise_for_status()
with open(jar_path, 'wb') as file:
file.write(response.content)
return jar_path
def copy_zip_file(src, dst):
if not os.path.exists(dst):
os.makedirs(dst)
shutil.copy(src, dst)
def run_java_command(version, jar_file, input_zip):
command = f"java -jar {jar_file} --from 1.20 --to {version} -i {input_zip}"
print(f"Executing: {command}")
subprocess.run(command, shell=True)
def main(version_type):
if version_type not in ['v2', 'v3']:
raise ValueError("Invalid version type. Choose 'v2' or 'v3'.")
versions_file = f'versions_{version_type}.txt'
jar_directory = '../Tools/'
jar_name = "ResourcePackConverter.jar"
src_zip = f'Examples-{version_type}/VPExample.zip'
output_dir = f'../../ResourcePacks/Examples-{version_type}/'
repo_url = "agentdid127/ResourcePackConverter"
output_zip_name = "VPExample_converted.zip"
# Remove all zip files in the output directory
for file in os.listdir(output_dir):
if file.endswith(".zip"):
os.remove(os.path.join(output_dir, file))
# Parse versions from the file
versions = parse_versions(versions_file)
# Download the latest JAR file from GitHub
latest_jar = os.path.join(jar_directory, jar_name)
# TODO Re-enable
# latest_jar = download_latest_jar(repo_url, jar_directory, jar_name)
# Copy the zip file to the tools directory
copy_zip_file(src_zip, jar_directory)
try:
for version_description in versions:
# Run the Java command
run_java_command(version_description.split('-')[-1], latest_jar, jar_directory)
# Define the destination path with the new name
final_output_path = os.path.join(output_dir, f"VPExample-{version_type}-{version_description}.zip")
# Move and rename the output zip file to the destination
output_zip_path = os.path.join(jar_directory, output_zip_name)
shutil.move(output_zip_path, final_output_path)
print(f"Moved {output_zip_path} to {final_output_path}")
# Add the file to git
os.system(f"git add {final_output_path}")
finally:
# Remove the JAR file and the input zip file
run_path_folder = os.path.join(jar_directory, "VPExample_converted")
if os.path.exists(run_path_folder):
shutil.rmtree(run_path_folder)
# if os.path.exists(latest_jar):
# os.remove(latest_jar)
input_zip_path = os.path.join(jar_directory, os.path.basename(src_zip))
if os.path.exists(input_zip_path):
os.remove(input_zip_path)
print("Conversion completed.")
if __name__ == '__main__':
import sys
if len(sys.argv) != 2:
print("Usage: python convert_versions.py [v2|v3]")
sys.exit(1)
version_type = sys.argv[1]
main(version_type)

View file

@ -1,180 +0,0 @@
import configparser
import hashlib
import re
import shutil
import subprocess
import tempfile
from pathlib import Path
# Load configuration from config.ini
config = configparser.ConfigParser()
config.read('config.ini')
# Retrieve credentials
USERNAME = config.get('git', 'username')
PASSWORD = config.get('git', 'password')
# Configuration
REPO_URL = f'https://{USERNAME}:{PASSWORD}@git.sbdevelopment.tech/SBDevelopment/docs'
REPO_DIR = tempfile.mkdtemp()
SETUP_FILE_PATH = 'vehiclesplus/setup.md'
RESOURCE_PACK_DIR = '../../ResourcePacks/Examples-v2'
VERSIONS_FILE_PATH = 'versions_v2.txt'
BRANCH = 'main'
BASE_URL = 'https://git.sbdevelopment.tech/SBDevelopment/VehiclesPlus/raw/branch/master/ResourcePacks/Examples-v2/'
def run_command(command):
"""Run a shell command and return its output."""
try:
result = subprocess.run(command, shell=True, capture_output=True, text=True)
result.check_returncode()
return result.stdout
except subprocess.CalledProcessError as e:
print(f"Error executing command: {command}")
print(f"Return code: {e.returncode}")
print(f"Standard output: {e.stdout}")
print(f"Standard error: {e.stderr}")
raise
def clone_repo():
"""Clone the repository into the temp directory."""
print(f"Cloning repository from {REPO_URL} into {REPO_DIR}")
run_command(f'git clone {REPO_URL} {REPO_DIR}')
def find_setup_file():
"""Find and return the path of the setup.md file."""
setup_file = Path(REPO_DIR) / SETUP_FILE_PATH
if not setup_file.exists():
raise FileNotFoundError(f"{setup_file} does not exist.")
return setup_file
def list_zip_files():
"""List all ZIP files in the ResourcePacks/Examples-v2 directory."""
resource_pack_path = Path(RESOURCE_PACK_DIR)
if not resource_pack_path.exists():
raise FileNotFoundError(f"{resource_pack_path} does not exist.")
zip_files = list(resource_pack_path.glob('VPExample-v2-*.zip'))
print(f"Found ZIP files: {zip_files}")
return zip_files
def extract_version_info(zip_filename):
"""Extract version information from the zip filename."""
pattern = re.compile(r'^VPExample-v2-(\d+\.\d+(?:\.\d+)?)(?:-(\d+\.\d+(?:\.\d+)?))?\.zip$')
match = pattern.match(zip_filename.name)
if match:
if match.group(2): # Handle version ranges
print(f"Version range detected: {match.group(1)} - {match.group(2)}")
return f"{match.group(1)}-{match.group(2)}"
else: # Single version
print(f"Version detected: {match.group(1)}")
return match.group(1)
def calculate_sha1(file_path):
"""Calculate SHA1 hash of the given file."""
sha1 = hashlib.sha1()
with open(file_path, 'rb') as f:
while chunk := f.read(8192):
sha1.update(chunk)
return sha1.hexdigest()
def read_versions_file():
"""Read the versions_v2.txt file and return a list of (order, version) tuples."""
versions = []
with open(VERSIONS_FILE_PATH, 'r') as file:
for line in file:
parts = line.strip().split('#')
if len(parts) == 2:
order = int(parts[0])
version_range = parts[1]
versions.append((order, version_range))
# Sort by order
versions.sort()
return [version for _, version in versions]
def update_setup_file(setup_file_path, zip_files):
"""Update the setup.md file with correct paths and SHA1 checksums."""
with open(setup_file_path, 'r') as file:
lines = file.readlines()
table_header_found = False
table_alignment_found = False
table_start_index = None
table_end_index = None
# Identify the table header and alignment rows
for index, line in enumerate(lines):
if line.strip() == '| Version | Download | SHA1 Hash |':
table_header_found = True
table_start_index = index
elif table_header_found and line.strip() == '|:---:|:---:|---|':
table_alignment_found = True
elif table_header_found and table_alignment_found and line.strip() == '':
table_end_index = index
break
if table_start_index is not None and table_end_index is not None:
# Prepare to insert new rows
new_lines = lines[:table_start_index + 2] # Keep header and alignment lines
# Read the versions file to determine the order
version_order = read_versions_file()
# Create a dictionary for quick lookup
zip_file_dict = {}
for zip_file in zip_files:
version = extract_version_info(zip_file)
if version:
zip_file_dict[version] = zip_file
print(f"ZIP file dictionary: {zip_file_dict}")
# Insert new rows in the correct order
new_rows = []
for version in version_order:
zip_file = zip_file_dict.get(version)
print(f"Checking version: {version}")
if zip_file:
print (f"Found ZIP file: {zip_file}")
file_url = f"{BASE_URL}{zip_file.name}"
sha1_checksum = calculate_sha1(zip_file)
new_row = f"| {version} | [Click here]({file_url}) | `{sha1_checksum}` |\n"
new_rows.append(new_row)
if new_rows:
# Only update the file if new rows were added
print(f"Adding rows: {new_rows}")
new_lines.extend(new_rows)
new_lines.extend(lines[table_end_index:])
else:
print("No new rows to add.")
with open(setup_file_path, 'w') as file:
file.writelines(new_lines)
def commit_and_push_changes():
"""Commit and push changes to the repository."""
print(f"Committing and pushing changes to {REPO_DIR}")
run_command(f'cd {REPO_DIR} && git add {SETUP_FILE_PATH}')
result = run_command(f'cd {REPO_DIR} && git commit -m "Update vehicle setup file with correct paths and SHA1 checksums"')
if 'nothing to commit' in result:
print("No changes detected.")
else:
run_command(f'cd {REPO_DIR} && git push origin {BRANCH}')
def cleanup():
"""Remove the temp directory."""
shutil.rmtree(REPO_DIR)
def main():
try:
clone_repo()
setup_file_path = find_setup_file()
zip_files = list_zip_files()
update_setup_file(setup_file_path, zip_files)
commit_and_push_changes()
finally:
cleanup()
if __name__ == "__main__":
main()

View file

@ -1,14 +0,0 @@
3#1.12.2
4#1.13.2-1.14.4
5#1.15.2-1.16.1
6#1.16.2-1.16.5
7#1.17-1.17.1
8#1.18-1.18.2
9#1.19-1.19.2
11#1.19.3
13#1.19.4
15#1.20-1.20.1
18#1.20.2
22#1.20.3-1.20.4
32#1.20.5-1.20.6
34#1.21

View file

@ -1,13 +0,0 @@
4#1.14-1.14.4
5#1.15.2-1.16.1
6#1.16.2-1.16.5
7#1.17-1.17.1
8#1.18-1.18.2
9#1.19-1.19.2
11#1.19.3
13#1.19.4
15#1.20-1.20.1
18#1.20.2
22#1.20.3-1.20.4
32#1.20.5-1.20.6
34#1.21

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.