mirror of
https://github.com/darksaid98/nightcore-spigot.git
synced 2026-12-01 14:38:47 +00:00
v2.7.10
This commit is contained in:
1 parent
fd3cdb4529
commit
abc8d5d054
25 files changed
+364
-54
No files matched your search
+2
-2
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>su.nightexpress.nightcore</groupId>
|
<groupId>su.nightexpress.nightcore</groupId>
|
||||||
<artifactId>nightcore</artifactId>
|
<artifactId>nightcore</artifactId>
|
||||||
<version>2.7.9</version>
|
<version>2.7.10</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>bridge</artifactId>
|
<artifactId>bridge</artifactId>
|
||||||
@@ -35,7 +35,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>su.nightexpress.nightcore</groupId>
|
<groupId>su.nightexpress.nightcore</groupId>
|
||||||
<artifactId>utils</artifactId>
|
<artifactId>utils</artifactId>
|
||||||
<version>2.7.9</version>
|
<version>2.7.10</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|||||||
@@ -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();
|
||||||
|
}
|
||||||
@@ -72,8 +72,8 @@ public interface RegistryType<T extends Keyed> {
|
|||||||
class Paper {
|
class Paper {
|
||||||
|
|
||||||
public static final RegistryType<DataComponentType> DATA_COMPONENT_TYPE = type(isSpigot -> forPaper(RegistryKey.DATA_COMPONENT_TYPE));
|
public static final RegistryType<DataComponentType> DATA_COMPONENT_TYPE = type(isSpigot -> forPaper(RegistryKey.DATA_COMPONENT_TYPE));
|
||||||
public static final RegistryType<Wolf.SoundVariant> WOLF_SOUND_VARIANT = type(isSpigot -> forPaper(RegistryKey.WOLF_SOUND_VARIANT));
|
|
||||||
public static final RegistryType<MemoryKey<?>> MEMORY_MODULE_TYPE = type(isSpigot -> forPaper(RegistryKey.MEMORY_MODULE_TYPE));
|
public static final RegistryType<MemoryKey<?>> MEMORY_MODULE_TYPE = type(isSpigot -> forPaper(RegistryKey.MEMORY_MODULE_TYPE));
|
||||||
|
public static final RegistryType<Wolf.SoundVariant> WOLF_SOUND_VARIANT = type(isSpigot -> forPaper(RegistryKey.WOLF_SOUND_VARIANT));
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull Registry<@NotNull T> getRegistry();
|
@NotNull Registry<@NotNull T> getRegistry();
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import org.bukkit.attribute.Attribute;
|
|||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.SimpleCommandMap;
|
import org.bukkit.command.SimpleCommandMap;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.InventoryView;
|
import org.bukkit.inventory.InventoryView;
|
||||||
@@ -78,6 +79,11 @@ public interface Software {
|
|||||||
@NotNull String getTranslationKey(@NotNull PotionEffectType effectType);
|
@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);
|
@NotNull ItemStack setType(@NotNull ItemStack itemStack, @NotNull Material material);
|
||||||
|
|
||||||
void editMeta(@NotNull ItemStack itemStack, @NotNull Consumer<ItemMeta> consumer);
|
void editMeta(@NotNull ItemStack itemStack, @NotNull Consumer<ItemMeta> consumer);
|
||||||
|
|||||||
+5
-5
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>su.nightexpress.nightcore</groupId>
|
<groupId>su.nightexpress.nightcore</groupId>
|
||||||
<artifactId>nightcore</artifactId>
|
<artifactId>nightcore</artifactId>
|
||||||
<version>2.7.9</version>
|
<version>2.7.10</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>main</artifactId>
|
<artifactId>main</artifactId>
|
||||||
@@ -53,25 +53,25 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>su.nightexpress.nightcore</groupId>
|
<groupId>su.nightexpress.nightcore</groupId>
|
||||||
<artifactId>bridge</artifactId>
|
<artifactId>bridge</artifactId>
|
||||||
<version>2.7.9</version>
|
<version>2.7.10</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>su.nightexpress.nightcore</groupId>
|
<groupId>su.nightexpress.nightcore</groupId>
|
||||||
<artifactId>utils</artifactId>
|
<artifactId>utils</artifactId>
|
||||||
<version>2.7.9</version>
|
<version>2.7.10</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>su.nightexpress.nightcore</groupId>
|
<groupId>su.nightexpress.nightcore</groupId>
|
||||||
<artifactId>paper</artifactId>
|
<artifactId>paper</artifactId>
|
||||||
<version>2.7.9</version>
|
<version>2.7.10</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>su.nightexpress.nightcore</groupId>
|
<groupId>su.nightexpress.nightcore</groupId>
|
||||||
<artifactId>spigot</artifactId>
|
<artifactId>spigot</artifactId>
|
||||||
<version>2.7.9</version>
|
<version>2.7.10</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@@ -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.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("com.zaxxer:HikariCP:6.0.0"), null));
|
||||||
resolver.addDependency(new Dependency(new DefaultArtifact("it.unimi.dsi:fastutil-core:8.5.13"), null));
|
resolver.addDependency(new Dependency(new DefaultArtifact("it.unimi.dsi:fastutil-core:8.5.13"), null));
|
||||||
|
|
||||||
|
|||||||
@@ -179,6 +179,11 @@ public class ConfigValue<T> {
|
|||||||
return create(path, FileConfig::getSound, FileConfig::set, defaultValue, description);
|
return create(path, FileConfig::getSound, FileConfig::set, defaultValue, description);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public static ConfigValue<su.nightexpress.nightcore.bridge.wrap.NightSound> 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
|
@NotNull
|
||||||
public static ConfigValue<UniParticle> create(@NotNull String path, @NotNull UniParticle defaultValue, @Nullable String... description) {
|
public static ConfigValue<UniParticle> create(@NotNull String path, @NotNull UniParticle defaultValue, @Nullable String... description) {
|
||||||
Loader<UniParticle> reader = UniParticle::read;
|
Loader<UniParticle> reader = UniParticle::read;
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import su.nightexpress.nightcore.NightCorePlugin;
|
|||||||
import su.nightexpress.nightcore.util.*;
|
import su.nightexpress.nightcore.util.*;
|
||||||
import su.nightexpress.nightcore.util.bukkit.NightItem;
|
import su.nightexpress.nightcore.util.bukkit.NightItem;
|
||||||
import su.nightexpress.nightcore.util.bukkit.NightSound;
|
import su.nightexpress.nightcore.util.bukkit.NightSound;
|
||||||
|
import su.nightexpress.nightcore.util.sound.AbstractSound;
|
||||||
import su.nightexpress.nightcore.util.text.NightMessage;
|
import su.nightexpress.nightcore.util.text.NightMessage;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -333,12 +334,20 @@ public class FileConfig extends YamlConfiguration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
@Deprecated
|
||||||
public NightSound getSound(@NotNull String path) {
|
public NightSound getSound(@NotNull String path) {
|
||||||
return NightSound.read(this, path); // Update
|
return NightSound.read(this, path); // Update
|
||||||
// if (this.contains(path + ".Name")) {
|
}
|
||||||
// return NightSound.read(this, path); // Update
|
|
||||||
// }
|
@Nullable
|
||||||
// return NightSound.deserialize(this.getString(path, "null"));
|
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
|
@Deprecated
|
||||||
|
|||||||
@@ -87,12 +87,19 @@ public abstract class AbstractUserManager<P extends NightPlugin, U extends Abstr
|
|||||||
user.setName(player.getName());
|
user.setName(player.getName());
|
||||||
user.setLastOnline(System.currentTimeMillis());
|
user.setLastOnline(System.currentTimeMillis());
|
||||||
|
|
||||||
this.plugin.runTaskAsync(task -> 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);
|
this.cacheTemporary(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveScheduled() {
|
public void saveScheduled() {
|
||||||
Set<U> users = this.getLoaded().stream().filter(AbstractUser::isAutoSaveReady).collect(Collectors.toCollection(HashSet::new));
|
Set<U> users = this.getLoaded().stream().filter(AbstractUser::isAutoSaveReady).collect(Collectors.toCollection(HashSet::new));
|
||||||
|
this.saveScheduled(users);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void saveScheduled(@NotNull Collection<U> users) {
|
||||||
if (users.isEmpty()) return;
|
if (users.isEmpty()) return;
|
||||||
|
|
||||||
this.dataManager.saveUsers(users);
|
this.dataManager.saveUsers(users);
|
||||||
|
|||||||
@@ -188,6 +188,9 @@ public abstract class AbstractMenu<P extends NightPlugin> implements Menu {
|
|||||||
// Do not yet use new NightItem#getItemStackUpdated method here, until we ensure there are no inventory content relies in #onReady.
|
// Do not yet use new NightItem#getItemStackUpdated method here, until we ensure there are no inventory content relies in #onReady.
|
||||||
if (item.getPlayerProfile() != null) {
|
if (item.getPlayerProfile() != null) {
|
||||||
item.getPlayerProfile().update().thenAccept(updated -> {
|
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);
|
ItemUtil.editMeta(itemStack, SkullMeta.class, updated::apply);
|
||||||
inventory.setItem(slot, itemStack);
|
inventory.setItem(slot, itemStack);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -12,14 +12,6 @@ public class BlockUtil {
|
|||||||
|
|
||||||
private static final Set<Material> FUNCTIONAL = new HashSet<>();
|
private static final Set<Material> 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 {
|
static {
|
||||||
FUNCTIONAL.addAll(Tag.ANVIL.getValues());
|
FUNCTIONAL.addAll(Tag.ANVIL.getValues());
|
||||||
FUNCTIONAL.add(Material.BARREL);
|
FUNCTIONAL.add(Material.BARREL);
|
||||||
@@ -41,7 +33,6 @@ public class BlockUtil {
|
|||||||
FUNCTIONAL.addAll(Tag.SIGNS.getValues());
|
FUNCTIONAL.addAll(Tag.SIGNS.getValues());
|
||||||
FUNCTIONAL.add(Material.SMITHING_TABLE);
|
FUNCTIONAL.add(Material.SMITHING_TABLE);
|
||||||
FUNCTIONAL.add(Material.STONECUTTER);
|
FUNCTIONAL.add(Material.STONECUTTER);
|
||||||
FUNCTIONAL.addAll(Tag.ITEMS_BANNERS.getValues());
|
|
||||||
FUNCTIONAL.add(Material.BEEHIVE);
|
FUNCTIONAL.add(Material.BEEHIVE);
|
||||||
FUNCTIONAL.addAll(Tag.BEDS.getValues());
|
FUNCTIONAL.addAll(Tag.BEDS.getValues());
|
||||||
FUNCTIONAL.add(Material.BELL);
|
FUNCTIONAL.add(Material.BELL);
|
||||||
@@ -52,60 +43,68 @@ public class BlockUtil {
|
|||||||
FUNCTIONAL.addAll(Tag.CAULDRONS.getValues());
|
FUNCTIONAL.addAll(Tag.CAULDRONS.getValues());
|
||||||
FUNCTIONAL.add(Material.CHISELED_BOOKSHELF);
|
FUNCTIONAL.add(Material.CHISELED_BOOKSHELF);
|
||||||
FUNCTIONAL.add(Material.COMPOSTER);
|
FUNCTIONAL.add(Material.COMPOSTER);
|
||||||
FUNCTIONAL.add(Material.CONDUIT);
|
|
||||||
FUNCTIONAL.add(Material.DECORATED_POT);
|
FUNCTIONAL.add(Material.DECORATED_POT);
|
||||||
FUNCTIONAL.add(Material.END_GATEWAY);
|
|
||||||
FUNCTIONAL.add(Material.END_PORTAL);
|
|
||||||
FUNCTIONAL.add(Material.END_PORTAL_FRAME);
|
FUNCTIONAL.add(Material.END_PORTAL_FRAME);
|
||||||
FUNCTIONAL.add(Material.FARMLAND);
|
|
||||||
FUNCTIONAL.add(Material.FLETCHING_TABLE);
|
FUNCTIONAL.add(Material.FLETCHING_TABLE);
|
||||||
FUNCTIONAL.add(Material.FLOWER_POT);
|
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.JUKEBOX);
|
||||||
FUNCTIONAL.add(Material.LADDER);
|
|
||||||
FUNCTIONAL.add(Material.LODESTONE);
|
FUNCTIONAL.add(Material.LODESTONE);
|
||||||
FUNCTIONAL.add(Material.SPAWNER);
|
FUNCTIONAL.add(Material.SPAWNER);
|
||||||
FUNCTIONAL.add(Material.NETHER_PORTAL);
|
|
||||||
FUNCTIONAL.add(Material.RESPAWN_ANCHOR);
|
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_GRAVEL);
|
||||||
FUNCTIONAL.add(Material.SUSPICIOUS_SAND);
|
FUNCTIONAL.add(Material.SUSPICIOUS_SAND);
|
||||||
FUNCTIONAL.add(Material.TNT);
|
FUNCTIONAL.add(Material.TNT);
|
||||||
FUNCTIONAL.add(Material.TRIAL_SPAWNER);
|
FUNCTIONAL.add(Material.TRIAL_SPAWNER);
|
||||||
FUNCTIONAL.add(Material.VAULT);
|
FUNCTIONAL.add(Material.VAULT);
|
||||||
FUNCTIONAL.addAll(Tag.BUTTONS.getValues());
|
FUNCTIONAL.addAll(Tag.BUTTONS.getValues());
|
||||||
FUNCTIONAL.add(Material.COPPER_BULB);
|
|
||||||
FUNCTIONAL.add(Material.CRAFTER);
|
FUNCTIONAL.add(Material.CRAFTER);
|
||||||
FUNCTIONAL.add(Material.DAYLIGHT_DETECTOR);
|
FUNCTIONAL.add(Material.DAYLIGHT_DETECTOR);
|
||||||
FUNCTIONAL.add(Material.DISPENSER);
|
FUNCTIONAL.add(Material.DISPENSER);
|
||||||
FUNCTIONAL.add(Material.DROPPER);
|
FUNCTIONAL.add(Material.DROPPER);
|
||||||
FUNCTIONAL.addAll(Tag.DOORS.getValues());
|
FUNCTIONAL.addAll(Tag.DOORS.getValues());
|
||||||
FUNCTIONAL.add(Material.HONEY_BLOCK);
|
|
||||||
FUNCTIONAL.add(Material.HOPPER);
|
FUNCTIONAL.add(Material.HOPPER);
|
||||||
FUNCTIONAL.add(Material.LEVER);
|
FUNCTIONAL.add(Material.LEVER);
|
||||||
FUNCTIONAL.add(Material.LIGHTNING_ROD);
|
|
||||||
FUNCTIONAL.add(Material.NOTE_BLOCK);
|
FUNCTIONAL.add(Material.NOTE_BLOCK);
|
||||||
FUNCTIONAL.add(Material.OBSERVER);
|
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.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.COMPARATOR);
|
||||||
FUNCTIONAL.add(Material.REPEATER);
|
FUNCTIONAL.add(Material.REPEATER);
|
||||||
FUNCTIONAL.add(Material.REDSTONE_TORCH);
|
|
||||||
FUNCTIONAL.add(Material.SLIME_BLOCK);
|
|
||||||
FUNCTIONAL.add(Material.TARGET);
|
FUNCTIONAL.add(Material.TARGET);
|
||||||
FUNCTIONAL.addAll(Tag.TRAPDOORS.getValues());
|
FUNCTIONAL.addAll(Tag.TRAPDOORS.getValues());
|
||||||
FUNCTIONAL.addAll(Tag.FENCE_GATES.getValues());
|
FUNCTIONAL.addAll(Tag.FENCE_GATES.getValues());
|
||||||
FUNCTIONAL.add(Material.TRIPWIRE);
|
|
||||||
FUNCTIONAL.add(Material.TRIPWIRE_HOOK);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -12,6 +12,7 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import su.nightexpress.nightcore.Engine;
|
import su.nightexpress.nightcore.Engine;
|
||||||
|
import su.nightexpress.nightcore.util.text.NightMessage;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -27,6 +28,21 @@ public class EntityUtil {
|
|||||||
return Engine.software().nextEntityId();
|
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) {
|
public static double getAttribute(@NotNull LivingEntity entity, @NotNull Attribute attribute) {
|
||||||
AttributeInstance instance = entity.getAttribute(attribute);
|
AttributeInstance instance = entity.getAttribute(attribute);
|
||||||
return instance == null ? 0D : instance.getValue();
|
return instance == null ? 0D : instance.getValue();
|
||||||
|
|||||||
@@ -173,7 +173,8 @@ public class ItemUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void setLore(@NotNull ItemMeta meta, @NotNull List<String> lore) {
|
public static void setLore(@NotNull ItemMeta meta, @NotNull List<String> 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));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import su.nightexpress.nightcore.util.BukkitThing;
|
|||||||
import su.nightexpress.nightcore.util.NumberUtil;
|
import su.nightexpress.nightcore.util.NumberUtil;
|
||||||
import su.nightexpress.nightcore.util.StringUtil;
|
import su.nightexpress.nightcore.util.StringUtil;
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public class NightSound implements Writeable {
|
public class NightSound implements Writeable {
|
||||||
|
|
||||||
private static final String DELIMITER = ";";
|
private static final String DELIMITER = ";";
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,11 +1,13 @@
|
|||||||
package su.nightexpress.nightcore.util.text;
|
package su.nightexpress.nightcore.util.text;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import su.nightexpress.nightcore.util.Lists;
|
||||||
import su.nightexpress.nightcore.util.bridge.wrapper.NightComponent;
|
import su.nightexpress.nightcore.util.bridge.wrapper.NightComponent;
|
||||||
import su.nightexpress.nightcore.util.text.tag.TagPool;
|
import su.nightexpress.nightcore.util.text.tag.TagPool;
|
||||||
import su.nightexpress.nightcore.util.text.tag.Tags;
|
import su.nightexpress.nightcore.util.text.tag.Tags;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class NightMessage {
|
public class NightMessage {
|
||||||
@@ -47,6 +49,22 @@ public class NightMessage {
|
|||||||
return from(string, tagPool).parseIfAbsent();
|
return from(string, tagPool).parseIfAbsent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public static List<String> splitLineTag(@NotNull String string) {
|
||||||
|
return splitLineTag(Lists.newList(string));
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public static List<String> splitLineTag(@NotNull List<String> list) {
|
||||||
|
List<String> segmented = new ArrayList<>();
|
||||||
|
|
||||||
|
list.forEach(line -> {
|
||||||
|
Collections.addAll(segmented, Tags.LINE_BREAK.split(line));
|
||||||
|
});
|
||||||
|
|
||||||
|
return segmented;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
|||||||
@@ -6,5 +6,6 @@ author: NightExpress
|
|||||||
api-version: 1.20
|
api-version: 1.20
|
||||||
load: STARTUP
|
load: STARTUP
|
||||||
libraries:
|
libraries:
|
||||||
|
- org.xerial:sqlite-jdbc:3.49.1.0
|
||||||
- com.zaxxer:HikariCP:6.0.0
|
- com.zaxxer:HikariCP:6.0.0
|
||||||
- it.unimi.dsi:fastutil-core:8.5.13
|
- it.unimi.dsi:fastutil-core:8.5.13
|
||||||
+2
-2
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>su.nightexpress.nightcore</groupId>
|
<groupId>su.nightexpress.nightcore</groupId>
|
||||||
<artifactId>nightcore</artifactId>
|
<artifactId>nightcore</artifactId>
|
||||||
<version>2.7.9</version>
|
<version>2.7.10</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>paper</artifactId>
|
<artifactId>paper</artifactId>
|
||||||
@@ -35,7 +35,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>su.nightexpress.nightcore</groupId>
|
<groupId>su.nightexpress.nightcore</groupId>
|
||||||
<artifactId>bridge</artifactId>
|
<artifactId>bridge</artifactId>
|
||||||
<version>2.7.9</version>
|
<version>2.7.10</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import org.bukkit.attribute.Attribute;
|
|||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.SimpleCommandMap;
|
import org.bukkit.command.SimpleCommandMap;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.InventoryView;
|
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
|
@Override
|
||||||
@NotNull
|
@NotNull
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>su.nightexpress.nightcore</groupId>
|
<groupId>su.nightexpress.nightcore</groupId>
|
||||||
<artifactId>nightcore</artifactId>
|
<artifactId>nightcore</artifactId>
|
||||||
<version>2.7.9</version>
|
<version>2.7.10</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<modules>
|
<modules>
|
||||||
<module>main</module>
|
<module>main</module>
|
||||||
|
|||||||
+2
-2
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>su.nightexpress.nightcore</groupId>
|
<groupId>su.nightexpress.nightcore</groupId>
|
||||||
<artifactId>nightcore</artifactId>
|
<artifactId>nightcore</artifactId>
|
||||||
<version>2.7.9</version>
|
<version>2.7.10</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>spigot</artifactId>
|
<artifactId>spigot</artifactId>
|
||||||
@@ -35,7 +35,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>su.nightexpress.nightcore</groupId>
|
<groupId>su.nightexpress.nightcore</groupId>
|
||||||
<artifactId>bridge</artifactId>
|
<artifactId>bridge</artifactId>
|
||||||
<version>2.7.9</version>
|
<version>2.7.10</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import org.bukkit.attribute.Attribute;
|
|||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.SimpleCommandMap;
|
import org.bukkit.command.SimpleCommandMap;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.InventoryView;
|
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
|
@Override
|
||||||
@NotNull
|
@NotNull
|
||||||
public ItemStack setType(@NotNull ItemStack itemStack, @NotNull Material material) {
|
public ItemStack setType(@NotNull ItemStack itemStack, @NotNull Material material) {
|
||||||
|
|||||||
+1
-1
@@ -6,7 +6,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>su.nightexpress.nightcore</groupId>
|
<groupId>su.nightexpress.nightcore</groupId>
|
||||||
<artifactId>nightcore</artifactId>
|
<artifactId>nightcore</artifactId>
|
||||||
<version>2.7.9</version>
|
<version>2.7.10</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>utils</artifactId>
|
<artifactId>utils</artifactId>
|
||||||
|
|||||||
Reference in new issue
Block a user