Compare commits

...

30 Commits

Author SHA1 Message Date
Lukas Rieger
1992148128
Rework gradle-build system (#7)
* Rework gradle-build setup

* Fix versioning

* Configure publishing

* Fix github action

* Fix github action 2

* Reorganize project naming

* Update gradle
2024-09-12 17:46:00 +02:00
Lukas Rieger (Blue)
4f8e814ef2
Update actions 2024-06-14 10:09:56 +02:00
Lukas Rieger (Blue)
ec97711349
Tidy up 2024-05-20 21:24:31 +02:00
Lukas Rieger (Blue)
8b179fb5e0
Deprecate/remove DebugDump annotation 2024-05-15 23:46:25 +02:00
Lukas Rieger (Blue)
6c84500dfc
Update gradle 2024-05-08 18:06:38 +02:00
Lukas Rieger (Blue)
b200d339f1
Publish on tag 2024-04-04 00:19:54 +02:00
Lukas Rieger (Blue)
030f29e7f3
Change project group 2024-04-03 23:02:41 +02:00
Lukas Rieger (Blue)
f5709ce836
Fix credentials problems 2024-04-03 22:55:28 +02:00
Lukas Rieger (Blue)
9d37bdeb15
Fix workflow syntax 2024-04-03 22:46:53 +02:00
Lukas Rieger (Blue)
baeef5994e
Publish to BlueColored Maven Repo 2024-04-03 22:45:31 +02:00
Lukas Rieger (Blue)
e7e32301f2
Require Java 16 2024-04-03 21:58:13 +02:00
TechnicJelle
6cad751ac5
Link javadocs to FlowPoweredMath & GSON (#6)
* Link javadocs to FlowPoweredMath & GSON

* Update build.gradle.kts
2024-02-20 01:15:43 +01:00
Lukas Rieger (Blue)
c7a9be42ad
Fix Javadoc 2024-02-07 20:49:31 +01:00
Lukas Rieger (Blue)
dcae50572a
Merge branch 'master' of https://github.com/BlueMap-Minecraft/BlueMapAPI 2024-02-07 20:45:54 +01:00
Lukas Rieger (Blue)
c3ce6d95de
Deprecate BlueMapWorld#getSaveFolder() 2024-02-07 20:45:28 +01:00
Takase
9ed7fdb1cf
Reduce marker coordinates precision (#5) 2024-02-03 12:08:46 +01:00
Lukas Rieger (Blue)
5c3624832f
Update gradle and action 2023-09-27 23:50:42 +02:00
Lukas Rieger (Blue)
2cdc5c8a87
Fix Shape label not being empty by default 2023-08-20 08:24:18 +02:00
Lukas Rieger (Blue)
f398e7ab2b
Make addPoints in Shape and List accept a collection of points as well 2023-07-15 12:31:34 +02:00
Lukas Rieger (Blue)
7776c8e979
Implement toString() for Color class 2023-07-15 12:29:05 +02:00
Lukas Rieger (Blue)
40140f87c6
Fix javadoc errors 2023-06-26 16:38:59 +02:00
Lukas Rieger (Blue)
f44fd20f5f
Add sources and javadoc jar to publish 2023-06-26 16:31:44 +02:00
Lukas Rieger (Blue)
85e3763d7a
Add enable/disable consumer invocation order guarantee 2023-05-02 21:29:10 +02:00
Lukas Rieger (Blue)
812e4b8fce
Add abillity to remove markers from the marker list while keeping them on the map 2023-02-07 19:43:15 +01:00
Lukas Rieger (Blue)
2a3cc1c270
Make builder value private 2023-02-07 17:06:28 +01:00
Lukas Rieger (Blue)
bee8770fde
Add sorting option to Marker and MarkerSet 2023-02-07 17:04:38 +01:00
Lukas Rieger (Blue)
1d0d63f088
Use the original value in the error 2023-02-07 11:08:35 +01:00
Lukas Rieger (Blue)
f9bbdc3d38
Add invalid value to color-format exception 2023-02-07 11:03:21 +01:00
Lukas Rieger (Blue)
c70ab29ae8
Fix javadoc errors 2023-01-02 22:42:50 +01:00
Lukas Rieger (Blue)
ad77b492dd
Add methods to add holes to shape and extrude markers 2022-12-29 17:39:28 +01:00
38 changed files with 686 additions and 347 deletions

24
.gitattributes vendored Normal file
View File

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

27
.github/workflows/publish.yml vendored Normal file
View File

@ -0,0 +1,27 @@
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,110 +1,22 @@
import java.io.IOException
import java.util.concurrent.TimeoutException
plugins { plugins {
java bluemap.base
`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 { dependencies {
api ("com.flowpowered:flow-math:1.0.3") api ( libs.flow.math )
api ("com.google.code.gson:gson:2.8.0") api ( libs.gson )
compileOnly ("org.jetbrains:annotations:23.0.0") compileOnly ( libs.jetbrains.annotations )
} compileOnly ( libs.lombok )
spotless { annotationProcessor ( libs.lombok )
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 { publishing {
publications { publications {
create<MavenPublication>("maven") { create<MavenPublication>("maven") {
groupId = project.group.toString() groupId = project.group.toString()
artifactId = project.name artifactId = "bluemap-${project.name}"
version = project.version.toString() version = project.version.toString()
from(components["java"]) from(components["java"])

17
buildSrc/build.gradle.kts Normal file
View File

@ -0,0 +1,17 @@
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

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

View File

@ -0,0 +1,78 @@
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

@ -0,0 +1,44 @@
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)
}
}

View File

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

14
gradle/libs.versions.toml Normal file
View File

@ -0,0 +1,14 @@
[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 distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.1-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

270
gradlew vendored
View File

@ -1,7 +1,7 @@
#!/usr/bin/env sh #!/bin/sh
# #
# Copyright 2015 the original author or authors. # Copyright © 2015-2021 the original authors.
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License. # you may not use this file except in compliance with the License.
@ -17,78 +17,113 @@
# #
############################################################################## ##############################################################################
## #
## Gradle start up script for UN*X # 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/.
#
############################################################################## ##############################################################################
# Attempt to set APP_HOME # Attempt to set APP_HOME
# Resolve links: $0 may be a link # Resolve links: $0 may be a link
PRG="$0" app_path=$0
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do # Need this for daisy-chained symlinks.
ls=`ls -ld "$PRG"` while
link=`expr "$ls" : '.*-> \(.*\)$'` APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
if expr "$link" : '/.*' > /dev/null; then [ -h "$app_path" ]
PRG="$link" do
else ls=$( ls -ld "$app_path" )
PRG=`dirname "$PRG"`"/$link" link=${ls#*' -> '}
fi case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
done done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle" APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"` APP_BASE_NAME=${0##*/}
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. # 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"' DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value. # Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum" MAX_FD=maximum
warn () { warn () {
echo "$*" echo "$*"
} } >&2
die () { die () {
echo echo
echo "$*" echo "$*"
echo echo
exit 1 exit 1
} } >&2
# OS specific support (must be 'true' or 'false'). # OS specific support (must be 'true' or 'false').
cygwin=false cygwin=false
msys=false msys=false
darwin=false darwin=false
nonstop=false nonstop=false
case "`uname`" in case "$( uname )" in #(
CYGWIN* ) CYGWIN* ) cygwin=true ;; #(
cygwin=true Darwin* ) darwin=true ;; #(
;; MSYS* | MINGW* ) msys=true ;; #(
Darwin* ) NONSTOP* ) nonstop=true ;;
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM. # Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables # IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java" JAVACMD=$JAVA_HOME/jre/sh/java
else else
JAVACMD="$JAVA_HOME/bin/java" JAVACMD=$JAVA_HOME/bin/java
fi fi
if [ ! -x "$JAVACMD" ] ; then if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
@ -97,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the
location of your Java installation." location of your Java installation."
fi fi
else 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. 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 Please set the JAVA_HOME variable in your environment to match the
@ -105,84 +140,95 @@ location of your Java installation."
fi fi
# Increase the maximum file descriptors if we can. # Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
MAX_FD_LIMIT=`ulimit -H -n` case $MAX_FD in #(
if [ $? -eq 0 ] ; then max*)
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then MAX_FD=$( ulimit -H -n ) ||
MAX_FD="$MAX_FD_LIMIT" warn "Could not query maximum file descriptor limit"
fi esac
ulimit -n $MAX_FD case $MAX_FD in #(
if [ $? -ne 0 ] ; then '' | soft) :;; #(
warn "Could not set maximum file descriptor limit: $MAX_FD" *)
fi ulimit -n "$MAX_FD" ||
else warn "Could not set maximum file descriptor limit to $MAX_FD"
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# 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" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# 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 esac
fi fi
# Escape application args # Collect all arguments for the java command, stacking in reverse order:
save () { # * args from the command line
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done # * the main class name
echo " " # * -classpath
} # * -D...appname settings
APP_ARGS=$(save "$@") # * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# Collect all arguments for the java command, following the shell quoting and substitution rules # For Cygwin or MSYS, switch paths to Windows format before running java
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong JAVACMD=$( cygpath --unix "$JAVACMD" )
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")" # 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
done
fi 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.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# 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' ' '
)" '"$@"'
exec "$JAVACMD" "$@" exec "$JAVACMD" "$@"

