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:
Andre_601 2021-07-11 01:37:09 +02:00 committed by GitHub
parent fa7c30df80
commit b4f6831e54
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 86 additions and 1182 deletions

View File

@ -13,17 +13,21 @@ version "2.10.10-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 "com.google.code.gson:gson:2.8.6"
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"
testImplementation "org.openjdk.jmh:jmh-core:1.23"
@ -60,6 +64,7 @@ shadowJar {
archiveClassifier.set("")
relocate "org.bstats", "me.clip.placeholderapi.metrics"
relocate "net.kyori", "me.clip.placeholderapi.libs.kyori"
}
license {
@ -69,10 +74,6 @@ license {
header = file('config/headers/main.txt')
}
matching('**/JSONMessage.java') {
header = file('config/headers/jsonmessage.txt')
}
ext {
year = 2021
}

0
gradlew vendored Normal file → Executable file
View File

View File

@ -32,6 +32,8 @@ import me.clip.placeholderapi.expansion.manager.CloudExpansionManager;
import me.clip.placeholderapi.expansion.manager.LocalExpansionManager;
import me.clip.placeholderapi.listeners.ServerLoadEventListener;
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.charts.AdvancedPie;
import org.bstats.charts.SimplePie;
@ -75,6 +77,8 @@ public final class PlaceholderAPIPlugin extends JavaPlugin {
@NotNull
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
* 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();
setupExpansions();
adventure = BukkitAudiences.create(this);
if (config.isCloudEnabled()) {
getCloudExpansionManager().load();
}
@ -158,6 +164,9 @@ public final class PlaceholderAPIPlugin extends JavaPlugin {
Bukkit.getScheduler().cancelTasks(this);
adventure.close();
adventure = null;
instance = null;
}
@ -185,6 +194,15 @@ public final class PlaceholderAPIPlugin extends JavaPlugin {
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.
*

View File

@ -26,14 +26,7 @@ import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.google.common.primitives.Ints;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
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.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Function;
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.expansion.PlaceholderExpansion;
import me.clip.placeholderapi.expansion.cloud.CloudExpansion;
import me.clip.placeholderapi.libs.JSONMessage;
import me.clip.placeholderapi.util.Format;
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.entity.Player;
import org.jetbrains.annotations.NotNull;
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 {
private static final int PAGE_SIZE = 10;
@ -132,77 +132,81 @@ public final class CommandECloudExpansionList extends PlaceholderCommand {
builder.append(" &bPage&7: &a")
.append(page)
.append("&r")
.append('\n');
.append("&r");
}
@NotNull
private static JSONMessage getMessage(@NotNull final List<CloudExpansion> expansions,
private static Component getMessage(@NotNull final List<CloudExpansion> expansions,
final int page, final int limit, @NotNull final String target) {
final SimpleDateFormat format = PlaceholderAPIPlugin.getDateFormat();
final StringBuilder tooltip = new StringBuilder();
final JSONMessage message = JSONMessage.create();
final TextComponent.Builder message = text();
for (int index = 0; index < expansions.size(); index++) {
final CloudExpansion expansion = expansions.get(index);
final TextComponent.Builder line = text();
tooltip.append("&bClick to download this expansion!")
.append('\n')
.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 int expansionNumber = index + ((page - 1) * PAGE_SIZE) + 1;
line.append(text(expansionNumber + ". ", DARK_GRAY));
final String description = expansion.getDescription();
if (description != null && !description.isEmpty()) {
tooltip.append('\n')
.append('\n')
.append("&f")
.append(description.replace("\r", "").trim());
final NamedTextColor expansionColour;
if (expansion.shouldUpdate()) {
expansionColour = GOLD;
} else {
if (expansion.hasExpansion()) {
expansionColour = GREEN;
} else {
expansionColour = GRAY;
}
}
message.then(Msg.color(
"&8" + (index + ((page - 1) * PAGE_SIZE) + 1) + ".&r " + (expansion.shouldUpdate() ? "&6"
: expansion.hasExpansion() ? "&a" : "&7") + expansion.getName()));
line.append(text(expansion.getName(), expansionColour));
message.tooltip(Msg.color(tooltip.toString()));
message.suggestCommand("/papi ecloud download " + expansion.getName());
line.clickEvent(ClickEvent.suggestCommand("/papi ecloud download " + expansion.getName()));
if (index < expansions.size() - 1) {
message.newline();
final TextComponent.Builder hoverText = text("Click to download this expansion!", AQUA)
.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) {
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) {
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) {
message.runCommand("/papi ecloud list " + target + " " + (page + 1));
right.clickEvent(ClickEvent.runCommand("/papi ecloud list " + target + " " + (page + 1)));
}
message.append(left, text(" " + page + " ", GREEN), right);
}
return message;
return message.build();
}
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 JSONMessage message = getMessage(values, page, limit, params.get(0));
message.send(((Player) sender));
final Component message = getMessage(values, page, limit, params.get(0));
plugin.getAdventure().player((Player) sender).sendMessage(message);
}
@Override

View File

@ -41,7 +41,8 @@ public enum NMSVersion {
SPIGOT_1_15_R1("v1_15_R1"),
SPIGOT_1_16_R1("v1_16_R1"),
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;

File diff suppressed because it is too large Load Diff