Skip to content

Commit

Permalink
兼容Java11,新增多版本编译脚本
Browse files Browse the repository at this point in the history
  • Loading branch information
SomeBottle committed Aug 13, 2024
1 parent bb737b0 commit b4da6c1
Show file tree
Hide file tree
Showing 9 changed files with 176 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
target/
artifacts/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ This tool finds out chunks where players have barely stayed by examining the `In

## 3. Installation

1. Ensure you have the corresponding version of the JRE (Java Runtime Environment).
2. Download the `PotatoPeeler*.jar` from the [Releases](https://github.com/Bottle-M/PotatoPeeler/releases/latest) page, and place it in wherever you want(e.g. The root directory of your Minecraft server).
1. You should have already installed the corresponding version of JRE (Java Runtime Environment). For details, refer to [this document](https://minecraft.wiki/w/Server/Requirements#Server_requirements).
2. Download the `PotatoPeeler*.jar` from [Releases](https://github.com/Bottle-M/PotatoPeeler/releases/latest) according to your Java version, and place it in a suitable location (such as the root directory of your Minecraft Server).

## 4. Usage

Expand Down
4 changes: 2 additions & 2 deletions README.zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ Lang: [English](README.md) | 简体中文

## 3. 安装

1. 确保你有相应版本的 JRE(Java 运行环境)
2.[Releases](https://github.com/Bottle-M/PotatoPeeler/releases/latest) 下载 `PotatoPeeler*.jar`,找个位置放着即可(比如 Minecraft 服务端根目录)。
1. 你应该已经按照了相应版本的 JRE(Java 运行环境),可以参考[这个文档](https://zh.minecraft.wiki/w/%E6%9C%8D%E5%8A%A1%E5%99%A8/%E9%9C%80%E6%B1%82#%E6%9C%8D%E5%8A%A1%E5%99%A8%E9%9C%80%E6%B1%82)
2.[Releases](https://github.com/Bottle-M/PotatoPeeler/releases/latest) 按照你的 Java 版本下载 `PotatoPeeler*.jar`,找个位置放着即可(比如 Minecraft 服务端根目录)。

## 4. 使用

Expand Down
15 changes: 15 additions & 0 deletions source/PotatoPeeler/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

OUTPUT_DIR="./artifacts"

rm -f $OUTPUT_DIR/*

mkdir -p $OUTPUT_DIR

# Maven Profiles

for p in java11 java16 java17 java21; do
# Skip tests
mvn clean package -f pom.multiple.xml -DskipTests -P$p
cp target/PotatoPeeler*java*.jar $OUTPUT_DIR
done
53 changes: 47 additions & 6 deletions source/PotatoPeeler/dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
<version>1.0.0</version>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<version>3.6.0</version>
Expand All @@ -21,13 +29,51 @@
<mainClass>indi.somebottle.Main</mainClass>
</transformer>
</transformers>
<finalName>PotatoPeeler-${project.version}</finalName>
<finalName>PotatoPeeler-${project.version}-java${javaVersion}</finalName>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>java11</id>
<properties>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.source>11</maven.compiler.source>
<javaVersion>11</javaVersion>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</profile>
<profile>
<id>java16</id>
<properties>
<maven.compiler.target>16</maven.compiler.target>
<maven.compiler.source>16</maven.compiler.source>
<javaVersion>16</javaVersion>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</profile>
<profile>
<id>java17</id>
<properties>
<maven.compiler.target>17</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source>
<javaVersion>17</javaVersion>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</profile>
<profile>
<id>java21</id>
<properties>
<maven.compiler.target>21</maven.compiler.target>
<maven.compiler.source>21</maven.compiler.source>
<javaVersion>21</javaVersion>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</profile>
</profiles>
<dependencies>
<dependency>
<groupId>junit</groupId>
Expand All @@ -42,9 +88,4 @@
</exclusions>
</dependency>
</dependencies>
<properties>
<maven.compiler.target>21</maven.compiler.target>
<maven.compiler.source>21</maven.compiler.source>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>
106 changes: 106 additions & 0 deletions source/PotatoPeeler/pom.multiple.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>indi.somebottle</groupId>
<artifactId>potatopeeler</artifactId>
<version>1.0.0</version>

<dependencies>
<dependency>
<groupId>org.lz4</groupId>
<artifactId>lz4-java</artifactId>
<version>1.8.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.davidmoten</groupId>
<artifactId>rtree2</artifactId>
<version>0.9.3</version>
</dependency>
</dependencies>

<profiles>
<profile>
<id>java11</id>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<javaVersion>11</javaVersion>
</properties>
</profile>
<profile>
<id>java16</id>
<properties>
<maven.compiler.source>16</maven.compiler.source>
<maven.compiler.target>16</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<javaVersion>16</javaVersion>
</properties>
</profile>
<profile>
<id>java17</id>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<javaVersion>17</javaVersion>
</properties>
</profile>
<profile>
<id>java21</id>
<properties>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<javaVersion>21</javaVersion>
</properties>
</profile>
</profiles>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.6.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>indi.somebottle.Main</mainClass>
</transformer>
</transformers>
<finalName>PotatoPeeler-${project.version}-java${javaVersion}</finalName>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>


</project>
2 changes: 2 additions & 0 deletions source/PotatoPeeler/src/main/java/indi/somebottle/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

public class Main {
public static void main(String[] args) {
// 设置编码为 UTF-8
System.setProperty("file.encoding", "UTF-8");
// 如果一个参数都没有
if (args.length == 0) {
// 尝试从工作目录下的 potatopeeler.args 文件中读取参数
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public static String bytesToHumanReadable(long bytes) {
sb.append(bytes / BYTES_PER_KIB).append(" KiB ");
bytes %= BYTES_PER_KIB;
}
if (bytes > 0 || sb.isEmpty()) {
if (bytes > 0 || sb.length() == 0) {
sb.append(bytes).append(" Bytes");
}
return sb.toString().trim();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ public static Region readRegion(File regionFile) throws RegionPosNotFoundExcepti
* 但是 wiki 里是:x 先递增。
* SomeBottle 2024.8.5
*/
// TODO:重新测试 forceloaded 区块的保留
for (int z = 0; z < 32; z++) {
for (int x = 0; x < 32; x++) {
// 先读取距离文件起点的偏移扇区数目
Expand Down

0 comments on commit b4da6c1

Please sign in to comment.