Skip to content

Commit

Permalink
Merge branch 'release/1.0.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
finn-evers committed Nov 25, 2021
2 parents d65880c + 1defde5 commit ee84b68
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 18 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Changelog
All notable changes to this project will be documented in this file.

## [1.0.3] - 2021-11-25
### Changed
- Update Paper Download Api to v2

## [1.0.2] - 2020-10-05
### Added
- Add Config Option for Server Gui

[1.0.3]: https://github.com/garrus-de/minecraft-server-plugin/releases/tag/1.0.3
[1.0.2]: https://github.com/garrus-de/minecraft-server-plugin/releases/tag/1.0.2
17 changes: 9 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
<groupId>de.garrus.maven</groupId>
<artifactId>minecraft-server-plugin</artifactId>
<packaging>maven-plugin</packaging>
<version>1.0.1</version>
<version>1.0.3</version>
<name>minecraft-server-launcher</name>
<description>Maven Plugin to launch an Server for Plugin Development.</description>
<url>https://github.com/MEGarrusVakarian/minecraft-server-plugin</url>
<url>https://github.com/garrus-de/minecraft-server-plugin/</url>

<developers>
<developer>
Expand All @@ -24,15 +24,15 @@
<licenses>
<license>
<name>The MIT License (MIT)</name>
<url>hhttp://opensource.org/licenses/MIT</url>
<url>https://opensource.org/licenses/MIT</url>
<distribution>repo</distribution>
</license>
</licenses>

<scm>
<connection>scm:git:git://git@github.com:MEGarrusVakarian/minecraft-server-plugin.git</connection>
<developerConnection>scm:git:git@github.com:MEGarrusVakarian/minecraft-server-plugin.git</developerConnection>
<url>https://github.com/MEGarrusVakarian/minecraft-server-plugin</url>
<connection>scm:git:git@github.com:garrus-de/minecraft-server-plugin.git</connection>
<developerConnection>scm:git:git@github.com:garrus-de/minecraft-server-plugin.git</developerConnection>
<url>https://github.com/garrus-de/minecraft-server-plugin/</url>
</scm>

<properties>
Expand All @@ -44,12 +44,13 @@
<maven-javadoc-plugin.version>3.1.1</maven-javadoc-plugin.version>
<maven-gpg-plugin.verion>1.5</maven-gpg-plugin.verion>
<nexus-staging-maven-plugin.version>1.6.7</nexus-staging-maven-plugin.version>
<maven.compiler.plugin>3.8.1</maven.compiler.plugin>

<!--Dependency Versions-->
<maven.version>3.6.0</maven.version>
<maven.compiler.plugin>3.8.1</maven.compiler.plugin>
<gson.version>2.8.6</gson.version>
<commons-io.version>2.6</commons-io.version>
<gson.version>2.8.9</gson.version>
<commons-io.version>2.7</commons-io.version>
</properties>

<dependencies>
Expand Down
6 changes: 3 additions & 3 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Minecraft Server Plugin [![Build Status](https://travis-ci.com/MEGarrusVakarian/minecraft-server-plugin.svg?branch=master)](https://travis-ci.com/MEGarrusVakarian/minecraft-server-plugin) [![Maven Central](https://img.shields.io/maven-central/v/de.garrus.maven/minecraft-server-plugin.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22de.garrus.maven%22%20AND%20a:%22minecraft-server-plugin%22)
# Minecraft Server Plugin [![Maven Central](https://img.shields.io/maven-central/v/de.garrus.maven/minecraft-server-plugin.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22de.garrus.maven%22%20AND%20a:%22minecraft-server-plugin%22)

Maven Plugin to launch an Server for Plugin Development.

Expand All @@ -9,9 +9,9 @@ __Notice__: Current only [Papermc](http://papermc.io) Server supported.
<plugin>
<groupId>de.garrus.maven</groupId>
<artifactId>minecraft-server-plugin</artifactId>
<version>1.0.2</version>
<version>1.0.3</version>
<configuration>
<serverVersion>1.16.3</serverVersion>
<serverVersion>1.17.1</serverVersion>
<createEula>true</createEula>
<gui>true</gui>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package de.garrus.maven.minecraftserverplugin.mojo;

import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import de.garrus.maven.minecraftserverplugin.ServerType;
import org.apache.commons.io.FileUtils;
Expand All @@ -15,7 +16,7 @@

@Mojo(name = "server-install", requiresOnline = true)
public class InstallMojo extends AbstractMojo {
private static final String PAPER_API = "https://papermc.io/api/v1/paper/";
private static final String PAPER_API = "https://papermc.io/api/v2/projects/paper/versions/";

/**
* The Server type (PAPER,SPIGOT,BUKKIT)
Expand Down Expand Up @@ -185,9 +186,17 @@ public URL getPaperServerDownload() {
JsonObject versionJson = new Gson().fromJson(new InputStreamReader(paperApiURL.openStream()), JsonObject.class);

if (versionJson.has("builds")) {
String buildVersion = versionJson.get("builds").getAsJsonObject().get("latest").getAsString();

return new URL(PAPER_API + serverVersion + "/" + buildVersion + "/download");
// Store arr, save on some memory;
JsonArray arr = versionJson.get("builds").getAsJsonArray();

// Find latest build, from arr.size-1
String buildVersion = arr.get(arr.size()-1).toString();

// Show us where the jar is coming from
System.out.println("Getting jar from: "+PAPER_API + serverVersion + "/builds/" + buildVersion + "/downloads/"+"paper-"+serverVersion+"-"+buildVersion+".jar");

// Return jar url and do work
return new URL(PAPER_API + serverVersion + "/builds/" + buildVersion + "/downloads/"+"paper-"+serverVersion+"-"+buildVersion+".jar");
} else {
getLog().error("Can't find the build version in the api json");
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

@Mojo(name = "server-start")
public class StartMojo extends AbstractMojo {
Expand All @@ -31,14 +33,17 @@ public class StartMojo extends AbstractMojo {
@Parameter(name = "targetFolder", readonly = true, defaultValue = "${project.build.directory}")
private File targetFolder;

@Parameter(name = "skipPluginCopy",defaultValue = "false")
@Parameter(name = "skipPluginCopy", defaultValue = "false")
private boolean skipPluginCopy;

@Parameter(name = "gui", defaultValue = "false")
private boolean gui;

private File serverFile;

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
serverFile = new File(serverFolder, "server.jar");
serverFile = new File(serverFolder, "server.jar");

if (serverFile.exists()) {

Expand Down Expand Up @@ -72,8 +77,15 @@ private void copyPluginToServer() throws MojoFailureException {
* start the Spigot/Paper/Bukkit server as {@link Process} form maven
*/
private void startServer() {
List<String> command = new ArrayList<>();
command.add("java");
command.add("-jar");
command.add("server.jar");
if (!gui) {
command.add("nogui");
}
try {
ProcessBuilder processBuilder = new ProcessBuilder("java", "-jar", "server.jar", "nogui");
ProcessBuilder processBuilder = new ProcessBuilder(command);
processBuilder.directory(serverFolder);

processBuilder.redirectOutput(ProcessBuilder.Redirect.INHERIT);
Expand Down

0 comments on commit ee84b68

Please sign in to comment.