├── .gitignore ├── README.md ├── build.gradle.kts ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle.kts └── src └── main ├── java └── com │ └── triassic │ └── pterovm │ ├── InstallerThread.java │ ├── Main.java │ └── handlers │ ├── FileDownloader.java │ ├── Log.java │ └── RandomNameGen.java └── resources └── config.yml /.gitignore: -------------------------------------------------------------------------------- 1 | # User-specific stuff 2 | .idea/ 3 | 4 | *.iml 5 | *.ipr 6 | *.iws 7 | 8 | # IntelliJ 9 | out/ 10 | 11 | # Compiled class file 12 | *.class 13 | 14 | # Log file 15 | *.log 16 | 17 | # BlueJ files 18 | *.ctxt 19 | 20 | # Package Files # 21 | *.jar 22 | *.war 23 | *.nar 24 | *.ear 25 | *.zip 26 | *.tar.gz 27 | *.rar 28 | 29 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 30 | hs_err_pid* 31 | 32 | *~ 33 | 34 | # temporary files which can be created if a process still has a handle open of a deleted file 35 | .fuse_hidden* 36 | 37 | # KDE directory preferences 38 | .directory 39 | 40 | # Linux trash folder which might appear on any partition or disk 41 | .Trash-* 42 | 43 | # .nfs files are created when an open file is removed but is still being accessed 44 | .nfs* 45 | 46 | # General 47 | .DS_Store 48 | .AppleDouble 49 | .LSOverride 50 | 51 | # Icon must end with two \r 52 | Icon 53 | 54 | # Thumbnails 55 | ._* 56 | 57 | # Files that might appear in the root of a volume 58 | .DocumentRevisions-V100 59 | .fseventsd 60 | .Spotlight-V100 61 | .TemporaryItems 62 | .Trashes 63 | .VolumeIcon.icns 64 | .com.apple.timemachine.donotpresent 65 | 66 | # Directories potentially created on remote AFP share 67 | .AppleDB 68 | .AppleDesktop 69 | Network Trash Folder 70 | Temporary Items 71 | .apdisk 72 | 73 | # Windows thumbnail cache files 74 | Thumbs.db 75 | Thumbs.db:encryptable 76 | ehthumbs.db 77 | ehthumbs_vista.db 78 | 79 | # Dump file 80 | *.stackdump 81 | 82 | # Folder config file 83 | [Dd]esktop.ini 84 | 85 | # Recycle Bin used on file shares 86 | $RECYCLE.BIN/ 87 | 88 | # Windows Installer files 89 | *.cab 90 | *.msi 91 | *.msix 92 | *.msm 93 | *.msp 94 | 95 | # Windows shortcuts 96 | *.lnk 97 | 98 | .gradle 99 | **/build/ 100 | !src/**/build/ 101 | 102 | # Ignore Gradle GUI config 103 | gradle-app.setting 104 | 105 | # Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) 106 | !gradle-wrapper.jar 107 | 108 | # Avoid ignore Gradle wrappper properties 109 | !gradle-wrapper.properties 110 | 111 | # Cache of project 112 | .gradletasknamecache 113 | 114 | # Eclipse Gradle plugin generated files 115 | # Eclipse Core 116 | .project 117 | # JDT-specific (Eclipse Java Development Tools) 118 | .classpath 119 | 120 | # Common working directory 121 | run/ 122 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ⚠️ Maintenance Notice 2 | This project is no longer maintained and has been superceded by [Harbor](https://github.com/RealTriassic/Harbor), please use that instead as it is a lot better, has a smaller footprint and simply just runs a lot better. It includes wrappers for Python, Javascript (NodeJS) and Java (Kotlin) and supports both `x86_64` and `AARCH64` CPU architectures. Thank you for your continued support and I hope to see you there. 3 | -------------------------------------------------------------------------------- /build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | java 3 | id("com.github.johnrengelman.shadow") version "7.1.2" 4 | } 5 | 6 | repositories { 7 | mavenCentral() 8 | } 9 | 10 | dependencies { 11 | implementation("org.yaml:snakeyaml:1.33") 12 | } 13 | 14 | java { 15 | toolchain.languageVersion.set(JavaLanguageVersion.of(project.extra["java_version"].toString())) 16 | } 17 | 18 | tasks.shadowJar { 19 | dependencies { 20 | include(dependency("org.yaml:snakeyaml:1.33")) 21 | } 22 | } 23 | 24 | tasks.withType { 25 | manifest { 26 | attributes("Main-Class" to "com.triassic.pterovm.Main") 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | group = com.triassic.pterovm 2 | version = 1.0.1-SNAPSHOT 3 | description = A Java wrapper for PteroVM made by Triassic. 4 | 5 | org.gradle.parallel = true 6 | org.gradle.caching = true 7 | org.gradle.warning.mode = all 8 | 9 | java_version = 8 -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RealTriassic/Ptero-VM-JAR/13b1c7727f5229f9a625eb5400a275c9d46f8de2/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # Copyright © 2015-2021 the original authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | # 21 | # Gradle start up script for POSIX generated by Gradle. 22 | # 23 | # Important for running: 24 | # 25 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is 26 | # noncompliant, but you have some other compliant shell such as ksh or 27 | # bash, then to run this script, type that shell name before the whole 28 | # command line, like: 29 | # 30 | # ksh Gradle 31 | # 32 | # Busybox and similar reduced shells will NOT work, because this script 33 | # requires all of these POSIX shell features: 34 | # * functions; 35 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}», 36 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»; 37 | # * compound commands having a testable exit status, especially «case»; 38 | # * various built-in commands including «command», «set», and «ulimit». 39 | # 40 | # Important for patching: 41 | # 42 | # (2) This script targets any POSIX shell, so it avoids extensions provided 43 | # by Bash, Ksh, etc; in particular arrays are avoided. 44 | # 45 | # The "traditional" practice of packing multiple parameters into a 46 | # space-separated string is a well documented source of bugs and security 47 | # problems, so this is (mostly) avoided, by progressively accumulating 48 | # options in "$@", and eventually passing that to Java. 49 | # 50 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, 51 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; 52 | # see the in-line comments for details. 53 | # 54 | # There are tweaks for specific operating systems such as AIX, CygWin, 55 | # Darwin, MinGW, and NonStop. 56 | # 57 | # (3) This script is generated from the Groovy template 58 | # https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt 59 | # within the Gradle project. 60 | # 61 | # You can find Gradle at https://github.com/gradle/gradle/. 62 | # 63 | ############################################################################## 64 | 65 | # Attempt to set APP_HOME 66 | 67 | # Resolve links: $0 may be a link 68 | app_path=$0 69 | 70 | # Need this for daisy-chained symlinks. 71 | while 72 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path 73 | [ -h "$app_path" ] 74 | do 75 | ls=$( ls -ld "$app_path" ) 76 | link=${ls#*' -> '} 77 | case $link in #( 78 | /*) app_path=$link ;; #( 79 | *) app_path=$APP_HOME$link ;; 80 | esac 81 | done 82 | 83 | APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit 84 | 85 | APP_NAME="Gradle" 86 | APP_BASE_NAME=${0##*/} 87 | 88 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 89 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 90 | 91 | # Use the maximum available, or set MAX_FD != -1 to use that value. 92 | MAX_FD=maximum 93 | 94 | warn () { 95 | echo "$*" 96 | } >&2 97 | 98 | die () { 99 | echo 100 | echo "$*" 101 | echo 102 | exit 1 103 | } >&2 104 | 105 | # OS specific support (must be 'true' or 'false'). 106 | cygwin=false 107 | msys=false 108 | darwin=false 109 | nonstop=false 110 | case "$( uname )" in #( 111 | CYGWIN* ) cygwin=true ;; #( 112 | Darwin* ) darwin=true ;; #( 113 | MSYS* | MINGW* ) msys=true ;; #( 114 | NONSTOP* ) nonstop=true ;; 115 | esac 116 | 117 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 118 | 119 | 120 | # Determine the Java command to use to start the JVM. 121 | if [ -n "$JAVA_HOME" ] ; then 122 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 123 | # IBM's JDK on AIX uses strange locations for the executables 124 | JAVACMD=$JAVA_HOME/jre/sh/java 125 | else 126 | JAVACMD=$JAVA_HOME/bin/java 127 | fi 128 | if [ ! -x "$JAVACMD" ] ; then 129 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 130 | 131 | Please set the JAVA_HOME variable in your environment to match the 132 | location of your Java installation." 133 | fi 134 | else 135 | JAVACMD=java 136 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 137 | 138 | Please set the JAVA_HOME variable in your environment to match the 139 | location of your Java installation." 140 | fi 141 | 142 | # Increase the maximum file descriptors if we can. 143 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then 144 | case $MAX_FD in #( 145 | max*) 146 | MAX_FD=$( ulimit -H -n ) || 147 | warn "Could not query maximum file descriptor limit" 148 | esac 149 | case $MAX_FD in #( 150 | '' | soft) :;; #( 151 | *) 152 | ulimit -n "$MAX_FD" || 153 | warn "Could not set maximum file descriptor limit to $MAX_FD" 154 | esac 155 | fi 156 | 157 | # Collect all arguments for the java command, stacking in reverse order: 158 | # * args from the command line 159 | # * the main class name 160 | # * -classpath 161 | # * -D...appname settings 162 | # * --module-path (only if needed) 163 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. 164 | 165 | # For Cygwin or MSYS, switch paths to Windows format before running java 166 | if "$cygwin" || "$msys" ; then 167 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) 168 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) 169 | 170 | JAVACMD=$( cygpath --unix "$JAVACMD" ) 171 | 172 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 173 | for arg do 174 | if 175 | case $arg in #( 176 | -*) false ;; # don't mess with options #( 177 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath 178 | [ -e "$t" ] ;; #( 179 | *) false ;; 180 | esac 181 | then 182 | arg=$( cygpath --path --ignore --mixed "$arg" ) 183 | fi 184 | # Roll the args list around exactly as many times as the number of 185 | # args, so each arg winds up back in the position where it started, but 186 | # possibly modified. 187 | # 188 | # NB: a `for` loop captures its iteration list before it begins, so 189 | # changing the positional parameters here affects neither the number of 190 | # iterations, nor the values presented in `arg`. 191 | shift # remove old arg 192 | set -- "$@" "$arg" # push replacement arg 193 | done 194 | fi 195 | 196 | # Collect all arguments for the java command; 197 | # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of 198 | # shell script including quotes and variable substitutions, so put them in 199 | # double quotes to make sure that they get re-expanded; and 200 | # * put everything else in single quotes, so that it's not re-expanded. 201 | 202 | set -- \ 203 | "-Dorg.gradle.appname=$APP_BASE_NAME" \ 204 | -classpath "$CLASSPATH" \ 205 | org.gradle.wrapper.GradleWrapperMain \ 206 | "$@" 207 | 208 | # Use "xargs" to parse quoted args. 209 | # 210 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed. 211 | # 212 | # In Bash we could simply go: 213 | # 214 | # readarray ARGS < <( xargs -n1 <<<"$var" ) && 215 | # set -- "${ARGS[@]}" "$@" 216 | # 217 | # but POSIX shell has neither arrays nor command substitution, so instead we 218 | # post-process each arg (as a line of input to sed) to backslash-escape any 219 | # character that might be a shell metacharacter, then use eval to reverse 220 | # that process (while maintaining the separation between arguments), and wrap 221 | # the whole thing up as a single "set" statement. 222 | # 223 | # This will of course break if any of these variables contains a newline or 224 | # an unmatched quote. 225 | # 226 | 227 | eval "set -- $( 228 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | 229 | xargs -n1 | 230 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | 231 | tr '\n' ' ' 232 | )" '"$@"' 233 | 234 | exec "$JAVACMD" "$@" 235 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if "%ERRORLEVEL%"=="0" goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 84 | exit /b 1 85 | 86 | :mainEnd 87 | if "%OS%"=="Windows_NT" endlocal 88 | 89 | :omega 90 | -------------------------------------------------------------------------------- /settings.gradle.kts: -------------------------------------------------------------------------------- 1 | rootProject.name = "PteroVM" 2 | 3 | -------------------------------------------------------------------------------- /src/main/java/com/triassic/pterovm/InstallerThread.java: -------------------------------------------------------------------------------- 1 | package com.triassic.pterovm; 2 | 3 | import org.yaml.snakeyaml.Yaml; 4 | 5 | import java.io.File; 6 | import java.io.IOException; 7 | import java.io.InputStream; 8 | import java.nio.file.Files; 9 | import java.util.HashMap; 10 | 11 | public class InstallerThread extends Thread { 12 | public void run() { 13 | Yaml yaml = new Yaml(); 14 | InputStream localFile; 15 | 16 | try { 17 | localFile = Files.newInputStream(new File("config.yml").toPath()); 18 | } catch (IOException e) { 19 | throw new RuntimeException(e); 20 | } 21 | 22 | HashMap localData = yaml.load(localFile); 23 | 24 | try { 25 | String[] startCommand; 26 | File customScript = new File((String) localData.get("filename")); 27 | 28 | if (customScript.exists()) { 29 | System.out.println("Found custom script file, loading from " + customScript + "..."); 30 | startCommand = new String[] { "bash", String.valueOf(customScript)}; 31 | } else { 32 | System.out.println("No custom script file was found, loading from local file..."); 33 | startCommand = new String[] { "bash", Main.randomName() }; 34 | } 35 | 36 | ProcessBuilder installerProcess = new ProcessBuilder(startCommand); 37 | installerProcess.inheritIO(); 38 | installerProcess.start().waitFor(); 39 | } catch (Exception error) { 40 | System.out.println("An error occurred in the InstallerThread thread."); 41 | error.printStackTrace(); 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /src/main/java/com/triassic/pterovm/Main.java: -------------------------------------------------------------------------------- 1 | package com.triassic.pterovm; 2 | 3 | import java.io.File; 4 | import java.io.IOException; 5 | import java.io.InputStream; 6 | import java.nio.file.Files; 7 | import java.util.HashMap; 8 | import java.util.LinkedHashMap; 9 | import java.util.List; 10 | import java.util.Objects; 11 | 12 | import com.triassic.pterovm.handlers.FileDownloader; 13 | import com.triassic.pterovm.handlers.Log; 14 | import com.triassic.pterovm.handlers.RandomNameGen; 15 | import org.yaml.snakeyaml.Yaml; 16 | 17 | public class Main { 18 | private static final Yaml yaml = new Yaml(); 19 | private static final String randomName = RandomNameGen.generate() + ".sh"; 20 | 21 | public static void main(String[] args) throws IOException { 22 | Config.createConfig(); 23 | Config.loadConfig(); 24 | 25 | InputStream localFile = Files.newInputStream(new File("config.yml").toPath()); 26 | HashMap localData = yaml.load(localFile); 27 | 28 | File customScript = new File((String) localData.get("filename")); 29 | final String fileUrl = (String) localData.get("url"); 30 | 31 | if (!customScript.exists()) { 32 | FileDownloader.downloadFile(fileUrl, randomName); 33 | } 34 | 35 | LinkedHashMap startupMessages = (LinkedHashMap ) localData.get("startup_messages"); 36 | 37 | List text = (List ) startupMessages.get("text"); 38 | Boolean toggle = (Boolean) startupMessages.get("enabled"); 39 | 40 | if (toggle.equals(true)) { 41 | for (String msg : text) { 42 | Log.info(msg); 43 | } 44 | } 45 | 46 | try { 47 | InstallerThread installProcess = new InstallerThread(); 48 | installProcess.start(); 49 | } catch (Exception error) { 50 | Log.severe("Failed to start installer thread."); 51 | error.printStackTrace(); 52 | } 53 | } 54 | 55 | public static String randomName() { 56 | return randomName; 57 | } 58 | 59 | public static class Config { 60 | public static void createConfig() { 61 | File configFile = new File("config.yml"); 62 | InputStream inputStream = Main.class.getClassLoader().getResourceAsStream("config.yml"); 63 | 64 | if (!configFile.exists()) { 65 | try { 66 | Files.copy(Objects.requireNonNull(inputStream), configFile.toPath()); 67 | } catch (IOException error) { 68 | System.out.println("Failed to create configuration file."); 69 | error.printStackTrace(); 70 | 71 | System.exit(0); 72 | } 73 | } 74 | } 75 | 76 | public static void loadConfig() throws IOException { 77 | Yaml yaml = new Yaml(); 78 | InputStream jarFile = Main.class.getClassLoader().getResourceAsStream("config.yml"); 79 | InputStream localFile = Files.newInputStream(new File("config.yml").toPath()); 80 | 81 | HashMap jarData = yaml.load(jarFile); 82 | HashMap localData = yaml.load(localFile); 83 | 84 | if(!Objects.equals(localData.get("config_version").toString(), jarData.get("config_version").toString())) { 85 | System.out.println("Your config.yml is outdated, delete it and start the server."); 86 | System.out.println("Your configuration is made for version " + localData.get("config_version") + ". Latest config version is " + jarData.get("config_version") + "."); 87 | System.exit(0); 88 | } 89 | } 90 | } 91 | } -------------------------------------------------------------------------------- /src/main/java/com/triassic/pterovm/handlers/FileDownloader.java: -------------------------------------------------------------------------------- 1 | package com.triassic.pterovm.handlers; 2 | 3 | import java.io.FileOutputStream; 4 | import java.io.IOException; 5 | import java.net.URL; 6 | import java.nio.channels.Channels; 7 | import java.nio.channels.ReadableByteChannel; 8 | 9 | public class FileDownloader { 10 | public static void downloadFile(String fileUrl, String fileName) throws IOException { 11 | URL fetchFile = new URL(fileUrl); 12 | ReadableByteChannel readableByteChannel = Channels.newChannel(fetchFile.openStream()); 13 | 14 | try (FileOutputStream fos = new FileOutputStream(fileName)) { 15 | fos.getChannel().transferFrom(readableByteChannel, 0, Long.MAX_VALUE); 16 | } catch (Exception e) { 17 | Log.severe("Failed to download " + fileName + "."); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /src/main/java/com/triassic/pterovm/handlers/Log.java: -------------------------------------------------------------------------------- 1 | package com.triassic.pterovm.handlers; 2 | 3 | import java.util.logging.FileHandler; 4 | import java.util.logging.Handler; 5 | import java.util.logging.Level; 6 | import java.util.logging.Logger; 7 | 8 | public class Log { 9 | private static final Logger logger = Logger.getLogger(Log.class.getName()); 10 | 11 | private Log() { 12 | try { 13 | Handler fileHandler = new FileHandler("pterovm.log"); 14 | logger.addHandler(fileHandler); 15 | } catch (Exception e) { 16 | e.printStackTrace(); 17 | } 18 | } 19 | 20 | public static Logger getInstance() { 21 | return logger; 22 | } 23 | 24 | public static void log(Level level, String msg) { 25 | logger.log(level, msg); 26 | } 27 | 28 | public static void severe(String msg) { 29 | logger.severe(msg); 30 | } 31 | 32 | public static void warning(String msg) { 33 | logger.warning(msg); 34 | } 35 | 36 | public static void info(String msg) { 37 | logger.info(msg); 38 | } 39 | } -------------------------------------------------------------------------------- /src/main/java/com/triassic/pterovm/handlers/RandomNameGen.java: -------------------------------------------------------------------------------- 1 | package com.triassic.pterovm.handlers; 2 | 3 | import java.util.Random; 4 | 5 | public class RandomNameGen { 6 | private static final int NAME_LENGTH = 32; 7 | private static final String ALPHABET = "abcdefghijklmnopqrstuvwxyz"; 8 | 9 | public static String generate() { 10 | Random random = new Random(); 11 | StringBuilder sb = new StringBuilder(); 12 | for (int i = 0; i < NAME_LENGTH; i++) { 13 | sb.append(ALPHABET.charAt(random.nextInt(ALPHABET.length()))); 14 | } 15 | return sb.toString(); 16 | } 17 | } -------------------------------------------------------------------------------- /src/main/resources/config.yml: -------------------------------------------------------------------------------- 1 | #-------------------------------------------------------------------------------------# 2 | # # 3 | # @@@@@@@ @@@@@@@ @@@@@@@@ @@@@@@@ @@@@@@ @@@ @@@ @@@@@@@@@@ # 4 | # @@@@@@@@ @@@@@@@ @@@@@@@@ @@@@@@@@ @@@@@@@@ @@@ @@@ @@@@@@@@@@@ # 5 | # @@! @@@ @@! @@! @@! @@@ @@! @@@ @@! @@@ @@! @@! @@! # 6 | # !@! @!@ !@! !@! !@! @!@ !@! @!@ !@! @!@ !@! !@! !@! # 7 | # @!@@!@! @!! @!!!:! @!@!!@! @!@ !@! @!@ !@! @!! !!@ @!@ # 8 | # !!@!!! !!! !!!!!: !!@!@! !@! !!! !@! !!! !@! ! !@! # 9 | # !!: !!: !!: !!: :!! !!: !!! :!: !!: !!: !!: # 10 | # :!: :!: :!: :!: !:! :!: !:! ::!!:! :!: :!: # 11 | # :: :: :: :::: :: ::: ::::: :: :::: ::: :: # 12 | # : : : :: :: : : : : : : : : : # 13 | # # 14 | #-------------------------------------------------------------------------------------# 15 | 16 | # If you have any issues or questions whilst attempting to run Ptero-VM, let us know! 17 | # https://github.com/RealTriassic/Ptero-VM-JAR 18 | 19 | 20 | # Set messages that should be printed to console during start-up. 21 | # This is usually used to set server status to "Online" on game management panels such as Pterodactyl. 22 | startup_messages: 23 | enabled: true # Default: true 24 | # You can add or remove entries here, you can have as many messages to be printed as you'd like. 25 | text: 26 | - "Done (0.000s)! For help, type \"help\"" 27 | - "Listening on /0.0.0.0:0" 28 | 29 | 30 | # File to use for when searching for custom script file. 31 | # This is usually used if the host you are using is blocking custom.sh from running. 32 | filename: "custom.sh" # Default: custom.sh 33 | 34 | 35 | # The URL used to download the script file from. 36 | # The download should start instantly when the JAR tries to visit it. 37 | url: "https://raw.githubusercontent.com/afnan007a/Ptero-vm/main/installer.sh" 38 | 39 | 40 | # DO NOT MODIFY. 41 | config_version: 1.0.2 --------------------------------------------------------------------------------