mirror of
https://github.com/darksaid98/nightcore-spigot.git
synced 2026-12-01 14:38:47 +00:00
v2.7.2
This commit is contained in:
1 parent
e9d5acf7c1
commit
bb5a24a60c
26 files changed
+789
-211
No files matched your search
@@ -6,11 +6,11 @@
|
||||
|
||||
<groupId>su.nightexpress.nightcore</groupId>
|
||||
<artifactId>nightcore</artifactId>
|
||||
<version>2.7.1</version>
|
||||
<version>2.7.2</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<maven.compiler.source>21</maven.compiler.source>
|
||||
<maven.compiler.target>21</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.20.4-R0.1-SNAPSHOT</version>
|
||||
<version>1.21.3-R0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<!--<dependency>
|
||||
|
||||
@@ -19,6 +19,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import su.nightexpress.nightcore.NightCorePlugin;
|
||||
import su.nightexpress.nightcore.util.*;
|
||||
import su.nightexpress.nightcore.util.bukkit.NightItem;
|
||||
import su.nightexpress.nightcore.util.text.NightMessage;
|
||||
|
||||
import java.io.File;
|
||||
@@ -308,12 +309,24 @@ public class FileConfig extends YamlConfiguration {
|
||||
}*/
|
||||
|
||||
@NotNull
|
||||
public NightItem getCosmeticItem(@NotNull String path, @NotNull NightItem def) {
|
||||
return this.contains(path) ? this.getCosmeticItem(path) : def;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public NightItem getCosmeticItem(@NotNull String path) {
|
||||
return NightItem.read(this, path);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Deprecated
|
||||
public ItemStack getItem(@NotNull String path, @Nullable ItemStack def) {
|
||||
ItemStack item = this.getItem(path);
|
||||
return item.getType().isAir() && def != null ? def : item;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Deprecated
|
||||
public ItemStack getItem(@NotNull String path) {
|
||||
if (!path.isEmpty() && !path.endsWith(".")) path = path + ".";
|
||||
|
||||
@@ -399,6 +412,7 @@ public class FileConfig extends YamlConfiguration {
|
||||
return item;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setItem(@NotNull String path, @Nullable ItemStack item) {
|
||||
if (item == null) {
|
||||
this.set(path, null);
|
||||
|
||||
@@ -18,6 +18,7 @@ public class CoreConfig {
|
||||
"IMPORTANT NOTE: You need to use this setting only once! Enable it, reboot the server and re-save all configurations that stores compressed item data: shops, crates, etc."
|
||||
);
|
||||
|
||||
@Deprecated
|
||||
public static final ConfigValue<Boolean> MODERN_TEXT_PRECOMPILE_LANG = ConfigValue.create("ModernTextFormation.Precompile_Language",
|
||||
true,
|
||||
"When enabled, parses (deserializes) language messages to Spigot TextComponent(s) on plugin load.",
|
||||
|
||||
@@ -206,8 +206,8 @@ public abstract class AbstractDataManager<P extends NightPlugin> extends Abstrac
|
||||
|
||||
@Nullable
|
||||
public <T> T selectFirst(@NotNull String table, @NotNull SelectQuery<T> query) {
|
||||
List<T> list = this.select(table, query);
|
||||
return list.isEmpty() ? null : list.get(0);
|
||||
List<T> list = this.select(table, query.limit(1));
|
||||
return list.isEmpty() ? null : list.getFirst();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -275,6 +275,26 @@ public abstract class AbstractUserManager<P extends NightPlugin, U extends Abstr
|
||||
this.manageUserSynchronized(() -> this.getLoaded(playerId), () -> this.getUserDataAsync(playerId), consumer);
|
||||
}
|
||||
|
||||
private void manageUserSynchronized(@NotNull Supplier<U> loadedSupplier, @NotNull Supplier<CompletableFuture<U>> fetchSupplier, @NotNull Consumer<U> consumer) {
|
||||
this.manageUser(loadedSupplier, fetchSupplier, user -> this.plugin.runTask(task -> consumer.accept(user)));
|
||||
}
|
||||
|
||||
public void manageUser(@NotNull Player player, Consumer<U> consumer) {
|
||||
this.manageUser(player, consumer, false);
|
||||
}
|
||||
|
||||
public void manageUserWithSave(@NotNull Player player, Consumer<U> consumer) {
|
||||
this.manageUser(player, consumer, true);
|
||||
}
|
||||
|
||||
private void manageUser(@NotNull Player player, Consumer<U> consumer, boolean save) {
|
||||
U user = this.getLoaded(player);
|
||||
if (user == null) return;
|
||||
|
||||
consumer.accept(user);
|
||||
if (save) this.save(user);
|
||||
}
|
||||
|
||||
private void manageUser(@NotNull Supplier<U> loadedSupplier, @NotNull Supplier<CompletableFuture<U>> fetchSupplier, @NotNull Consumer<U> consumer) {
|
||||
U user = loadedSupplier.get();
|
||||
if (user != null) {
|
||||
@@ -283,10 +303,6 @@ public abstract class AbstractUserManager<P extends NightPlugin, U extends Abstr
|
||||
else fetchSupplier.get().thenAccept(consumer);
|
||||
}
|
||||
|
||||
private void manageUserSynchronized(@NotNull Supplier<U> loadedSupplier, @NotNull Supplier<CompletableFuture<U>> fetchSupplier, @NotNull Consumer<U> consumer) {
|
||||
this.manageUser(loadedSupplier, fetchSupplier, user -> this.plugin.runTask(task -> consumer.accept(user)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Fetches all users from the database and returns them in as a single set.<br>
|
||||
* Users that are already loaded won't be replaced by ones from the database, however they will be fetched anyway.
|
||||
|
||||
@@ -51,6 +51,7 @@ public class VaultHook {
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
private static void setEconomy() {
|
||||
economy = getProvider(Economy.class);
|
||||
if (economy != null) {
|
||||
@@ -97,16 +98,19 @@ public class VaultHook {
|
||||
return chat;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static boolean hasEconomy() {
|
||||
return economy != null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Deprecated
|
||||
public static Economy getEconomy() {
|
||||
return economy;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Deprecated
|
||||
public static String getEconomyName() {
|
||||
return hasEconomy() ? economy.getName() : "null";
|
||||
}
|
||||
@@ -139,10 +143,12 @@ public class VaultHook {
|
||||
return hasChat() ? chat.getPlayerSuffix(player) : "";
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static double getBalance(@NotNull Player player) {
|
||||
return getBalance((OfflinePlayer) player);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static double getBalance(@NotNull OfflinePlayer player) {
|
||||
return economy.getBalance(player);
|
||||
}
|
||||
@@ -157,10 +163,12 @@ public class VaultHook {
|
||||
return deposit(player, amount);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static boolean deposit(@NotNull Player player, double amount) {
|
||||
return deposit((OfflinePlayer) player, amount);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static boolean deposit(@NotNull OfflinePlayer player, double amount) {
|
||||
return economy.depositPlayer(player, Math.abs(amount)).transactionSuccess();
|
||||
}
|
||||
@@ -175,10 +183,12 @@ public class VaultHook {
|
||||
return withdraw(player, Math.abs(amount));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static boolean withdraw(@NotNull Player player, double amount) {
|
||||
return withdraw((OfflinePlayer) player, amount);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static boolean withdraw(@NotNull OfflinePlayer player, double amount) {
|
||||
return economy.withdrawPlayer(player, Math.abs(amount)).transactionSuccess();
|
||||
}
|
||||
|
||||
@@ -48,8 +48,8 @@ public class LangKeyed<E extends Keyed> implements LangElement {
|
||||
|
||||
@NotNull
|
||||
public String getLocalized(@NotNull E keyed) {
|
||||
String namespace = BukkitThing.toString(keyed);
|
||||
String key = BukkitThing.toString(keyed);
|
||||
|
||||
return this.localeMap.getOrDefault(namespace, namespace);
|
||||
return this.localeMap.getOrDefault(key, key);
|
||||
}
|
||||
}
|
||||
@@ -1,25 +1,20 @@
|
||||
package su.nightexpress.nightcore.language.message;
|
||||
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import su.nightexpress.nightcore.NightCorePlugin;
|
||||
import su.nightexpress.nightcore.core.CoreConfig;
|
||||
import su.nightexpress.nightcore.language.tag.MessageTag;
|
||||
import su.nightexpress.nightcore.language.tag.MessageTags;
|
||||
import su.nightexpress.nightcore.util.NumberUtil;
|
||||
import su.nightexpress.nightcore.util.Placeholders;
|
||||
import su.nightexpress.nightcore.util.Players;
|
||||
import su.nightexpress.nightcore.util.StringUtil;
|
||||
import su.nightexpress.nightcore.util.*;
|
||||
import su.nightexpress.nightcore.util.bukkit.NightSound;
|
||||
import su.nightexpress.nightcore.util.placeholder.Replacer;
|
||||
import su.nightexpress.nightcore.util.text.NightMessage;
|
||||
import su.nightexpress.nightcore.util.text.TextRoot;
|
||||
import su.nightexpress.nightcore.util.text.tag.Tags;
|
||||
import su.nightexpress.nightcore.util.text.tag.api.Tag;
|
||||
import su.nightexpress.nightcore.util.wrapper.UniSound;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -31,7 +26,8 @@ public class LangMessage {
|
||||
private final NightCorePlugin plugin;
|
||||
private final String defaultText;
|
||||
private final MessageOptions options;
|
||||
private final TextRoot message;
|
||||
|
||||
private TextRoot message;
|
||||
|
||||
public LangMessage(@NotNull NightCorePlugin plugin, @NotNull String defaultText, @NotNull MessageOptions options) {
|
||||
this(plugin, defaultText, options, null);
|
||||
@@ -41,10 +37,22 @@ public class LangMessage {
|
||||
this.plugin = plugin;
|
||||
this.defaultText = defaultText;
|
||||
this.options = options;
|
||||
|
||||
this.setPrefix(prefix);
|
||||
// this.message = NightMessage.from(prefix == null || !options.hasPrefix() ? defaultText : prefix + defaultText);
|
||||
// if (CoreConfig.MODERN_TEXT_PRECOMPILE_LANG.get() && options.getOutputType() != OutputType.TITLES) {
|
||||
// this.message.compile();
|
||||
// }
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public LangMessage setPrefix(@Nullable String prefix) {
|
||||
this.message = NightMessage.from(prefix == null || !options.hasPrefix() ? defaultText : prefix + defaultText);
|
||||
if (CoreConfig.MODERN_TEXT_PRECOMPILE_LANG.get() && options.getOutputType() != OutputType.TITLES) {
|
||||
|
||||
if (this.options.getOutputType() != OutputType.TITLES) {
|
||||
this.message.compile();
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@@ -96,7 +104,7 @@ public class LangMessage {
|
||||
}
|
||||
}
|
||||
else if (type.equalsIgnoreCase("sound")) {
|
||||
StringUtil.getEnum(typeContent, Sound.class).ifPresent(options::setSound);
|
||||
options.setSound(BukkitThing.getSound(typeContent));
|
||||
}
|
||||
else if (type.equalsIgnoreCase("prefix")) {
|
||||
boolean b = Boolean.parseBoolean(typeContent);
|
||||
@@ -162,10 +170,10 @@ public class LangMessage {
|
||||
return new LangMessage(plugin, strippedText, options, prefix);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public LangMessage setPrefix(@NotNull String prefix) {
|
||||
return new LangMessage(this.plugin, this.defaultText, this.options, prefix);
|
||||
}
|
||||
// @NotNull
|
||||
// public LangMessage setPrefix(@NotNull String prefix) {
|
||||
// return new LangMessage(this.plugin, this.defaultText, this.options, prefix);
|
||||
// }
|
||||
|
||||
@NotNull
|
||||
public String getDefaultText() {
|
||||
@@ -227,10 +235,19 @@ public class LangMessage {
|
||||
}
|
||||
|
||||
public void broadcast() {
|
||||
// if (this.isDisabled()) return;
|
||||
//
|
||||
// this.plugin.getServer().getOnlinePlayers().forEach(this::send);
|
||||
// this.send(this.plugin.getServer().getConsoleSender());
|
||||
//
|
||||
this.broadcast(replacer -> {});
|
||||
}
|
||||
|
||||
public void broadcast(@NotNull Consumer<Replacer> consumer) {
|
||||
if (this.isDisabled()) return;
|
||||
|
||||
this.plugin.getServer().getOnlinePlayers().forEach(this::send);
|
||||
this.send(this.plugin.getServer().getConsoleSender());
|
||||
Players.getOnline().forEach(player -> this.send(player, consumer));
|
||||
this.send(plugin.getServer().getConsoleSender(), consumer);
|
||||
}
|
||||
|
||||
public void send(@NotNull CommandSender sender) {
|
||||
@@ -266,7 +283,7 @@ public class LangMessage {
|
||||
if (this.isDisabled()) return;
|
||||
|
||||
if (this.options.getSound() != null && sender instanceof Player player) {
|
||||
UniSound.of(this.options.getSound()).play(player);
|
||||
NightSound.of(this.options.getSound()).play(player);
|
||||
}
|
||||
|
||||
Replacer replacer = new Replacer();
|
||||
@@ -275,7 +292,7 @@ public class LangMessage {
|
||||
replacer.replacePlaceholderAPI(player);
|
||||
}
|
||||
|
||||
TextRoot message = replacer.getReplaced(this.message);
|
||||
TextRoot message = replacer.apply(this.message);
|
||||
|
||||
if (this.options.getOutputType() == OutputType.CHAT) {
|
||||
message.send(sender);
|
||||
|
||||
@@ -55,10 +55,10 @@ public class MessageOptions {
|
||||
|
||||
@Nullable
|
||||
public Sound getSound() {
|
||||
return sound;
|
||||
return this.sound;
|
||||
}
|
||||
|
||||
public void setSound(Sound sound) {
|
||||
public void setSound(@Nullable Sound sound) {
|
||||
this.sound = sound;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import su.nightexpress.nightcore.language.message.MessageOptions;
|
||||
import su.nightexpress.nightcore.language.tag.MessageTag;
|
||||
import su.nightexpress.nightcore.util.StringUtil;
|
||||
import su.nightexpress.nightcore.util.BukkitThing;
|
||||
|
||||
public class SoundTag extends MessageTag {
|
||||
|
||||
@@ -15,14 +15,13 @@ public class SoundTag extends MessageTag {
|
||||
|
||||
@NotNull
|
||||
public String enclose(@NotNull Sound sound) {
|
||||
return this.enclose(sound.name().toLowerCase());
|
||||
return this.enclose(BukkitThing.toString(sound));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(@NotNull MessageOptions options, @Nullable String tagContent) {
|
||||
if (tagContent == null) return;
|
||||
|
||||
Sound sound = StringUtil.getEnum(tagContent, Sound.class).orElse(null);
|
||||
options.setSound(sound);
|
||||
options.setSound(BukkitThing.getSound(tagContent));
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,7 @@ public class MenuViewer {
|
||||
private int page;
|
||||
private int pages;
|
||||
private long lastClickTime;
|
||||
private boolean updateTitle;
|
||||
|
||||
public MenuViewer(@NotNull Player player) {
|
||||
this.player = player;
|
||||
@@ -29,7 +30,10 @@ public class MenuViewer {
|
||||
|
||||
public void flushInventory(@NotNull MenuOptions options) {
|
||||
this.inventory.clear();
|
||||
//this.view.setTitle(options.getTitleFormatted());
|
||||
if (this.isUpdateTitle()) {
|
||||
this.view.setTitle(options.getTitleFormatted());
|
||||
this.setUpdateTitle(false);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasInventory() {
|
||||
@@ -78,4 +82,12 @@ public class MenuViewer {
|
||||
public void setLastClickTime(long lastClickTime) {
|
||||
this.lastClickTime = lastClickTime;
|
||||
}
|
||||
|
||||
public boolean isUpdateTitle() {
|
||||
return updateTitle;
|
||||
}
|
||||
|
||||
public void setUpdateTitle(boolean updateTitle) {
|
||||
this.updateTitle = updateTitle;
|
||||
}
|
||||
}
|
||||
@@ -1,19 +1,19 @@
|
||||
package su.nightexpress.nightcore.menu.impl;
|
||||
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import su.nightexpress.nightcore.NightCorePlugin;
|
||||
import su.nightexpress.nightcore.config.ConfigValue;
|
||||
import su.nightexpress.nightcore.config.FileConfig;
|
||||
import su.nightexpress.nightcore.menu.api.AutoFilled;
|
||||
import su.nightexpress.nightcore.menu.MenuOptions;
|
||||
import su.nightexpress.nightcore.menu.api.AutoFilled;
|
||||
import su.nightexpress.nightcore.menu.click.ClickAction;
|
||||
import su.nightexpress.nightcore.menu.click.ClickType;
|
||||
import su.nightexpress.nightcore.menu.item.ItemHandler;
|
||||
import su.nightexpress.nightcore.menu.item.MenuItem;
|
||||
import su.nightexpress.nightcore.util.*;
|
||||
import su.nightexpress.nightcore.util.bukkit.NightItem;
|
||||
import su.nightexpress.nightcore.util.text.NightMessage;
|
||||
|
||||
import java.util.*;
|
||||
@@ -25,7 +25,9 @@ public abstract class ConfigMenu<P extends NightCorePlugin> extends AbstractMenu
|
||||
|
||||
protected final FileConfig cfg;
|
||||
protected final Map<String, ItemHandler> handlerMap;
|
||||
protected String itemSection;
|
||||
|
||||
protected String itemSection;
|
||||
protected boolean applyPAPI;
|
||||
|
||||
public ConfigMenu(@NotNull P plugin, @NotNull FileConfig config) {
|
||||
super(plugin);
|
||||
@@ -73,6 +75,12 @@ public abstract class ConfigMenu<P extends NightCorePlugin> extends AbstractMenu
|
||||
"Sets GUI auto-refresh interval (in seconds). Set this to 0 to disable."
|
||||
).read(cfg);
|
||||
|
||||
boolean applyPAPI = ConfigValue.create("Settings.PlaceholderAPI.Enabled",
|
||||
this.applyPAPI,
|
||||
"Sets whether " + Plugins.PLACEHOLDER_API + " placeholders will be applied on all items from the '" + this.itemSection + "' section of this GUI.",
|
||||
"[*] Disable if you don't use any " + Plugins.PLACEHOLDER_API + " placeholders on your items to improve GUI performance."
|
||||
).read(cfg);
|
||||
|
||||
this.getOptions().setTitle(NightMessage.asLegacy(title));
|
||||
this.getOptions().setSize(size);
|
||||
this.getOptions().setType(type);
|
||||
@@ -84,7 +92,7 @@ public abstract class ConfigMenu<P extends NightCorePlugin> extends AbstractMenu
|
||||
this.createDefaultItems().forEach(menuItem -> {
|
||||
AtomicInteger count = new AtomicInteger();
|
||||
String raw = ItemUtil.getItemName(menuItem.getItemStack());
|
||||
String name = StringUtil.lowerCaseUnderscoreStrict(NightMessage.asLegacy(raw));
|
||||
String name = StringUtil.lowerCaseUnderscoreStrict(NightMessage.stripAll(raw));
|
||||
String finalName = name;
|
||||
|
||||
while (this.cfg.contains(this.itemSection + "." + finalName)) {
|
||||
@@ -98,6 +106,10 @@ public abstract class ConfigMenu<P extends NightCorePlugin> extends AbstractMenu
|
||||
this.cfg.getSection(this.itemSection).forEach(sId -> {
|
||||
MenuItem menuItem = this.readItem(this.itemSection + "." + sId);
|
||||
this.addItem(menuItem);
|
||||
|
||||
if (applyPAPI) {
|
||||
menuItem.getOptions().addDisplayModifier((viewer, itemStack) -> ItemReplacer.replacePlaceholderAPI(itemStack, viewer.getPlayer()));
|
||||
}
|
||||
});
|
||||
|
||||
List<String> comments = new ArrayList<>();
|
||||
@@ -148,7 +160,7 @@ public abstract class ConfigMenu<P extends NightCorePlugin> extends AbstractMenu
|
||||
@NotNull
|
||||
protected MenuItem readItem(@NotNull String path) {
|
||||
String handlerName = cfg.getString(path + ".Type", Placeholders.DEFAULT);
|
||||
ItemStack item = cfg.getItem(path + ".Item");
|
||||
NightItem item = cfg.getCosmeticItem(path + ".Item");
|
||||
int[] slots = cfg.getIntArray(path + ".Slots");
|
||||
int priority = cfg.getInt(path + ".Priority");
|
||||
|
||||
@@ -184,7 +196,7 @@ public abstract class ConfigMenu<P extends NightCorePlugin> extends AbstractMenu
|
||||
|
||||
protected void writeItem(@NotNull MenuItem menuItem, @NotNull String path) {
|
||||
this.cfg.set(path + ".Priority", menuItem.getPriority());
|
||||
this.cfg.setItem(path + ".Item", menuItem.getItemStack());
|
||||
this.cfg.set(path + ".Item", menuItem.getItem());
|
||||
this.cfg.setIntArray(path + ".Slots", menuItem.getSlots());
|
||||
this.cfg.set(path + ".Type", menuItem.getHandler().getName());
|
||||
}
|
||||
|
||||
@@ -63,6 +63,7 @@ public class ItemHandler {
|
||||
(viewer, event) -> {
|
||||
if (viewer.getPage() < viewer.getPages()) {
|
||||
viewer.setPage(viewer.getPage() + 1);
|
||||
viewer.setUpdateTitle(true);
|
||||
menu.open(viewer.getPlayer());
|
||||
}
|
||||
},
|
||||
@@ -75,6 +76,7 @@ public class ItemHandler {
|
||||
(viewer, event) -> {
|
||||
if (viewer.getPage() > 1) {
|
||||
viewer.setPage(viewer.getPage() - 1);
|
||||
viewer.setUpdateTitle(true);
|
||||
menu.open(viewer.getPlayer());
|
||||
}
|
||||
},
|
||||
|
||||
@@ -4,28 +4,33 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import su.nightexpress.nightcore.menu.MenuViewer;
|
||||
import su.nightexpress.nightcore.menu.click.ClickAction;
|
||||
import su.nightexpress.nightcore.util.bukkit.NightItem;
|
||||
|
||||
public class MenuItem {
|
||||
|
||||
protected ItemStack itemStack;
|
||||
protected NightItem item;
|
||||
protected int priority;
|
||||
protected int[] slots;
|
||||
|
||||
protected ItemOptions options;
|
||||
protected ItemHandler handler;
|
||||
|
||||
@Deprecated
|
||||
public MenuItem(@NotNull ItemStack itemStack) {
|
||||
this(itemStack, new int[0]);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public MenuItem(@NotNull ItemStack itemStack, int... slots) {
|
||||
this(itemStack, 0, slots);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public MenuItem(@NotNull ItemStack itemStack, int priority, int[] slots) {
|
||||
this(itemStack, priority, slots, new ItemOptions(), new ItemHandler());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public MenuItem(@NotNull ItemStack itemStack, int priority, int[] slots, @NotNull ItemOptions options, @NotNull ItemHandler handler) {
|
||||
this.setItemStack(itemStack);
|
||||
this.setPriority(priority);
|
||||
@@ -34,9 +39,29 @@ public class MenuItem {
|
||||
this.setHandler(handler);
|
||||
}
|
||||
|
||||
public MenuItem(@NotNull NightItem item) {
|
||||
this(item, new int[0]);
|
||||
}
|
||||
|
||||
public MenuItem(@NotNull NightItem item, int... slots) {
|
||||
this(item, 0, slots);
|
||||
}
|
||||
|
||||
public MenuItem(@NotNull NightItem item, int priority, int[] slots) {
|
||||
this(item, priority, slots, new ItemOptions(), new ItemHandler());
|
||||
}
|
||||
|
||||
public MenuItem(@NotNull NightItem item, int priority, int[] slots, @NotNull ItemOptions options, @NotNull ItemHandler handler) {
|
||||
this.setItem(item);
|
||||
this.setPriority(priority);
|
||||
this.setSlots(slots);
|
||||
this.setOptions(options);
|
||||
this.setHandler(handler);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public MenuItem copy() {
|
||||
return new MenuItem(this.getItemStack(), this.getPriority(), this.getSlots(), this.getOptions(), this.getHandler());
|
||||
return new MenuItem(this.getItem(), this.getPriority(), this.getSlots(), this.getOptions(), this.getHandler());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -53,14 +78,28 @@ public class MenuItem {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ItemStack getItemStack() {
|
||||
return new ItemStack(this.itemStack);
|
||||
public NightItem getItem() {
|
||||
return this.item;
|
||||
}
|
||||
|
||||
public MenuItem setItem(@NotNull NightItem item) {
|
||||
this.item = item;
|
||||
return this;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Deprecated
|
||||
public ItemStack getItemStack() {
|
||||
return this.item.getTranslated();
|
||||
//return new ItemStack(this.itemStack);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Deprecated
|
||||
public MenuItem setItemStack(@NotNull ItemStack itemStack) {
|
||||
this.itemStack = new ItemStack(itemStack);
|
||||
return this;
|
||||
return this.setItem(NightItem.fromItemStack(itemStack));
|
||||
//this.itemStack = new ItemStack(itemStack);
|
||||
//return this;
|
||||
}
|
||||
|
||||
public int getPriority() {
|
||||
|
||||
@@ -6,6 +6,7 @@ import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.generator.WorldInfo;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.potion.PotionType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -24,10 +25,8 @@ public class BukkitThing {
|
||||
|
||||
@Nullable
|
||||
public static <T extends Keyed> T fromRegistry(@NotNull Registry<T> registry, @NotNull String key) {
|
||||
key = StringUtil.lowerCaseUnderscore(key);
|
||||
|
||||
try {
|
||||
NamespacedKey namespacedKey = NamespacedKey.minecraft(key);
|
||||
NamespacedKey namespacedKey = NamespacedKey.minecraft(key.toLowerCase());
|
||||
return registry.get(namespacedKey);
|
||||
}
|
||||
catch (IllegalArgumentException exception) {
|
||||
@@ -99,8 +98,21 @@ public class BukkitThing {
|
||||
return fromRegistry(Registry.EFFECT, name);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static PotionType getPotionType(@NotNull String name) {
|
||||
return fromRegistry(Registry.POTION, name);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Sound getSound(@NotNull String name) {
|
||||
// if (Version.isBehind(Version.MC_1_21_3)) {
|
||||
// return Sound.valueOf(name.toUpperCase());
|
||||
// }
|
||||
return fromRegistry(Registry.SOUNDS, name);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Particle getParticle(@NotNull String name) {
|
||||
return fromRegistry(Registry.PARTICLE_TYPE, name);
|
||||
}
|
||||
}
|
||||
@@ -82,25 +82,13 @@ public class ItemReplacer {
|
||||
public void writeMeta() {
|
||||
if (!this.hasMeta()) return;
|
||||
|
||||
//List<UnaryOperator<String>> operators = new ArrayList<>(this.operatorCache);
|
||||
//operators.add(this.placeholderCache.replacer());
|
||||
|
||||
//boolean hasDisplayName = this.displayName != null;
|
||||
//boolean hasLore = this.lore != null;
|
||||
|
||||
// operators.forEach(operator -> {
|
||||
// if (hasDisplayName) this.setDisplayName(operator.apply(this.displayName));
|
||||
// this.replaceLore(operator);
|
||||
// //if (hasLore) this.setLore(operator.apply(this.lore));
|
||||
// });
|
||||
|
||||
if (this.displayName != null) {
|
||||
this.meta.setDisplayName(this.replacer.getReplaced(this.displayName).toLegacy());
|
||||
this.meta.setDisplayName(NightMessage.asLegacy(this.replacer.apply(this.displayName)));
|
||||
}
|
||||
if (this.lore != null) {
|
||||
this.replacer.getReplacers().forEach(this::replaceLore);
|
||||
this.meta.setLore(this.packTrimmedLore());
|
||||
}
|
||||
this.replacer.getReplacers().forEach(this::replaceLore);
|
||||
|
||||
//this.meta.setDisplayName(this.getDisplayName() == null ? null : NightMessage.asLegacy(this.getDisplayName()));
|
||||
this.meta.setLore(this.packTrimmedLore());
|
||||
|
||||
if (this.isHideFlags()) {
|
||||
ItemUtil.hideAttributes(this.meta, this.item.getType());
|
||||
@@ -110,8 +98,6 @@ public class ItemReplacer {
|
||||
this.item.setItemMeta(this.meta);
|
||||
}
|
||||
|
||||
//this.placeholderCache.clear();
|
||||
//this.operatorCache.clear();
|
||||
this.replacer.clear();
|
||||
}
|
||||
|
||||
@@ -327,8 +313,6 @@ public class ItemReplacer {
|
||||
}
|
||||
|
||||
private void replaceLore(@NotNull UnaryOperator<String> operator) {
|
||||
if (this.lore == null) return;
|
||||
|
||||
List<String> replaced = new ArrayList<>();
|
||||
for (String line : this.lore) {
|
||||
if (!line.isBlank()) {
|
||||
|
||||
@@ -16,6 +16,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import su.nightexpress.nightcore.language.LangAssets;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
@@ -32,11 +33,24 @@ public class ItemUtil {
|
||||
}
|
||||
|
||||
public static void editMeta(@NotNull ItemStack item, @NotNull Consumer<ItemMeta> function) {
|
||||
// ItemMeta meta = item.getItemMeta();
|
||||
// if (meta == null) return;
|
||||
//
|
||||
// function.accept(meta);
|
||||
// item.setItemMeta(meta);
|
||||
|
||||
editMeta(item, ItemMeta.class, function);
|
||||
}
|
||||
|
||||
public static <T extends ItemMeta> void editMeta(@NotNull ItemStack item, @NotNull Class<T> clazz, @NotNull Consumer<T> function) {
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
if (meta == null) return;
|
||||
if (!clazz.isAssignableFrom(meta.getClass())) return;
|
||||
|
||||
function.accept(meta);
|
||||
item.setItemMeta(meta);
|
||||
T specific = clazz.cast(meta);
|
||||
|
||||
function.accept(specific);
|
||||
item.setItemMeta(specific);
|
||||
}
|
||||
|
||||
public static void hideAttributes(@NotNull ItemStack itemStack) {
|
||||
@@ -94,7 +108,7 @@ public class ItemUtil {
|
||||
// sometimes swtiching to "new" spigot api is a pain.
|
||||
// why the hell i have to dig into nms to learn that...
|
||||
PlayerProfile profile = Bukkit.createPlayerProfile(uuid, name);
|
||||
URL url = new URL(urlData);
|
||||
URL url = URI.create(urlData).toURL();//new URL(urlData);
|
||||
PlayerTextures textures = profile.getTextures();
|
||||
|
||||
textures.setSkin(url);
|
||||
|
||||
@@ -262,6 +262,31 @@ public class StringUtil {
|
||||
return Color.fromRGB(red, green, blue);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String transformForID(@NotNull String str, int length) {
|
||||
char[] chars = str.toCharArray();
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for (int index = 0; index < chars.length; index++) {
|
||||
if (length > 0 && index >= length) break;
|
||||
|
||||
char letter = chars[index];
|
||||
if (Character.isWhitespace(letter)) {
|
||||
builder.append("_");
|
||||
continue;
|
||||
}
|
||||
if (!isValidIDChar(letter)) {
|
||||
continue;
|
||||
}
|
||||
builder.append(Character.toLowerCase(letter));
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
private static boolean isValidIDChar(char c) {
|
||||
return (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') || c == '_' || c == '-';
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String lowerCaseUnderscore(@NotNull String str) {
|
||||
return lowerCaseUnderscore(str, -1);
|
||||
|
||||
@@ -118,8 +118,23 @@ public final class PlayerBlockTracker {
|
||||
}
|
||||
|
||||
public static void shift(@NotNull BlockFace direction, @NotNull List<Block> blocks) {
|
||||
unTrack(blocks);
|
||||
track(blocks.stream().map(block -> block.getRelative(direction)).toList());
|
||||
//unTrack(blocks);
|
||||
//track(blocks.stream().map(block -> block.getRelative(direction)).toList());
|
||||
|
||||
Set<Block> toTrack = new HashSet<>();
|
||||
Set<Block> toUntrack = new HashSet<>();
|
||||
|
||||
blocks.forEach(block -> {
|
||||
if (isTracked(block)) {
|
||||
toTrack.add(block.getRelative(direction));
|
||||
}
|
||||
else {
|
||||
toUntrack.add(block.getRelative(direction));
|
||||
}
|
||||
});
|
||||
|
||||
toTrack.forEach(PlayerBlockTracker::track);
|
||||
toUntrack.forEach(PlayerBlockTracker::unTrack);
|
||||
}
|
||||
|
||||
public static void move(@NotNull Block from, @NotNull Block to) {
|
||||
|
||||
@@ -0,0 +1,439 @@
|
||||
package su.nightexpress.nightcore.util.bukkit;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonParser;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import su.nightexpress.nightcore.config.FileConfig;
|
||||
import su.nightexpress.nightcore.config.Writeable;
|
||||
import su.nightexpress.nightcore.core.CoreLogger;
|
||||
import su.nightexpress.nightcore.util.BukkitThing;
|
||||
import su.nightexpress.nightcore.util.ItemUtil;
|
||||
import su.nightexpress.nightcore.util.StringUtil;
|
||||
import su.nightexpress.nightcore.util.Version;
|
||||
import su.nightexpress.nightcore.util.placeholder.Replacer;
|
||||
import su.nightexpress.nightcore.util.text.NightMessage;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Base64;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Utility class to create <b>cosmetic</b> items only.<br>
|
||||
* Do <b>NOT</b> use to create custom items for regular gameplay.
|
||||
*/
|
||||
public class NightItem implements Writeable {
|
||||
|
||||
private Material material;
|
||||
private int amount;
|
||||
|
||||
private int damage;
|
||||
private boolean unbreakable;
|
||||
|
||||
private String itemName;
|
||||
private String displayName;
|
||||
private List<String> lore;
|
||||
|
||||
private String skinURL;
|
||||
private Color color;
|
||||
|
||||
private Integer modelData;
|
||||
private NamespacedKey modelPath;
|
||||
private NamespacedKey tooltipStyle;
|
||||
|
||||
private boolean enchantGlint;
|
||||
private boolean hideComponents;
|
||||
private boolean hideTooltip;
|
||||
|
||||
public NightItem(@NotNull Material material) {
|
||||
this(material, 1);
|
||||
}
|
||||
|
||||
public NightItem(@NotNull Material material, int amount) {
|
||||
this.setMaterial(material);
|
||||
this.setAmount(amount);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static NightItem fromItemStack(@NotNull ItemStack itemStack) {
|
||||
NightItem nightItem = new NightItem(itemStack.getType());
|
||||
|
||||
nightItem.setAmount(itemStack.getAmount());
|
||||
|
||||
ItemMeta meta = itemStack.getItemMeta();
|
||||
if (meta == null) return nightItem;
|
||||
|
||||
if (meta instanceof Damageable damageable) {
|
||||
nightItem.setDamage(damageable.getDamage());
|
||||
}
|
||||
|
||||
nightItem.setDisplayName(meta.getDisplayName());
|
||||
nightItem.setLore(meta.getLore());
|
||||
nightItem.setUnbreakable(meta.isUnbreakable());
|
||||
nightItem.setSkinURL(ItemUtil.getHeadSkin(itemStack));
|
||||
nightItem.setModelData(meta.hasCustomModelData() ? meta.getCustomModelData() : null);
|
||||
if (Version.isAtLeast(Version.MC_1_21)) {
|
||||
nightItem.setItemName(meta.getItemName());
|
||||
nightItem.setEnchantGlint((meta.hasEnchantmentGlintOverride() && meta.getEnchantmentGlintOverride()) || meta.hasEnchants());
|
||||
nightItem.setHideTooltip(meta.isHideTooltip());
|
||||
}
|
||||
if (Version.isAtLeast(Version.MC_1_21_3)) {
|
||||
nightItem.setModelPath(meta.getItemModel());
|
||||
nightItem.setTooltipStyle(meta.getTooltipStyle());
|
||||
}
|
||||
nightItem.setHideComponents(!meta.getItemFlags().isEmpty());
|
||||
|
||||
if (meta instanceof LeatherArmorMeta armorMeta) {
|
||||
nightItem.setColor(armorMeta.getColor());
|
||||
}
|
||||
else if (meta instanceof PotionMeta potionMeta) {
|
||||
nightItem.setColor(potionMeta.getColor());
|
||||
}
|
||||
|
||||
return nightItem;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static NightItem read(@NotNull FileConfig config, @NotNull String path) {
|
||||
// -------- UPDATE OLD FIELDS - START --------
|
||||
String headTexture = config.getString(path + ".Head_Texture");
|
||||
if (headTexture != null && !headTexture.isEmpty()) {
|
||||
try {
|
||||
byte[] decoded = Base64.getDecoder().decode(headTexture);
|
||||
String decodedStr = new String(decoded, StandardCharsets.UTF_8);
|
||||
JsonElement element = JsonParser.parseString(decodedStr);
|
||||
|
||||
String url = element.getAsJsonObject().getAsJsonObject("textures").getAsJsonObject("SKIN").get("url").getAsString();
|
||||
url = url.substring(ItemUtil.TEXTURES_HOST.length());
|
||||
|
||||
config.set(path + ".SkinURL", url);
|
||||
config.remove(path + ".Head_Texture");
|
||||
}
|
||||
catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (config.contains(path + ".Durability")) {
|
||||
int oldDurability = config.getInt(path + ".Durability");
|
||||
config.set(path + ".Durabilities.Damage", oldDurability);
|
||||
config.remove(path + ".Durability");
|
||||
}
|
||||
|
||||
if (config.contains(path + ".Unbreakable")) {
|
||||
boolean oldUnbreakable = config.getBoolean(path + ".Unbreakable");
|
||||
config.set(path + ".Durabilities.Unbreakable", oldUnbreakable);
|
||||
config.remove(path + ".Unbreakable");
|
||||
}
|
||||
|
||||
if (config.contains(path + ".Name")) {
|
||||
String oldName = config.getString(path + ".Name", "null");
|
||||
config.set(path + ".Display_Name", oldName);
|
||||
config.remove(path + ".Name");
|
||||
}
|
||||
|
||||
if (config.contains(path + ".Enchants")) {
|
||||
config.set(path + ".Enchant_Glint", true);
|
||||
config.remove(path + ".Enchants");
|
||||
}
|
||||
|
||||
if (config.contains(path + ".Item_Flags")) {
|
||||
config.set(path + ".Hide_Components", true);
|
||||
config.remove(path + ".Item_Flags");
|
||||
}
|
||||
|
||||
if (config.contains(path + ".Custom_Model_Data")) {
|
||||
int oldModel = config.getInt(path + ".Custom_Model_Data");
|
||||
config.set(path + ".Model.Data", oldModel);
|
||||
config.remove(path + ".Custom_Model_Data");
|
||||
}
|
||||
// -------- UPDATE OLD FIELDS - END --------
|
||||
|
||||
String materialName = config.getString(path + ".Material");
|
||||
|
||||
Material material = BukkitThing.getMaterial(String.valueOf(materialName));
|
||||
if (material == null) {
|
||||
CoreLogger.error("Invalid material '" + materialName + "'. Caused by '" + config.getFile().getAbsolutePath() + "'.");
|
||||
material = Material.AIR;
|
||||
}
|
||||
NightItem nightItem = new NightItem(material);
|
||||
|
||||
nightItem.setAmount(config.getInt(path + ".Amount", 1));
|
||||
nightItem.setItemName(config.getString(path + ".Item_Name"));
|
||||
nightItem.setDisplayName(config.getString(path + ".Display_Name"));
|
||||
nightItem.setLore(config.getStringList(path + ".Lore"));
|
||||
|
||||
if (material == Material.PLAYER_HEAD) {
|
||||
nightItem.setSkinURL(config.getString(path + ".SkinURL"));
|
||||
}
|
||||
if (config.contains(path + ".Model.Data")) {
|
||||
nightItem.setModelData(config.getInt(path + ".Model.Data"));
|
||||
}
|
||||
if (config.contains(path + ".Model.Path")) {
|
||||
String packPath = config.getString(path + ".Model.Path");
|
||||
NamespacedKey key = packPath == null ? null : NamespacedKey.minecraft(packPath);
|
||||
nightItem.setModelPath(key);
|
||||
}
|
||||
if (config.contains(path + ".Tooltip.Style")) {
|
||||
String packPath = config.getString(path + ".Tooltip.Style");
|
||||
NamespacedKey key = packPath == null ? null : NamespacedKey.minecraft(packPath);
|
||||
nightItem.setTooltipStyle(key);
|
||||
}
|
||||
|
||||
nightItem.setDamage(config.getInt(path + ".Durabilities.Damage", 0));
|
||||
nightItem.setUnbreakable(config.getBoolean(path + ".Durabilities.Unbreakable", false));
|
||||
|
||||
nightItem.setEnchantGlint(config.getBoolean(path + ".Enchant_Glint", false));
|
||||
nightItem.setHideComponents(config.getBoolean(path + ".Hide_Components", false));
|
||||
nightItem.setHideTooltip(config.getBoolean(path + ".Hide_Tooltip", false));
|
||||
|
||||
String rawColor = config.getString(path + ".Color");
|
||||
Color color = rawColor == null ? null : StringUtil.getColor(rawColor);
|
||||
nightItem.setColor(color);
|
||||
|
||||
return nightItem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(@NotNull FileConfig config, @NotNull String path) {
|
||||
config.set(path + ".Material", BukkitThing.toString(this.material));
|
||||
config.set(path + ".Amount", this.amount == 1 ? null : this.amount);
|
||||
config.set(path + ".Item_Name", this.itemName);
|
||||
config.set(path + ".Display_Name", this.displayName);
|
||||
config.set(path + ".Lore", this.lore);
|
||||
config.set(path + ".SkinURL", this.skinURL);
|
||||
config.set(path + ".Model.Data", this.modelData);
|
||||
config.set(path + ".Model.Path", this.modelPath == null ? null : this.modelPath.getKey());
|
||||
config.set(path + ".Tooltip.Style", this.tooltipStyle == null ? null : this.tooltipStyle.getKey());
|
||||
config.set(path + ".Durabilities.Damage", this.damage == 0 ? null : this.damage);
|
||||
config.set(path + ".Durabilities.Unbreakable", this.unbreakable ? true : null);
|
||||
config.set(path + ".Enchant_Glint", this.enchantGlint ? true : null);
|
||||
config.set(path + ".Hide_Components", this.hideComponents ? true : null);
|
||||
config.set(path + ".Hide_Tooltip", this.hideTooltip ? true : null);
|
||||
config.set(path + ".Color", this.color == null ? null : color.getRed() + "," + color.getBlue() + "," + color.getGreen());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ItemStack getPlain() {
|
||||
return this.getPlain(null);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ItemStack getPlain(@Nullable Replacer replacer) {
|
||||
return this.build(false, replacer);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ItemStack getTranslated() {
|
||||
return this.getTranslated(null);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ItemStack getTranslated(@Nullable Replacer replacer) {
|
||||
return this.build(true, replacer);
|
||||
}
|
||||
|
||||
// @NotNull
|
||||
// private ItemStack build(boolean legacy, @NotNull Consumer<Replacer> consumer) {
|
||||
// Replacer replacer = new Replacer();
|
||||
// consumer.accept(replacer);
|
||||
//
|
||||
// return this.build(legacy, replacer);
|
||||
// }
|
||||
|
||||
@NotNull
|
||||
private ItemStack build(boolean legacy, @Nullable Replacer replacer) {
|
||||
ItemStack itemStack = new ItemStack(this.material);
|
||||
|
||||
if (this.skinURL != null) ItemUtil.setHeadSkin(itemStack, this.skinURL);
|
||||
|
||||
ItemUtil.editMeta(itemStack, meta -> {
|
||||
String replacedItemName = replacer == null || this.itemName == null ? this.itemName : replacer.apply(this.itemName);
|
||||
String replacedDisplayName = replacer == null || this.displayName == null ? this.displayName : replacer.apply(this.displayName);
|
||||
List<String> replacedLore = replacer == null || this.lore == null ? this.lore : replacer.apply(this.lore);
|
||||
|
||||
meta.setDisplayName(replacedDisplayName == null ? null : (legacy ? NightMessage.asLegacy(replacedDisplayName) : replacedDisplayName));
|
||||
meta.setLore(replacedLore == null ? null : (legacy ? NightMessage.asLegacy(replacedLore) : replacedLore));
|
||||
meta.setCustomModelData(this.modelData);
|
||||
meta.setUnbreakable(this.unbreakable);
|
||||
|
||||
if (this.hideComponents) ItemUtil.hideAttributes(meta, this.material);
|
||||
|
||||
if (Version.isAtLeast(Version.MC_1_21)) {
|
||||
meta.setItemName(replacedItemName == null ? null : (legacy ? NightMessage.asLegacy(replacedItemName) : replacedItemName));
|
||||
if (this.enchantGlint) meta.setEnchantmentGlintOverride(true);
|
||||
meta.setHideTooltip(this.hideTooltip);
|
||||
}
|
||||
if (Version.isAtLeast(Version.MC_1_21_3)) {
|
||||
meta.setItemModel(this.modelPath);
|
||||
meta.setTooltipStyle(this.tooltipStyle);
|
||||
}
|
||||
|
||||
if (meta instanceof Damageable damageable) {
|
||||
damageable.setDamage(this.damage);
|
||||
}
|
||||
|
||||
switch (meta) {
|
||||
case LeatherArmorMeta armorMeta -> armorMeta.setColor(this.color);
|
||||
case PotionMeta potionMeta -> potionMeta.setColor(this.color);
|
||||
default -> {}
|
||||
}
|
||||
});
|
||||
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public NightItem removeNameAndLore() {
|
||||
this.setItemName(null);
|
||||
this.setDisplayName(null);
|
||||
this.setLore(null);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Material getMaterial() {
|
||||
return material;
|
||||
}
|
||||
|
||||
public NightItem setMaterial(Material material) {
|
||||
this.material = material;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
public NightItem setAmount(int amount) {
|
||||
this.amount = Math.max(1, Math.min(64, amount));
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getDamage() {
|
||||
return damage;
|
||||
}
|
||||
|
||||
public NightItem setDamage(int damage) {
|
||||
this.damage = damage;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getItemName() {
|
||||
return this.itemName;
|
||||
}
|
||||
|
||||
public NightItem setItemName(@Nullable String itemName) {
|
||||
this.itemName = itemName;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getDisplayName() {
|
||||
return this.displayName;
|
||||
}
|
||||
|
||||
public NightItem setDisplayName(@Nullable String displayName) {
|
||||
this.displayName = displayName;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public List<String> getLore() {
|
||||
return this.lore;
|
||||
}
|
||||
|
||||
public NightItem setLore(@Nullable List<String> lore) {
|
||||
this.lore = lore;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getSkinURL() {
|
||||
return skinURL;
|
||||
}
|
||||
|
||||
public NightItem setSkinURL(@Nullable String skinURL) {
|
||||
this.skinURL = skinURL;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Integer getModelData() {
|
||||
return this.modelData;
|
||||
}
|
||||
|
||||
public NightItem setModelData(@Nullable Integer modelData) {
|
||||
this.modelData = modelData;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public NamespacedKey getModelPath() {
|
||||
return this.modelPath;
|
||||
}
|
||||
|
||||
public NightItem setModelPath(@Nullable NamespacedKey modelPath) {
|
||||
this.modelPath = modelPath;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public NamespacedKey getTooltipStyle() {
|
||||
return this.tooltipStyle;
|
||||
}
|
||||
|
||||
public NightItem setTooltipStyle(@Nullable NamespacedKey tooltipStyle) {
|
||||
this.tooltipStyle = tooltipStyle;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Color getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public NightItem setColor(Color color) {
|
||||
this.color = color;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isUnbreakable() {
|
||||
return unbreakable;
|
||||
}
|
||||
|
||||
public NightItem setUnbreakable(boolean unbreakable) {
|
||||
this.unbreakable = unbreakable;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isEnchantGlint() {
|
||||
return enchantGlint;
|
||||
}
|
||||
|
||||
public NightItem setEnchantGlint(boolean enchantGlint) {
|
||||
this.enchantGlint = enchantGlint;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isHideComponents() {
|
||||
return hideComponents;
|
||||
}
|
||||
|
||||
public NightItem setHideComponents(boolean hideComponents) {
|
||||
this.hideComponents = hideComponents;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isHideTooltip() {
|
||||
return this.hideTooltip;
|
||||
}
|
||||
|
||||
public NightItem setHideTooltip(boolean hideTooltip) {
|
||||
this.hideTooltip = hideTooltip;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import su.nightexpress.nightcore.util.StringUtil;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.function.UnaryOperator;
|
||||
@@ -24,14 +25,24 @@ public class PlaceholderList<T> {
|
||||
this.entries = new ArrayList<>(entries);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <T> PlaceholderList<T> create(@NotNull Consumer<PlaceholderList<T>> consumer) {
|
||||
PlaceholderList<T> placeholderList = new PlaceholderList<>();
|
||||
consumer.accept(placeholderList);
|
||||
return placeholderList;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public List<PlaceholderEntry<T>> getEntries() {
|
||||
return this.entries;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public PlaceholderList<T> add(@NotNull PlaceholderList<T> other) {
|
||||
this.entries.addAll(other.getEntries());
|
||||
public PlaceholderList<T> add(@NotNull PlaceholderList<? super T> other) {
|
||||
other.getEntries().forEach(entry -> {
|
||||
this.add(entry.getKey(), entry::get);
|
||||
});
|
||||
//this.entries.addAll(other.getEntries());
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,10 @@ package su.nightexpress.nightcore.util.placeholder;
|
||||
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import su.nightexpress.nightcore.util.ItemUtil;
|
||||
import su.nightexpress.nightcore.util.Placeholders;
|
||||
import su.nightexpress.nightcore.util.Plugins;
|
||||
import su.nightexpress.nightcore.util.text.NightMessage;
|
||||
@@ -24,6 +27,11 @@ public class Replacer {
|
||||
this.replacers = new ArrayList<>();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Replacer create() {
|
||||
return new Replacer();
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
this.placeholders.clear();
|
||||
this.replacers.clear();
|
||||
@@ -38,17 +46,75 @@ public class Replacer {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Deprecated
|
||||
public TextRoot getReplaced(@NotNull String source) {
|
||||
return this.getReplaced(NightMessage.from(source));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Deprecated
|
||||
public TextRoot getReplaced(@NotNull TextRoot source) {
|
||||
// TextRoot root = source.copy();
|
||||
// this.getReplacers().forEach(root::replace);
|
||||
// return root;
|
||||
return this.apply(source);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public TextRoot apply(@NotNull TextRoot source) {
|
||||
TextRoot root = source.copy();
|
||||
this.getReplacers().forEach(root::replace);
|
||||
return root;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Deprecated
|
||||
public String getReplacedRaw(@NotNull String source) {
|
||||
// String result = source;
|
||||
// for (UnaryOperator<String> operator : this.getReplacers()) {
|
||||
// result = operator.apply(result);
|
||||
// }
|
||||
// return result;
|
||||
return this.apply(source);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String apply(@NotNull String source) {
|
||||
String result = source;
|
||||
for (UnaryOperator<String> operator : this.getReplacers()) {
|
||||
result = operator.apply(result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public List<String> apply(@NotNull List<String> list) {
|
||||
List<String> replaced = new ArrayList<>();
|
||||
list.forEach(line -> replaced.add(this.apply(line)));
|
||||
return replaced;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ItemStack apply(@NotNull ItemStack itemStack) {
|
||||
ItemUtil.editMeta(itemStack, this::apply);
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ItemMeta apply(@NotNull ItemMeta meta) {
|
||||
String displayName = meta.hasDisplayName() ? meta.getDisplayName() : null;
|
||||
List<String> lore = meta.getLore();
|
||||
|
||||
if (displayName != null) {
|
||||
meta.setDisplayName(this.apply(displayName));
|
||||
}
|
||||
if (lore != null) {
|
||||
meta.setLore(this.apply(lore));
|
||||
}
|
||||
|
||||
return meta;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Replacer replacePlaceholderAPI(@NotNull Player player) {
|
||||
if (!Plugins.hasPlaceholderAPI()) return this;
|
||||
@@ -66,8 +132,7 @@ public class Replacer {
|
||||
|
||||
@NotNull
|
||||
public Replacer replace(@NotNull String key, @NotNull List<String> replacer) {
|
||||
this.placeholders.add(key, () -> String.join(Placeholders.TAG_LINE_BREAK, replacer));
|
||||
return this;
|
||||
return this.replace(key, () -> String.join(Placeholders.TAG_LINE_BREAK, replacer));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -46,7 +46,6 @@ public class TextNode implements ComponentBuildable {
|
||||
public int textLength() {
|
||||
int legnth = 0;
|
||||
if (this.translation != null) return 1;
|
||||
//if (this.textBuilder.toString().equals("\n")) return legnth; // Do not count length for line breaks.
|
||||
|
||||
for (int index = 0; index < this.textBuilder.length(); index++) {
|
||||
char letter = this.textBuilder.charAt(index);
|
||||
|
||||
@@ -44,18 +44,6 @@ public class TextRoot {
|
||||
string = Colorizer.tagPlainHex(Colorizer.plain(string));
|
||||
}
|
||||
|
||||
/*if (CoreConfig.LEGACY_COLOR_SUPPORT.get()) {
|
||||
TimedMatcher timedMatcher = TimedMatcher.create(Colorizer.PATTERN_HEX_LEGACY, string);
|
||||
Set<String> rawCodes = new HashSet<>();
|
||||
while (timedMatcher.find()) {
|
||||
String hex = timedMatcher.getMatcher().group(1);
|
||||
rawCodes.add(hex);
|
||||
}
|
||||
for (String hex : rawCodes) {
|
||||
string = string.replace(hex, Tag.brackets(hex));
|
||||
}
|
||||
}*/
|
||||
|
||||
this.string = string;
|
||||
this.component = null;
|
||||
}
|
||||
@@ -169,64 +157,6 @@ public class TextRoot {
|
||||
|
||||
this.doJob(Mode.PARSE, letter -> this.currentNode().append(letter));
|
||||
|
||||
/*int length = string.length();
|
||||
for (int index = 0; index < length; index++) {
|
||||
char letter = string.charAt(index);
|
||||
|
||||
Tag:
|
||||
if (letter == Tag.OPEN_BRACKET && index != (length - 1)) {
|
||||
int indexEnd = indexOfIgnoreEscaped(string, Tag.CLOSE_BRACKET, index);//string.indexOf(Tag.CLOSE_BRACKET, index);
|
||||
//System.out.println("indexEnd = " + indexEnd);
|
||||
if (indexEnd == -1) break Tag;
|
||||
|
||||
char next = string.charAt(index + 1);
|
||||
if (next == Tag.CLOSE_BRACKET) break Tag;
|
||||
|
||||
boolean closeTag = false;
|
||||
if (next == Tag.CLOSE_SLASH) {
|
||||
closeTag = true;
|
||||
index++;
|
||||
}
|
||||
|
||||
String bracketsContent = string.substring(index + 1, indexEnd);
|
||||
//System.out.println("bracketsContent = " + bracketsContent);
|
||||
|
||||
String tagName = bracketsContent;
|
||||
String tagContent = null;
|
||||
|
||||
// Check for content tags
|
||||
int semicolonIndex = bracketsContent.indexOf(':');
|
||||
if (semicolonIndex >= 0) {
|
||||
tagName = bracketsContent.substring(0, semicolonIndex);
|
||||
tagContent = bracketsContent.substring(semicolonIndex + 1);
|
||||
//System.out.println("tagName = " + tagName);
|
||||
//System.out.println("tagContent = " + tagContent);
|
||||
}
|
||||
else if (tagName.startsWith(ShortHexColorTag.NAME)) {
|
||||
tagName = ShortHexColorTag.NAME;
|
||||
tagContent = bracketsContent;
|
||||
}
|
||||
|
||||
Tag tag = Tags.getTag(tagName);
|
||||
//System.out.println("found tag = " + tag);
|
||||
|
||||
if (tag != null) {
|
||||
if (tagPool.isGoodTag(tag)) {
|
||||
this.proceedTag(tag, closeTag, tagContent);
|
||||
}
|
||||
index = indexEnd;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Move cursor back to '/' of invalid closing tag.
|
||||
if (closeTag) {
|
||||
index--;
|
||||
}
|
||||
}
|
||||
|
||||
this.currentNode().append(letter);
|
||||
}*/
|
||||
|
||||
this.component = this.rootGroup.toComponent();
|
||||
|
||||
// Clean memory
|
||||
@@ -243,53 +173,6 @@ public class TextRoot {
|
||||
|
||||
this.doJob(Mode.STRIP, builder::append);
|
||||
|
||||
/*int length = string.length();
|
||||
for (int index = 0; index < length; index++) {
|
||||
char letter = string.charAt(index);
|
||||
|
||||
Tag:
|
||||
if (letter == Tag.OPEN_BRACKET && index != (length - 1)) {
|
||||
int indexEnd = indexOfIgnoreEscaped(string, Tag.CLOSE_BRACKET, index);
|
||||
if (indexEnd == -1) break Tag;
|
||||
|
||||
char next = string.charAt(index + 1);
|
||||
if (next == Tag.CLOSE_BRACKET) break Tag;
|
||||
|
||||
boolean closeTag = false;
|
||||
if (next == Tag.CLOSE_SLASH) {
|
||||
closeTag = true;
|
||||
index++;
|
||||
}
|
||||
|
||||
String bracketsContent = string.substring(index + 1, indexEnd);
|
||||
String tagName = bracketsContent;
|
||||
|
||||
// Check for content tags
|
||||
int semicolonIndex = bracketsContent.indexOf(':');
|
||||
if (semicolonIndex >= 0) {
|
||||
tagName = bracketsContent.substring(0, semicolonIndex);
|
||||
}
|
||||
else if (tagName.startsWith(ShortHexColorTag.NAME)) {
|
||||
tagName = ShortHexColorTag.NAME;
|
||||
}
|
||||
|
||||
Tag tag = Tags.getTag(tagName);
|
||||
if (tag != null) {
|
||||
if (!tagPool.isGoodTag(tag)) {
|
||||
index = indexEnd;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// Move cursor back to '/' of invalid closing tag.
|
||||
if (closeTag) {
|
||||
index--;
|
||||
}
|
||||
}
|
||||
|
||||
builder.append(letter);
|
||||
}*/
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
@@ -376,7 +259,8 @@ public class TextRoot {
|
||||
return;
|
||||
}
|
||||
|
||||
this.currentNode = null; // Reset current node because of current group change below.
|
||||
// Reset current node to create a new one inside for a group jumped/created below.
|
||||
this.currentNode = null;
|
||||
|
||||
if (closeTag) {
|
||||
this.toParentGroup(tag.getName()); // Jump to the first parent group of closed tag (or root group if there is no parent for this tag).
|
||||
@@ -384,7 +268,7 @@ public class TextRoot {
|
||||
}
|
||||
|
||||
if (tag instanceof ResetTag) {
|
||||
this.currentGroup = this.rootGroup; // Jump to the parent group for 'Reset' tag, so it will create new children groups without decorators on further parsing.
|
||||
this.currentGroup = this.rootGroup; // Jump to the root group for 'Reset' tag, so it will create new children groups without decorators on further parsing.
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,9 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import su.nightexpress.nightcore.config.FileConfig;
|
||||
import su.nightexpress.nightcore.util.BukkitThing;
|
||||
import su.nightexpress.nightcore.util.StringUtil;
|
||||
import su.nightexpress.nightcore.util.Version;
|
||||
|
||||
public class UniParticle {
|
||||
|
||||
@@ -31,22 +33,27 @@ public class UniParticle {
|
||||
|
||||
@NotNull
|
||||
public static UniParticle itemCrack(@NotNull ItemStack item) {
|
||||
return new UniParticle(Particle.ITEM_CRACK, new ItemStack(item));
|
||||
Particle var = Version.isBehind(Version.MC_1_21_3) ? Particle.valueOf("ITEM_CRACK") : BukkitThing.getParticle("item");
|
||||
return new UniParticle(var, new ItemStack(item));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static UniParticle itemCrack(@NotNull Material material) {
|
||||
return new UniParticle(Particle.ITEM_CRACK, new ItemStack(material));
|
||||
Particle var = Version.isBehind(Version.MC_1_21_3) ? Particle.valueOf("ITEM_CRACK") : BukkitThing.getParticle("item");
|
||||
return new UniParticle(var, new ItemStack(material));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static UniParticle blockCrack(@NotNull Material material) {
|
||||
return new UniParticle(Particle.BLOCK_CRACK, material.createBlockData());
|
||||
Particle var = Version.isBehind(Version.MC_1_21_3) ? Particle.valueOf("BLOCK_CRACK") : BukkitThing.getParticle("block");
|
||||
return new UniParticle(var, material.createBlockData());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static UniParticle blockDust(@NotNull Material material) {
|
||||
return new UniParticle(Particle.BLOCK_DUST, material.createBlockData());
|
||||
return blockCrack(material);
|
||||
// Particle var = Version.isAtLeast(Version.MC_1_21_3) ? Particle.valueOf("BLOCK_DUST") : BukkitThing.getParticle("dust");
|
||||
// return new UniParticle(Particle.DUST, material.createBlockData());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -61,7 +68,8 @@ public class UniParticle {
|
||||
|
||||
@NotNull
|
||||
public static UniParticle redstone(@NotNull Color color, float size) {
|
||||
return new UniParticle(Particle.REDSTONE, new Particle.DustOptions(color, size));
|
||||
Particle var = Version.isBehind(Version.MC_1_21_3) ? Particle.valueOf("REDSTONE") : BukkitThing.getParticle("dust");
|
||||
return new UniParticle(var, new Particle.DustOptions(color, size));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -149,7 +157,7 @@ public class UniParticle {
|
||||
if (this.particle == null) return;
|
||||
|
||||
Class<?> dataType = this.particle.getDataType();
|
||||
if (this.data != null && this.data.getClass() == dataType) return;
|
||||
if (this.data != null && dataType.isAssignableFrom(this.data.getClass())) return;
|
||||
|
||||
if (dataType == BlockData.class) {
|
||||
this.data = Material.STONE.createBlockData();
|
||||
|
||||
@@ -8,7 +8,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import su.nightexpress.nightcore.config.ConfigValue;
|
||||
import su.nightexpress.nightcore.config.FileConfig;
|
||||
import su.nightexpress.nightcore.util.StringUtil;
|
||||
import su.nightexpress.nightcore.util.BukkitThing;
|
||||
|
||||
@Deprecated
|
||||
public class UniSound {
|
||||
@@ -37,7 +37,7 @@ public class UniSound {
|
||||
|
||||
@NotNull
|
||||
public static UniSound of(@NotNull Sound sound, float volume, float pitch) {
|
||||
return new UniSound(sound.name(), sound, volume, pitch);
|
||||
return new UniSound(BukkitThing.toString(sound), sound, volume, pitch);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -55,7 +55,7 @@ public class UniSound {
|
||||
"Sound speed. From 0.5 to 2.0"
|
||||
).read(cfg).floatValue();
|
||||
|
||||
Sound soundType = StringUtil.getEnum(soundName, Sound.class).orElse(null);
|
||||
Sound soundType = BukkitThing.getSound(soundName);//StringUtil.getEnum(soundName, Sound.class).orElse(null);
|
||||
|
||||
return new UniSound(soundName, soundType, volume, pitch);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user