Compare commits

..

No commits in common. "master" and "v2.3.0" have entirely different histories.

38 changed files with 343 additions and 682 deletions

24
.gitattributes vendored
View File

@ -1,24 +0,0 @@
# Normalize as LF in the repository, OS native locally
* text=auto
*.bat text eol=crlf
gradlew text eol=lf
*.sh text eol=lf
*.conf text eol=lf
*.java text
*.java diff=java
# Binary files that should not be modified
*.dat binary
*.db binary
*.icns binary
*.ico binary
*.jar binary
*.jks binary
*.jpg binary
*.key binary
*.png binary
*.ttf binary
*.wav binary
JavaApplicationStub binary

View File

@ -1,4 +1,4 @@
name: Build
name: Java CI
on: [push]
@ -6,19 +6,17 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 0 # needed for versioning
- name: Set up Java
uses: actions/setup-java@v4
- name: Set up Java 11
uses: actions/setup-java@v1
with:
distribution: 'temurin'
java-version: 21
cache: 'gradle'
java-version: 11
- name: Build with Gradle
run: ./gradlew clean build test
- uses: actions/upload-artifact@v4
- uses: actions/upload-artifact@v2-preview
with:
name: artifact
path: build/libs/*

View File

@ -1,27 +0,0 @@
name: Publish
on:
workflow_dispatch:
push:
tags:
- '**'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0 # needed for versioning
- name: Set up Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 21
cache: 'gradle'
- name: Build with Gradle
run: ./gradlew publish
env:
BLUECOLORED_USERNAME: ${{ secrets.BLUECOLORED_USERNAME }}
BLUECOLORED_PASSWORD: ${{ secrets.BLUECOLORED_PASSWORD }}

View File

@ -1,22 +1,110 @@
import java.io.IOException
import java.util.concurrent.TimeoutException
plugins {
bluemap.base
java
`java-library`
`maven-publish`
id("com.diffplug.spotless") version "6.1.2"
}
fun String.runCommand(): String = ProcessBuilder(split("\\s(?=(?:[^'\"`]*(['\"`])[^'\"`]*\\1)*[^'\"`]*$)".toRegex()))
.directory(projectDir)
.redirectOutput(ProcessBuilder.Redirect.PIPE)
.redirectError(ProcessBuilder.Redirect.PIPE)
.start()
.apply {
if (!waitFor(10, TimeUnit.SECONDS)) {
throw TimeoutException("Failed to execute command: '" + this@runCommand + "'")
}
}
.run {
val error = errorStream.bufferedReader().readText().trim()
if (error.isNotEmpty()) {
throw IOException(error)
}
inputStream.bufferedReader().readText().trim()
}
val gitHash = "git rev-parse --verify HEAD".runCommand()
val clean = "git status --porcelain".runCommand().isEmpty()
val lastTag = "git describe --tags --abbrev=0".runCommand()
val lastVersion = lastTag.substring(1) // remove the leading 'v'
val commits = "git rev-list --count $lastTag..HEAD".runCommand()
println("Git hash: $gitHash" + if (clean) "" else " (dirty)")
group = "de.bluecolored.bluemap.api"
version = lastVersion +
(if (commits == "0") "" else "-$commits") +
(if (clean) "" else "-dirty")
println("Version: $version")
val javaTarget = 11
java {
sourceCompatibility = JavaVersion.toVersion(javaTarget)
targetCompatibility = JavaVersion.toVersion(javaTarget)
}
repositories {
mavenCentral()
}
dependencies {
api ( libs.flow.math )
api ( libs.gson )
api ("com.flowpowered:flow-math:1.0.3")
api ("com.google.code.gson:gson:2.8.0")
compileOnly ( libs.jetbrains.annotations )
compileOnly ( libs.lombok )
compileOnly ("org.jetbrains:annotations:23.0.0")
}
annotationProcessor ( libs.lombok )
spotless {
java {
target ("src/*/java/**/*.java")
licenseHeaderFile("LICENSE_HEADER")
indentWithSpaces()
trimTrailingWhitespace()
}
}
tasks.withType(JavaCompile::class).configureEach {
options.apply {
encoding = "utf-8"
}
}
tasks.withType(AbstractArchiveTask::class).configureEach {
isReproducibleFileOrder = true
isPreserveFileTimestamps = false
}
tasks.javadoc {
options {
(this as? StandardJavadocDocletOptions)?.apply {
links(
"https://docs.oracle.com/javase/8/docs/api/"
)
}
}
}
tasks.processResources {
from("src/main/resources") {
include("de/bluecolored/bluemap/api/version.json")
duplicatesStrategy = DuplicatesStrategy.INCLUDE
expand (
"version" to project.version,
"gitHash" to gitHash + if (clean) "" else " (dirty)"
)
}
}
publishing {
publications {
create<MavenPublication>("maven") {
groupId = project.group.toString()
artifactId = "bluemap-${project.name}"
artifactId = project.name
version = project.version.toString()
from(components["java"])

View File

@ -1,17 +0,0 @@
plugins {
`kotlin-dsl`
}
repositories {
mavenCentral()
gradlePluginPortal()
}
dependencies {
fun plugin(dependency: Provider<PluginDependency>) = dependency.map {
"${it.pluginId}:${it.pluginId}.gradle.plugin:${it.version}"
}
implementation ( plugin( libs.plugins.spotless ) )
implementation ( plugin( libs.plugins.shadow ) )
}

View File

@ -1,9 +0,0 @@
// use version-catalog from root project
dependencyResolutionManagement {
versionCatalogs {
register("libs") {
from(files("../gradle/libs.versions.toml"))
}
}
}

View File

@ -1,78 +0,0 @@
plugins {
java
`java-library`
`maven-publish`
id ( "com.diffplug.spotless" )
}
group = "de.bluecolored"
version = gitVersion()
repositories {
maven ("https://repo.bluecolored.de/releases") {
content { includeGroupByRegex ("de\\.bluecolored\\..*") }
}
maven ("https://hub.spigotmc.org/nexus/content/repositories/snapshots/") {
content { includeGroup ("org.spigotmc") }
}
mavenCentral()
maven ("https://libraries.minecraft.net")
maven ( "https://maven.minecraftforge.net" )
maven ("https://repo.papermc.io/repository/maven-public/")
}
tasks.withType(JavaCompile::class).configureEach {
options.encoding = "utf-8"
}
tasks.withType(AbstractArchiveTask::class).configureEach {
isReproducibleFileOrder = true
isPreserveFileTimestamps = false
}
java {
toolchain.languageVersion = JavaLanguageVersion.of(21)
withSourcesJar()
withJavadocJar()
}
tasks.javadoc {
(options as StandardJavadocDocletOptions).apply {
links(
"https://docs.oracle.com/en/java/javase/16/docs/api/",
"https://javadoc.io/doc/com.flowpowered/flow-math/1.0.3/",
"https://javadoc.io/doc/com.google.code.gson/gson/2.8.9/",
)
addStringOption("Xdoclint:none", "-quiet")
addBooleanOption("html5", true)
}
}
tasks.test {
useJUnitPlatform()
}
spotless {
java {
target ("src/*/java/**/*.java")
licenseHeaderFile(rootProject.file("LICENSE_HEADER"))
indentWithSpaces()
trimTrailingWhitespace()
}
}
publishing {
repositories {
maven {
name = "bluecolored"
url = uri( "https://repo.bluecolored.de/releases" )
credentials {
username = project.findProperty("bluecoloredUsername") as String? ?: System.getenv("BLUECOLORED_USERNAME")
password = project.findProperty("bluecoloredPassword") as String? ?: System.getenv("BLUECOLORED_PASSWORD")
}
}
}
}

View File

@ -1,44 +0,0 @@
import org.gradle.api.Project
import java.io.IOException
import java.util.concurrent.TimeUnit
import java.util.concurrent.TimeoutException
fun Project.gitHash(): String {
return runCommand("git rev-parse --verify HEAD", "-")
}
fun Project.gitClean(): Boolean {
return runCommand("git status --porcelain", "NOT_CLEAN").isEmpty()
}
fun Project.gitVersion(): String {
val lastTag = if (runCommand("git tag", "").isEmpty()) "" else runCommand("git describe --tags --abbrev=0", "")
val lastVersion = if (lastTag.isEmpty()) "0.0" else lastTag.substring(1) // remove the leading 'v'
val commits = runCommand("git rev-list --count $lastTag..HEAD", "0")
val gitVersion = lastVersion +
(if (commits == "0") "" else "-$commits") +
(if (gitClean()) "" else "-dirty")
logger.lifecycle("${project.name} version: $gitVersion")
return gitVersion
}
private fun Project.runCommand(cmd: String, fallback: String? = null): String {
ProcessBuilder(cmd.split("\\s(?=(?:[^'\"`]*(['\"`])[^'\"`]*\\1)*[^'\"`]*$)".toRegex()))
.directory(projectDir)
.redirectOutput(ProcessBuilder.Redirect.PIPE)
.redirectError(ProcessBuilder.Redirect.PIPE)
.start()
.apply {
if (!waitFor(10, TimeUnit.SECONDS))
throw TimeoutException("Failed to execute command: '$cmd'")
}
.run {
val error = errorStream.bufferedReader().readText().trim()
if (error.isEmpty()) return inputStream.bufferedReader().readText().trim()
logger.warn("Failed to execute command '$cmd': $error")
if (fallback != null) return fallback
throw IOException(error)
}
}

2
gradle.properties Normal file
View File

@ -0,0 +1,2 @@
org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false

View File

@ -1,14 +0,0 @@
[versions]
junit = "5.8.2"
[libraries]
flow-math = { module = "com.flowpowered:flow-math", version = "1.0.3" }
gson = { module = "com.google.code.gson:gson", version = "2.8.9" }
jetbrains-annotations = { module = "org.jetbrains:annotations", version = "23.0.0" }
junit-core = { module = "org.junit.jupiter:junit-jupiter", version.ref = "junit" }
junit-engine = { module = "org.junit.jupiter:junit-jupiter-engine", version.ref = "junit" }
lombok = { module = "org.projectlombok:lombok", version = "1.18.32" }
[plugins]
shadow = { id = "io.github.goooler.shadow", version = "8.+" }
spotless = { id = "com.diffplug.spotless", version = "6.+" }

Binary file not shown.

View File

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

262
gradlew vendored
View File

@ -1,7 +1,7 @@
#!/bin/sh
#!/usr/bin/env sh
#
# Copyright © 2015-2021 the original authors.
# Copyright 2015 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@ -17,113 +17,78 @@
#
##############################################################################
#
# Gradle start up script for POSIX generated by Gradle.
#
# Important for running:
#
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
# noncompliant, but you have some other compliant shell such as ksh or
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh Gradle
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
# (2) This script targets any POSIX shell, so it avoids extensions provided
# by Bash, Ksh, etc; in particular arrays are avoided.
#
# The "traditional" practice of packing multiple parameters into a
# space-separated string is a well documented source of bugs and security
# problems, so this is (mostly) avoided, by progressively accumulating
# options in "$@", and eventually passing that to Java.
#
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
# see the in-line comments for details.
#
# There are tweaks for specific operating systems such as AIX, CygWin,
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
#
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
app_path=$0
# Need this for daisy-chained symlinks.
while
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
[ -h "$app_path" ]
do
ls=$( ls -ld "$app_path" )
link=${ls#*' -> '}
case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=${0##*/}
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
MAX_FD="maximum"
warn () {
echo "$*"
} >&2
}
die () {
echo
echo "$*"
echo
exit 1
} >&2
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "$( uname )" in #(
CYGWIN* ) cygwin=true ;; #(
Darwin* ) darwin=true ;; #(
MSYS* | MINGW* ) msys=true ;; #(
NONSTOP* ) nonstop=true ;;
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD=$JAVA_HOME/jre/sh/java
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD=$JAVA_HOME/bin/java
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
@ -132,7 +97,7 @@ Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD=java
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
@ -140,95 +105,84 @@ location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# Collect all arguments for the java command, stacking in reverse order:
# * args from the command line
# * the main class name
# * -classpath
# * -D...appname settings
# * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
JAVACMD=$( cygpath --unix "$JAVACMD" )
# Now convert the arguments - kludge to limit ourselves to /bin/sh
for arg do
if
case $arg in #(
-*) false ;; # don't mess with options #(
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
[ -e "$t" ] ;; #(
*) false ;;
esac
then
arg=$( cygpath --path --ignore --mixed "$arg" )
fi
# Roll the args list around exactly as many times as the number of
# args, so each arg winds up back in the position where it started, but
# possibly modified.
#
# NB: a `for` loop captures its iteration list before it begins, so
# changing the positional parameters here affects neither the number of
# iterations, nor the values presented in `arg`.
shift # remove old arg
set -- "$@" "$arg" # push replacement arg
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#
eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' '
)" '"$@"'
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi
exec "$JAVACMD" "$@"

