From 100547514dde3389f1b5f83df21a24fc285fe4cb Mon Sep 17 00:00:00 2001 From: Rainnny7 Date: Fri, 5 Apr 2024 22:47:26 -0400 Subject: [PATCH] Init app --- pom.xml | 9 ++++++ src/main/java/me/braydon/mc/RESTfulMC.java | 33 ++++++++++++++++++++++ src/main/resources/application.yml | 25 ++++++++++++++++ src/main/resources/banner.txt | 10 +++++++ 4 files changed, 77 insertions(+) create mode 100644 src/main/java/me/braydon/mc/RESTfulMC.java create mode 100644 src/main/resources/application.yml create mode 100644 src/main/resources/banner.txt diff --git a/pom.xml b/pom.xml index 8af1d6f..a54eec2 100644 --- a/pom.xml +++ b/pom.xml @@ -35,11 +35,20 @@ + org.springframework.boot spring-boot-starter-web + + + org.projectlombok + lombok + 1.18.32 + provided + + org.springframework.boot diff --git a/src/main/java/me/braydon/mc/RESTfulMC.java b/src/main/java/me/braydon/mc/RESTfulMC.java new file mode 100644 index 0000000..2a62f95 --- /dev/null +++ b/src/main/java/me/braydon/mc/RESTfulMC.java @@ -0,0 +1,33 @@ +package me.braydon.mc; + +import lombok.NonNull; +import lombok.SneakyThrows; +import lombok.extern.slf4j.Slf4j; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.StandardCopyOption; +import java.util.Objects; + +/** + * @author Braydon + */ +@SpringBootApplication +@Slf4j(topic = "RESTfulMC") +public final class RESTfulMC { + @SneakyThrows + public static void main(@NonNull String[] args) { + File config = new File("application.yml"); + if (!config.exists()) { // Saving the default config if it doesn't exist locally + Files.copy(Objects.requireNonNull(RESTfulMC.class.getResourceAsStream("/application.yml")), config.toPath(), StandardCopyOption.REPLACE_EXISTING); + log.info("Saved the default configuration to '{}', please re-launch the application", // Log the default config being saved + config.getAbsolutePath() + ); + return; + } + log.info("Found configuration at '{}'", config.getAbsolutePath()); // Log the found config + SpringApplication.run(RESTfulMC.class, args); + } +} \ No newline at end of file diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml new file mode 100644 index 0000000..27e80e9 --- /dev/null +++ b/src/main/resources/application.yml @@ -0,0 +1,25 @@ +# Server Configuration +server: + address: 0.0.0.0 + port: 7500 + +# Log Configuration +logging: + file: + path: "./logs" + +# Spring Configuration +spring: + data: + # Redis - This is used for caching + redis: + host: "127.0.0.1" + port: 6379 + database: 0 + auth: "" # Leave blank for no auth + + # Ignore + application: + name: "RESTfulMC" + banner: + location: "classpath:banner.txt" \ No newline at end of file diff --git a/src/main/resources/banner.txt b/src/main/resources/banner.txt new file mode 100644 index 0000000..c386a34 --- /dev/null +++ b/src/main/resources/banner.txt @@ -0,0 +1,10 @@ + _____ ______ _____ _______ __ _ __ __ _____ + | __ \| ____|/ ____|__ __/ _| | | \/ |/ ____| + | |__) | |__ | (___ | | | |_ _ _| | \ / | | + | _ /| __| \___ \ | | | _| | | | | |\/| | | + | | \ \| |____ ____) | | | | | | |_| | | | | | |____ + |_| \_\______|_____/ |_| |_| \__,_|_|_| |_|\_____| + + | API Version - v${application.version} + | Spring Version - ${spring-boot.formatted-version} +_______________________________________