25
gradlew.bat vendored
View File

@ -29,6 +29,9 @@ if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0 set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME% 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. @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" set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@ -37,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1 %JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init if "%ERRORLEVEL%" == "0" goto execute
echo. echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@ -51,7 +54,7 @@ goto fail
set JAVA_HOME=%JAVA_HOME:"=% set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init if exist "%JAVA_EXE%" goto execute
echo. echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
@ -61,28 +64,14 @@ echo location of your Java installation.
goto fail 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 :execute
@rem Setup the command line @rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle @rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end :end
@rem End local scope for the variables with windows NT shell @rem End local scope for the variables with windows NT shell

View File

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

View File

@ -1 +1,8 @@
rootProject.name = "BlueMapAPI" 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")}
""")

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. * 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 { public interface AssetStorage {
/** /**
* Writes a new asset into this storage, overwriting any existent assets with the same name.<br> * 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 * 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! * gets closed!<br>
* <p> * <br>
* Example: * Example:
* <pre> * <pre>
* try (OutputStream out = assetStorage.writeAsset("image.png")) { * try (OutputStream out = assetStorage.writeAsset("image.png")) {
* ImageIO.write(image, "png", out); * ImageIO.write(image, "png", out);
* } * }
* </pre> * </pre>
* </p>
* @param name The (unique) name for this asset * @param name The (unique) name for this asset
* @return An {@link OutputStream} that should be used to write the asset and closed once! * @return An {@link OutputStream} that should be used to write the asset and closed once!
* @throws IOException when the underlying storage rises an IOException * @throws IOException when the underlying storage rises an IOException
@ -57,8 +57,8 @@ public interface AssetStorage {
/** /**
* Reads an asset from this storage.<br> * Reads an asset from this storage.<br>
* Use the returned {@link InputStream} to read the asset-data. * Use the returned {@link InputStream} to read the asset-data.<br>
* <p> * <br>
* Example: * Example:
* <pre> * <pre>
* Optional&lt;InputStream&gt; optIn = assetStorage.readAsset("image.png"); * Optional&lt;InputStream&gt; optIn = assetStorage.readAsset("image.png");
@ -68,7 +68,6 @@ public interface AssetStorage {
* } * }
* } * }
* </pre> * </pre>
* </p>
* @param name The name of the asset that should be read from the storage. * @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. * @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. * 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.Gson;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import de.bluecolored.bluemap.api.debug.DebugDump;
import de.bluecolored.bluemap.api.plugin.Plugin; import de.bluecolored.bluemap.api.plugin.Plugin;
import org.jetbrains.annotations.ApiStatus;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
@ -43,6 +43,7 @@
* An API to control the running instance of BlueMap. * 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> * <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 { public abstract class BlueMapAPI {
@SuppressWarnings("unused") @SuppressWarnings("unused")
@ -58,6 +59,7 @@ public abstract class BlueMapAPI {
gitHash = element.get("git-hash").getAsString(); gitHash = element.get("git-hash").getAsString();
} catch (Exception ex) { } catch (Exception ex) {
System.err.println("Failed to load version from resources!"); System.err.println("Failed to load version from resources!");
//noinspection CallToPrintStackTrace
ex.printStackTrace(); ex.printStackTrace();
} }
} }
@ -71,42 +73,37 @@ public abstract class BlueMapAPI {
private static BlueMapAPI instance; private static BlueMapAPI instance;
private static final Collection<Consumer<BlueMapAPI>> onEnableConsumers = new HashSet<>(2); private static final LinkedHashSet<Consumer<BlueMapAPI>> onEnableConsumers = new LinkedHashSet<>();
private static final Collection<Consumer<BlueMapAPI>> onDisableConsumers = new HashSet<>(2); private static final LinkedHashSet<Consumer<BlueMapAPI>> onDisableConsumers = new LinkedHashSet<>();
/** /**
* Getter for the {@link RenderManager}. * Getter for the {@link RenderManager}.
* @return the {@link RenderManager} * @return the {@link RenderManager}
*/ */
@DebugDump
public abstract RenderManager getRenderManager(); public abstract RenderManager getRenderManager();
/** /**
* Getter for the {@link WebApp}. * Getter for the {@link WebApp}.
* @return the {@link WebApp} * @return the {@link WebApp}
*/ */
@DebugDump
public abstract WebApp getWebApp(); public abstract WebApp getWebApp();
/** /**
* Getter for the {@link Plugin} * Getter for the {@link Plugin}
* @return the {@link Plugin} * @return the {@link Plugin}
*/ */
@DebugDump
public abstract Plugin getPlugin(); public abstract Plugin getPlugin();
/** /**
* Getter for all {@link BlueMapMap}s loaded by BlueMap. * Getter for all {@link BlueMapMap}s loaded by BlueMap.
* @return an unmodifiable collection of all loaded {@link BlueMapMap}s * @return an unmodifiable collection of all loaded {@link BlueMapMap}s
*/ */
@DebugDump
public abstract Collection<BlueMapMap> getMaps(); public abstract Collection<BlueMapMap> getMaps();
/** /**
* Getter for all {@link BlueMapWorld}s loaded by BlueMap. * Getter for all {@link BlueMapWorld}s loaded by BlueMap.
* @return an unmodifiable collection of all loaded {@link BlueMapWorld}s * @return an unmodifiable collection of all loaded {@link BlueMapWorld}s
*/ */
@DebugDump
public abstract Collection<BlueMapWorld> getWorlds(); public abstract Collection<BlueMapWorld> getWorlds();
/** /**
@ -137,14 +134,12 @@ public abstract class BlueMapAPI {
* Getter for the installed BlueMap version * Getter for the installed BlueMap version
* @return the version-string * @return the version-string
*/ */
@DebugDump
public abstract String getBlueMapVersion(); public abstract String getBlueMapVersion();
/** /**
* Getter for the installed BlueMapAPI version * Getter for the installed BlueMapAPI version
* @return the version-string * @return the version-string
*/ */
@DebugDump
public String getAPIVersion() { public String getAPIVersion() {
return VERSION; return VERSION;
} }
@ -163,6 +158,7 @@ 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><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><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>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} * @param consumer the {@link Consumer}
*/ */
public static synchronized void onEnable(Consumer<BlueMapAPI> consumer) { public static synchronized void onEnable(Consumer<BlueMapAPI> consumer) {
@ -176,6 +172,7 @@ 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><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><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>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} * @param consumer the {@link Consumer}
*/ */
public static synchronized void onDisable(Consumer<BlueMapAPI> consumer) { public static synchronized void onDisable(Consumer<BlueMapAPI> consumer) {
@ -197,39 +194,33 @@ 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 * @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 * @throws ExecutionException if a listener threw an exception during the registration
*/ */
protected static synchronized boolean registerInstance(BlueMapAPI instance) throws ExecutionException { @ApiStatus.Internal
protected static synchronized boolean registerInstance(BlueMapAPI instance) throws Exception {
if (BlueMapAPI.instance != null) return false; if (BlueMapAPI.instance != null) return false;
BlueMapAPI.instance = instance; BlueMapAPI.instance = instance;
List<Throwable> thrownExceptions = new ArrayList<>(0); List<Exception> thrownExceptions = new ArrayList<>(0);
for (Consumer<BlueMapAPI> listener : BlueMapAPI.onEnableConsumers) { for (Consumer<BlueMapAPI> listener : BlueMapAPI.onEnableConsumers) {
try { try {
listener.accept(BlueMapAPI.instance); listener.accept(BlueMapAPI.instance);
} catch (Throwable ex) { } catch (Exception ex) {
thrownExceptions.add(ex); thrownExceptions.add(ex);
} }
} }
if (!thrownExceptions.isEmpty()) { return throwAsOne(thrownExceptions);
ExecutionException ex = new ExecutionException(thrownExceptions.get(0));
for (int i = 1; i < thrownExceptions.size(); i++) {
ex.addSuppressed(thrownExceptions.get(i));
}
throw ex;
}
return true;
} }
/** /**
* Used by BlueMap to unregister the API and call the listeners properly. * Used by BlueMap to unregister the API and call the listeners properly.
* @param instance the {@link BlueMapAPI} instance * @param instance the {@link BlueMapAPI} instance
* @return <code>true</code> if the instance was unregistered, <code>false</code> if there was no or an other instance registered * @return <code>true</code> if the instance was unregistered, <code>false</code> if there was no or another instance registered
* @throws ExecutionException if a listener threw an exception during the un-registration * @throws ExecutionException if a listener threw an exception during the un-registration
*/ */
protected static synchronized boolean unregisterInstance(BlueMapAPI instance) throws ExecutionException { @ApiStatus.Internal
protected static synchronized boolean unregisterInstance(BlueMapAPI instance) throws Exception {
if (BlueMapAPI.instance != instance) return false; if (BlueMapAPI.instance != instance) return false;
List<Exception> thrownExceptions = new ArrayList<>(0); List<Exception> thrownExceptions = new ArrayList<>(0);
@ -244,8 +235,12 @@ protected static synchronized boolean unregisterInstance(BlueMapAPI instance) th
BlueMapAPI.instance = null; BlueMapAPI.instance = null;
return throwAsOne(thrownExceptions);
}
private static boolean throwAsOne(List<Exception> thrownExceptions) throws Exception {
if (!thrownExceptions.isEmpty()) { if (!thrownExceptions.isEmpty()) {
ExecutionException ex = new ExecutionException(thrownExceptions.get(0)); Exception ex = thrownExceptions.get(0);
for (int i = 1; i < thrownExceptions.size(); i++) { for (int i = 1; i < thrownExceptions.size(); i++) {
ex.addSuppressed(thrownExceptions.get(i)); ex.addSuppressed(thrownExceptions.get(i));
} }

View File

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

View File

@ -24,8 +24,6 @@
*/ */
package de.bluecolored.bluemap.api; package de.bluecolored.bluemap.api;
import de.bluecolored.bluemap.api.debug.DebugDump;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.Collection; import java.util.Collection;
@ -38,21 +36,21 @@ public interface BlueMapWorld {
* Getter for the id of this world. * Getter for the id of this world.
* @return the id of this world * @return the id of this world
*/ */
@DebugDump
String getId(); String getId();
/** /**
* 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> ). * 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)
* @return the save-folder of this world. * @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.
*/ */
@DebugDump @Deprecated
Path getSaveFolder(); Path getSaveFolder();
/** /**
* Getter for all {@link BlueMapMap}s for this world * Getter for all {@link BlueMapMap}s for this world
* @return an unmodifiable {@link Collection} of all {@link BlueMapMap}s for this world * @return an unmodifiable {@link Collection} of all {@link BlueMapMap}s for this world
*/ */
@DebugDump
Collection<BlueMapMap> getMaps(); Collection<BlueMapMap> getMaps();
} }

View File

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

View File

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

View File

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

View File

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

View File

@ -49,8 +49,9 @@ public final class MarkerGson {
.setLenient() .setLenient()
.create(); .create();
/* This class can not be instantiated. */ private MarkerGson() {
private MarkerGson() {} throw new UnsupportedOperationException("Utility class");
}
public static GsonBuilder addAdapters(GsonBuilder builder) { public static GsonBuilder addAdapters(GsonBuilder builder) {
return builder return builder
@ -235,8 +236,8 @@ public void write(JsonWriter out, Vector2d value) throws IOException {
} }
out.beginObject(); out.beginObject();
out.name("x"); out.value(value.getX()); out.name("x"); writeRounded(out, value.getX());
out.name(useZ ? "z" : "y"); out.value(value.getY()); out.name(useZ ? "z" : "y"); writeRounded(out, value.getY());
out.endObject(); out.endObject();
} }
@ -262,6 +263,13 @@ public Vector2d read(JsonReader in) throws IOException {
return new Vector2d(x, y); 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> { static class Vector3dAdapter extends TypeAdapter<Vector3d> {
@ -274,9 +282,9 @@ public void write(JsonWriter out, Vector3d value) throws IOException {
} }
out.beginObject(); out.beginObject();
out.name("x"); out.value(value.getX()); out.name("x"); writeRounded(out, value.getX());
out.name("y"); out.value(value.getY()); out.name("y"); writeRounded(out, value.getY());
out.name("z"); out.value(value.getZ()); out.name("z"); writeRounded(out, value.getZ());
out.endObject(); out.endObject();
} }
@ -302,6 +310,13 @@ public Vector3d read(JsonReader in) throws IOException {
return new Vector3d(x, y, z); 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> { static class Vector2iAdapter extends TypeAdapter<Vector2i> {

View File

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

View File

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

View File

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

View File

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

View File

@ -25,7 +25,6 @@
package de.bluecolored.bluemap.api.markers; package de.bluecolored.bluemap.api.markers;
import com.flowpowered.math.vector.Vector3d; import com.flowpowered.math.vector.Vector3d;
import de.bluecolored.bluemap.api.debug.DebugDump;
import java.util.Objects; import java.util.Objects;
@ -38,17 +37,20 @@
* @see ExtrudeMarker * @see ExtrudeMarker
* @see LineMarker * @see LineMarker
*/ */
@DebugDump
public abstract class Marker { public abstract class Marker {
private final String type; private final String type;
private String label; private String label;
private Vector3d position; private Vector3d position;
private int sorting;
private boolean listed;
public Marker(String type, String label, Vector3d position) { public Marker(String type, String label, Vector3d position) {
this.type = Objects.requireNonNull(type, "type cannot be null"); this.type = Objects.requireNonNull(type, "type cannot be null");
this.label = Objects.requireNonNull(label, "label cannot be null"); this.label = Objects.requireNonNull(label, "label cannot be null");
this.position = Objects.requireNonNull(position, "position cannot be null"); this.position = Objects.requireNonNull(position, "position cannot be null");
this.sorting = 0;
this.listed = true;
} }
/** /**
@ -107,6 +109,46 @@ public void setPosition(double x, double y, double z) {
setPosition(new Vector3d(x, y, 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 @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) return true; if (this == o) return true;
@ -131,6 +173,8 @@ public static abstract class Builder<T extends Marker, B extends Marker.Builder<
String label; String label;
Vector3d position; Vector3d position;
Integer sorting;
Boolean listed;
/** /**
* Sets the label of the {@link Marker}. * Sets the label of the {@link Marker}.
@ -164,6 +208,28 @@ public B position(double x, double y, double z) {
return position(new Vector3d(x, y, 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 * Creates a new {@link Marker} with the current builder-settings
* @return The new {@link Marker}-instance * @return The new {@link Marker}-instance
@ -173,6 +239,8 @@ public B position(double x, double y, double z) {
T build(T marker) { T build(T marker) {
if (label != null) marker.setLabel(label); if (label != null) marker.setLabel(label);
if (position != null) marker.setPosition(position); if (position != null) marker.setPosition(position);
if (sorting != null) marker.setSorting(sorting);
if (listed != null) marker.setListed(listed);
return marker; return marker;
} }

View File

@ -24,8 +24,6 @@
*/ */
package de.bluecolored.bluemap.api.markers; package de.bluecolored.bluemap.api.markers;
import de.bluecolored.bluemap.api.debug.DebugDump;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
@ -33,11 +31,11 @@
/** /**
* A set of {@link Marker}s that are displayed on the maps in the web-app. * A set of {@link Marker}s that are displayed on the maps in the web-app.
*/ */
@DebugDump
public class MarkerSet { public class MarkerSet {
private String label; private String label;
private boolean toggleable, defaultHidden; private boolean toggleable, defaultHidden;
private int sorting;
private final ConcurrentHashMap<String, Marker> markers; private final ConcurrentHashMap<String, Marker> markers;
/** /**
@ -56,10 +54,7 @@ private MarkerSet() {
* @see #setLabel(String) * @see #setLabel(String)
*/ */
public MarkerSet(String label) { public MarkerSet(String label) {
this.label = Objects.requireNonNull(label); this(label, true, false);
this.toggleable = true;
this.defaultHidden = false;
this.markers = new ConcurrentHashMap<>();
} }
/** /**
@ -77,6 +72,7 @@ public MarkerSet(String label, boolean toggleable, boolean defaultHidden) {
this.label = Objects.requireNonNull(label); this.label = Objects.requireNonNull(label);
this.toggleable = toggleable; this.toggleable = toggleable;
this.defaultHidden = defaultHidden; this.defaultHidden = defaultHidden;
this.sorting = 0;
this.markers = new ConcurrentHashMap<>(); this.markers = new ConcurrentHashMap<>();
} }
@ -149,6 +145,28 @@ public void setDefaultHidden(boolean defaultHidden) {
this.defaultHidden = 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}. * 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. * The keys of the map are the id's of the {@link Marker}s.
@ -220,6 +238,7 @@ public static class Builder {
private String label; private String label;
private Boolean toggleable, defaultHidden; private Boolean toggleable, defaultHidden;
private Integer sorting;
/** /**
* Sets the label of the {@link MarkerSet}. * Sets the label of the {@link MarkerSet}.
@ -262,6 +281,18 @@ public Builder defaultHidden(Boolean defaultHidden) {
return this; 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> * Creates a new {@link MarkerSet} with the current builder-settings.<br>
* The minimum required settings to build this marker-set are: * The minimum required settings to build this marker-set are:
@ -276,6 +307,7 @@ public MarkerSet build() {
); );
if (toggleable != null) markerSet.setToggleable(toggleable); if (toggleable != null) markerSet.setToggleable(toggleable);
if (defaultHidden != null) markerSet.setDefaultHidden(defaultHidden); if (defaultHidden != null) markerSet.setDefaultHidden(defaultHidden);
if (sorting != null) markerSet.setSorting(sorting);
return markerSet; return markerSet;
} }

View File

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

View File

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

View File

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

View File

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

View File

@ -25,7 +25,6 @@
package de.bluecolored.bluemap.api.math; package de.bluecolored.bluemap.api.math;
import com.flowpowered.math.vector.Vector3d; import com.flowpowered.math.vector.Vector3d;
import de.bluecolored.bluemap.api.debug.DebugDump;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import java.util.ArrayList; import java.util.ArrayList;
@ -36,7 +35,6 @@
/** /**
* A line consisting of 2 or more {@link Vector3d}-points. * A line consisting of 2 or more {@link Vector3d}-points.
*/ */
@DebugDump
public class Line { public class Line {
private final Vector3d[] points; private final Vector3d[] points;
@ -160,6 +158,16 @@ public Builder addPoints(Vector3d... points) {
return this; 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> * 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}. * There need to be at least 2 points to build a {@link Line}.

View File

@ -25,7 +25,6 @@
package de.bluecolored.bluemap.api.math; package de.bluecolored.bluemap.api.math;
import com.flowpowered.math.vector.Vector2d; import com.flowpowered.math.vector.Vector2d;
import de.bluecolored.bluemap.api.debug.DebugDump;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import java.util.ArrayList; import java.util.ArrayList;
@ -36,7 +35,6 @@
/** /**
* A shape consisting of 3 or more {@link Vector2d}-points on a plane. * A shape consisting of 3 or more {@link Vector2d}-points on a plane.
*/ */
@DebugDump
public class Shape { public class Shape {
private final Vector2d[] points; private final Vector2d[] points;
@ -248,6 +246,16 @@ public Builder addPoints(Vector2d... points) {
return this; 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> * 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}. * There need to be at least 3 points to build a {@link Shape}.

View File

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