Merge branch 'development' into master

This commit is contained in:
Andre_601 2021-07-01 16:16:29 +02:00 committed by GitHub
commit 0fa592383f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
57 changed files with 215 additions and 104 deletions

31
.github/workflows/pr_build_jars.yml vendored Normal file
View File

@ -0,0 +1,31 @@
name: "Test compiling against Java 8, 11 and 16"
on:
pull_request:
branches:
- development
paths:
- "src/**"
- "build.gradle"
jobs:
testBuilds:
name: "Test-compile against Java 8, 11 and 16"
runs-on: ubuntu-latest
strategy:
fail-fast: false
max-parallel: 4
matrix:
java-version: [8, 11, 16]
steps:
- name: "Checkout Code"
uses: actions/checkout@v2
- name: "Prepare Java ${{ matrix.java-version }}"
uses: actions/setup-java@v2
with:
distribution: "adopt"
java-version: "${{ matrix.java-version }}"
- name: "Make build.gradle executable"
run: "chmod +x gradlew"
- name: "Build jar with Java ${{ matrix.java-version }}"
run: "./gradlew shadowJar"

View File

@ -1,3 +1,5 @@
import org.apache.tools.ant.filters.ReplaceTokens
plugins { plugins {
id "java" id "java"
id "maven-publish" id "maven-publish"
@ -18,8 +20,7 @@ repositories {
} }
dependencies { dependencies {
implementation "com.google.code.gson:gson:2.8.6" implementation "org.bstats:bstats-bukkit:1.5"
implementation "org.bstats:bstats-bukkit:2.2.1"
compileOnly "org.spigotmc:spigot-api:1.17-R0.1-SNAPSHOT" compileOnly "org.spigotmc:spigot-api:1.17-R0.1-SNAPSHOT"
compileOnly "org.jetbrains:annotations:19.0.0" compileOnly "org.jetbrains:annotations:19.0.0"
@ -32,7 +33,9 @@ dependencies {
} }
processResources { processResources {
filter org.apache.tools.ant.filters.ReplaceTokens, tokens: [name: rootProject.name, version: project.version.toString(), description: project.description] from(sourceSets.main.resources.srcDirs) {
filter ReplaceTokens, tokens: [name: rootProject.name, version: project.version.toString(), description: project.description]
}
} }
java { java {
@ -58,7 +61,6 @@ shadowJar {
archiveClassifier.set("") archiveClassifier.set("")
relocate "org.bstats", "me.clip.placeholderapi.metrics" relocate "org.bstats", "me.clip.placeholderapi.metrics"
relocate "com.google.gson", "me.clip.placeholderapi.libs.gson"
} }
license { license {
@ -73,7 +75,7 @@ license {
} }
ext { ext {
year = 2020 year = 2021
} }
} }
@ -90,7 +92,7 @@ configurations {
publishing { publishing {
repositories { repositories {
maven { maven {
if (version.contains("-DEV-")) { if (version.contains("-DEV")) {
url = uri("https://repo.extendedclip.com/content/repositories/dev/") url = uri("https://repo.extendedclip.com/content/repositories/dev/")
} else { } else {
url = uri("https://repo.extendedclip.com/content/repositories/placeholderapi/") url = uri("https://repo.extendedclip.com/content/repositories/placeholderapi/")

View File

@ -4,7 +4,7 @@
* PlaceholderAPI * PlaceholderAPI
* Copyright (c) 2015 - 2021 PlaceholderAPI Team * Copyright (c) 2015 - 2021 PlaceholderAPI Team
* *
* PlaceholderAPI free software: you can redistribute it and/or modify * PlaceholderAPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
@ -162,7 +162,7 @@ public final class PlaceholderAPI {
* @return String containing all translated placeholders * @return String containing all translated placeholders
*/ */
public static List<String> setBracketPlaceholders(Player player, List<String> text) { public static List<String> setBracketPlaceholders(Player player, List<String> text) {
return setPlaceholders((OfflinePlayer) player, text); return setBracketPlaceholders((OfflinePlayer) player, text);
} }
/** /**

View File

@ -4,7 +4,7 @@
* PlaceholderAPI * PlaceholderAPI
* Copyright (c) 2015 - 2021 PlaceholderAPI Team * Copyright (c) 2015 - 2021 PlaceholderAPI Team
* *
* PlaceholderAPI free software: you can redistribute it and/or modify * PlaceholderAPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.

View File

@ -4,7 +4,7 @@
* PlaceholderAPI * PlaceholderAPI
* Copyright (c) 2015 - 2021 PlaceholderAPI Team * Copyright (c) 2015 - 2021 PlaceholderAPI Team
* *
* PlaceholderAPI free software: you can redistribute it and/or modify * PlaceholderAPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.

View File

@ -4,7 +4,7 @@
* PlaceholderAPI * PlaceholderAPI
* Copyright (c) 2015 - 2021 PlaceholderAPI Team * Copyright (c) 2015 - 2021 PlaceholderAPI Team
* *
* PlaceholderAPI free software: you can redistribute it and/or modify * PlaceholderAPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.

View File

@ -4,7 +4,7 @@
* PlaceholderAPI * PlaceholderAPI
* Copyright (c) 2015 - 2021 PlaceholderAPI Team * Copyright (c) 2015 - 2021 PlaceholderAPI Team
* *
* PlaceholderAPI free software: you can redistribute it and/or modify * PlaceholderAPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.

View File

@ -4,7 +4,7 @@
* PlaceholderAPI * PlaceholderAPI
* Copyright (c) 2015 - 2021 PlaceholderAPI Team * Copyright (c) 2015 - 2021 PlaceholderAPI Team
* *
* PlaceholderAPI free software: you can redistribute it and/or modify * PlaceholderAPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.

View File

@ -4,7 +4,7 @@
* PlaceholderAPI * PlaceholderAPI
* Copyright (c) 2015 - 2021 PlaceholderAPI Team * Copyright (c) 2015 - 2021 PlaceholderAPI Team
* *
* PlaceholderAPI free software: you can redistribute it and/or modify * PlaceholderAPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.

View File

@ -4,7 +4,7 @@
* PlaceholderAPI * PlaceholderAPI
* Copyright (c) 2015 - 2021 PlaceholderAPI Team * Copyright (c) 2015 - 2021 PlaceholderAPI Team
* *
* PlaceholderAPI free software: you can redistribute it and/or modify * PlaceholderAPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.

View File

@ -4,7 +4,7 @@
* PlaceholderAPI * PlaceholderAPI
* Copyright (c) 2015 - 2021 PlaceholderAPI Team * Copyright (c) 2015 - 2021 PlaceholderAPI Team
* *
* PlaceholderAPI free software: you can redistribute it and/or modify * PlaceholderAPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.

View File

@ -4,7 +4,7 @@
* PlaceholderAPI * PlaceholderAPI
* Copyright (c) 2015 - 2021 PlaceholderAPI Team * Copyright (c) 2015 - 2021 PlaceholderAPI Team
* *
* PlaceholderAPI free software: you can redistribute it and/or modify * PlaceholderAPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.

View File

@ -4,7 +4,7 @@
* PlaceholderAPI * PlaceholderAPI
* Copyright (c) 2015 - 2021 PlaceholderAPI Team * Copyright (c) 2015 - 2021 PlaceholderAPI Team
* *
* PlaceholderAPI free software: you can redistribute it and/or modify * PlaceholderAPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.

View File

@ -4,7 +4,7 @@
* PlaceholderAPI * PlaceholderAPI
* Copyright (c) 2015 - 2021 PlaceholderAPI Team * Copyright (c) 2015 - 2021 PlaceholderAPI Team
* *
* PlaceholderAPI free software: you can redistribute it and/or modify * PlaceholderAPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.

View File

@ -4,7 +4,7 @@
* PlaceholderAPI * PlaceholderAPI
* Copyright (c) 2015 - 2021 PlaceholderAPI Team * Copyright (c) 2015 - 2021 PlaceholderAPI Team
* *
* PlaceholderAPI free software: you can redistribute it and/or modify * PlaceholderAPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.

View File

@ -4,7 +4,7 @@
* PlaceholderAPI * PlaceholderAPI
* Copyright (c) 2015 - 2021 PlaceholderAPI Team * Copyright (c) 2015 - 2021 PlaceholderAPI Team
* *
* PlaceholderAPI free software: you can redistribute it and/or modify * PlaceholderAPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.

View File

@ -4,7 +4,7 @@
* PlaceholderAPI * PlaceholderAPI
* Copyright (c) 2015 - 2021 PlaceholderAPI Team * Copyright (c) 2015 - 2021 PlaceholderAPI Team
* *
* PlaceholderAPI free software: you can redistribute it and/or modify * PlaceholderAPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.

View File

@ -4,7 +4,7 @@
* PlaceholderAPI * PlaceholderAPI
* Copyright (c) 2015 - 2021 PlaceholderAPI Team * Copyright (c) 2015 - 2021 PlaceholderAPI Team
* *
* PlaceholderAPI free software: you can redistribute it and/or modify * PlaceholderAPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
@ -21,7 +21,17 @@
package me.clip.placeholderapi.commands.impl.local; package me.clip.placeholderapi.commands.impl.local;
import com.google.common.io.CharStreams; import com.google.common.io.CharStreams;
import com.google.gson.JsonParser; import com.google.gson.Gson;
import com.google.gson.JsonObject;
import me.clip.placeholderapi.PlaceholderAPIPlugin;
import me.clip.placeholderapi.commands.PlaceholderCommand;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import me.clip.placeholderapi.util.Msg;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Unmodifiable;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
@ -41,20 +51,15 @@ import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionException; import java.util.concurrent.CompletionException;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import me.clip.placeholderapi.PlaceholderAPIPlugin;
import me.clip.placeholderapi.commands.PlaceholderCommand;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import me.clip.placeholderapi.util.Msg;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Unmodifiable;
public final class CommandDump extends PlaceholderCommand { public final class CommandDump extends PlaceholderCommand {
@NotNull @NotNull
private static final String URL = "https://paste.helpch.at/"; private static final String URL = "https://paste.helpch.at/";
@NotNull
private static final Gson gson = new Gson();
@NotNull @NotNull
private static final DateTimeFormatter DATE_FORMAT = DateTimeFormatter private static final DateTimeFormatter DATE_FORMAT = DateTimeFormatter
.ofLocalizedDateTime(FormatStyle.LONG) .ofLocalizedDateTime(FormatStyle.LONG)
@ -102,9 +107,8 @@ public final class CommandDump extends PlaceholderCommand {
try (final InputStream stream = connection.getInputStream()) { try (final InputStream stream = connection.getInputStream()) {
//noinspection UnstableApiUsage //noinspection UnstableApiUsage
final String json = CharStreams final String json = CharStreams.toString(new InputStreamReader(stream, StandardCharsets.UTF_8));
.toString(new InputStreamReader(stream, StandardCharsets.UTF_8)); return gson.fromJson(json, JsonObject.class).get("key").getAsString();
return JsonParser.parseString(json).getAsJsonObject().get("key").getAsString();
} }
} catch (final IOException ex) { } catch (final IOException ex) {
throw new CompletionException(ex); throw new CompletionException(ex);

View File

@ -4,7 +4,7 @@
* PlaceholderAPI * PlaceholderAPI
* Copyright (c) 2015 - 2021 PlaceholderAPI Team * Copyright (c) 2015 - 2021 PlaceholderAPI Team
* *
* PlaceholderAPI free software: you can redistribute it and/or modify * PlaceholderAPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.

View File

@ -4,7 +4,7 @@
* PlaceholderAPI * PlaceholderAPI
* Copyright (c) 2015 - 2021 PlaceholderAPI Team * Copyright (c) 2015 - 2021 PlaceholderAPI Team
* *
* PlaceholderAPI free software: you can redistribute it and/or modify * PlaceholderAPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.

View File

@ -4,7 +4,7 @@
* PlaceholderAPI * PlaceholderAPI
* Copyright (c) 2015 - 2021 PlaceholderAPI Team * Copyright (c) 2015 - 2021 PlaceholderAPI Team
* *
* PlaceholderAPI free software: you can redistribute it and/or modify * PlaceholderAPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.

View File

@ -4,7 +4,7 @@
* PlaceholderAPI * PlaceholderAPI
* Copyright (c) 2015 - 2021 PlaceholderAPI Team * Copyright (c) 2015 - 2021 PlaceholderAPI Team
* *
* PlaceholderAPI free software: you can redistribute it and/or modify * PlaceholderAPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.

View File

@ -4,7 +4,7 @@
* PlaceholderAPI * PlaceholderAPI
* Copyright (c) 2015 - 2021 PlaceholderAPI Team * Copyright (c) 2015 - 2021 PlaceholderAPI Team
* *
* PlaceholderAPI free software: you can redistribute it and/or modify * PlaceholderAPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.

View File

@ -4,7 +4,7 @@
* PlaceholderAPI * PlaceholderAPI
* Copyright (c) 2015 - 2021 PlaceholderAPI Team * Copyright (c) 2015 - 2021 PlaceholderAPI Team
* *
* PlaceholderAPI free software: you can redistribute it and/or modify * PlaceholderAPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.

View File

@ -4,7 +4,7 @@
* PlaceholderAPI * PlaceholderAPI
* Copyright (c) 2015 - 2021 PlaceholderAPI Team * Copyright (c) 2015 - 2021 PlaceholderAPI Team
* *
* PlaceholderAPI free software: you can redistribute it and/or modify * PlaceholderAPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.

View File

@ -4,7 +4,7 @@
* PlaceholderAPI * PlaceholderAPI
* Copyright (c) 2015 - 2021 PlaceholderAPI Team * Copyright (c) 2015 - 2021 PlaceholderAPI Team
* *
* PlaceholderAPI free software: you can redistribute it and/or modify * PlaceholderAPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.

View File

@ -4,7 +4,7 @@
* PlaceholderAPI * PlaceholderAPI
* Copyright (c) 2015 - 2021 PlaceholderAPI Team * Copyright (c) 2015 - 2021 PlaceholderAPI Team
* *
* PlaceholderAPI free software: you can redistribute it and/or modify * PlaceholderAPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.

View File

@ -4,7 +4,7 @@
* PlaceholderAPI * PlaceholderAPI
* Copyright (c) 2015 - 2021 PlaceholderAPI Team * Copyright (c) 2015 - 2021 PlaceholderAPI Team
* *
* PlaceholderAPI free software: you can redistribute it and/or modify * PlaceholderAPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.

View File

@ -4,7 +4,7 @@
* PlaceholderAPI * PlaceholderAPI
* Copyright (c) 2015 - 2021 PlaceholderAPI Team * Copyright (c) 2015 - 2021 PlaceholderAPI Team
* *
* PlaceholderAPI free software: you can redistribute it and/or modify * PlaceholderAPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.

View File

@ -4,7 +4,7 @@
* PlaceholderAPI * PlaceholderAPI
* Copyright (c) 2015 - 2021 PlaceholderAPI Team * Copyright (c) 2015 - 2021 PlaceholderAPI Team
* *
* PlaceholderAPI free software: you can redistribute it and/or modify * PlaceholderAPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.

View File

@ -4,7 +4,7 @@
* PlaceholderAPI * PlaceholderAPI
* Copyright (c) 2015 - 2021 PlaceholderAPI Team * Copyright (c) 2015 - 2021 PlaceholderAPI Team
* *
* PlaceholderAPI free software: you can redistribute it and/or modify * PlaceholderAPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
@ -26,7 +26,7 @@ import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
/** /**
* Indicates that <b>all</b> {@link PlaceholderExpansion PlayceholderExpansions} * Indicates that <b>all</b> {@link me.clip.placeholderapi.expansion.PlaceholderExpansion PlayceholderExpansions}
* have been loaded. * have been loaded.
* <br/>This event is fired on Server load and when reloading the * <br/>This event is fired on Server load and when reloading the
* confiuration. * confiuration.

View File

@ -4,7 +4,7 @@
* PlaceholderAPI * PlaceholderAPI
* Copyright (c) 2015 - 2021 PlaceholderAPI Team * Copyright (c) 2015 - 2021 PlaceholderAPI Team
* *
* PlaceholderAPI free software: you can redistribute it and/or modify * PlaceholderAPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.

View File

@ -4,7 +4,7 @@
* PlaceholderAPI * PlaceholderAPI
* Copyright (c) 2015 - 2021 PlaceholderAPI Team * Copyright (c) 2015 - 2021 PlaceholderAPI Team
* *
* PlaceholderAPI free software: you can redistribute it and/or modify * PlaceholderAPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.

View File

@ -4,7 +4,7 @@
* PlaceholderAPI * PlaceholderAPI
* Copyright (c) 2015 - 2021 PlaceholderAPI Team * Copyright (c) 2015 - 2021 PlaceholderAPI Team
* *
* PlaceholderAPI free software: you can redistribute it and/or modify * PlaceholderAPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.

View File

@ -4,7 +4,7 @@
* PlaceholderAPI * PlaceholderAPI
* Copyright (c) 2015 - 2021 PlaceholderAPI Team * Copyright (c) 2015 - 2021 PlaceholderAPI Team
* *
* PlaceholderAPI free software: you can redistribute it and/or modify * PlaceholderAPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.

View File

@ -4,7 +4,7 @@
* PlaceholderAPI * PlaceholderAPI
* Copyright (c) 2015 - 2021 PlaceholderAPI Team * Copyright (c) 2015 - 2021 PlaceholderAPI Team
* *
* PlaceholderAPI free software: you can redistribute it and/or modify * PlaceholderAPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.

View File

@ -4,7 +4,7 @@
* PlaceholderAPI * PlaceholderAPI
* Copyright (c) 2015 - 2021 PlaceholderAPI Team * Copyright (c) 2015 - 2021 PlaceholderAPI Team
* *
* PlaceholderAPI free software: you can redistribute it and/or modify * PlaceholderAPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.

View File

@ -4,7 +4,7 @@
* PlaceholderAPI * PlaceholderAPI
* Copyright (c) 2015 - 2021 PlaceholderAPI Team * Copyright (c) 2015 - 2021 PlaceholderAPI Team
* *
* PlaceholderAPI free software: you can redistribute it and/or modify * PlaceholderAPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
@ -22,7 +22,6 @@ package me.clip.placeholderapi.expansion;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Objects;
import me.clip.placeholderapi.PlaceholderAPIPlugin; import me.clip.placeholderapi.PlaceholderAPIPlugin;
import me.clip.placeholderapi.PlaceholderHook; import me.clip.placeholderapi.PlaceholderHook;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -368,5 +367,4 @@ public abstract class PlaceholderExpansion extends PlaceholderHook {
public String getLink() { public String getLink() {
return null; return null;
} }
} }

View File

@ -4,7 +4,7 @@
* PlaceholderAPI * PlaceholderAPI
* Copyright (c) 2015 - 2021 PlaceholderAPI Team * Copyright (c) 2015 - 2021 PlaceholderAPI Team
* *
* PlaceholderAPI free software: you can redistribute it and/or modify * PlaceholderAPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.

View File

@ -4,7 +4,7 @@
* PlaceholderAPI * PlaceholderAPI
* Copyright (c) 2015 - 2021 PlaceholderAPI Team * Copyright (c) 2015 - 2021 PlaceholderAPI Team
* *
* PlaceholderAPI free software: you can redistribute it and/or modify * PlaceholderAPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.

View File

@ -4,7 +4,7 @@
* PlaceholderAPI * PlaceholderAPI
* Copyright (c) 2015 - 2021 PlaceholderAPI Team * Copyright (c) 2015 - 2021 PlaceholderAPI Team
* *
* PlaceholderAPI free software: you can redistribute it and/or modify * PlaceholderAPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.

View File

@ -4,7 +4,7 @@
* PlaceholderAPI * PlaceholderAPI
* Copyright (c) 2015 - 2021 PlaceholderAPI Team * Copyright (c) 2015 - 2021 PlaceholderAPI Team
* *
* PlaceholderAPI free software: you can redistribute it and/or modify * PlaceholderAPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.

View File

@ -4,7 +4,7 @@
* PlaceholderAPI * PlaceholderAPI
* Copyright (c) 2015 - 2021 PlaceholderAPI Team * Copyright (c) 2015 - 2021 PlaceholderAPI Team
* *
* PlaceholderAPI free software: you can redistribute it and/or modify * PlaceholderAPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.

View File

@ -4,7 +4,7 @@
* PlaceholderAPI * PlaceholderAPI
* Copyright (c) 2015 - 2021 PlaceholderAPI Team * Copyright (c) 2015 - 2021 PlaceholderAPI Team
* *
* PlaceholderAPI free software: you can redistribute it and/or modify * PlaceholderAPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.

View File

@ -4,7 +4,7 @@
* PlaceholderAPI * PlaceholderAPI
* Copyright (c) 2015 - 2021 PlaceholderAPI Team * Copyright (c) 2015 - 2021 PlaceholderAPI Team
* *
* PlaceholderAPI free software: you can redistribute it and/or modify * PlaceholderAPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
@ -46,18 +46,25 @@ import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.Unmodifiable; import org.jetbrains.annotations.Unmodifiable;
import java.io.File; import java.io.File;
import java.lang.reflect.Modifier;
import java.util.*; import java.util.*;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionException; import java.util.concurrent.CompletionException;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.locks.ReentrantLock; import java.util.concurrent.locks.ReentrantLock;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.stream.Collectors;
public final class LocalExpansionManager implements Listener { public final class LocalExpansionManager implements Listener {
@NotNull @NotNull
private static final String EXPANSIONS_FOLDER_NAME = "expansions"; private static final String EXPANSIONS_FOLDER_NAME = "expansions";
@NotNull
private static final Set<MethodSignature> ABSTRACT_EXPANSION_METHODS = Arrays.stream(PlaceholderExpansion.class.getDeclaredMethods())
.filter(method -> Modifier.isAbstract(method.getModifiers()))
.map(method -> new MethodSignature(method.getName(), method.getParameterTypes()))
.collect(Collectors.toSet());
@NotNull @NotNull
private final File folder; private final File folder;
@ -153,15 +160,28 @@ public final class LocalExpansionManager implements Listener {
@NotNull final Class<? extends PlaceholderExpansion> clazz) { @NotNull final Class<? extends PlaceholderExpansion> clazz) {
try { try {
final PlaceholderExpansion expansion = createExpansionInstance(clazz); final PlaceholderExpansion expansion = createExpansionInstance(clazz);
if (expansion == null || !expansion.register()) {
Objects.requireNonNull(expansion.getAuthor(), "The expansion author is null!");
Objects.requireNonNull(expansion.getIdentifier(), "The expansion identifier is null!");
Objects.requireNonNull(expansion.getVersion(), "The expansion version is null!");
if (!expansion.register()) {
return Optional.empty(); return Optional.empty();
} }
return Optional.of(expansion); return Optional.of(expansion);
} catch (final LinkageError ex) { } catch (LinkageError | NullPointerException ex) {
plugin.getLogger().severe("Failed to load Expansion class " + clazz.getSimpleName() + final String reason;
" (Is a dependency missing?)");
plugin.getLogger().severe("Cause: " + ex.getClass().getSimpleName() + " " + ex.getMessage()); if (ex instanceof LinkageError) {
reason = " (Is a dependency missing?)";
} else {
reason = " - One of its properties is null which is not allowed!";
}
plugin.getLogger().severe("Failed to load expansion class " + clazz.getSimpleName() +
reason);
plugin.getLogger().log(Level.SEVERE, "", ex);
} }
return Optional.empty(); return Optional.empty();
@ -341,6 +361,16 @@ public final class LocalExpansionManager implements Listener {
if (expansionClass == null) { if (expansionClass == null) {
plugin.getLogger().severe("Failed to load Expansion: " + file.getName() + ", as it does not have" + plugin.getLogger().severe("Failed to load Expansion: " + file.getName() + ", as it does not have" +
" a class which extends PlaceholderExpansion."); " a class which extends PlaceholderExpansion.");
return null;
}
Set<MethodSignature> expansionMethods = Arrays.stream(expansionClass.getDeclaredMethods())
.map(method -> new MethodSignature(method.getName(), method.getParameterTypes()))
.collect(Collectors.toSet());
if (!expansionMethods.containsAll(ABSTRACT_EXPANSION_METHODS)) {
plugin.getLogger().severe("Failed to load Expansion: " + file.getName() + ", as it does not have the" +
" required methods declared for a PlaceholderExpansion.");
return null;
} }
return expansionClass; return expansionClass;
@ -366,7 +396,7 @@ public final class LocalExpansionManager implements Listener {
throw ((LinkageError) ex.getCause()); throw ((LinkageError) ex.getCause());
} }
plugin.getLogger().warning("There was an issue with loading an expansion"); plugin.getLogger().warning("There was an issue with loading an expansion.");
return null; return null;
} }

View File

@ -0,0 +1,37 @@
package me.clip.placeholderapi.expansion.manager;
import java.util.Arrays;
import java.util.Objects;
public final class MethodSignature {
private final String name;
private final Class<?>[] params;
protected MethodSignature(String name, Class<?>[] params) {
this.name = name;
this.params = params;
}
public String getName() {
return name;
}
public Class<?>[] getParams() {
return params;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
MethodSignature that = (MethodSignature) o;
return Objects.equals(name, that.name) && Arrays.equals(params, that.params);
}
@Override
public int hashCode() {
int result = Objects.hash(name);
result = 31 * result + Arrays.hashCode(params);
return result;
}
}

View File

@ -4,7 +4,7 @@
* PlaceholderAPI * PlaceholderAPI
* Copyright (c) 2015 - 2021 PlaceholderAPI Team * Copyright (c) 2015 - 2021 PlaceholderAPI Team
* *
* PlaceholderAPI free software: you can redistribute it and/or modify * PlaceholderAPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.

View File

@ -4,7 +4,7 @@
* PlaceholderAPI * PlaceholderAPI
* Copyright (c) 2015 - 2021 PlaceholderAPI Team * Copyright (c) 2015 - 2021 PlaceholderAPI Team
* *
* PlaceholderAPI free software: you can redistribute it and/or modify * PlaceholderAPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.

View File

@ -4,7 +4,7 @@
* PlaceholderAPI * PlaceholderAPI
* Copyright (c) 2015 - 2021 PlaceholderAPI Team * Copyright (c) 2015 - 2021 PlaceholderAPI Team
* *
* PlaceholderAPI free software: you can redistribute it and/or modify * PlaceholderAPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.

View File

@ -4,7 +4,7 @@
* PlaceholderAPI * PlaceholderAPI
* Copyright (c) 2015 - 2021 PlaceholderAPI Team * Copyright (c) 2015 - 2021 PlaceholderAPI Team
* *
* PlaceholderAPI free software: you can redistribute it and/or modify * PlaceholderAPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.

View File

@ -4,7 +4,7 @@
* PlaceholderAPI * PlaceholderAPI
* Copyright (c) 2015 - 2021 PlaceholderAPI Team * Copyright (c) 2015 - 2021 PlaceholderAPI Team
* *
* PlaceholderAPI free software: you can redistribute it and/or modify * PlaceholderAPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
@ -23,6 +23,7 @@ package me.clip.placeholderapi.updatechecker;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.net.URL; import java.net.URL;
import java.util.Arrays;
import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.HttpsURLConnection;
import me.clip.placeholderapi.PlaceholderAPIPlugin; import me.clip.placeholderapi.PlaceholderAPIPlugin;
import me.clip.placeholderapi.util.Msg; import me.clip.placeholderapi.util.Msg;
@ -90,17 +91,24 @@ public class UpdateChecker implements Listener {
return false; return false;
} }
String plV = toReadable(pluginVersion); int[] plV = toReadable(pluginVersion);
String spV = toReadable(spigotVersion); int[] spV = toReadable(spigotVersion);
return plV.compareTo(spV) < 0;
if (plV[0] < spV[0]) {
return true;
} else if ((plV[1] < spV[1])) {
return true;
} else {
return plV[2] < spV[2];
}
} }
private String toReadable(String version) { private int[] toReadable(String version) {
if (version.contains("-DEV-")) { if (version.contains("-DEV")) {
version = version.split("-DEV-")[0]; version = version.split("-DEV")[0];
} }
return version.replaceAll("\\.", ""); return Arrays.stream(version.split("\\.")).mapToInt(Integer::parseInt).toArray();
} }
@EventHandler(priority = EventPriority.MONITOR) @EventHandler(priority = EventPriority.MONITOR)

View File

@ -2,9 +2,9 @@
* This file is part of PlaceholderAPI * This file is part of PlaceholderAPI
* *
* PlaceholderAPI * PlaceholderAPI
* Copyright (c) 2015 - 2020 PlaceholderAPI Team * Copyright (c) 2015 - 2021 PlaceholderAPI Team
* *
* PlaceholderAPI free software: you can redistribute it and/or modify * PlaceholderAPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
@ -42,13 +42,11 @@ public class FileUtil {
} }
final URL jar = file.toURI().toURL(); final URL jar = file.toURI().toURL();
final URLClassLoader loader = new URLClassLoader(new URL[]{jar}, clazz.getClassLoader());
final List<String> matches = new ArrayList<>(); final List<String> matches = new ArrayList<>();
final List<Class<? extends T>> classes = new ArrayList<>(); final List<Class<? extends T>> classes = new ArrayList<>();
try (final JarInputStream stream = new JarInputStream( try (final JarInputStream stream = new JarInputStream(jar.openStream())) {
jar.openStream()); final URLClassLoader loader = new URLClassLoader(new URL[]{jar},
clazz.getClassLoader())) {
JarEntry entry; JarEntry entry;
while ((entry = stream.getNextJarEntry()) != null) { while ((entry = stream.getNextJarEntry()) != null) {
final String name = entry.getName(); final String name = entry.getName();
@ -69,8 +67,11 @@ public class FileUtil {
} }
} }
} }
if (classes.isEmpty()) {
return classes.isEmpty() ? null : classes.get(0); loader.close();
return null;
}
return classes.get(0);
} }
} }

View File

@ -2,9 +2,9 @@
* This file is part of PlaceholderAPI * This file is part of PlaceholderAPI
* *
* PlaceholderAPI * PlaceholderAPI
* Copyright (c) 2015 - 2020 PlaceholderAPI Team * Copyright (c) 2015 - 2021 PlaceholderAPI Team
* *
* PlaceholderAPI free software: you can redistribute it and/or modify * PlaceholderAPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.

View File

@ -2,9 +2,9 @@
* This file is part of PlaceholderAPI * This file is part of PlaceholderAPI
* *
* PlaceholderAPI * PlaceholderAPI
* Copyright (c) 2015 - 2020 PlaceholderAPI Team * Copyright (c) 2015 - 2021 PlaceholderAPI Team
* *
* PlaceholderAPI free software: you can redistribute it and/or modify * PlaceholderAPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.

View File

@ -2,9 +2,9 @@
* This file is part of PlaceholderAPI * This file is part of PlaceholderAPI
* *
* PlaceholderAPI * PlaceholderAPI
* Copyright (c) 2015 - 2020 PlaceholderAPI Team * Copyright (c) 2015 - 2021 PlaceholderAPI Team
* *
* PlaceholderAPI free software: you can redistribute it and/or modify * PlaceholderAPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.

View File

@ -2,9 +2,9 @@
* This file is part of PlaceholderAPI * This file is part of PlaceholderAPI
* *
* PlaceholderAPI * PlaceholderAPI
* Copyright (c) 2015 - 2020 PlaceholderAPI Team * Copyright (c) 2015 - 2021 PlaceholderAPI Team
* *
* PlaceholderAPI free software: you can redistribute it and/or modify * PlaceholderAPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.

View File

@ -2,9 +2,9 @@
* This file is part of PlaceholderAPI * This file is part of PlaceholderAPI
* *
* PlaceholderAPI * PlaceholderAPI
* Copyright (c) 2015 - 2020 PlaceholderAPI Team * Copyright (c) 2015 - 2021 PlaceholderAPI Team
* *
* PlaceholderAPI free software: you can redistribute it and/or modify * PlaceholderAPI is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.