diff --git a/bridge/pom.xml b/bridge/pom.xml index 1e711fe..00b2461 100644 --- a/bridge/pom.xml +++ b/bridge/pom.xml @@ -6,7 +6,7 @@ su.nightexpress.nightcore nightcore - 2.7.9 + 2.7.10 bridge @@ -35,7 +35,7 @@ su.nightexpress.nightcore utils - 2.7.9 + 2.7.10 diff --git a/bridge/src/main/java/su/nightexpress/nightcore/bridge/wrap/NightSound.java b/bridge/src/main/java/su/nightexpress/nightcore/bridge/wrap/NightSound.java new file mode 100644 index 0000000..f5c5116 --- /dev/null +++ b/bridge/src/main/java/su/nightexpress/nightcore/bridge/wrap/NightSound.java @@ -0,0 +1,20 @@ +package su.nightexpress.nightcore.bridge.wrap; + +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; + +public interface NightSound { + + boolean isSilent(); + + void play(@NotNull Player player); + + void play(@NotNull Location location); + + @NotNull String getName(); + + float getVolume(); + + float getPitch(); +} diff --git a/bridge/src/main/java/su/nightexpress/nightcore/util/bridge/RegistryType.java b/bridge/src/main/java/su/nightexpress/nightcore/util/bridge/RegistryType.java index ec15d19..93fe679 100644 --- a/bridge/src/main/java/su/nightexpress/nightcore/util/bridge/RegistryType.java +++ b/bridge/src/main/java/su/nightexpress/nightcore/util/bridge/RegistryType.java @@ -72,8 +72,8 @@ public interface RegistryType { class Paper { public static final RegistryType DATA_COMPONENT_TYPE = type(isSpigot -> forPaper(RegistryKey.DATA_COMPONENT_TYPE)); - public static final RegistryType WOLF_SOUND_VARIANT = type(isSpigot -> forPaper(RegistryKey.WOLF_SOUND_VARIANT)); public static final RegistryType> MEMORY_MODULE_TYPE = type(isSpigot -> forPaper(RegistryKey.MEMORY_MODULE_TYPE)); + public static final RegistryType WOLF_SOUND_VARIANT = type(isSpigot -> forPaper(RegistryKey.WOLF_SOUND_VARIANT)); } @NotNull Registry<@NotNull T> getRegistry(); diff --git a/bridge/src/main/java/su/nightexpress/nightcore/util/bridge/Software.java b/bridge/src/main/java/su/nightexpress/nightcore/util/bridge/Software.java index 20d30c7..335e49b 100644 --- a/bridge/src/main/java/su/nightexpress/nightcore/util/bridge/Software.java +++ b/bridge/src/main/java/su/nightexpress/nightcore/util/bridge/Software.java @@ -6,6 +6,7 @@ import org.bukkit.attribute.Attribute; import org.bukkit.command.Command; import org.bukkit.command.SimpleCommandMap; import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.inventory.InventoryView; @@ -78,6 +79,11 @@ public interface Software { @NotNull String getTranslationKey(@NotNull PotionEffectType effectType); + void setCustomName(@NotNull Entity entity, @NotNull NightComponent component); + + @Nullable String getEntityName(@NotNull Entity entity); + + @NotNull ItemStack setType(@NotNull ItemStack itemStack, @NotNull Material material); void editMeta(@NotNull ItemStack itemStack, @NotNull Consumer consumer); diff --git a/main/pom.xml b/main/pom.xml index 5343cc7..f90386e 100644 --- a/main/pom.xml +++ b/main/pom.xml @@ -6,7 +6,7 @@ su.nightexpress.nightcore nightcore - 2.7.9 + 2.7.10 main @@ -53,25 +53,25 @@ su.nightexpress.nightcore bridge - 2.7.9 + 2.7.10 su.nightexpress.nightcore utils - 2.7.9 + 2.7.10 su.nightexpress.nightcore paper - 2.7.9 + 2.7.10 su.nightexpress.nightcore spigot - 2.7.9 + 2.7.10 diff --git a/main/src/main/java/su/nightexpress/nightcore/NightCoreLoader.java b/main/src/main/java/su/nightexpress/nightcore/NightCoreLoader.java index b2882a2..c7d3dd1 100644 --- a/main/src/main/java/su/nightexpress/nightcore/NightCoreLoader.java +++ b/main/src/main/java/su/nightexpress/nightcore/NightCoreLoader.java @@ -21,6 +21,7 @@ public class NightCoreLoader implements PluginLoader { resolver.addRepository(new RemoteRepository.Builder("maven", "default", "https://maven-central.storage-download.googleapis.com/maven2").build()); } + resolver.addDependency(new Dependency(new DefaultArtifact("org.xerial:sqlite-jdbc:3.49.1.0"), null)); resolver.addDependency(new Dependency(new DefaultArtifact("com.zaxxer:HikariCP:6.0.0"), null)); resolver.addDependency(new Dependency(new DefaultArtifact("it.unimi.dsi:fastutil-core:8.5.13"), null)); diff --git a/main/src/main/java/su/nightexpress/nightcore/config/ConfigValue.java b/main/src/main/java/su/nightexpress/nightcore/config/ConfigValue.java index c4cfb46..14434ae 100644 --- a/main/src/main/java/su/nightexpress/nightcore/config/ConfigValue.java +++ b/main/src/main/java/su/nightexpress/nightcore/config/ConfigValue.java @@ -179,6 +179,11 @@ public class ConfigValue { return create(path, FileConfig::getSound, FileConfig::set, defaultValue, description); } + @NotNull + public static ConfigValue create(@NotNull String path, @NotNull su.nightexpress.nightcore.bridge.wrap.NightSound defaultValue, @Nullable String... description) { + return create(path, (config, path2) -> config.readSound(path2), FileConfig::set, defaultValue, description); + } + @NotNull public static ConfigValue create(@NotNull String path, @NotNull UniParticle defaultValue, @Nullable String... description) { Loader reader = UniParticle::read; diff --git a/main/src/main/java/su/nightexpress/nightcore/config/FileConfig.java b/main/src/main/java/su/nightexpress/nightcore/config/FileConfig.java index 6e682e2..82d5a98 100644 --- a/main/src/main/java/su/nightexpress/nightcore/config/FileConfig.java +++ b/main/src/main/java/su/nightexpress/nightcore/config/FileConfig.java @@ -21,6 +21,7 @@ import su.nightexpress.nightcore.NightCorePlugin; import su.nightexpress.nightcore.util.*; import su.nightexpress.nightcore.util.bukkit.NightItem; import su.nightexpress.nightcore.util.bukkit.NightSound; +import su.nightexpress.nightcore.util.sound.AbstractSound; import su.nightexpress.nightcore.util.text.NightMessage; import java.io.File; @@ -333,12 +334,20 @@ public class FileConfig extends YamlConfiguration { } @NotNull + @Deprecated public NightSound getSound(@NotNull String path) { return NightSound.read(this, path); // Update -// if (this.contains(path + ".Name")) { -// return NightSound.read(this, path); // Update -// } -// return NightSound.deserialize(this.getString(path, "null")); + } + + @Nullable + public su.nightexpress.nightcore.bridge.wrap.NightSound readSound(@NotNull String path) { + return AbstractSound.read(this, path); + } + + @Nullable + public su.nightexpress.nightcore.bridge.wrap.NightSound readSound(@NotNull String path, @NotNull su.nightexpress.nightcore.bridge.wrap.NightSound def) { + su.nightexpress.nightcore.bridge.wrap.NightSound sound = this.readSound(path); + return sound == null ? def : sound; } @Deprecated diff --git a/main/src/main/java/su/nightexpress/nightcore/db/AbstractUserManager.java b/main/src/main/java/su/nightexpress/nightcore/db/AbstractUserManager.java index b57cf68..6e79c71 100644 --- a/main/src/main/java/su/nightexpress/nightcore/db/AbstractUserManager.java +++ b/main/src/main/java/su/nightexpress/nightcore/db/AbstractUserManager.java @@ -87,12 +87,19 @@ public abstract class AbstractUserManager

this.saveInDatabase(user)); + // Force save data on quit + disable auto-save and delay synchronization. + this.plugin.runTaskAsync(task -> this.saveScheduled(Collections.singletonList(user))); + //this.plugin.runTaskAsync(task -> this.saveInDatabase(user)); + this.cacheTemporary(user); } public void saveScheduled() { Set users = this.getLoaded().stream().filter(AbstractUser::isAutoSaveReady).collect(Collectors.toCollection(HashSet::new)); + this.saveScheduled(users); + } + + private void saveScheduled(@NotNull Collection users) { if (users.isEmpty()) return; this.dataManager.saveUsers(users); diff --git a/main/src/main/java/su/nightexpress/nightcore/ui/menu/type/AbstractMenu.java b/main/src/main/java/su/nightexpress/nightcore/ui/menu/type/AbstractMenu.java index 73bf3fc..e3b31d9 100644 --- a/main/src/main/java/su/nightexpress/nightcore/ui/menu/type/AbstractMenu.java +++ b/main/src/main/java/su/nightexpress/nightcore/ui/menu/type/AbstractMenu.java @@ -188,6 +188,9 @@ public abstract class AbstractMenu

implements Menu { // Do not yet use new NightItem#getItemStackUpdated method here, until we ensure there are no inventory content relies in #onReady. if (item.getPlayerProfile() != null) { item.getPlayerProfile().update().thenAccept(updated -> { + MenuItem overlap = this.getItem(viewer, slot); + if (overlap != null && overlap.getPriority() >= menuItem.getPriority()) return; + ItemUtil.editMeta(itemStack, SkullMeta.class, updated::apply); inventory.setItem(slot, itemStack); }); diff --git a/main/src/main/java/su/nightexpress/nightcore/util/BlockUtil.java b/main/src/main/java/su/nightexpress/nightcore/util/BlockUtil.java index 82d939d..6d432e4 100644 --- a/main/src/main/java/su/nightexpress/nightcore/util/BlockUtil.java +++ b/main/src/main/java/su/nightexpress/nightcore/util/BlockUtil.java @@ -12,14 +12,6 @@ public class BlockUtil { private static final Set FUNCTIONAL = new HashSet<>(); - public static boolean isFunctional(@NotNull Block block) { - return isFunctional(block.getType()); - } - - public static boolean isFunctional(@NotNull Material material) { - return FUNCTIONAL.contains(material); - } - static { FUNCTIONAL.addAll(Tag.ANVIL.getValues()); FUNCTIONAL.add(Material.BARREL); @@ -41,7 +33,6 @@ public class BlockUtil { FUNCTIONAL.addAll(Tag.SIGNS.getValues()); FUNCTIONAL.add(Material.SMITHING_TABLE); FUNCTIONAL.add(Material.STONECUTTER); - FUNCTIONAL.addAll(Tag.ITEMS_BANNERS.getValues()); FUNCTIONAL.add(Material.BEEHIVE); FUNCTIONAL.addAll(Tag.BEDS.getValues()); FUNCTIONAL.add(Material.BELL); @@ -52,60 +43,68 @@ public class BlockUtil { FUNCTIONAL.addAll(Tag.CAULDRONS.getValues()); FUNCTIONAL.add(Material.CHISELED_BOOKSHELF); FUNCTIONAL.add(Material.COMPOSTER); - FUNCTIONAL.add(Material.CONDUIT); FUNCTIONAL.add(Material.DECORATED_POT); - FUNCTIONAL.add(Material.END_GATEWAY); - FUNCTIONAL.add(Material.END_PORTAL); FUNCTIONAL.add(Material.END_PORTAL_FRAME); - FUNCTIONAL.add(Material.FARMLAND); FUNCTIONAL.add(Material.FLETCHING_TABLE); FUNCTIONAL.add(Material.FLOWER_POT); - FUNCTIONAL.add(Material.FROSTED_ICE); - FUNCTIONAL.addAll(Tag.ITEMS_SKULLS.getValues()); - FUNCTIONAL.add(Material.HEAVY_CORE); FUNCTIONAL.add(Material.JUKEBOX); - FUNCTIONAL.add(Material.LADDER); FUNCTIONAL.add(Material.LODESTONE); FUNCTIONAL.add(Material.SPAWNER); - FUNCTIONAL.add(Material.NETHER_PORTAL); FUNCTIONAL.add(Material.RESPAWN_ANCHOR); - FUNCTIONAL.add(Material.SCAFFOLDING); - FUNCTIONAL.add(Material.SPONGE); - FUNCTIONAL.add(Material.WET_SPONGE); FUNCTIONAL.add(Material.SUSPICIOUS_GRAVEL); FUNCTIONAL.add(Material.SUSPICIOUS_SAND); FUNCTIONAL.add(Material.TNT); FUNCTIONAL.add(Material.TRIAL_SPAWNER); FUNCTIONAL.add(Material.VAULT); FUNCTIONAL.addAll(Tag.BUTTONS.getValues()); - FUNCTIONAL.add(Material.COPPER_BULB); FUNCTIONAL.add(Material.CRAFTER); FUNCTIONAL.add(Material.DAYLIGHT_DETECTOR); FUNCTIONAL.add(Material.DISPENSER); FUNCTIONAL.add(Material.DROPPER); FUNCTIONAL.addAll(Tag.DOORS.getValues()); - FUNCTIONAL.add(Material.HONEY_BLOCK); FUNCTIONAL.add(Material.HOPPER); FUNCTIONAL.add(Material.LEVER); - FUNCTIONAL.add(Material.LIGHTNING_ROD); FUNCTIONAL.add(Material.NOTE_BLOCK); FUNCTIONAL.add(Material.OBSERVER); - FUNCTIONAL.add(Material.PISTON); - FUNCTIONAL.add(Material.PISTON_HEAD); - FUNCTIONAL.add(Material.STICKY_PISTON); - FUNCTIONAL.add(Material.MOVING_PISTON); FUNCTIONAL.addAll(Tag.PRESSURE_PLATES.getValues()); - FUNCTIONAL.addAll(Tag.RAILS.getValues()); - FUNCTIONAL.add(Material.REDSTONE_LAMP); - FUNCTIONAL.add(Material.REDSTONE_WIRE); FUNCTIONAL.add(Material.COMPARATOR); FUNCTIONAL.add(Material.REPEATER); - FUNCTIONAL.add(Material.REDSTONE_TORCH); - FUNCTIONAL.add(Material.SLIME_BLOCK); FUNCTIONAL.add(Material.TARGET); FUNCTIONAL.addAll(Tag.TRAPDOORS.getValues()); FUNCTIONAL.addAll(Tag.FENCE_GATES.getValues()); - FUNCTIONAL.add(Material.TRIPWIRE); FUNCTIONAL.add(Material.TRIPWIRE_HOOK); } + + public static boolean isFunctional(@NotNull Block block) { + return isFunctional(block.getType()); + } + + public static boolean isFunctional(@NotNull Material material) { + return FUNCTIONAL.contains(material); + } + + public static boolean isPressurePlate(@NotNull Material material) { + return Tag.PRESSURE_PLATES.isTagged(material); + } + + public static boolean isButtonLever(@NotNull Material material) { + return Tag.BUTTONS.isTagged(material) || material == Material.LEVER; + //return material.createBlockData() instanceof Switch; + } + + public static boolean isDoor(@NotNull Material material) { + return Tag.DOORS.isTagged(material) || Tag.TRAPDOORS.isTagged(material) || Tag.FENCE_GATES.isTagged(material); + } + + public static boolean isTramplable(@NotNull Material material) { + return material == Material.TURTLE_EGG; + } + + public static boolean isTripwire(@NotNull Material material) { + return material == Material.TRIPWIRE; + } + + public static boolean isPhysicalInteractionBlock(@NotNull Material material) { + return isPressurePlate(material) || isTramplable(material) || isTripwire(material); + } } diff --git a/main/src/main/java/su/nightexpress/nightcore/util/EntityUtil.java b/main/src/main/java/su/nightexpress/nightcore/util/EntityUtil.java index 7f7df2a..a2c5f72 100644 --- a/main/src/main/java/su/nightexpress/nightcore/util/EntityUtil.java +++ b/main/src/main/java/su/nightexpress/nightcore/util/EntityUtil.java @@ -12,6 +12,7 @@ import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import su.nightexpress.nightcore.Engine; +import su.nightexpress.nightcore.util.text.NightMessage; import java.util.Collections; import java.util.HashMap; @@ -27,6 +28,21 @@ public class EntityUtil { return Engine.software().nextEntityId(); } + + public static void setCustomName(@NotNull Entity entity, @NotNull String name) { + Engine.software().setCustomName(entity, NightMessage.parse(name)); + } + + @NotNull + public static String getNameSerialized(@NotNull Entity entity) { + String customName = Engine.software().getEntityName(entity); + if (customName != null) return customName; + + return LangUtil.getSerializedName(entity.getType()); + } + + + public static double getAttribute(@NotNull LivingEntity entity, @NotNull Attribute attribute) { AttributeInstance instance = entity.getAttribute(attribute); return instance == null ? 0D : instance.getValue(); diff --git a/main/src/main/java/su/nightexpress/nightcore/util/ItemUtil.java b/main/src/main/java/su/nightexpress/nightcore/util/ItemUtil.java index fb6ba36..7bebfc6 100644 --- a/main/src/main/java/su/nightexpress/nightcore/util/ItemUtil.java +++ b/main/src/main/java/su/nightexpress/nightcore/util/ItemUtil.java @@ -173,7 +173,8 @@ public class ItemUtil { } public static void setLore(@NotNull ItemMeta meta, @NotNull List lore) { - Engine.software().setLore(meta, Lists.modify(lore, NightMessage::parse)); + // It seems that direct '\n' usage is not supported for item meta anymore since ~1.21.7. + Engine.software().setLore(meta, Lists.modify(NightMessage.splitLineTag(lore), NightMessage::parse)); } diff --git a/main/src/main/java/su/nightexpress/nightcore/util/bukkit/NightSound.java b/main/src/main/java/su/nightexpress/nightcore/util/bukkit/NightSound.java index 1d36719..470393c 100644 --- a/main/src/main/java/su/nightexpress/nightcore/util/bukkit/NightSound.java +++ b/main/src/main/java/su/nightexpress/nightcore/util/bukkit/NightSound.java @@ -12,6 +12,7 @@ import su.nightexpress.nightcore.util.BukkitThing; import su.nightexpress.nightcore.util.NumberUtil; import su.nightexpress.nightcore.util.StringUtil; +@Deprecated public class NightSound implements Writeable { private static final String DELIMITER = ";"; diff --git a/main/src/main/java/su/nightexpress/nightcore/util/sound/AbstractSound.java b/main/src/main/java/su/nightexpress/nightcore/util/sound/AbstractSound.java new file mode 100644 index 0000000..911e6fa --- /dev/null +++ b/main/src/main/java/su/nightexpress/nightcore/util/sound/AbstractSound.java @@ -0,0 +1,76 @@ +package su.nightexpress.nightcore.util.sound; + +import org.bukkit.Sound; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import su.nightexpress.nightcore.bridge.wrap.NightSound; +import su.nightexpress.nightcore.config.FileConfig; +import su.nightexpress.nightcore.config.Writeable; +import su.nightexpress.nightcore.util.BukkitThing; +import su.nightexpress.nightcore.util.NumberUtil; + +public abstract class AbstractSound implements NightSound, Writeable { + + protected static final String DELIMITER = ";"; + + protected static final float MIN_PITCH = 0.5f; + protected static final float MAX_PITCH = 2.0f; + protected static final float MIN_VOLUME = 0f; + protected static final float MAX_VOLUME = 1.0f; + + protected static final float DEFAULT_VOLUME = 0.8f; + protected static final float DEFAULT_PITCH = 1f; + + protected final float volume; + protected final float pitch; + + public AbstractSound(float volume, float pitch) { + this.volume = NumberUtil.clamp(volume, MIN_VOLUME, MAX_VOLUME); + this.pitch = NumberUtil.clamp(pitch, MIN_PITCH, MAX_PITCH); + } + + @NotNull + public static NightSound deserialize(@NotNull String from) { + String[] split = from.split(DELIMITER); + + String name = split[0]; + float volume = split.length >= 2 ? (float) NumberUtil.getDoubleAbs(split[1], MAX_VOLUME) : MAX_VOLUME; + float pitch = split.length >= 3 ? (float) NumberUtil.getDoubleAbs(split[2], 1f) : 1f; + + Sound bukkit = BukkitThing.getSound(name); + return bukkit == null ? CustomSound.of(name, volume, pitch) : VanillaSound.of(bukkit, volume, pitch); + } + + @NotNull + public String serialize() { + return this.getName() + DELIMITER + this.volume + DELIMITER + this.pitch; + } + + @Nullable + public static NightSound read(@NotNull FileConfig config, @NotNull String path) { + String raw = config.getString(path); + if (raw == null) return null; + + return deserialize(raw); + } + + @Override + public void write(@NotNull FileConfig config, @NotNull String path) { + config.set(path, this.serialize()); + } + + @Override + public boolean isSilent() { + return this.volume <= 0f; + } + + @Override + public float getVolume() { + return this.volume; + } + + @Override + public float getPitch() { + return this.pitch; + } +} diff --git a/main/src/main/java/su/nightexpress/nightcore/util/sound/CustomSound.java b/main/src/main/java/su/nightexpress/nightcore/util/sound/CustomSound.java new file mode 100644 index 0000000..a30458f --- /dev/null +++ b/main/src/main/java/su/nightexpress/nightcore/util/sound/CustomSound.java @@ -0,0 +1,55 @@ +package su.nightexpress.nightcore.util.sound; + +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; + +public class CustomSound extends AbstractSound { + + private final String sound; + + public CustomSound(@NotNull String sound, float volume, float pitch) { + super(volume, pitch); + this.sound = sound; + } + + @NotNull + public static CustomSound of(@NotNull String sound) { + return of(sound, DEFAULT_VOLUME); + } + + @NotNull + public static CustomSound of(@NotNull String sound, float volume) { + return of(sound, volume, DEFAULT_PITCH); + } + + @NotNull + public static CustomSound of(@NotNull String sound, float volume, float pitch) { + return new CustomSound(sound, volume, pitch); + } + + @Override + public void play(@NotNull Player player) { + if (this.isSilent()) return; + + Location location = player.getLocation(); + player.playSound(location, this.sound, this.volume, this.pitch); + } + + @Override + public void play(@NotNull Location location) { + if (this.isSilent()) return; + + World world = location.getWorld(); + if (world == null) return; + + world.playSound(location, this.sound, this.volume, this.pitch); + } + + @Override + @NotNull + public String getName() { + return this.sound; + } +} diff --git a/main/src/main/java/su/nightexpress/nightcore/util/sound/VanillaSound.java b/main/src/main/java/su/nightexpress/nightcore/util/sound/VanillaSound.java new file mode 100644 index 0000000..081849a --- /dev/null +++ b/main/src/main/java/su/nightexpress/nightcore/util/sound/VanillaSound.java @@ -0,0 +1,62 @@ +package su.nightexpress.nightcore.util.sound; + +import org.bukkit.Location; +import org.bukkit.Sound; +import org.bukkit.World; +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; +import su.nightexpress.nightcore.util.BukkitThing; + +public class VanillaSound extends AbstractSound { + + private final Sound sound; + + public VanillaSound(@NotNull Sound sound, float volume, float pitch) { + super(volume, pitch); + this.sound = sound; + } + + @NotNull + public static VanillaSound of(@NotNull Sound sound) { + return of(sound, DEFAULT_VOLUME); + } + + @NotNull + public static VanillaSound of(@NotNull Sound sound, float volume) { + return of(sound, volume, DEFAULT_PITCH); + } + + @NotNull + public static VanillaSound of(@NotNull Sound sound, float volume, float pitch) { + return new VanillaSound(sound, volume, pitch); + } + + @Override + public void play(@NotNull Player player) { + if (this.isSilent()) return; + + Location location = player.getLocation(); + player.playSound(location, this.sound, this.volume, this.pitch); + } + + @Override + public void play(@NotNull Location location) { + if (this.isSilent()) return; + + World world = location.getWorld(); + if (world == null) return; + + world.playSound(location, this.sound, this.volume, this.pitch); + } + + @Override + @NotNull + public String getName() { + return BukkitThing.getAsString(this.sound); + } + + @NotNull + public Sound getSound() { + return this.sound; + } +} diff --git a/main/src/main/java/su/nightexpress/nightcore/util/text/NightMessage.java b/main/src/main/java/su/nightexpress/nightcore/util/text/NightMessage.java index 613f9f6..f48444a 100644 --- a/main/src/main/java/su/nightexpress/nightcore/util/text/NightMessage.java +++ b/main/src/main/java/su/nightexpress/nightcore/util/text/NightMessage.java @@ -1,11 +1,13 @@ package su.nightexpress.nightcore.util.text; import org.jetbrains.annotations.NotNull; +import su.nightexpress.nightcore.util.Lists; import su.nightexpress.nightcore.util.bridge.wrapper.NightComponent; import su.nightexpress.nightcore.util.text.tag.TagPool; import su.nightexpress.nightcore.util.text.tag.Tags; import java.util.ArrayList; +import java.util.Collections; import java.util.List; public class NightMessage { @@ -47,6 +49,22 @@ public class NightMessage { return from(string, tagPool).parseIfAbsent(); } + @NotNull + public static List splitLineTag(@NotNull String string) { + return splitLineTag(Lists.newList(string)); + } + + @NotNull + public static List splitLineTag(@NotNull List list) { + List segmented = new ArrayList<>(); + + list.forEach(line -> { + Collections.addAll(segmented, Tags.LINE_BREAK.split(line)); + }); + + return segmented; + } + @NotNull diff --git a/main/src/main/resources/plugin.yml b/main/src/main/resources/plugin.yml index dd46d8b..3ccb33c 100644 --- a/main/src/main/resources/plugin.yml +++ b/main/src/main/resources/plugin.yml @@ -6,5 +6,6 @@ author: NightExpress api-version: 1.20 load: STARTUP libraries: + - org.xerial:sqlite-jdbc:3.49.1.0 - com.zaxxer:HikariCP:6.0.0 - it.unimi.dsi:fastutil-core:8.5.13 \ No newline at end of file diff --git a/paper/pom.xml b/paper/pom.xml index 03f5065..15aa8d8 100644 --- a/paper/pom.xml +++ b/paper/pom.xml @@ -6,7 +6,7 @@ su.nightexpress.nightcore nightcore - 2.7.9 + 2.7.10 paper @@ -35,7 +35,7 @@ su.nightexpress.nightcore bridge - 2.7.9 + 2.7.10 diff --git a/paper/src/main/java/su/nightexpress/nightcore/bridge/paper/PaperBridge.java b/paper/src/main/java/su/nightexpress/nightcore/bridge/paper/PaperBridge.java index eb4fd89..d534661 100644 --- a/paper/src/main/java/su/nightexpress/nightcore/bridge/paper/PaperBridge.java +++ b/paper/src/main/java/su/nightexpress/nightcore/bridge/paper/PaperBridge.java @@ -16,6 +16,7 @@ import org.bukkit.attribute.Attribute; import org.bukkit.command.Command; import org.bukkit.command.SimpleCommandMap; import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.inventory.InventoryView; @@ -210,6 +211,20 @@ public class PaperBridge implements Software { + @Override + public void setCustomName(@NotNull Entity entity, @NotNull NightComponent component) { + entity.customName(fromNightComponent(component)); + } + + @Override + @Nullable + public String getEntityName(@NotNull Entity entity) { + Component component = entity.customName(); + return component == null ? null : serializeComponent(component); + } + + + @Override @NotNull diff --git a/pom.xml b/pom.xml index e1560eb..88b2508 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ su.nightexpress.nightcore nightcore - 2.7.9 + 2.7.10 pom main diff --git a/spigot/pom.xml b/spigot/pom.xml index ff72110..f359645 100644 --- a/spigot/pom.xml +++ b/spigot/pom.xml @@ -6,7 +6,7 @@ su.nightexpress.nightcore nightcore - 2.7.9 + 2.7.10 spigot @@ -35,7 +35,7 @@ su.nightexpress.nightcore bridge - 2.7.9 + 2.7.10 diff --git a/spigot/src/main/java/su/nightexpress/nightcore/bridge/spigot/SpigotBridge.java b/spigot/src/main/java/su/nightexpress/nightcore/bridge/spigot/SpigotBridge.java index eb8d43e..d74c34c 100644 --- a/spigot/src/main/java/su/nightexpress/nightcore/bridge/spigot/SpigotBridge.java +++ b/spigot/src/main/java/su/nightexpress/nightcore/bridge/spigot/SpigotBridge.java @@ -8,6 +8,7 @@ import org.bukkit.attribute.Attribute; import org.bukkit.command.Command; import org.bukkit.command.SimpleCommandMap; import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.inventory.InventoryView; @@ -220,6 +221,20 @@ public class SpigotBridge implements Software { + @Override + public void setCustomName(@NotNull Entity entity, @NotNull NightComponent component) { + entity.setCustomName(component.toLegacy()); + } + + @Override + @Nullable + public String getEntityName(@NotNull Entity entity) { + String name = entity.getCustomName(); + return name == null ? null : LegacyColors.plainColors(name); + } + + + @Override @NotNull public ItemStack setType(@NotNull ItemStack itemStack, @NotNull Material material) { diff --git a/utils/pom.xml b/utils/pom.xml index 6e0bb48..b80000c 100644 --- a/utils/pom.xml +++ b/utils/pom.xml @@ -6,7 +6,7 @@ su.nightexpress.nightcore nightcore - 2.7.9 + 2.7.10 utils