finished kyori impl

This commit is contained in:
PiggyPiglet 2021-07-09 12:24:36 +08:00
parent d7a4acc2f5
commit c4789b7db0
No known key found for this signature in database
GPG Key ID: 0DADDAC359165A31
4 changed files with 27 additions and 30 deletions

@ -13,21 +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() 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/" })
maven({ url = "https://oss.sonatype.org/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"
implementation "net.kyori:adventure-platform-bukkit:4.0.0-SNAPSHOT" 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" compileOnly "org.jetbrains:annotations:19.0.0"
testImplementation "org.openjdk.jmh:jmh-core:1.23" testImplementation "org.openjdk.jmh:jmh-core:1.23"
@ -63,20 +63,7 @@ tasks.withType(Javadoc) {
shadowJar { shadowJar {
archiveClassifier.set("") 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 "org.bstats", "me.clip.placeholderapi.metrics"
relocate "com.google.gson", "me.clip.placeholderapi.libs.gson"
relocate "net.kyori", "me.clip.placeholderapi.libs.kyori" relocate "net.kyori", "me.clip.placeholderapi.libs.kyori"
} }

0
gradlew vendored Normal file → Executable file

@ -33,6 +33,7 @@ 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.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;

@ -44,16 +44,10 @@ import net.kyori.adventure.text.event.ClickEvent;
import net.kyori.adventure.text.event.HoverEvent; import net.kyori.adventure.text.event.HoverEvent;
import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.format.TextDecoration; 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.command.CommandSender;
import org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer;
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 org.w3c.dom.Text;
import static net.kyori.adventure.text.Component.*; import static net.kyori.adventure.text.Component.*;
import static net.kyori.adventure.text.format.NamedTextColor.*; import static net.kyori.adventure.text.format.NamedTextColor.*;
@ -138,8 +132,7 @@ 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');
} }
private static Component getMessage(@NotNull final List<CloudExpansion> expansions, private static Component getMessage(@NotNull final List<CloudExpansion> expansions,
@ -187,12 +180,31 @@ public final class CommandECloudExpansionList extends PlaceholderCommand {
); );
line.hoverEvent(HoverEvent.showText(hoverText.build())); line.hoverEvent(HoverEvent.showText(hoverText.build()));
if (index != expansions.size() - 1) {
line.append(newline()); line.append(newline());
}
message.append(line.build()); 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(); 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 int limit = (int) Math.ceil((double) expansions.size() / PAGE_SIZE);
final Component message = getMessage(values, page, limit, params.get(0)); final Component message = getMessage(values, page, limit, params.get(0));
// plugin.getAdventure().player((Player) sender).sendMessage(message); 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));
} }
@Override @Override