mirror of
https://github.com/darksaid98/nightcore-spigot.git
synced 2026-12-04 06:28:51 +00:00
v2.7.6
- Add support for the 'fallback' argument of the Translatable tag. - Apply PlaceholderAPI for menu titles if enabled in the menu config. - Split 'spigot' and 'paper' bridge into modules. - Full reload support for the nightcore plugin.
This commit is contained in:
1 parent
84addd3454
commit
12a85ce198
326 files changed
+3586
-1534
No files matched your search
@@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>su.nightexpress.nightcore</groupId>
|
||||
<artifactId>nightcore</artifactId>
|
||||
<version>2.7.6</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>paper</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>21</maven.compiler.source>
|
||||
<maven.compiler.target>21</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>papermc</id>
|
||||
<url>https://repo.papermc.io/repository/maven-public/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>io.papermc.paper</groupId>
|
||||
<artifactId>paper-api</artifactId>
|
||||
<version>1.21.5-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>su.nightexpress.nightcore</groupId>
|
||||
<artifactId>bridge</artifactId>
|
||||
<version>2.7.6</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,324 @@
|
||||
package su.nightexpress.nightcore.bridge.paper;
|
||||
|
||||
import com.destroystokyo.paper.profile.PlayerProfile;
|
||||
import io.papermc.paper.datacomponent.DataComponentType;
|
||||
import io.papermc.paper.datacomponent.DataComponentTypes;
|
||||
import io.papermc.paper.datacomponent.item.TooltipDisplay;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.title.Title;
|
||||
import net.kyori.adventure.translation.Translatable;
|
||||
import net.kyori.adventure.util.Ticks;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.SimpleCommandMap;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.InventoryView;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.MenuType;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import su.nightexpress.nightcore.bridge.wrap.NightProfile;
|
||||
import su.nightexpress.nightcore.util.BukkitThing;
|
||||
import su.nightexpress.nightcore.util.Lists;
|
||||
import su.nightexpress.nightcore.util.Version;
|
||||
import su.nightexpress.nightcore.util.bridge.RegistryType;
|
||||
import su.nightexpress.nightcore.util.bridge.Software;
|
||||
import su.nightexpress.nightcore.util.bridge.wrapper.ComponentBuildable;
|
||||
import su.nightexpress.nightcore.util.bridge.wrapper.NightComponent;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class PaperBridge implements Software {
|
||||
|
||||
private Set<DataComponentType> commonComponentsToHide;
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getName() {
|
||||
return "paper-bridge";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPaper() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean initialize() {
|
||||
if (Version.isAtLeast(Version.MC_1_21_5)) {
|
||||
this.commonComponentsToHide = BukkitThing.getAll(RegistryType.Paper.DATA_COMPONENT_TYPE);
|
||||
this.commonComponentsToHide.remove(DataComponentTypes.LORE);
|
||||
this.commonComponentsToHide.remove(DataComponentTypes.ITEM_NAME);
|
||||
this.commonComponentsToHide.remove(DataComponentTypes.ITEM_MODEL);
|
||||
this.commonComponentsToHide.remove(DataComponentTypes.CUSTOM_NAME);
|
||||
this.commonComponentsToHide.remove(DataComponentTypes.CUSTOM_MODEL_DATA);
|
||||
this.commonComponentsToHide.remove(DataComponentTypes.TOOLTIP_DISPLAY);
|
||||
this.commonComponentsToHide.remove(DataComponentTypes.TOOLTIP_STYLE);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public int nextEntityId() {
|
||||
return Bukkit.getUnsafe().nextEntityId();
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public SimpleCommandMap getCommandMap() {
|
||||
return (SimpleCommandMap) Bukkit.getCommandMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public Map<String, Command> getKnownCommands(@NotNull SimpleCommandMap commandMap) {
|
||||
return commandMap.getKnownCommands();
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public PaperComponent textComponent(@NotNull String text) {
|
||||
return PaperComponent.text(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public PaperComponent translateComponent(@NotNull String key) {
|
||||
return PaperComponent.translate(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public PaperComponent translateComponent(@NotNull String key, @Nullable String fallback) {
|
||||
return PaperComponent.translate(key, fallback);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public PaperComponent buildComponent(@NotNull List<ComponentBuildable> childrens) {
|
||||
return PaperComponent.builder(childrens);
|
||||
}
|
||||
|
||||
// @NotNull
|
||||
// private static Component fromNightComponent(@NotNull String component) {
|
||||
// return fromNightComponent(NightMessage.parse(component));
|
||||
// }
|
||||
|
||||
@NotNull
|
||||
static Component fromNightComponent(@NotNull NightComponent component) {
|
||||
return ((PaperComponent)component).getParent();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String serializeComponent(@NotNull Component component) {
|
||||
return MiniMessage.miniMessage().serialize(component);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public NightProfile createProfile(@NotNull UUID uuid) {
|
||||
return new PaperProfile(Bukkit.createProfile(uuid));
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public NightProfile createProfile(@NotNull String name) {
|
||||
return new PaperProfile(Bukkit.createProfile(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public NightProfile createProfile(@Nullable UUID uuid, @Nullable String name) {
|
||||
return new PaperProfile(Bukkit.createProfile(uuid, name));
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public NightProfile getProfile(@NotNull OfflinePlayer player) {
|
||||
return new PaperProfile(player.getPlayerProfile());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendTitles(@NotNull Player player, @NotNull NightComponent title, @NotNull NightComponent subtitle, int fadeIn, int stay, int fadeOut) {
|
||||
Component titleComp = fromNightComponent(title);
|
||||
Component subComp = fromNightComponent(subtitle);
|
||||
|
||||
Title.Times times = Title.Times.times(Ticks.duration(fadeIn), Ticks.duration(stay), Ticks.duration(fadeIn));
|
||||
Title titles = Title.title(titleComp, subComp, times);
|
||||
|
||||
player.showTitle(titles);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public InventoryView createView(@NotNull MenuType menuType, @NotNull NightComponent title, @NotNull Player player) {
|
||||
if (Version.isAtLeast(Version.MC_1_21_4)) {
|
||||
return menuType.typed().builder().title(fromNightComponent(title)).build(player);
|
||||
}
|
||||
else {
|
||||
return menuType.typed().create(player, fromNightComponent(title));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getTranslationKey(@NotNull Material material) {
|
||||
return getTranslation(material);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getTranslationKey(@NotNull Attribute attribute) {
|
||||
return getTranslation(attribute);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getTranslationKey(@NotNull EntityType entityType) {
|
||||
return getTranslation(entityType);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getTranslationKey(@NotNull Enchantment enchantment) {
|
||||
return getTranslation(enchantment);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getTranslationKey(@NotNull PotionEffectType effectType) {
|
||||
return getTranslation(effectType);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String getTranslation(@NotNull Translatable translatable) {
|
||||
return translatable.translationKey();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public ItemStack setType(@NotNull ItemStack itemStack, @NotNull Material material) {
|
||||
return itemStack.withType(material);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void editMeta(@NotNull ItemStack itemStack, @NotNull Consumer<ItemMeta> consumer) {
|
||||
itemStack.editMeta(consumer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends ItemMeta> void editMeta(@NotNull ItemStack itemStack, @NotNull Class<T> clazz, @NotNull Consumer<T> consumer) {
|
||||
itemStack.editMeta(clazz, consumer);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public String getCustomName(@NotNull ItemMeta meta) {
|
||||
Component component;
|
||||
if (Version.isBehind(Version.MC_1_21_4)) {
|
||||
component = meta.displayName();
|
||||
}
|
||||
else {
|
||||
component = meta.customName();
|
||||
}
|
||||
return component == null ? null : serializeComponent(component);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomName(@NotNull ItemMeta meta, @NotNull NightComponent name) {
|
||||
if (Version.isBehind(Version.MC_1_21_4)) {
|
||||
meta.displayName(fromNightComponent(name));
|
||||
}
|
||||
else {
|
||||
meta.customName(fromNightComponent(name));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public String getItemName(@NotNull ItemMeta meta) {
|
||||
return meta.hasItemName() ? serializeComponent(meta.itemName()) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItemName(@NotNull ItemMeta meta, @NotNull NightComponent name) {
|
||||
meta.itemName(fromNightComponent(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public List<String> getLore(@NotNull ItemMeta meta) {
|
||||
List<Component> lore = meta.lore();
|
||||
return lore == null ? null : Lists.modify(lore, PaperBridge::serializeComponent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLore(@NotNull ItemMeta meta, @NotNull List<NightComponent> lore) {
|
||||
meta.lore(Lists.modify(lore, PaperBridge::fromNightComponent));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public NightProfile getOwnerProfile(@NotNull ItemStack itemStack) {
|
||||
if (!(itemStack.getItemMeta() instanceof SkullMeta skullMeta)) return null;
|
||||
|
||||
PlayerProfile profile = skullMeta.getPlayerProfile();
|
||||
return profile == null ? null : new PaperProfile(profile);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Set<String> getCommonComponentsToHide() {
|
||||
if (this.commonComponentsToHide == null) return new HashSet<>(); // Fix for <= 1.21.4
|
||||
|
||||
return /*BukkitThing.allFromRegistry(Registry.DATA_COMPONENT_TYPE)*/this.commonComponentsToHide.stream().map(BukkitThing::getAsString).collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public Set<String> getHiddenComponents(@NotNull ItemStack itemStack) {
|
||||
TooltipDisplay tooltipDisplay = itemStack.getData(DataComponentTypes.TOOLTIP_DISPLAY);
|
||||
if (tooltipDisplay == null) return Collections.emptySet();
|
||||
|
||||
return tooltipDisplay.hiddenComponents().stream().map(BukkitThing::getAsString).collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hideComponents(@NotNull ItemStack itemStack) {
|
||||
// TooltipDisplay tooltipDisplay = TooltipDisplay.tooltipDisplay().hiddenComponents(this.commonComponentsToHide).build();
|
||||
// itemStack.setData(DataComponentTypes.TOOLTIP_DISPLAY, tooltipDisplay);
|
||||
//
|
||||
if (commonComponentsToHide == null) return;
|
||||
|
||||
hidePaperComponents(itemStack, this.commonComponentsToHide);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hideComponents(@NotNull ItemStack itemStack, @NotNull Set<String> componentNames) {
|
||||
Set<DataComponentType> componentTypes = componentNames.stream().map(name -> BukkitThing.getByString(RegistryType.Paper.DATA_COMPONENT_TYPE, name))
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
hidePaperComponents(itemStack, componentTypes);
|
||||
}
|
||||
|
||||
public static void hidePaperComponents(@NotNull ItemStack itemStack, @NotNull Set<DataComponentType> componentTypes) {
|
||||
TooltipDisplay tooltipDisplay = TooltipDisplay.tooltipDisplay().hiddenComponents(componentTypes).build();
|
||||
itemStack.setData(DataComponentTypes.TOOLTIP_DISPLAY, tooltipDisplay);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,218 @@
|
||||
package su.nightexpress.nightcore.bridge.paper;
|
||||
|
||||
import net.kyori.adventure.key.Key;
|
||||
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.TextColor;
|
||||
import net.kyori.adventure.text.format.TextDecoration;
|
||||
import net.kyori.adventure.text.serializer.json.JSONComponentSerializer;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import su.nightexpress.nightcore.util.Lists;
|
||||
import su.nightexpress.nightcore.util.bridge.wrapper.ClickEventType;
|
||||
import su.nightexpress.nightcore.util.bridge.wrapper.NightComponent;
|
||||
import su.nightexpress.nightcore.util.bridge.wrapper.ComponentBuildable;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.List;
|
||||
|
||||
public class PaperComponent implements NightComponent {
|
||||
|
||||
private Component parent;
|
||||
|
||||
public PaperComponent(@NotNull Component parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static PaperComponent text(@NotNull String text) {
|
||||
return new PaperComponent(Component.text(text));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static PaperComponent translate(@NotNull String key) {
|
||||
return new PaperComponent(Component.translatable(key));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static PaperComponent translate(@NotNull String key, @Nullable String fallback) {
|
||||
return new PaperComponent(Component.translatable(key, fallback));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static PaperComponent builder(@NotNull List<ComponentBuildable> childrens) {
|
||||
// Force remove all decortaions, otherwise it'll be decorated by default (italic on items, etc).
|
||||
var builder = Component.text().decorations(Lists.newSet(TextDecoration.values()), false);
|
||||
|
||||
childrens.forEach(child -> {
|
||||
PaperComponent childComponent = (PaperComponent) child.toComponent();
|
||||
builder.append(childComponent.parent);
|
||||
});
|
||||
|
||||
return new PaperComponent(builder.build());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Component getParent() {
|
||||
return this.parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public NightComponent duplicate() {
|
||||
return new PaperComponent(Component.empty().append(this.parent).asComponent());
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String toJson() {
|
||||
return JSONComponentSerializer.json().serialize(this.parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String toLegacy() {
|
||||
return LegacyComponentSerializer.legacy('§').serialize(this.parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void send(@NotNull CommandSender sender) {
|
||||
sender.sendMessage(this.parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendActionBar(@NotNull Player player) {
|
||||
player.sendActionBar(this.parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return this.parent instanceof TextComponent textComponent && textComponent.content().isEmpty() && textComponent.children().isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isText() {
|
||||
return this.parent instanceof TextComponent;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getText() {
|
||||
return this.parent instanceof TextComponent textComponent ? textComponent.content() : "";
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public List<PaperComponent> getChildrens() {
|
||||
return this.parent.children().stream().map(PaperComponent::new).toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setChildrens(@NotNull List<NightComponent> childrens) {
|
||||
this.parent = this.parent.children(childrens.stream().map(PaperBridge::fromNightComponent).toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addChildren(@NotNull NightComponent other) {
|
||||
this.parent = this.parent.append(PaperBridge.fromNightComponent(other));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setText(@NotNull String text) {
|
||||
if (this.parent instanceof TextComponent textComponent) {
|
||||
this.parent = textComponent.content(text);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColor(@NotNull Color color) {
|
||||
this.parent = this.parent.color(TextColor.color(color.getRed(), color.getGreen(), color.getBlue()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setClickEvent(@NotNull ClickEventType type, @NotNull String value) {
|
||||
ClickEvent.Action action = switch (type) {
|
||||
case COPY_TO_CLIPBOARD -> ClickEvent.Action.COPY_TO_CLIPBOARD;
|
||||
case SUGGEST_COMMAND -> ClickEvent.Action.SUGGEST_COMMAND;
|
||||
case RUN_COMMAND -> ClickEvent.Action.RUN_COMMAND;
|
||||
case CHANGE_PAGE -> ClickEvent.Action.CHANGE_PAGE;
|
||||
case OPEN_FILE -> ClickEvent.Action.OPEN_FILE;
|
||||
case OPEN_URL -> ClickEvent.Action.OPEN_URL;
|
||||
};
|
||||
|
||||
this.parent = this.parent.clickEvent(ClickEvent.clickEvent(action, value));
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void setHoverEvent(@NotNull HoverEventType type, @NotNull String value) {
|
||||
// HoverEvent<?> event = null;
|
||||
//
|
||||
// switch (type) {
|
||||
// case SHOW_TEXT -> {
|
||||
// PaperComponent component = (PaperComponent) NightMessage.parse(value);
|
||||
// event = HoverEvent.showText(component.parent);
|
||||
// }
|
||||
// case SHOW_ITEM -> {
|
||||
// ItemStack itemStack = ItemNbt.getHoverEventItem(value);
|
||||
// event = itemStack == null ? null : itemStack.asHoverEvent();
|
||||
// }
|
||||
// }
|
||||
// if (event == null) return;
|
||||
//
|
||||
// this.parent = this.parent.hoverEvent(event);
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void setHoverEvent(@NotNull NightComponent text) {
|
||||
Component component = PaperBridge.fromNightComponent(text);
|
||||
this.parent = this.parent.hoverEvent(HoverEvent.showText(component));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHoverEvent(@NotNull ItemStack itemStack) {
|
||||
this.parent = this.parent.hoverEvent(itemStack.asHoverEvent());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFont(@NotNull String font) {
|
||||
this.parent = this.parent.font(Key.key(font));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBold(boolean bold) {
|
||||
this.parent = this.parent.decoration(TextDecoration.BOLD, bold);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItalic(boolean italic) {
|
||||
this.parent = this.parent.decoration(TextDecoration.ITALIC, italic);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setObfuscated(boolean obfuscated) {
|
||||
this.parent = this.parent.decoration(TextDecoration.OBFUSCATED, obfuscated);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUnderlined(boolean underlined) {
|
||||
this.parent = this.parent.decoration(TextDecoration.UNDERLINED, underlined);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStrikethrough(boolean strikethrough) {
|
||||
this.parent = this.parent.decoration(TextDecoration.STRIKETHROUGH, strikethrough);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PaperComponent{" +
|
||||
"parent=" + parent +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package su.nightexpress.nightcore.bridge.paper;
|
||||
|
||||
import com.destroystokyo.paper.profile.PlayerProfile;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
import org.bukkit.profile.PlayerTextures;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import su.nightexpress.nightcore.bridge.wrap.NightProfile;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class PaperProfile implements NightProfile {
|
||||
|
||||
private final PlayerProfile backend;
|
||||
|
||||
public PaperProfile(@NotNull PlayerProfile backend) {
|
||||
this.backend = backend;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(@NotNull SkullMeta meta) {
|
||||
meta.setPlayerProfile(this.backend);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public UUID getId() {
|
||||
return this.backend.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public String getName() {
|
||||
return this.backend.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public PlayerTextures getTextures() {
|
||||
return this.backend.getTextures();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTextures(@Nullable PlayerTextures textures) {
|
||||
this.backend.setTextures(textures);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isComplete() {
|
||||
return this.backend.isComplete();
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public CompletableFuture<NightProfile> update() {
|
||||
return this.backend.update().thenApplyAsync(PaperProfile::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PaperProfile{" +
|
||||
"backend=" + backend +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user