From c4789b7db028a3fea48b77d460a98e222b45786b Mon Sep 17 00:00:00 2001 From: PiggyPiglet Date: Fri, 9 Jul 2021 12:24:36 +0800 Subject: [PATCH] finished kyori impl --- build.gradle | 19 ++-------- gradlew | 0 .../placeholderapi/PlaceholderAPIPlugin.java | 1 + .../cloud/CommandECloudExpansionList.java | 37 ++++++++++++------- 4 files changed, 27 insertions(+), 30 deletions(-) mode change 100644 => 100755 gradlew diff --git a/build.gradle b/build.gradle index 1654574..5df263f 100644 --- a/build.gradle +++ b/build.gradle @@ -13,21 +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/" }) - maven({ url = "https://oss.sonatype.org/content/repositories/snapshots/" }) } dependencies { - implementation "com.google.code.gson:gson:2.8.6" implementation "org.bstats:bstats-bukkit:2.2.1" implementation "net.kyori:adventure-platform-bukkit:4.0.0-SNAPSHOT" - compileOnly "org.spigotmc:spigot:+" + 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" @@ -63,20 +63,7 @@ tasks.withType(Javadoc) { shadowJar { archiveClassifier.set("") -// destinationDirectory.set(file("server/1.17/plugins")) -// doLast { -// def path = "build/libs/PlaceholderAPI-2.10.10-DEV-null.jar" -// -// ["1.17", "1.8"].each {dest -> -// copy { -// from path -// into "server/${dest}/plugins/" -// } -// } -// } - relocate "org.bstats", "me.clip.placeholderapi.metrics" - relocate "com.google.gson", "me.clip.placeholderapi.libs.gson" relocate "net.kyori", "me.clip.placeholderapi.libs.kyori" } diff --git a/gradlew b/gradlew old mode 100644 new mode 100755 diff --git a/src/main/java/me/clip/placeholderapi/PlaceholderAPIPlugin.java b/src/main/java/me/clip/placeholderapi/PlaceholderAPIPlugin.java index 3314caf..b121bd3 100644 --- a/src/main/java/me/clip/placeholderapi/PlaceholderAPIPlugin.java +++ b/src/main/java/me/clip/placeholderapi/PlaceholderAPIPlugin.java @@ -33,6 +33,7 @@ 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; diff --git a/src/main/java/me/clip/placeholderapi/commands/impl/cloud/CommandECloudExpansionList.java b/src/main/java/me/clip/placeholderapi/commands/impl/cloud/CommandECloudExpansionList.java index a3ce804..cb4d38c 100644 --- a/src/main/java/me/clip/placeholderapi/commands/impl/cloud/CommandECloudExpansionList.java +++ b/src/main/java/me/clip/placeholderapi/commands/impl/cloud/CommandECloudExpansionList.java @@ -44,16 +44,10 @@ 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 net.kyori.adventure.text.serializer.gson.GsonComponentSerializer; -import net.minecraft.network.chat.ChatMessageType; -import net.minecraft.network.chat.IChatBaseComponent; -import net.minecraft.network.protocol.game.PacketPlayOutChat; import org.bukkit.command.CommandSender; -import org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer; import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Unmodifiable; -import org.w3c.dom.Text; import static net.kyori.adventure.text.Component.*; import static net.kyori.adventure.text.format.NamedTextColor.*; @@ -138,8 +132,7 @@ public final class CommandECloudExpansionList extends PlaceholderCommand { builder.append(" &bPage&7: &a") .append(page) - .append("&r") - .append('\n'); + .append("&r"); } private static Component getMessage(@NotNull final List expansions, @@ -187,12 +180,31 @@ public final class CommandECloudExpansionList extends PlaceholderCommand { ); line.hoverEvent(HoverEvent.showText(hoverText.build())); - line.append(newline()); + + if (index != expansions.size() - 1) { + line.append(newline()); + } message.append(line.build()); } - message.append(text("test").hoverEvent(HoverEvent.showText(text("testtt")))); + if (limit > 1) { + message.append(newline()); + + final TextComponent.Builder left = text("◀", page > 1 ? GRAY : DARK_GRAY).toBuilder(); + + if (page > 1) { + left.clickEvent(ClickEvent.runCommand("/papi ecloud list " + target + " " + (page - 1))); + } + + final TextComponent.Builder right = text("▶", page < limit ? GRAY : DARK_GRAY).toBuilder(); + + if (page < limit) { + right.clickEvent(ClickEvent.runCommand("/papi ecloud list " + target + " " + (page + 1))); + } + + message.append(left, text(" " + page + " ", GREEN), right); + } return message.build(); } @@ -314,10 +326,7 @@ public final class CommandECloudExpansionList extends PlaceholderCommand { final int limit = (int) Math.ceil((double) expansions.size() / PAGE_SIZE); final Component message = getMessage(values, page, limit, params.get(0)); -// plugin.getAdventure().player((Player) sender).sendMessage(message); - System.out.println(GsonComponentSerializer.gson().serialize(message)); - ((CraftPlayer) sender).getHandle().b.sendPacket(new PacketPlayOutChat(IChatBaseComponent.ChatSerializer.a(GsonComponentSerializer.gson().serialize(message)), ChatMessageType.a, ((CraftPlayer) sender).getUniqueId())); - //message.send(((Player) sender)); + plugin.getAdventure().player((Player) sender).sendMessage(message); } @Override