25
gradlew.bat vendored
View File

@ -29,9 +29,6 @@ if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@ -40,7 +37,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@ -54,7 +51,7 @@ goto fail
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
@ -64,14 +61,28 @@ echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell

2
jitpack.yml Normal file
View File

@ -0,0 +1,2 @@
jdk:
- openjdk11

View File

@ -1,8 +1 @@
rootProject.name = "api"
logger.lifecycle("""
## Building BlueMapAPI ...
Java: ${System.getProperty("java.version")}
JVM: ${System.getProperty("java.vm.version")} (${System.getProperty("java.vendor")})
Arch: ${System.getProperty("os.arch")}
""")
rootProject.name = "BlueMapAPI"

View File

@ -35,20 +35,20 @@
/**
* A storage that is able to hold any "asset"-data for a map. For example images, icons, scripts or json-files.
*/
@SuppressWarnings("unused")
public interface AssetStorage {
/**
* Writes a new asset into this storage, overwriting any existent assets with the same name.<br>
* Use the returned {@link OutputStream} to write the asset-data. The asset will be added to the storage as soon as that stream
* gets closed!<br>
* <br>
* gets closed!
* <p>
* Example:
* <pre>
* try (OutputStream out = assetStorage.writeAsset("image.png")) {
* ImageIO.write(image, "png", out);
* }
* </pre>
* </p>
* @param name The (unique) name for this asset
* @return An {@link OutputStream} that should be used to write the asset and closed once!
* @throws IOException when the underlying storage rises an IOException
@ -57,8 +57,8 @@ public interface AssetStorage {
/**
* Reads an asset from this storage.<br>
* Use the returned {@link InputStream} to read the asset-data.<br>
* <br>
* Use the returned {@link InputStream} to read the asset-data.
* <p>
* Example:
* <pre>
* Optional&lt;InputStream&gt; optIn = assetStorage.readAsset("image.png");
@ -68,6 +68,7 @@ public interface AssetStorage {
* }
* }
* </pre>
* </p>
* @param name The name of the asset that should be read from the storage.
* @return An {@link Optional} with an {@link InputStream} when the asset is found, from which the asset can be read.
* Or an empty optional if there is no asset with this name.

View File

@ -27,8 +27,8 @@
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import de.bluecolored.bluemap.api.debug.DebugDump;
import de.bluecolored.bluemap.api.plugin.Plugin;
import org.jetbrains.annotations.ApiStatus;
import java.io.InputStream;
import java.io.InputStreamReader;
@ -43,7 +43,6 @@
* An API to control the running instance of BlueMap.
* <p>This API is thread-save, so you <b>can</b> use it async, off the main-server-thread, to save performance!</p>
*/
@SuppressWarnings({"unused", "UnusedReturnValue"})
public abstract class BlueMapAPI {
@SuppressWarnings("unused")
@ -59,7 +58,6 @@ public abstract class BlueMapAPI {
gitHash = element.get("git-hash").getAsString();
} catch (Exception ex) {
System.err.println("Failed to load version from resources!");
//noinspection CallToPrintStackTrace
ex.printStackTrace();
}
}
@ -73,37 +71,42 @@ public abstract class BlueMapAPI {
private static BlueMapAPI instance;
private static final LinkedHashSet<Consumer<BlueMapAPI>> onEnableConsumers = new LinkedHashSet<>();
private static final LinkedHashSet<Consumer<BlueMapAPI>> onDisableConsumers = new LinkedHashSet<>();
private static final Collection<Consumer<BlueMapAPI>> onEnableConsumers = new HashSet<>(2);
private static final Collection<Consumer<BlueMapAPI>> onDisableConsumers = new HashSet<>(2);
/**
* Getter for the {@link RenderManager}.
* @return the {@link RenderManager}
*/
@DebugDump
public abstract RenderManager getRenderManager();
/**
* Getter for the {@link WebApp}.
* @return the {@link WebApp}
*/
@DebugDump
public abstract WebApp getWebApp();
/**
* Getter for the {@link Plugin}
* @return the {@link Plugin}
*/
@DebugDump
public abstract Plugin getPlugin();
/**
* Getter for all {@link BlueMapMap}s loaded by BlueMap.
* @return an unmodifiable collection of all loaded {@link BlueMapMap}s
*/
@DebugDump
public abstract Collection<BlueMapMap> getMaps();
/**
* Getter for all {@link BlueMapWorld}s loaded by BlueMap.
* @return an unmodifiable collection of all loaded {@link BlueMapWorld}s
*/
@DebugDump
public abstract Collection<BlueMapWorld> getWorlds();
/**
@ -134,12 +137,14 @@ public abstract class BlueMapAPI {
* Getter for the installed BlueMap version
* @return the version-string
*/
@DebugDump
public abstract String getBlueMapVersion();
/**
* Getter for the installed BlueMapAPI version
* @return the version-string
*/
@DebugDump
public String getAPIVersion() {
return VERSION;
}
@ -158,7 +163,6 @@ public static synchronized Optional<BlueMapAPI> getInstance() {
* <p><b>The {@link Consumer} can be called multiple times if BlueMap disables and enables again, e.g. if BlueMap gets reloaded!</b></p>
* <p><i>(Note: The consumer will likely be called asynchronously, <b>not</b> on the server-thread!)</i></p>
* <p>Remember to unregister the consumer when you no longer need it using {@link #unregisterListener(Consumer)}.</p>
* <p>The {@link Consumer}s are guaranteed to be called in the order they were registered in.</p>
* @param consumer the {@link Consumer}
*/
public static synchronized void onEnable(Consumer<BlueMapAPI> consumer) {
@ -172,7 +176,6 @@ public static synchronized void onEnable(Consumer<BlueMapAPI> consumer) {
* <p><b>The {@link Consumer} can be called multiple times if BlueMap disables and enables again, e.g. if BlueMap gets reloaded!</b></p>
* <p><i>(Note: The consumer will likely be called asynchronously, <b>not</b> on the server-thread!)</i></p>
* <p>Remember to unregister the consumer when you no longer need it using {@link #unregisterListener(Consumer)}.</p>
* <p>The {@link Consumer}s are guaranteed to be called in the order they were registered in.</p>
* @param consumer the {@link Consumer}
*/
public static synchronized void onDisable(Consumer<BlueMapAPI> consumer) {
@ -194,23 +197,30 @@ public static synchronized boolean unregisterListener(Consumer<BlueMapAPI> consu
* @return <code>true</code> if the instance has been registered, <code>false</code> if there already was an instance registered
* @throws ExecutionException if a listener threw an exception during the registration
*/
@ApiStatus.Internal
protected static synchronized boolean registerInstance(BlueMapAPI instance) throws Exception {
protected static synchronized boolean registerInstance(BlueMapAPI instance) throws ExecutionException {
if (BlueMapAPI.instance != null) return false;
BlueMapAPI.instance = instance;
List<Exception> thrownExceptions = new ArrayList<>(0);
List<Throwable> thrownExceptions = new ArrayList<>(0);
for (Consumer<BlueMapAPI> listener : BlueMapAPI.onEnableConsumers) {
try {
listener.accept(BlueMapAPI.instance);
} catch (Exception ex) {
} catch (Throwable ex) {
thrownExceptions.add(ex);
}
}
return throwAsOne(thrownExceptions);
if (!thrownExceptions.isEmpty()) {
ExecutionException ex = new ExecutionException(thrownExceptions.get(0));
for (int i = 1; i < thrownExceptions.size(); i++) {
ex.addSuppressed(thrownExceptions.get(i));
}
throw ex;
}
return true;
}
/**
@ -219,8 +229,7 @@ protected static synchronized boolean registerInstance(BlueMapAPI instance) thro
* @return <code>true</code> if the instance was unregistered, <code>false</code> if there was no or an other instance registered
* @throws ExecutionException if a listener threw an exception during the un-registration
*/
@ApiStatus.Internal
protected static synchronized boolean unregisterInstance(BlueMapAPI instance) throws Exception {
protected static synchronized boolean unregisterInstance(BlueMapAPI instance) throws ExecutionException {
if (BlueMapAPI.instance != instance) return false;
List<Exception> thrownExceptions = new ArrayList<>(0);
@ -235,12 +244,8 @@ protected static synchronized boolean unregisterInstance(BlueMapAPI instance) th
BlueMapAPI.instance = null;
return throwAsOne(thrownExceptions);
}
private static boolean throwAsOne(List<Exception> thrownExceptions) throws Exception {
if (!thrownExceptions.isEmpty()) {
Exception ex = thrownExceptions.get(0);
ExecutionException ex = new ExecutionException(thrownExceptions.get(0));
for (int i = 1; i < thrownExceptions.size(); i++) {
ex.addSuppressed(thrownExceptions.get(i));
}

View File

@ -27,8 +27,8 @@
import com.flowpowered.math.vector.Vector2i;
import com.flowpowered.math.vector.Vector3d;
import com.flowpowered.math.vector.Vector3i;
import de.bluecolored.bluemap.api.debug.DebugDump;
import de.bluecolored.bluemap.api.markers.MarkerSet;
import org.jetbrains.annotations.ApiStatus;
import java.util.Map;
import java.util.function.Predicate;
@ -37,25 +37,27 @@
* This class represents a map that is rendered by BlueMap of a specific world ({@link BlueMapWorld}).
* Each map belongs to a map configured in BlueMap's configuration file (in the <code>maps: []</code> list).
*/
@SuppressWarnings("unused")
public interface BlueMapMap {
/**
* Returns this maps id, this is equal to the id configured in bluemap's config for this map.
* @return the id of this map
*/
@DebugDump
String getId();
/**
* Returns this maps display-name, this is equal to the name configured in bluemap's config for this map.
* @return the name of this map
*/
@DebugDump
String getName();
/**
* Getter for the {@link BlueMapWorld} of this map.
* @return the {@link BlueMapWorld} of this map
*/
@DebugDump
BlueMapWorld getWorld();
/**
@ -64,6 +66,7 @@ public interface BlueMapMap {
* is displaying this map. E.g. these assets are also available in server-networks.
* @return the {@link AssetStorage} of this map
*/
@DebugDump
AssetStorage getAssetStorage();
/**
@ -71,12 +74,14 @@ public interface BlueMapMap {
* Changing this map will change the {@link MarkerSet}s and markers displayed on the web-app for this map.
* @return a {@link Map} of {@link MarkerSet}s.
*/
@DebugDump
Map<String, MarkerSet> getMarkerSets();
/**
* Getter for the size of all tiles on this map in blocks.
* @return the tile-size in blocks
*/
@DebugDump
Vector2i getTileSize();
/**
@ -84,6 +89,7 @@ public interface BlueMapMap {
* E.g. an offset of (2|-1) would mean that the tile (0|0) has block (2|0|-1) at it's min-corner.
* @return the tile-offset in blocks
*/
@DebugDump
Vector2i getTileOffset();
/**
@ -93,7 +99,6 @@ public interface BlueMapMap {
* <p>Any previously set filters will get overwritten with the new one. You can get the current filter using {@link #getTileFilter()} and combine them if you wish.</p>
* @param filter The filter that will be used from now on.
*/
@ApiStatus.Experimental
void setTileFilter(Predicate<Vector2i> filter);
/**
@ -110,9 +115,8 @@ public interface BlueMapMap {
boolean isFrozen();
/**
* Returns the currently set TileFilter. The default TileFilter is equivalent to <code>t -&gt; true</code>.
* Returns the currently set TileFilter. The default TileFilter is equivalent to <code>t -> true</code>.
*/
@ApiStatus.Experimental
Predicate<Vector2i> getTileFilter();
/**

View File

@ -24,6 +24,8 @@
*/
package de.bluecolored.bluemap.api;
import de.bluecolored.bluemap.api.debug.DebugDump;
import java.nio.file.Path;
import java.util.Collection;
@ -36,21 +38,21 @@ public interface BlueMapWorld {
* Getter for the id of this world.
* @return the id of this world
*/
@DebugDump
String getId();
/**
* Getter for the {@link Path} of this world's save-files.<br>
* (To be exact: the parent-folder of the regions-folder used for rendering)
* Getter for the {@link Path} of this world's save-files (folder). This matches the folder configured in bluemap's config for this map ( <code>world:</code> ).
* @return the save-folder of this world.
* @deprecated Getting the save-folder of a world is no longer supported. As it is not guaranteed that every world has a save-folder.
*/
@Deprecated
@DebugDump
Path getSaveFolder();
/**
* Getter for all {@link BlueMapMap}s for this world
* @return an unmodifiable {@link Collection} of all {@link BlueMapMap}s for this world
*/
@DebugDump
Collection<BlueMapMap> getMaps();
}

View File

@ -110,7 +110,7 @@ public static String fromFileSuffix(String suffix) {
}
/**
* Registers a new file-suffix =&gt; content-type mapping to this registry.
* Registers a new file-suffix => content-type mapping to this registry.
* @param fileSuffix The type-suffix of a file-name
* @param contentType The content-type string
*/

View File

@ -25,13 +25,14 @@
package de.bluecolored.bluemap.api;
import com.flowpowered.math.vector.Vector2i;
import de.bluecolored.bluemap.api.debug.DebugDump;
import java.io.IOException;
import java.util.Collection;
/**
* The {@link RenderManager} is used to schedule tile-renders and process them on a number of different threads.
*/
@SuppressWarnings("unused")
public interface RenderManager {
/**
@ -66,25 +67,29 @@ default boolean scheduleMapUpdateTask(BlueMapMap map) {
* An update-task will be scheduled right after the purge, to get the map up-to-date again.
* @param map the map to be purged
* @return true if a new task has been scheduled, false if not (usually because there is already an update-task for this map scheduled)
* @throws IOException if an IOException occurs while trying to create the task.
*/
boolean scheduleMapPurgeTask(BlueMapMap map);
boolean scheduleMapPurgeTask(BlueMapMap map) throws IOException;
/**
* Getter for the current size of the render-queue.
* @return the current size of the render-queue
*/
@DebugDump
int renderQueueSize();
/**
* Getter for the current count of render threads.
* @return the count of render threads
*/
@DebugDump
int renderThreadCount();
/**
* Whether this {@link RenderManager} is currently running or stopped.
* @return <code>true</code> if this renderer is running
*/
@DebugDump
boolean isRunning();
/**

View File

@ -24,7 +24,7 @@
*/
package de.bluecolored.bluemap.api;
import org.jetbrains.annotations.ApiStatus;
import de.bluecolored.bluemap.api.debug.DebugDump;
import java.awt.image.BufferedImage;
import java.io.IOException;
@ -33,13 +33,13 @@
import java.util.UUID;
import java.util.function.Consumer;
@SuppressWarnings("unused")
public interface WebApp {
/**
* Getter for the configured web-root folder
* @return The {@link Path} of the web-root folder
*/
@DebugDump
Path getWebRoot();
/**
@ -47,7 +47,6 @@ public interface WebApp {
* @param player the UUID of the player
* @param visible true if the player-marker should be visible, false if it should be hidden
*/
@ApiStatus.Experimental
void setPlayerVisibility(UUID player, boolean visible);
/**
@ -55,7 +54,6 @@ public interface WebApp {
* @see #setPlayerVisibility(UUID, boolean)
* @param player the UUID of the player
*/
@ApiStatus.Experimental
boolean getPlayerVisibility(UUID player);
/**
@ -63,14 +61,15 @@ public interface WebApp {
* This method should only be used inside the {@link Consumer} that got registered <i>(before bluemap loaded,
* pre server-start!)</i> to {@link BlueMapAPI#onEnable(Consumer)}.<br>
* Invoking this method at any other time is not supported.<br>
* Style-registrations are <b>not persistent</b>, register your style each time bluemap enables!<br>
* <br>
* Style-registrations are <b>not persistent</b>, register your style each time bluemap enables!
* <p>
* Example:
* <pre>
* BlueMapAPI.onEnable(api -&gt; {
* BlueMapAPI.onEnable(api -> {
* api.getWebApp().registerStyle("js/my-custom-style.css");
* });
* </pre>
* </p>
* @param url The (relative) URL that links to the style.css file. The {@link #getWebRoot()}-method can be used to
* create the custom file in the correct location and make it available to the web-app.
*/
@ -81,14 +80,15 @@ public interface WebApp {
* This method should only be used inside the {@link Consumer} that got registered <i>(before bluemap loaded,
* pre server-start!)</i> to {@link BlueMapAPI#onEnable(Consumer)}.<br>
* Invoking this method at any other time is not supported.<br>
* Script-registrations are <b>not persistent</b>, register your script each time bluemap enables!<br>
* <br>
* Script-registrations are <b>not persistent</b>, register your script each time bluemap enables!
* <p>
* Example:
* <pre>
* BlueMapAPI.onEnable(api -&gt; {
* BlueMapAPI.onEnable(api -> {
* api.getWebApp().registerScript("js/my-custom-script.js");
* });
* </pre>
* </p>
* @param url The (relative) URL that links to the script.js file. The {@link #getWebRoot()}-method can be used to
* create the custom file in the correct location and make it available to the web-app.
*/

View File

@ -30,7 +30,8 @@
import java.lang.annotation.Target;
/**
* @deprecated not implemented, unused
* Marks a class, field or method to be included in detail in a possible state-dump.
* E.g. triggered by <code>/bluemap debug dump</code>
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({
@ -38,7 +39,6 @@
ElementType.FIELD,
ElementType.TYPE
})
@Deprecated(forRemoval = true)
public @interface DebugDump {
String value() default "";

View File

@ -49,9 +49,8 @@ public final class MarkerGson {
.setLenient()
.create();
private MarkerGson() {
throw new UnsupportedOperationException("Utility class");
}
/* This class can not be instantiated. */
private MarkerGson() {}
public static GsonBuilder addAdapters(GsonBuilder builder) {
return builder
@ -236,8 +235,8 @@ public void write(JsonWriter out, Vector2d value) throws IOException {
}
out.beginObject();
out.name("x"); writeRounded(out, value.getX());
out.name(useZ ? "z" : "y"); writeRounded(out, value.getY());
out.name("x"); out.value(value.getX());
out.name(useZ ? "z" : "y"); out.value(value.getY());
out.endObject();
}
@ -263,13 +262,6 @@ public Vector2d read(JsonReader in) throws IOException {
return new Vector2d(x, y);
}
private void writeRounded(JsonWriter json, double value) throws IOException {
// rounding and remove ".0" to save string space
double d = Math.round(value * 10000d) / 10000d;
if (d == (long) d) json.value((long) d);
else json.value(d);
}
}
static class Vector3dAdapter extends TypeAdapter<Vector3d> {
@ -282,9 +274,9 @@ public void write(JsonWriter out, Vector3d value) throws IOException {
}
out.beginObject();
out.name("x"); writeRounded(out, value.getX());
out.name("y"); writeRounded(out, value.getY());
out.name("z"); writeRounded(out, value.getZ());
out.name("x"); out.value(value.getX());
out.name("y"); out.value(value.getY());
out.name("z"); out.value(value.getZ());
out.endObject();
}
@ -310,13 +302,6 @@ public Vector3d read(JsonReader in) throws IOException {
return new Vector3d(x, y, z);
}
private void writeRounded(JsonWriter json, double value) throws IOException {
// rounding and remove ".0" to save string space
double d = Math.round(value * 10000d) / 10000d;
if (d == (long) d) json.value((long) d);
else json.value(d);
}
}
static class Vector2iAdapter extends TypeAdapter<Vector2i> {

View File

@ -25,6 +25,7 @@
package de.bluecolored.bluemap.api.markers;
import com.flowpowered.math.vector.Vector3d;
import de.bluecolored.bluemap.api.debug.DebugDump;
/**
* @see HtmlMarker
@ -33,6 +34,7 @@
* @see ExtrudeMarker
* @see LineMarker
*/
@DebugDump
public abstract class DistanceRangedMarker extends Marker {
private double minDistance, maxDistance;

View File

@ -26,20 +26,17 @@
import com.flowpowered.math.vector.Vector2d;
import com.flowpowered.math.vector.Vector3d;
import de.bluecolored.bluemap.api.debug.DebugDump;
import de.bluecolored.bluemap.api.math.Color;
import de.bluecolored.bluemap.api.math.Shape;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Objects;
@SuppressWarnings("FieldMayBeFinal")
@DebugDump
public class ExtrudeMarker extends ObjectMarker {
private static final Shape DEFAULT_SHAPE = Shape.createRect(0, 0, 1, 1);
private Shape shape;
private Collection<Shape> holes = new ArrayList<>();
private float shapeMinY, shapeMaxY;
private boolean depthTest = true;
private int lineWidth = 2;
@ -141,15 +138,6 @@ public void setShape(Shape shape, float minY, float maxY) {
this.shapeMaxY = maxY;
}
/**
* Getter for the <b>mutable</b> collection of holes in this {@link ExtrudeMarker}.
* <p>Any shape in this collection will be a hole in the main {@link Shape} of this marker</p>
* @return A <b>mutable</b> collection of hole-shapes
*/
public Collection<Shape> getHoles() {
return holes;
}
/**
* Sets the position of this {@link ExtrudeMarker} to the center of the {@link Shape} (it's bounding box).
* <p><i>(Invoke this after changing the {@link Shape} to make sure the markers position gets updated as well)</i></p>
@ -284,7 +272,6 @@ public static class Builder extends ObjectMarker.Builder<ExtrudeMarker, Builder>
Shape shape;
float shapeMinY, shapeMaxY;
Collection<Shape> holes = new ArrayList<>();
Boolean depthTest;
Integer lineWidth;
Color lineColor;
@ -307,25 +294,6 @@ public Builder shape(Shape shape, float minY, float maxY) {
return this;
}
/**
* <b>Adds</b> some hole-{@link Shape}s.
* @param holes the additional holes
* @return this builder for chaining
*/
public Builder holes(Shape... holes) {
this.holes.addAll(Arrays.asList(holes));
return this;
}
/**
* Removes all hole-shapes from this Builder.
* @return this builder for chaining
*/
public Builder clearHoles() {
this.holes.clear();
return this;
}
/**
* Sets the position of the {@link ExtrudeMarker} to the center of the {@link Shape} (it's bounding box).
* @return this builder for chaining
@ -393,7 +361,6 @@ public ExtrudeMarker build() {
shapeMinY,
shapeMaxY
);
marker.getHoles().addAll(holes);
if (depthTest != null) marker.setDepthTestEnabled(depthTest);
if (lineWidth != null) marker.setLineWidth(lineWidth);
if (lineColor != null) marker.setLineColor(lineColor);

View File

@ -27,6 +27,7 @@
import com.flowpowered.math.vector.Vector2i;
import com.flowpowered.math.vector.Vector3d;
import de.bluecolored.bluemap.api.debug.DebugDump;
import java.util.*;
@ -34,6 +35,7 @@
* A marker that is a html-element placed somewhere on the map.
*/
@SuppressWarnings("FieldMayBeFinal")
@DebugDump
public class HtmlMarker extends DistanceRangedMarker implements ElementMarker {
private Set<String> classes = new HashSet<>();

View File

@ -25,11 +25,13 @@
package de.bluecolored.bluemap.api.markers;
import com.flowpowered.math.vector.Vector3d;
import de.bluecolored.bluemap.api.debug.DebugDump;
import de.bluecolored.bluemap.api.math.Color;
import de.bluecolored.bluemap.api.math.Line;
import java.util.Objects;
@DebugDump
public class LineMarker extends ObjectMarker {
private static final Line DEFAULT_LINE = new Line(Vector3d.ZERO, Vector3d.ONE);

View File

@ -25,6 +25,7 @@
package de.bluecolored.bluemap.api.markers;
import com.flowpowered.math.vector.Vector3d;
import de.bluecolored.bluemap.api.debug.DebugDump;
import java.util.Objects;
@ -37,20 +38,17 @@
* @see ExtrudeMarker
* @see LineMarker
*/
@DebugDump
public abstract class Marker {
private final String type;
private String label;
private Vector3d position;
private int sorting;
private boolean listed;
public Marker(String type, String label, Vector3d position) {
this.type = Objects.requireNonNull(type, "type cannot be null");
this.label = Objects.requireNonNull(label, "label cannot be null");
this.position = Objects.requireNonNull(position, "position cannot be null");
this.sorting = 0;
this.listed = true;
}
/**
@ -109,46 +107,6 @@ public void setPosition(double x, double y, double z) {
setPosition(new Vector3d(x, y, z));
}
/**
* Returns the sorting-value that will be used by the webapp to sort the markers ("default"-sorting).<br>
* A lower value makes the marker sorted first (in lists and menus), a higher value makes it sorted later.<br>
* If multiple markers have the same sorting-value, their order will be arbitrary.<br>
* This value defaults to 0.
* @return this markers sorting-value
*/
public int getSorting() {
return sorting;
}
/**
* Sets the sorting-value that will be used by the webapp to sort the markers ("default"-sorting).<br>
* A lower value makes the marker sorted first (in lists and menus), a higher value makes it sorted later.<br>
* If multiple markers have the same sorting-value, their order will be arbitrary.<br>
* This value defaults to 0.
* @param sorting the new sorting-value for this marker
*/
public void setSorting(int sorting) {
this.sorting = sorting;
}
/**
* This value defines whether the marker will be listed (true) in markers and lists by the webapp (additionally to being
* displayed on the map) or not (false).
* @return whether the marker will be listed or not
*/
public boolean isListed() {
return listed;
}
/**
* Defines whether the marker will be listed (true) in markers and lists by the webapp (additionally to being
* displayed on the map) or not (false).
* @param listed whether the marker will be listed or not
*/
public void setListed(boolean listed) {
this.listed = listed;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
@ -173,8 +131,6 @@ public static abstract class Builder<T extends Marker, B extends Marker.Builder<
String label;
Vector3d position;
Integer sorting;
Boolean listed;
/**
* Sets the label of the {@link Marker}.
@ -208,28 +164,6 @@ public B position(double x, double y, double z) {
return position(new Vector3d(x, y, z));
}
/**
* Sets the sorting-value that will be used by the webapp to sort the markers ("default"-sorting).<br>
* A lower value makes the marker sorted first (in lists and menus), a higher value makes it sorted later.<br>
* If multiple markers have the same sorting-value, their order will be arbitrary.<br>
* This value defaults to 0.
* @param sorting the new sorting-value for this marker
*/
public B sorting(Integer sorting) {
this.sorting = sorting;
return self();
}
/**
* Defines whether the marker will be listed (true) in markers and lists by the webapp (additionally to being
* displayed on the map) or not (false).
* @param listed whether the marker will be listed or not
*/
public B listed(Boolean listed) {
this.listed = listed;
return self();
}
/**
* Creates a new {@link Marker} with the current builder-settings
* @return The new {@link Marker}-instance
@ -239,8 +173,6 @@ public B listed(Boolean listed) {
T build(T marker) {
if (label != null) marker.setLabel(label);
if (position != null) marker.setPosition(position);
if (sorting != null) marker.setSorting(sorting);
if (listed != null) marker.setListed(listed);
return marker;
}

View File

@ -24,6 +24,8 @@
*/
package de.bluecolored.bluemap.api.markers;
import de.bluecolored.bluemap.api.debug.DebugDump;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
@ -31,11 +33,11 @@
/**
* A set of {@link Marker}s that are displayed on the maps in the web-app.
*/
@DebugDump
public class MarkerSet {
private String label;
private boolean toggleable, defaultHidden;
private int sorting;
private final ConcurrentHashMap<String, Marker> markers;
/**
@ -54,7 +56,10 @@ private MarkerSet() {
* @see #setLabel(String)
*/
public MarkerSet(String label) {
this(label, true, false);
this.label = Objects.requireNonNull(label);
this.toggleable = true;
this.defaultHidden = false;
this.markers = new ConcurrentHashMap<>();
}
/**
@ -72,7 +77,6 @@ public MarkerSet(String label, boolean toggleable, boolean defaultHidden) {
this.label = Objects.requireNonNull(label);
this.toggleable = toggleable;
this.defaultHidden = defaultHidden;
this.sorting = 0;
this.markers = new ConcurrentHashMap<>();
}
@ -145,28 +149,6 @@ public void setDefaultHidden(boolean defaultHidden) {
this.defaultHidden = defaultHidden;
}
/**
* Returns the sorting-value that will be used by the webapp to sort the marker-sets.<br>
* A lower value makes the marker-set sorted first (in lists and menus), a higher value makes it sorted later.<br>
* If multiple marker-sets have the same sorting-value, their order will be arbitrary.<br>
* This value defaults to 0.
* @return This marker-sets sorting-value
*/
public int getSorting() {
return sorting;
}
/**
* Sets the sorting-value that will be used by the webapp to sort the marker-sets ("default"-sorting).<br>
* A lower value makes the marker-set sorted first (in lists and menus), a higher value makes it sorted later.<br>
* If multiple marker-sets have the same sorting-value, their order will be arbitrary.<br>
* This value defaults to 0.
* @param sorting the new sorting-value for this marker-set
*/
public void setSorting(int sorting) {
this.sorting = sorting;
}
/**
* Getter for a (modifiable) {@link Map} of all {@link Marker}s in this {@link MarkerSet}.
* The keys of the map are the id's of the {@link Marker}s.
@ -238,7 +220,6 @@ public static class Builder {
private String label;
private Boolean toggleable, defaultHidden;
private Integer sorting;
/**
* Sets the label of the {@link MarkerSet}.
@ -281,18 +262,6 @@ public Builder defaultHidden(Boolean defaultHidden) {
return this;
}
/**
* Sets the sorting-value that will be used by the webapp to sort the marker-sets ("default"-sorting).<br>
* A lower value makes the marker-set sorted first (in lists and menus), a higher value makes it sorted later.<br>
* If multiple marker-sets have the same sorting-value, their order will be arbitrary.<br>
* This value defaults to 0.
* @param sorting the new sorting-value for this marker-set
*/
public Builder sorting(Integer sorting) {
this.sorting = sorting;
return this;
}
/**
* Creates a new {@link MarkerSet} with the current builder-settings.<br>
* The minimum required settings to build this marker-set are:
@ -307,7 +276,6 @@ public MarkerSet build() {
);
if (toggleable != null) markerSet.setToggleable(toggleable);
if (defaultHidden != null) markerSet.setDefaultHidden(defaultHidden);
if (sorting != null) markerSet.setSorting(sorting);
return markerSet;
}

View File

@ -25,6 +25,7 @@
package de.bluecolored.bluemap.api.markers;
import com.flowpowered.math.vector.Vector3d;
import de.bluecolored.bluemap.api.debug.DebugDump;
import org.jetbrains.annotations.Nullable;
import java.util.Objects;
@ -35,6 +36,7 @@
* @see ExtrudeMarker
* @see LineMarker
*/
@DebugDump
public abstract class ObjectMarker extends DistanceRangedMarker implements DetailMarker {
private String detail;

View File

@ -27,10 +27,12 @@
import com.flowpowered.math.vector.Vector2i;
import com.flowpowered.math.vector.Vector3d;
import de.bluecolored.bluemap.api.BlueMapMap;
import de.bluecolored.bluemap.api.debug.DebugDump;
import java.util.*;
@SuppressWarnings("FieldMayBeFinal")
@DebugDump
public class POIMarker extends DistanceRangedMarker implements DetailMarker, ElementMarker {
private Set<String> classes = new HashSet<>();

View File

@ -27,20 +27,17 @@
import com.flowpowered.math.vector.Vector2d;
import com.flowpowered.math.vector.Vector3d;
import de.bluecolored.bluemap.api.debug.DebugDump;
import de.bluecolored.bluemap.api.math.Color;
import de.bluecolored.bluemap.api.math.Shape;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Objects;
@SuppressWarnings("FieldMayBeFinal")
@DebugDump
public class ShapeMarker extends ObjectMarker {
private static final Shape DEFAULT_SHAPE = Shape.createRect(0, 0, 1, 1);
private Shape shape;
private Collection<Shape> holes = new ArrayList<>();
private float shapeY;
private boolean depthTest = true;
private int lineWidth = 2;
@ -52,7 +49,7 @@ public class ShapeMarker extends ObjectMarker {
*/
@SuppressWarnings("unused")
private ShapeMarker() {
this("", DEFAULT_SHAPE, 0);
this("shape", DEFAULT_SHAPE, 0);
}
/**
@ -122,15 +119,6 @@ public void setShape(Shape shape, float y) {
this.shapeY = y;
}
/**
* Getter for the <b>mutable</b> collection of holes in this {@link ShapeMarker}.
* <p>Any shape in this collection will be a hole in the main {@link Shape} of this marker</p>
* @return A <b>mutable</b> collection of hole-shapes
*/
public Collection<Shape> getHoles() {
return holes;
}
/**
* Sets the position of this {@link ShapeMarker} to the center of the {@link Shape} (it's bounding box).
* <p><i>(Invoke this after changing the {@link Shape} to make sure the markers position gets updated as well)</i></p>
@ -262,7 +250,6 @@ public static class Builder extends ObjectMarker.Builder<ShapeMarker, Builder> {
Shape shape;
float shapeY;
Collection<Shape> holes = new ArrayList<>();
Boolean depthTest;
Integer lineWidth;
Color lineColor;
@ -282,25 +269,6 @@ public Builder shape(Shape shape, float y) {
return this;
}
/**
* <b>Adds</b> some hole-{@link Shape}s.
* @param holes the additional holes
* @return this builder for chaining
*/
public Builder holes(Shape... holes) {
this.holes.addAll(Arrays.asList(holes));
return this;
}
/**
* Removes all hole-shapes from this Builder.
* @return this builder for chaining
*/
public Builder clearHoles() {
this.holes.clear();
return this;
}
/**
* Sets the position of the {@link ShapeMarker} to the center of the {@link Shape} (it's bounding box).
* @return this builder for chaining
@ -366,7 +334,6 @@ public ShapeMarker build() {
checkNotNull(shape, "shape"),
shapeY
);
marker.getHoles().addAll(holes);
if (depthTest != null) marker.setDepthTestEnabled(depthTest);
if (lineWidth != null) marker.setLineWidth(lineWidth);
if (lineColor != null) marker.setLineColor(lineColor);

View File

@ -24,8 +24,11 @@
*/
package de.bluecolored.bluemap.api.math;
import de.bluecolored.bluemap.api.debug.DebugDump;
import java.util.Objects;
@DebugDump
public class Color {
private final int r, g, b;
@ -125,8 +128,7 @@ public float getAlpha() {
return a;
}
private static int parseColorString(String value) {
String val = value;
private static int parseColorString(String val) {
if (val.charAt(0) == '#') {
val = val.substring(1);
if (val.length() == 3) val = val + "f";
@ -134,7 +136,7 @@ private static int parseColorString(String value) {
val.charAt(0) + val.charAt(0) + val.charAt(1) + val.charAt(1) +
val.charAt(2) + val.charAt(2) + val.charAt(3) + val.charAt(3);
if (val.length() == 6) val = val + "ff";
if (val.length() != 8) throw new NumberFormatException("Invalid color format: '" + value + "'!");
if (val.length() != 8) throw new NumberFormatException("Invalid color format!");
val = val.substring(6, 8) + val.substring(0, 6); // move alpha to front
return Integer.parseUnsignedInt(val, 16);
}
@ -164,13 +166,4 @@ public int hashCode() {
return result;
}
@Override
public String toString() {
return "Color{" +
"r=" + r +
", g=" + g +
", b=" + b +
", a=" + a +
'}';
}
}

View File

@ -25,6 +25,7 @@
package de.bluecolored.bluemap.api.math;
import com.flowpowered.math.vector.Vector3d;
import de.bluecolored.bluemap.api.debug.DebugDump;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
@ -35,6 +36,7 @@
/**
* A line consisting of 2 or more {@link Vector3d}-points.
*/
@DebugDump
public class Line {
private final Vector3d[] points;
@ -158,16 +160,6 @@ public Builder addPoints(Vector3d... points) {
return this;
}
/**
* Adds multiple points to the end of line.
* @param points the points to be added.
* @return this builder for chaining
*/
public Builder addPoints(Collection<Vector3d> points) {
this.points.addAll(points);
return this;
}
/**
* Builds a new {@link Line} with the points set in this builder.<br>
* There need to be at least 2 points to build a {@link Line}.

View File

@ -25,6 +25,7 @@
package de.bluecolored.bluemap.api.math;
import com.flowpowered.math.vector.Vector2d;
import de.bluecolored.bluemap.api.debug.DebugDump;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
@ -35,6 +36,7 @@
/**
* A shape consisting of 3 or more {@link Vector2d}-points on a plane.
*/
@DebugDump
public class Shape {
private final Vector2d[] points;
@ -246,16 +248,6 @@ public Builder addPoints(Vector2d... points) {
return this;
}
/**
* Adds multiple points to the end of line.
* @param points the points to be added.
* @return this builder for chaining
*/
public Builder addPoints(Collection<Vector2d> points) {
this.points.addAll(points);
return this;
}
/**
* Builds a new {@link Shape} with the points set in this builder.<br>
* There need to be at least 3 points to build a {@link Shape}.

View File

@ -24,13 +24,15 @@
*/
package de.bluecolored.bluemap.api.plugin;
@SuppressWarnings("unused")
import de.bluecolored.bluemap.api.debug.DebugDump;
public interface Plugin {
/**
* Get the {@link SkinProvider} that bluemap is using to fetch player-skins
* @return the {@link SkinProvider} instance bluemap is using
*/
@DebugDump
SkinProvider getSkinProvider();
/**
@ -44,6 +46,7 @@ public interface Plugin {
* for the Player-Markers
* @return The {@link PlayerIconFactory} bluemap uses to convert skins into player-marker icons
*/
@DebugDump
PlayerIconFactory getPlayerMarkerIconFactory();
/**