mirror of
https://github.com/PlaceholderAPI/PlaceholderAPI
synced 2024-11-18 00:46:55 +01:00
Update development from master (#662)
* Add contributing and expansion section * Start using new Issue template system * Create bug_report.yml * Rename feature_request.md to feature_request_old.md * Create feature_request.yml * fix unique name * Update feature_request_old.md * Add Checkboxes * Add checkboxes * disable default issue body * Delete bug_report_old.md * Delete feature_request_old.md * Rename bug_report_new.yml to bug_report.yml * Check if deleting this fixed the PR... * Use description in favour of about * improve feature_request.md * Update bug_report.yml * Assign "Type: Issue (Unconfirmed)" label * Use lists and not comma-separated string * Update feature_request.yml * Use id option for error and dump fields * Add field for logs * Remove deprecated issue_body type * Update feature_request.yml * Improve description of bug_report.yml * Initial 1.17 Changes * add render * Revert build.gradle dependencies change * Fixed duplicate files * Initial test on adventure * started moving to pure adventure * finished kyori impl * added 1.17 to nmsversion (what does this even do) * removed dev for release * added dev back Co-authored-by: PiggyPiglet <PiggyPiglet@users.noreply.github.com> Co-authored-by: darbyjack <admin@glaremasters.me> Co-authored-by: PiggyPiglet <noreply@piggypiglet.me>
This commit is contained in:
parent
fa7c30df80
commit
b4f6831e54
13
build.gradle
13
build.gradle
@ -13,17 +13,21 @@ version "2.10.10-DEV-${System.getProperty("BUILD_NUMBER")}"
|
|||||||
description "An awesome placeholder provider!"
|
description "An awesome placeholder provider!"
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
|
maven({ url = "https://oss.sonatype.org/content/repositories/snapshots/" })
|
||||||
|
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
mavenLocal()
|
||||||
|
|
||||||
maven({ url = "https://repo.codemc.org/repository/maven-public" })
|
maven({ url = "https://repo.codemc.org/repository/maven-public" })
|
||||||
maven({ url = "https://hub.spigotmc.org/nexus/content/repositories/snapshots/" })
|
maven({ url = "https://hub.spigotmc.org/nexus/content/repositories/snapshots/" })
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation "com.google.code.gson:gson:2.8.6"
|
|
||||||
implementation "org.bstats:bstats-bukkit:2.2.1"
|
implementation "org.bstats:bstats-bukkit:2.2.1"
|
||||||
|
|
||||||
compileOnly "org.spigotmc:spigot-api:1.17-R0.1-SNAPSHOT"
|
implementation "net.kyori:adventure-platform-bukkit:4.0.0-SNAPSHOT"
|
||||||
|
|
||||||
|
compileOnly "org.spigotmc:spigot-api:1.17.1-R0.1-SNAPSHOT"
|
||||||
compileOnly "org.jetbrains:annotations:19.0.0"
|
compileOnly "org.jetbrains:annotations:19.0.0"
|
||||||
|
|
||||||
testImplementation "org.openjdk.jmh:jmh-core:1.23"
|
testImplementation "org.openjdk.jmh:jmh-core:1.23"
|
||||||
@ -60,6 +64,7 @@ shadowJar {
|
|||||||
archiveClassifier.set("")
|
archiveClassifier.set("")
|
||||||
|
|
||||||
relocate "org.bstats", "me.clip.placeholderapi.metrics"
|
relocate "org.bstats", "me.clip.placeholderapi.metrics"
|
||||||
|
relocate "net.kyori", "me.clip.placeholderapi.libs.kyori"
|
||||||
}
|
}
|
||||||
|
|
||||||
license {
|
license {
|
||||||
@ -69,10 +74,6 @@ license {
|
|||||||
header = file('config/headers/main.txt')
|
header = file('config/headers/main.txt')
|
||||||
}
|
}
|
||||||
|
|
||||||
matching('**/JSONMessage.java') {
|
|
||||||
header = file('config/headers/jsonmessage.txt')
|
|
||||||
}
|
|
||||||
|
|
||||||
ext {
|
ext {
|
||||||
year = 2021
|
year = 2021
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,8 @@ import me.clip.placeholderapi.expansion.manager.CloudExpansionManager;
|
|||||||
import me.clip.placeholderapi.expansion.manager.LocalExpansionManager;
|
import me.clip.placeholderapi.expansion.manager.LocalExpansionManager;
|
||||||
import me.clip.placeholderapi.listeners.ServerLoadEventListener;
|
import me.clip.placeholderapi.listeners.ServerLoadEventListener;
|
||||||
import me.clip.placeholderapi.updatechecker.UpdateChecker;
|
import me.clip.placeholderapi.updatechecker.UpdateChecker;
|
||||||
|
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
||||||
|
import net.kyori.adventure.text.serializer.craftbukkit.MinecraftComponentSerializer;
|
||||||
import org.bstats.bukkit.Metrics;
|
import org.bstats.bukkit.Metrics;
|
||||||
import org.bstats.charts.AdvancedPie;
|
import org.bstats.charts.AdvancedPie;
|
||||||
import org.bstats.charts.SimplePie;
|
import org.bstats.charts.SimplePie;
|
||||||
@ -75,6 +77,8 @@ public final class PlaceholderAPIPlugin extends JavaPlugin {
|
|||||||
@NotNull
|
@NotNull
|
||||||
private final CloudExpansionManager cloudExpansionManager = new CloudExpansionManager(this);
|
private final CloudExpansionManager cloudExpansionManager = new CloudExpansionManager(this);
|
||||||
|
|
||||||
|
private BukkitAudiences adventure;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the static instance of the main class for PlaceholderAPI. This class is not the actual API
|
* Gets the static instance of the main class for PlaceholderAPI. This class is not the actual API
|
||||||
* class, this is the main class that extends JavaPlugin. For most API methods, use static methods
|
* class, this is the main class that extends JavaPlugin. For most API methods, use static methods
|
||||||
@ -140,6 +144,8 @@ public final class PlaceholderAPIPlugin extends JavaPlugin {
|
|||||||
setupMetrics();
|
setupMetrics();
|
||||||
setupExpansions();
|
setupExpansions();
|
||||||
|
|
||||||
|
adventure = BukkitAudiences.create(this);
|
||||||
|
|
||||||
if (config.isCloudEnabled()) {
|
if (config.isCloudEnabled()) {
|
||||||
getCloudExpansionManager().load();
|
getCloudExpansionManager().load();
|
||||||
}
|
}
|
||||||
@ -158,6 +164,9 @@ public final class PlaceholderAPIPlugin extends JavaPlugin {
|
|||||||
|
|
||||||
Bukkit.getScheduler().cancelTasks(this);
|
Bukkit.getScheduler().cancelTasks(this);
|
||||||
|
|
||||||
|
adventure.close();
|
||||||
|
adventure = null;
|
||||||
|
|
||||||
instance = null;
|
instance = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -185,6 +194,15 @@ public final class PlaceholderAPIPlugin extends JavaPlugin {
|
|||||||
return cloudExpansionManager;
|
return cloudExpansionManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public BukkitAudiences getAdventure() {
|
||||||
|
if(adventure == null) {
|
||||||
|
throw new IllegalStateException("Tried to access Adventure when the plugin was disabled!");
|
||||||
|
}
|
||||||
|
|
||||||
|
return adventure;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Obtain the configuration class for PlaceholderAPI.
|
* Obtain the configuration class for PlaceholderAPI.
|
||||||
*
|
*
|
||||||
|
@ -26,14 +26,7 @@ import com.google.common.collect.Lists;
|
|||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import com.google.common.primitives.Ints;
|
import com.google.common.primitives.Ints;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@ -43,15 +36,22 @@ import me.clip.placeholderapi.commands.PlaceholderCommand;
|
|||||||
import me.clip.placeholderapi.configuration.ExpansionSort;
|
import me.clip.placeholderapi.configuration.ExpansionSort;
|
||||||
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.libs.JSONMessage;
|
|
||||||
import me.clip.placeholderapi.util.Format;
|
import me.clip.placeholderapi.util.Format;
|
||||||
import me.clip.placeholderapi.util.Msg;
|
import me.clip.placeholderapi.util.Msg;
|
||||||
import org.bukkit.ChatColor;
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.TextComponent;
|
||||||
|
import net.kyori.adventure.text.event.ClickEvent;
|
||||||
|
import net.kyori.adventure.text.event.HoverEvent;
|
||||||
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
|
import net.kyori.adventure.text.format.TextDecoration;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Unmodifiable;
|
import org.jetbrains.annotations.Unmodifiable;
|
||||||
|
|
||||||
|
import static net.kyori.adventure.text.Component.*;
|
||||||
|
import static net.kyori.adventure.text.format.NamedTextColor.*;
|
||||||
|
|
||||||
public final class CommandECloudExpansionList extends PlaceholderCommand {
|
public final class CommandECloudExpansionList extends PlaceholderCommand {
|
||||||
|
|
||||||
private static final int PAGE_SIZE = 10;
|
private static final int PAGE_SIZE = 10;
|
||||||
@ -132,77 +132,81 @@ public final class CommandECloudExpansionList extends PlaceholderCommand {
|
|||||||
|
|
||||||
builder.append(" &bPage&7: &a")
|
builder.append(" &bPage&7: &a")
|
||||||
.append(page)
|
.append(page)
|
||||||
.append("&r")
|
.append("&r");
|
||||||
.append('\n');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
private static Component getMessage(@NotNull final List<CloudExpansion> expansions,
|
||||||
private static JSONMessage getMessage(@NotNull final List<CloudExpansion> expansions,
|
|
||||||
final int page, final int limit, @NotNull final String target) {
|
final int page, final int limit, @NotNull final String target) {
|
||||||
final SimpleDateFormat format = PlaceholderAPIPlugin.getDateFormat();
|
final SimpleDateFormat format = PlaceholderAPIPlugin.getDateFormat();
|
||||||
|
|
||||||
final StringBuilder tooltip = new StringBuilder();
|
final TextComponent.Builder message = text();
|
||||||
final JSONMessage message = JSONMessage.create();
|
|
||||||
|
|
||||||
for (int index = 0; index < expansions.size(); index++) {
|
for (int index = 0; index < expansions.size(); index++) {
|
||||||
final CloudExpansion expansion = expansions.get(index);
|
final CloudExpansion expansion = expansions.get(index);
|
||||||
|
final TextComponent.Builder line = text();
|
||||||
|
|
||||||
tooltip.append("&bClick to download this expansion!")
|
final int expansionNumber = index + ((page - 1) * PAGE_SIZE) + 1;
|
||||||
.append('\n')
|
line.append(text(expansionNumber + ". ", DARK_GRAY));
|
||||||
.append('\n')
|
|
||||||
.append("&bAuthor: &f")
|
|
||||||
.append(expansion.getAuthor())
|
|
||||||
.append('\n')
|
|
||||||
.append("&bVerified: ")
|
|
||||||
.append(expansion.isVerified() ? "&a&l✔&r" : "&c&l❌&r")
|
|
||||||
.append('\n')
|
|
||||||
.append("&bLatest Version: &f")
|
|
||||||
.append(expansion.getLatestVersion())
|
|
||||||
.append('\n')
|
|
||||||
.append("&bReleased: &f")
|
|
||||||
.append(format.format(expansion.getLastUpdate()));
|
|
||||||
|
|
||||||
final String description = expansion.getDescription();
|
final NamedTextColor expansionColour;
|
||||||
if (description != null && !description.isEmpty()) {
|
|
||||||
tooltip.append('\n')
|
if (expansion.shouldUpdate()) {
|
||||||
.append('\n')
|
expansionColour = GOLD;
|
||||||
.append("&f")
|
} else {
|
||||||
.append(description.replace("\r", "").trim());
|
if (expansion.hasExpansion()) {
|
||||||
|
expansionColour = GREEN;
|
||||||
|
} else {
|
||||||
|
expansionColour = GRAY;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
message.then(Msg.color(
|
line.append(text(expansion.getName(), expansionColour));
|
||||||
"&8" + (index + ((page - 1) * PAGE_SIZE) + 1) + ".&r " + (expansion.shouldUpdate() ? "&6"
|
|
||||||
: expansion.hasExpansion() ? "&a" : "&7") + expansion.getName()));
|
|
||||||
|
|
||||||
message.tooltip(Msg.color(tooltip.toString()));
|
line.clickEvent(ClickEvent.suggestCommand("/papi ecloud download " + expansion.getName()));
|
||||||
message.suggestCommand("/papi ecloud download " + expansion.getName());
|
|
||||||
|
|
||||||
if (index < expansions.size() - 1) {
|
final TextComponent.Builder hoverText = text("Click to download this expansion!", AQUA)
|
||||||
message.newline();
|
.append(newline()).append(newline())
|
||||||
|
.append(text("Author: ", AQUA)).append(text(expansion.getAuthor(), WHITE))
|
||||||
|
.append(newline())
|
||||||
|
.append(text("Verified: ", AQUA)).append(text(expansion.isVerified() ? "✔" : "❌", expansion.isVerified() ? GREEN : RED, TextDecoration.BOLD))
|
||||||
|
.append(newline())
|
||||||
|
.append(text("Released: ", AQUA)).append(text(format.format(expansion.getLastUpdate()), WHITE))
|
||||||
|
.toBuilder();
|
||||||
|
|
||||||
|
Optional.ofNullable(expansion.getDescription())
|
||||||
|
.filter(description -> !description.isEmpty())
|
||||||
|
.ifPresent(description -> hoverText.append(newline()).append(newline())
|
||||||
|
.append(text(description.replace("\r", "").trim(), WHITE))
|
||||||
|
);
|
||||||
|
|
||||||
|
line.hoverEvent(HoverEvent.showText(hoverText.build()));
|
||||||
|
|
||||||
|
if (index != expansions.size() - 1) {
|
||||||
|
line.append(newline());
|
||||||
}
|
}
|
||||||
|
|
||||||
tooltip.setLength(0);
|
message.append(line.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (limit > 1) {
|
if (limit > 1) {
|
||||||
message.newline();
|
message.append(newline());
|
||||||
|
|
||||||
|
final TextComponent.Builder left = text("◀", page > 1 ? GRAY : DARK_GRAY).toBuilder();
|
||||||
|
|
||||||
message.then("◀")
|
|
||||||
.color(page > 1 ? ChatColor.GRAY : ChatColor.DARK_GRAY);
|
|
||||||
if (page > 1) {
|
if (page > 1) {
|
||||||
message.runCommand("/papi ecloud list " + target + " " + (page - 1));
|
left.clickEvent(ClickEvent.runCommand("/papi ecloud list " + target + " " + (page - 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
message.then(" " + page + " ").color(ChatColor.GREEN);
|
final TextComponent.Builder right = text("▶", page < limit ? GRAY : DARK_GRAY).toBuilder();
|
||||||
|
|
||||||
message.then("▶")
|
|
||||||
.color(page < limit ? ChatColor.GRAY : ChatColor.DARK_GRAY);
|
|
||||||
if (page < limit) {
|
if (page < limit) {
|
||||||
message.runCommand("/papi ecloud list " + target + " " + (page + 1));
|
right.clickEvent(ClickEvent.runCommand("/papi ecloud list " + target + " " + (page + 1)));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return message;
|
message.append(left, text(" " + page + " ", GREEN), right);
|
||||||
|
}
|
||||||
|
|
||||||
|
return message.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void addExpansionTable(@NotNull final List<CloudExpansion> expansions,
|
private static void addExpansionTable(@NotNull final List<CloudExpansion> expansions,
|
||||||
@ -321,8 +325,8 @@ public final class CommandECloudExpansionList extends PlaceholderCommand {
|
|||||||
|
|
||||||
final int limit = (int) Math.ceil((double) expansions.size() / PAGE_SIZE);
|
final int limit = (int) Math.ceil((double) expansions.size() / PAGE_SIZE);
|
||||||
|
|
||||||
final JSONMessage message = getMessage(values, page, limit, params.get(0));
|
final Component message = getMessage(values, page, limit, params.get(0));
|
||||||
message.send(((Player) sender));
|
plugin.getAdventure().player((Player) sender).sendMessage(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -41,7 +41,8 @@ public enum NMSVersion {
|
|||||||
SPIGOT_1_15_R1("v1_15_R1"),
|
SPIGOT_1_15_R1("v1_15_R1"),
|
||||||
SPIGOT_1_16_R1("v1_16_R1"),
|
SPIGOT_1_16_R1("v1_16_R1"),
|
||||||
SPIGOT_1_16_R2("v1_16_R2"),
|
SPIGOT_1_16_R2("v1_16_R2"),
|
||||||
SPIGOT_1_16_R3("v1_16_R3");
|
SPIGOT_1_16_R3("v1_16_R3"),
|
||||||
|
SPIGOT_1_17_R1("v1_17_R1");
|
||||||
|
|
||||||
private final String version;
|
private final String version;
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user