commit
1f57f97c21
|
@ -1,8 +1,8 @@
|
||||||
comment:
|
comment:
|
||||||
footer: "\
|
footer: "\
|
||||||
----\n\n
|
----<br><br>
|
||||||
> **Note**\n
|
> [!NOTE]<br>
|
||||||
> *This is an automated response created by a **GitHub Action***\n
|
> *This is an automated response created by a **GitHub Action***<br>
|
||||||
> *Mentioning the bot won't have any effect!*
|
> *Mentioning the bot won't have any effect!*
|
||||||
"
|
"
|
||||||
|
|
||||||
|
|
131
build.gradle
131
build.gradle
|
@ -1,131 +0,0 @@
|
||||||
import org.apache.tools.ant.filters.ReplaceTokens
|
|
||||||
|
|
||||||
plugins {
|
|
||||||
id "java"
|
|
||||||
id "maven-publish"
|
|
||||||
id "org.cadixdev.licenser" version "0.6.1"
|
|
||||||
id "com.github.johnrengelman.shadow" version "7.1.0"
|
|
||||||
}
|
|
||||||
|
|
||||||
group "me.clip"
|
|
||||||
version "2.11.3-DEV-${System.getProperty("BUILD_NUMBER")}"
|
|
||||||
|
|
||||||
description "An awesome placeholder provider!"
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
maven({ url = "https://oss.sonatype.org/content/repositories/snapshots/" })
|
|
||||||
|
|
||||||
mavenCentral()
|
|
||||||
mavenLocal()
|
|
||||||
|
|
||||||
maven({ url = "https://repo.codemc.org/repository/maven-public/" })
|
|
||||||
maven({ url = "https://hub.spigotmc.org/nexus/content/repositories/snapshots/" })
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
implementation "org.bstats:bstats-bukkit:3.0.0"
|
|
||||||
implementation "net.kyori:adventure-platform-bukkit:4.1.1"
|
|
||||||
|
|
||||||
compileOnly "org.spigotmc:spigot-api:1.19-R0.1-SNAPSHOT"
|
|
||||||
compileOnly "org.jetbrains:annotations:23.0.0"
|
|
||||||
|
|
||||||
testImplementation "org.openjdk.jmh:jmh-core:1.32"
|
|
||||||
testImplementation "org.openjdk.jmh:jmh-generator-annprocess:1.32"
|
|
||||||
|
|
||||||
testImplementation "org.junit.jupiter:junit-jupiter-engine:5.8.2"
|
|
||||||
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.8.1"
|
|
||||||
}
|
|
||||||
|
|
||||||
processResources {
|
|
||||||
filter ReplaceTokens, tokens: [name: rootProject.name, version: project.version.toString(), description: project.description]
|
|
||||||
}
|
|
||||||
|
|
||||||
java {
|
|
||||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
|
||||||
targetCompatibility = JavaVersion.VERSION_1_8
|
|
||||||
|
|
||||||
withJavadocJar()
|
|
||||||
withSourcesJar()
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.withType(JavaCompile) {
|
|
||||||
options.encoding = "UTF-8"
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.withType(Javadoc) {
|
|
||||||
failOnError false
|
|
||||||
options.addStringOption('Xdoclint:none', '-quiet')
|
|
||||||
options.addStringOption('encoding', 'UTF-8')
|
|
||||||
options.addStringOption('charSet', 'UTF-8')
|
|
||||||
}
|
|
||||||
|
|
||||||
shadowJar {
|
|
||||||
archiveClassifier.set("")
|
|
||||||
|
|
||||||
relocate "org.bstats", "me.clip.placeholderapi.metrics"
|
|
||||||
relocate "net.kyori", "me.clip.placeholderapi.libs.kyori"
|
|
||||||
}
|
|
||||||
|
|
||||||
license {
|
|
||||||
include '**/*.java'
|
|
||||||
|
|
||||||
matching('**/*.java') {
|
|
||||||
header = file('config/headers/main.txt')
|
|
||||||
}
|
|
||||||
|
|
||||||
ext {
|
|
||||||
year = 2021
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
test {
|
|
||||||
useJUnitPlatform()
|
|
||||||
}
|
|
||||||
|
|
||||||
configurations {
|
|
||||||
testImplementation {
|
|
||||||
extendsFrom(compileOnly)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
publishing {
|
|
||||||
repositories {
|
|
||||||
maven {
|
|
||||||
if (version.contains("-DEV")) {
|
|
||||||
url = uri("https://repo.extendedclip.com/content/repositories/dev/")
|
|
||||||
} else {
|
|
||||||
url = uri("https://repo.extendedclip.com/content/repositories/placeholderapi/")
|
|
||||||
}
|
|
||||||
|
|
||||||
credentials {
|
|
||||||
username = System.getenv("JENKINS_USER")
|
|
||||||
password = System.getenv("JENKINS_PASS")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
publications {
|
|
||||||
mavenJava(MavenPublication) {
|
|
||||||
artifactId = "placeholderapi"
|
|
||||||
|
|
||||||
from components.java
|
|
||||||
|
|
||||||
pom.withXml {
|
|
||||||
|
|
||||||
// some are having issues with bstats so we might need to add that to the pom as well
|
|
||||||
|
|
||||||
asNode().appendNode("packaging", "jar")
|
|
||||||
asNode().remove(asNode().get("dependencies"))
|
|
||||||
|
|
||||||
def dependenciesNode = asNode().appendNode("dependencies")
|
|
||||||
// jetbrains annotations
|
|
||||||
def jetbrainsAnnotations = dependenciesNode.appendNode("dependency")
|
|
||||||
jetbrainsAnnotations.appendNode("groupId", "org.jetbrains")
|
|
||||||
jetbrainsAnnotations.appendNode("artifactId", "annotations")
|
|
||||||
jetbrainsAnnotations.appendNode("version", "19.0.0")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
publish.dependsOn clean, test, jar
|
|
|
@ -0,0 +1,128 @@
|
||||||
|
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
`java-library`
|
||||||
|
`maven-publish`
|
||||||
|
id("com.github.hierynomus.license") version "0.16.1"
|
||||||
|
id("com.github.johnrengelman.shadow") version "8.1.0"
|
||||||
|
}
|
||||||
|
|
||||||
|
group = "me.clip"
|
||||||
|
version = "2.11.5-DEV-${System.getProperty("BUILD_NUMBER")}"
|
||||||
|
|
||||||
|
description = "An awesome placeholder provider!"
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
maven("https://oss.sonatype.org/content/repositories/snapshots/")
|
||||||
|
|
||||||
|
mavenCentral()
|
||||||
|
mavenLocal()
|
||||||
|
|
||||||
|
maven("https://repo.codemc.org/repository/maven-public/")
|
||||||
|
maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/")
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation("org.bstats:bstats-bukkit:3.0.1")
|
||||||
|
implementation("net.kyori:adventure-platform-bukkit:4.3.0")
|
||||||
|
|
||||||
|
compileOnly("org.spigotmc:spigot-api:1.20-R0.1-SNAPSHOT")
|
||||||
|
compileOnlyApi("org.jetbrains:annotations:23.0.0")
|
||||||
|
|
||||||
|
testImplementation("org.openjdk.jmh:jmh-core:1.32")
|
||||||
|
testImplementation("org.openjdk.jmh:jmh-generator-annprocess:1.32")
|
||||||
|
|
||||||
|
testImplementation("org.junit.jupiter:junit-jupiter-engine:5.8.2")
|
||||||
|
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.8.1")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
java {
|
||||||
|
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||||
|
targetCompatibility = JavaVersion.VERSION_1_8
|
||||||
|
|
||||||
|
withJavadocJar()
|
||||||
|
withSourcesJar()
|
||||||
|
}
|
||||||
|
|
||||||
|
license {
|
||||||
|
header = rootProject.file("config/headers/main.txt")
|
||||||
|
|
||||||
|
include("**/*.java")
|
||||||
|
mapping("java", "JAVADOC_STYLE")
|
||||||
|
|
||||||
|
encoding = "UTF-8"
|
||||||
|
|
||||||
|
ext {
|
||||||
|
set("year", 2021)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val javaComponent: SoftwareComponent = components["java"]
|
||||||
|
|
||||||
|
tasks {
|
||||||
|
processResources {
|
||||||
|
eachFile { expand("version" to project.version) }
|
||||||
|
}
|
||||||
|
|
||||||
|
build {
|
||||||
|
dependsOn(named("shadowJar"))
|
||||||
|
}
|
||||||
|
|
||||||
|
withType<JavaCompile> {
|
||||||
|
options.encoding = "UTF-8"
|
||||||
|
}
|
||||||
|
|
||||||
|
withType<Javadoc> {
|
||||||
|
isFailOnError = false
|
||||||
|
|
||||||
|
with(options as StandardJavadocDocletOptions) {
|
||||||
|
addStringOption("Xdoclint:none", "-quiet")
|
||||||
|
addStringOption("encoding", "UTF-8")
|
||||||
|
addStringOption("charSet", "UTF-8")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
withType<ShadowJar> {
|
||||||
|
archiveClassifier.set("")
|
||||||
|
|
||||||
|
relocate("org.bstats", "me.clip.placeholderapi.metrics")
|
||||||
|
relocate("net.kyori", "me.clip.placeholderapi.libs.kyori")
|
||||||
|
}
|
||||||
|
|
||||||
|
test {
|
||||||
|
useJUnitPlatform()
|
||||||
|
}
|
||||||
|
|
||||||
|
publishing {
|
||||||
|
publications {
|
||||||
|
create<MavenPublication>("maven") {
|
||||||
|
artifactId = "placeholderapi"
|
||||||
|
from(javaComponent)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
maven {
|
||||||
|
if ("-DEV" in version.toString()) {
|
||||||
|
url = uri("https://repo.extendedclip.com/content/repositories/dev/")
|
||||||
|
} else {
|
||||||
|
url = uri("https://repo.extendedclip.com/content/repositories/placeholderapi/")
|
||||||
|
}
|
||||||
|
|
||||||
|
credentials {
|
||||||
|
username = System.getenv("JENKINS_USER")
|
||||||
|
password = System.getenv("JENKINS_PASS")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
publish.get().setDependsOn(listOf(build.get()))
|
||||||
|
}
|
||||||
|
|
||||||
|
configurations {
|
||||||
|
testImplementation {
|
||||||
|
extendsFrom(compileOnly.get())
|
||||||
|
}
|
||||||
|
}
|
|
@ -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.2-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
rootProject.name = 'PlaceholderAPI'
|
|
|
@ -0,0 +1 @@
|
||||||
|
rootProject.name = "PlaceholderAPI"
|
|
@ -22,11 +22,6 @@ package me.clip.placeholderapi.commands.impl.cloud;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
||||||
import me.clip.placeholderapi.commands.PlaceholderCommand;
|
import me.clip.placeholderapi.commands.PlaceholderCommand;
|
||||||
import me.clip.placeholderapi.util.Msg;
|
import me.clip.placeholderapi.util.Msg;
|
||||||
|
@ -34,12 +29,17 @@ import org.bukkit.command.CommandSender;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Unmodifiable;
|
import org.jetbrains.annotations.Unmodifiable;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public final class CommandECloud extends PlaceholderCommand {
|
public final class CommandECloud extends PlaceholderCommand {
|
||||||
|
|
||||||
@Unmodifiable
|
@Unmodifiable
|
||||||
private static final List<PlaceholderCommand> COMMANDS = ImmutableList
|
private static final List<PlaceholderCommand> COMMANDS = ImmutableList
|
||||||
.of(new CommandECloudClear(),
|
.of(new CommandECloudClear(),
|
||||||
new CommandECloudToggle(),
|
|
||||||
new CommandECloudStatus(),
|
new CommandECloudStatus(),
|
||||||
new CommandECloudUpdate(),
|
new CommandECloudUpdate(),
|
||||||
new CommandECloudRefresh(),
|
new CommandECloudRefresh(),
|
||||||
|
@ -79,8 +79,6 @@ public final class CommandECloud extends PlaceholderCommand {
|
||||||
Msg.msg(sender,
|
Msg.msg(sender,
|
||||||
"&b&lPlaceholderAPI &8- &7eCloud Help Menu &8- ",
|
"&b&lPlaceholderAPI &8- &7eCloud Help Menu &8- ",
|
||||||
" ",
|
" ",
|
||||||
"&b/papi &fenable/disable/toggle",
|
|
||||||
" &7&oEnable or disable the eCloud",
|
|
||||||
"&b/papi &fecloud status",
|
"&b/papi &fecloud status",
|
||||||
" &7&oView status of the eCloud",
|
" &7&oView status of the eCloud",
|
||||||
"&b/papi &fecloud list <all/{author}/installed> {page}",
|
"&b/papi &fecloud list <all/{author}/installed> {page}",
|
||||||
|
@ -115,10 +113,8 @@ public final class CommandECloud extends PlaceholderCommand {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(target instanceof CommandECloudToggle) && !plugin.getPlaceholderAPIConfig()
|
if (!plugin.getPlaceholderAPIConfig().isCloudEnabled()) {
|
||||||
.isCloudEnabled()) {
|
Msg.msg(sender, "&cThe eCloud Manager is not enabled! To enable it, set 'cloud_enabled' to true and reload the plugin.");
|
||||||
Msg.msg(sender,
|
|
||||||
"&cThe eCloud Manager is not enabled!");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
package me.clip.placeholderapi.commands.impl.cloud;
|
package me.clip.placeholderapi.commands.impl.cloud;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
@ -37,6 +38,25 @@ public final class CommandECloudDownload extends PlaceholderCommand {
|
||||||
super("download");
|
super("download");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isBlockedExpansion(String name) {
|
||||||
|
String env = System.getenv("PAPI_BLOCKED_EXPANSIONS");
|
||||||
|
if (env == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Arrays.stream(env.split(","))
|
||||||
|
.anyMatch(s -> s.equalsIgnoreCase(name));
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean areUnverifiedExpansionsAllowed(@NotNull final PlaceholderAPIPlugin plugin) {
|
||||||
|
String env = System.getenv("PAPI_ALLOW_UNVERIFIED_EXPANSIONS");
|
||||||
|
if (env != null) {
|
||||||
|
return env.equalsIgnoreCase("true");
|
||||||
|
}
|
||||||
|
|
||||||
|
return plugin.getPlaceholderAPIConfig().cloudAllowUnverifiedExpansions();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin,
|
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin,
|
||||||
@NotNull final CommandSender sender, @NotNull final String alias,
|
@NotNull final CommandSender sender, @NotNull final String alias,
|
||||||
|
@ -47,6 +67,12 @@ public final class CommandECloudDownload extends PlaceholderCommand {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isBlockedExpansion(params.get(0))) {
|
||||||
|
Msg.msg(sender,
|
||||||
|
"&cThis expansion can't be downloaded.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
final CloudExpansion expansion = plugin.getCloudExpansionManager()
|
final CloudExpansion expansion = plugin.getCloudExpansionManager()
|
||||||
.findCloudExpansionByName(params.get(0)).orElse(null);
|
.findCloudExpansionByName(params.get(0)).orElse(null);
|
||||||
if (expansion == null) {
|
if (expansion == null) {
|
||||||
|
@ -55,6 +81,11 @@ public final class CommandECloudDownload extends PlaceholderCommand {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!expansion.isVerified() && !this.areUnverifiedExpansionsAllowed(plugin)) {
|
||||||
|
Msg.msg(sender, "&cThe expansion '&f" + params.get(0) + "&c' is not verified and can only be downloaded manually from &fhttps://placeholderapi.com/ecloud");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
final CloudExpansion.Version version;
|
final CloudExpansion.Version version;
|
||||||
if (params.size() < 2) {
|
if (params.size() < 2) {
|
||||||
version = expansion.getVersion(expansion.getLatestVersion());
|
version = expansion.getVersion(expansion.getLatestVersion());
|
||||||
|
@ -86,9 +117,7 @@ public final class CommandECloudDownload extends PlaceholderCommand {
|
||||||
.getVersion() + "] &ato file: &f" + file.getName(),
|
.getVersion() + "] &ato file: &f" + file.getName(),
|
||||||
"&aMake sure to type &f/papi reload &ato enable your new expansion!");
|
"&aMake sure to type &f/papi reload &ato enable your new expansion!");
|
||||||
|
|
||||||
plugin.getCloudExpansionManager().clean();
|
plugin.getCloudExpansionManager().load();
|
||||||
plugin.getCloudExpansionManager()
|
|
||||||
.fetch(plugin.getPlaceholderAPIConfig().cloudAllowUnverifiedExpansions());
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,9 +38,7 @@ public final class CommandECloudRefresh extends PlaceholderCommand {
|
||||||
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin,
|
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin,
|
||||||
@NotNull final CommandSender sender, @NotNull final String alias,
|
@NotNull final CommandSender sender, @NotNull final String alias,
|
||||||
@NotNull @Unmodifiable final List<String> params) {
|
@NotNull @Unmodifiable final List<String> params) {
|
||||||
plugin.getCloudExpansionManager().clean();
|
plugin.getCloudExpansionManager().load();
|
||||||
plugin.getCloudExpansionManager()
|
|
||||||
.fetch(plugin.getPlaceholderAPIConfig().cloudAllowUnverifiedExpansions());
|
|
||||||
|
|
||||||
Msg.msg(sender,
|
Msg.msg(sender,
|
||||||
"&aThe eCloud manager has been refreshed!");
|
"&aThe eCloud manager has been refreshed!");
|
||||||
|
|
|
@ -54,7 +54,7 @@ public final class CommandECloudStatus extends PlaceholderCommand {
|
||||||
|
|
||||||
if (updateCount > 0) {
|
if (updateCount > 0) {
|
||||||
builder.append("&eYou have &f").append(updateCount)
|
builder.append("&eYou have &f").append(updateCount)
|
||||||
.append(updateCount > 1 ? "&e expansions" : "&e expansion").append("installed that ")
|
.append(updateCount > 1 ? "&e expansions" : "&e expansion").append(" installed that ")
|
||||||
.append(updateCount > 1 ? "have an" : "has an").append(" update available.");
|
.append(updateCount > 1 ? "have an" : "has an").append(" update available.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,74 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of PlaceholderAPI
|
|
||||||
*
|
|
||||||
* PlaceholderAPI
|
|
||||||
* Copyright (c) 2015 - 2021 PlaceholderAPI Team
|
|
||||||
*
|
|
||||||
* PlaceholderAPI free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* PlaceholderAPI is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package me.clip.placeholderapi.commands.impl.cloud;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
|
||||||
import me.clip.placeholderapi.commands.PlaceholderCommand;
|
|
||||||
import me.clip.placeholderapi.util.Msg;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.annotations.Unmodifiable;
|
|
||||||
|
|
||||||
public final class CommandECloudToggle extends PlaceholderCommand {
|
|
||||||
|
|
||||||
public CommandECloudToggle() {
|
|
||||||
super("toggle", "enable", "disable");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void evaluate(@NotNull final PlaceholderAPIPlugin plugin,
|
|
||||||
@NotNull final CommandSender sender, @NotNull final String alias,
|
|
||||||
@NotNull @Unmodifiable final List<String> params) {
|
|
||||||
final boolean desiredState;
|
|
||||||
final boolean currentState = plugin.getPlaceholderAPIConfig().isCloudEnabled();
|
|
||||||
|
|
||||||
switch (alias.toLowerCase(Locale.ROOT)) {
|
|
||||||
case "enable":
|
|
||||||
desiredState = true;
|
|
||||||
break;
|
|
||||||
case "disable":
|
|
||||||
desiredState = false;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
desiredState = !currentState;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (desiredState == currentState) {
|
|
||||||
Msg.msg(sender, "&7The eCloud Manager is already " + (desiredState ? "enabled" : "disabled"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
plugin.getPlaceholderAPIConfig().setCloudEnabled(desiredState);
|
|
||||||
|
|
||||||
if (desiredState) {
|
|
||||||
plugin.getCloudExpansionManager().load();
|
|
||||||
} else {
|
|
||||||
plugin.getCloudExpansionManager().kill();
|
|
||||||
}
|
|
||||||
|
|
||||||
Msg.msg(sender, "&aThe eCloud Manager has been " + (desiredState ? "enabled" : "disabled"));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -54,7 +54,7 @@ public final class CommandExpansionRegister extends PlaceholderCommand {
|
||||||
final LocalExpansionManager manager = plugin.getLocalExpansionManager();
|
final LocalExpansionManager manager = plugin.getLocalExpansionManager();
|
||||||
|
|
||||||
final File file = new File(manager.getExpansionsFolder(), params.get(0));
|
final File file = new File(manager.getExpansionsFolder(), params.get(0));
|
||||||
if (!file.exists()) {
|
if (!file.exists() || !file.getParentFile().equals(manager.getExpansionsFolder())) {
|
||||||
Msg.msg(sender,
|
Msg.msg(sender,
|
||||||
"&cThe file &f" + file.getName() + "&c doesn't exist!");
|
"&cThe file &f" + file.getName() + "&c doesn't exist!");
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -30,7 +30,6 @@ import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
||||||
import me.clip.placeholderapi.commands.PlaceholderCommand;
|
import me.clip.placeholderapi.commands.PlaceholderCommand;
|
||||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||||
import me.clip.placeholderapi.util.Msg;
|
import me.clip.placeholderapi.util.Msg;
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
@ -123,13 +122,9 @@ public final class CommandParse extends PlaceholderCommand {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (broadcast) {
|
if (broadcast) {
|
||||||
Msg.broadcast(message);
|
Bukkit.broadcastMessage(message);
|
||||||
} else {
|
} else {
|
||||||
if (!(sender instanceof Player)) {
|
sender.sendMessage(message);
|
||||||
Msg.msg(sender, message);
|
|
||||||
} else {
|
|
||||||
((Player) sender).spigot().sendMessage(TextComponent.fromLegacyText(message));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,7 +151,8 @@ public final class CommandParse extends PlaceholderCommand {
|
||||||
final String message = PlaceholderAPI
|
final String message = PlaceholderAPI
|
||||||
.setRelationalPlaceholders(((Player) targetOne), ((Player) targetTwo),
|
.setRelationalPlaceholders(((Player) targetOne), ((Player) targetTwo),
|
||||||
String.join(" ", params.subList(2, params.size())));
|
String.join(" ", params.subList(2, params.size())));
|
||||||
Msg.msg(sender, message);
|
|
||||||
|
sender.sendMessage(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,10 @@ public enum NMSVersion {
|
||||||
SPIGOT_1_16_R3("v1_16_R3"),
|
SPIGOT_1_16_R3("v1_16_R3"),
|
||||||
SPIGOT_1_17_R1("v1_17_R1"),
|
SPIGOT_1_17_R1("v1_17_R1"),
|
||||||
SPIGOT_1_18_R1("v1_18_R1"),
|
SPIGOT_1_18_R1("v1_18_R1"),
|
||||||
SPIGOT_1_19("v1_19_R1");
|
SPIGOT_1_19_R1("v1_19_R1"),
|
||||||
|
SPIGOT_1_19_R2("v1_19_R2"),
|
||||||
|
SPIGOT_1_19_R3("v1_19_R3"),
|
||||||
|
SPIGOT_1_20_R1("v1_20_R1");
|
||||||
|
|
||||||
private final String version;
|
private final String version;
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,14 @@ import org.jetbrains.annotations.Nullable;
|
||||||
*/
|
*/
|
||||||
public abstract class PlaceholderExpansion extends PlaceholderHook {
|
public abstract class PlaceholderExpansion extends PlaceholderHook {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type is {@link Type#INTERNAL} by default.
|
||||||
|
* For external expansions, the type is updated on {@link me.clip.placeholderapi.expansion.manager.LocalExpansionManager#register(Class) register}.
|
||||||
|
* @since 2.11.4
|
||||||
|
*/
|
||||||
|
@ApiStatus.Internal
|
||||||
|
protected Type expansionType = Type.INTERNAL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The placeholder identifier of this expansion. May not contain {@literal %},
|
* The placeholder identifier of this expansion. May not contain {@literal %},
|
||||||
* {@literal {}} or _
|
* {@literal {}} or _
|
||||||
|
@ -159,6 +167,27 @@ public abstract class PlaceholderExpansion extends PlaceholderHook {
|
||||||
return PlaceholderAPIPlugin.getInstance();
|
return PlaceholderAPIPlugin.getInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the type of the expansion
|
||||||
|
*
|
||||||
|
* @return the type of the expansion
|
||||||
|
* @since 2.11.4
|
||||||
|
*/
|
||||||
|
@ApiStatus.Internal
|
||||||
|
public Type getExpansionType() {
|
||||||
|
return expansionType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the type of the expansion
|
||||||
|
* @param expansionType the new type
|
||||||
|
* @since 2.11.4
|
||||||
|
*/
|
||||||
|
@ApiStatus.Internal
|
||||||
|
public void setExpansionType(Type expansionType) {
|
||||||
|
this.expansionType = expansionType;
|
||||||
|
}
|
||||||
|
|
||||||
// === Configuration ===
|
// === Configuration ===
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -166,7 +195,7 @@ public abstract class PlaceholderExpansion extends PlaceholderHook {
|
||||||
* null when not specified.
|
* null when not specified.
|
||||||
* <br>You may use the {@link Configurable} interface to define default values set
|
* <br>You may use the {@link Configurable} interface to define default values set
|
||||||
*
|
*
|
||||||
* @return ConfigurationSection that this epxpansion has.
|
* @return ConfigurationSection that this expansion has.
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public final ConfigurationSection getConfigSection() {
|
public final ConfigurationSection getConfigSection() {
|
||||||
|
@ -394,8 +423,8 @@ public abstract class PlaceholderExpansion extends PlaceholderHook {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final String toString() {
|
public final String toString() {
|
||||||
return String.format("PlaceholderExpansion[name: '%s', author: '%s', version: '%s']", getName(),
|
return String.format("PlaceholderExpansion[name: '%s', author: '%s', version: '%s', type: '%s']", getName(),
|
||||||
getAuthor(), getVersion());
|
getAuthor(), getVersion(), getExpansionType());
|
||||||
}
|
}
|
||||||
|
|
||||||
// === Deprecated API ===
|
// === Deprecated API ===
|
||||||
|
@ -432,4 +461,19 @@ public abstract class PlaceholderExpansion extends PlaceholderHook {
|
||||||
public String getLink() {
|
public String getLink() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum Type {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An expansion provided by a plugin is considered internal
|
||||||
|
*/
|
||||||
|
INTERNAL,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An expansion loaded from the expansions folder is considered external
|
||||||
|
*/
|
||||||
|
EXTERNAL
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,6 +53,7 @@ import java.util.stream.Collectors;
|
||||||
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
||||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||||
import me.clip.placeholderapi.expansion.cloud.CloudExpansion;
|
import me.clip.placeholderapi.expansion.cloud.CloudExpansion;
|
||||||
|
import me.clip.placeholderapi.util.Msg;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Unmodifiable;
|
import org.jetbrains.annotations.Unmodifiable;
|
||||||
|
|
||||||
|
@ -99,7 +100,7 @@ public final class CloudExpansionManager {
|
||||||
|
|
||||||
public void load() {
|
public void load() {
|
||||||
clean();
|
clean();
|
||||||
fetch(plugin.getPlaceholderAPIConfig().cloudAllowUnverifiedExpansions());
|
fetch();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void kill() {
|
public void kill() {
|
||||||
|
@ -169,7 +170,7 @@ public final class CloudExpansionManager {
|
||||||
await.clear();
|
await.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void fetch(final boolean allowUnverified) {
|
public void fetch() {
|
||||||
plugin.getLogger().info("Fetching available expansion information...");
|
plugin.getLogger().info("Fetching available expansion information...");
|
||||||
|
|
||||||
ASYNC_EXECUTOR.submit(
|
ASYNC_EXECUTOR.submit(
|
||||||
|
@ -189,9 +190,6 @@ public final class CloudExpansionManager {
|
||||||
|| expansion.getVersion(expansion.getLatestVersion()) == null) {
|
|| expansion.getVersion(expansion.getLatestVersion()) == null) {
|
||||||
toRemove.add(entry.getKey());
|
toRemove.add(entry.getKey());
|
||||||
}
|
}
|
||||||
if (!allowUnverified && !expansion.isVerified()) {
|
|
||||||
toRemove.add(entry.getKey());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String name : toRemove) {
|
for (String name : toRemove) {
|
||||||
|
@ -202,7 +200,7 @@ public final class CloudExpansionManager {
|
||||||
plugin.getLogger().log(Level.WARNING, "Failed to download expansion information", e);
|
plugin.getLogger().log(Level.WARNING, "Failed to download expansion information", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
// loop thru what's left on the main thread
|
// loop through what's left on the main thread
|
||||||
plugin
|
plugin
|
||||||
.getServer()
|
.getServer()
|
||||||
.getScheduler()
|
.getScheduler()
|
||||||
|
@ -268,8 +266,7 @@ public final class CloudExpansionManager {
|
||||||
await.remove(toIndexName(expansion));
|
await.remove(toIndexName(expansion));
|
||||||
|
|
||||||
if (exception != null) {
|
if (exception != null) {
|
||||||
plugin.getLogger().log(Level.SEVERE,
|
Msg.severe("Failed to download %s:%s", exception, expansion.getName(), expansion.getVersion());
|
||||||
"failed to download " + expansion.getName() + ":" + version.getVersion(), exception);
|
|
||||||
}
|
}
|
||||||
}, ASYNC_EXECUTOR);
|
}, ASYNC_EXECUTOR);
|
||||||
|
|
||||||
|
|
|
@ -187,6 +187,8 @@ public final class LocalExpansionManager implements Listener {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
expansion.setExpansionType(PlaceholderExpansion.Type.EXTERNAL);
|
||||||
|
|
||||||
if (!expansion.register()) {
|
if (!expansion.register()) {
|
||||||
Msg.warn("Cannot load expansion %s due to an unknown issue.", expansion.getIdentifier());
|
Msg.warn("Cannot load expansion %s due to an unknown issue.", expansion.getIdentifier());
|
||||||
|
@ -209,6 +211,11 @@ public final class LocalExpansionManager implements Listener {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attempt to register a {@link PlaceholderExpansion}
|
||||||
|
* @param expansion the expansion to register
|
||||||
|
* @return if the expansion was registered
|
||||||
|
*/
|
||||||
@ApiStatus.Internal
|
@ApiStatus.Internal
|
||||||
public boolean register(@NotNull final PlaceholderExpansion expansion) {
|
public boolean register(@NotNull final PlaceholderExpansion expansion) {
|
||||||
final String identifier = expansion.getIdentifier().toLowerCase(Locale.ROOT);
|
final String identifier = expansion.getIdentifier().toLowerCase(Locale.ROOT);
|
||||||
|
@ -217,6 +224,12 @@ public final class LocalExpansionManager implements Listener {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Avoid loading two external expansions with the same identifier
|
||||||
|
if (expansion.getExpansionType() == PlaceholderExpansion.Type.EXTERNAL && expansions.containsKey(identifier)) {
|
||||||
|
Msg.warn("Failed to load external expansion %s. Identifier is already in use.", expansion.getIdentifier());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (expansion instanceof Configurable) {
|
if (expansion instanceof Configurable) {
|
||||||
Map<String, Object> defaults = ((Configurable) expansion).getDefaults();
|
Map<String, Object> defaults = ((Configurable) expansion).getDefaults();
|
||||||
String pre = "expansions." + identifier + ".";
|
String pre = "expansions." + identifier + ".";
|
||||||
|
@ -281,21 +294,24 @@ public final class LocalExpansionManager implements Listener {
|
||||||
Bukkit.getPluginManager().registerEvents(((Listener) expansion), plugin);
|
Bukkit.getPluginManager().registerEvents(((Listener) expansion), plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
Msg.info("Successfully registered expansion: %s [%s]", expansion.getIdentifier(),
|
Msg.info(
|
||||||
expansion.getVersion());
|
"Successfully registered %s expansion: %s [%s]",
|
||||||
|
expansion.getExpansionType().name().toLowerCase(),
|
||||||
|
expansion.getIdentifier(),
|
||||||
|
expansion.getVersion()
|
||||||
|
);
|
||||||
|
|
||||||
if (expansion instanceof Taskable) {
|
if (expansion instanceof Taskable) {
|
||||||
((Taskable) expansion).start();
|
((Taskable) expansion).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.getPlaceholderAPIConfig().isCloudEnabled()) {
|
// Check eCloud for updates only if the expansion is external
|
||||||
final Optional<CloudExpansion> cloudExpansionOptional =
|
if (plugin.getPlaceholderAPIConfig().isCloudEnabled() && expansion.getExpansionType() == PlaceholderExpansion.Type.EXTERNAL) {
|
||||||
plugin.getCloudExpansionManager().findCloudExpansionByName(identifier);
|
final Optional<CloudExpansion> cloudExpansionOptional = plugin.getCloudExpansionManager().findCloudExpansionByName(identifier);
|
||||||
if (cloudExpansionOptional.isPresent()) {
|
if (cloudExpansionOptional.isPresent()) {
|
||||||
CloudExpansion cloudExpansion = cloudExpansionOptional.get();
|
CloudExpansion cloudExpansion = cloudExpansionOptional.get();
|
||||||
cloudExpansion.setHasExpansion(true);
|
cloudExpansion.setHasExpansion(true);
|
||||||
cloudExpansion.setShouldUpdate(
|
cloudExpansion.setShouldUpdate(!cloudExpansion.getLatestVersion().equals(expansion.getVersion()));
|
||||||
!cloudExpansion.getLatestVersion().equals(expansion.getVersion()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -388,7 +404,7 @@ public final class LocalExpansionManager implements Listener {
|
||||||
@NotNull
|
@NotNull
|
||||||
public CompletableFuture<@NotNull List<@Nullable Class<? extends PlaceholderExpansion>>> findExpansionsOnDisk() {
|
public CompletableFuture<@NotNull List<@Nullable Class<? extends PlaceholderExpansion>>> findExpansionsOnDisk() {
|
||||||
File[] files = folder.listFiles((dir, name) -> name.endsWith(".jar"));
|
File[] files = folder.listFiles((dir, name) -> name.endsWith(".jar"));
|
||||||
if(files == null){
|
if (files == null) {
|
||||||
return CompletableFuture.completedFuture(Collections.emptyList());
|
return CompletableFuture.completedFuture(Collections.emptyList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -420,12 +436,11 @@ public final class LocalExpansionManager implements Listener {
|
||||||
}
|
}
|
||||||
|
|
||||||
return expansionClass;
|
return expansionClass;
|
||||||
} catch (final VerifyError ex) {
|
} catch (VerifyError | NoClassDefFoundError e) {
|
||||||
Msg.severe("Failed to load expansion class %s (is a dependency missing?", file.getName() + ')');
|
Msg.severe("Failed to load expansion %s (is a dependency missing?)", e, file.getName());
|
||||||
Msg.severe("Cause: %s %s", ex.getClass().getSimpleName(), ex.getMessage());
|
|
||||||
return null;
|
return null;
|
||||||
} catch (final Exception ex) {
|
} catch (Exception e) {
|
||||||
throw new CompletionException(ex);
|
throw new CompletionException(e.getMessage() + " (expansion file: " + file.getAbsolutePath() + ")", e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
name: "@name@"
|
name: PlaceholderAPI
|
||||||
main: "me.clip.placeholderapi.PlaceholderAPIPlugin"
|
main: "me.clip.placeholderapi.PlaceholderAPIPlugin"
|
||||||
|
|
||||||
version: "@version@"
|
version: ${version}
|
||||||
author: HelpChat
|
author: HelpChat
|
||||||
|
|
||||||
api-version: "1.13"
|
api-version: "1.13"
|
||||||
description: "@description@"
|
description: "An awesome placeholder provider!"
|
||||||
|
|
||||||
commands:
|
commands:
|
||||||
placeholderapi:
|
placeholderapi:
|
||||||
|
@ -37,7 +37,6 @@ permissions:
|
||||||
placeholderapi.ecloud.info: true
|
placeholderapi.ecloud.info: true
|
||||||
placeholderapi.ecloud.list: true
|
placeholderapi.ecloud.list: true
|
||||||
placeholderapi.ecloud.clear: true
|
placeholderapi.ecloud.clear: true
|
||||||
placeholderapi.ecloud.toggle: true
|
|
||||||
placeholderapi.ecloud.status: true
|
placeholderapi.ecloud.status: true
|
||||||
placeholderapi.ecloud.update: true
|
placeholderapi.ecloud.update: true
|
||||||
placeholderapi.ecloud.refresh: true
|
placeholderapi.ecloud.refresh: true
|
||||||
|
@ -82,9 +81,6 @@ permissions:
|
||||||
placeholderapi.ecloud.clear:
|
placeholderapi.ecloud.clear:
|
||||||
default: "op"
|
default: "op"
|
||||||
description: "Allows you to clear the local eCloud expansion cache"
|
description: "Allows you to clear the local eCloud expansion cache"
|
||||||
placeholderapi.ecloud.toggle:
|
|
||||||
default: "op"
|
|
||||||
description: "Allows you to toggle/enable/disable the eCloud manager"
|
|
||||||
placeholderapi.ecloud.status:
|
placeholderapi.ecloud.status:
|
||||||
default: "op"
|
default: "op"
|
||||||
description: "Allows you to view the status of eCloud expansions"
|
description: "Allows you to view the status of eCloud expansions"
|
||||||
|
@ -99,4 +95,4 @@ permissions:
|
||||||
description: "Allows you to download an expansion from the eCloud"
|
description: "Allows you to download an expansion from the eCloud"
|
||||||
placeholderapi.ecloud.placeholders:
|
placeholderapi.ecloud.placeholders:
|
||||||
default: "op"
|
default: "op"
|
||||||
description: "Allows you to view the placeholders of a eCloud expansion"
|
description: "Allows you to view the placeholders of a eCloud expansion"
|
||||||
|
|
Loading…
Reference in New Issue