diff --git a/src/main/java/dev/esophose/playerparticles/gui/GuiActionButton.java b/src/main/java/dev/esophose/playerparticles/gui/GuiActionButton.java index aef4aaf..d4f06e4 100644 --- a/src/main/java/dev/esophose/playerparticles/gui/GuiActionButton.java +++ b/src/main/java/dev/esophose/playerparticles/gui/GuiActionButton.java @@ -16,12 +16,26 @@ import org.bukkit.material.Dye; public class GuiActionButton { private int slot; + private ItemStack itemStack; private Material[] icons; private ColorData[] colors; private String name; private String[] lore; private GuiActionButtonClickCallback onClick; private int iconIndex; + + /** + * Constructor for creating a non-animated item from an already created ItemStack + * + * @param slot The slot ID of the inventory + * @param itemStack The ItemStack to display + * @param onClick The callback to execute when this button is clicked + */ + public GuiActionButton(int slot, ItemStack itemStack, GuiActionButtonClickCallback onClick) { + this.slot = slot; + this.itemStack = itemStack; + this.onClick = onClick; + } /** * Constructor for creating animated icons @@ -101,6 +115,9 @@ public class GuiActionButton { * @return The icon ItemStack for the GUI */ public ItemStack getIcon(PPlayer pplayer) { + if (this.itemStack != null) + return this.itemStack; + ItemStack itemStack; if (this.icons != null) { itemStack = new ItemStack(this.icons[this.iconIndex]); diff --git a/src/main/java/dev/esophose/playerparticles/gui/GuiInventoryDefault.java b/src/main/java/dev/esophose/playerparticles/gui/GuiInventoryDefault.java index 92a02fc..a9b28c7 100644 --- a/src/main/java/dev/esophose/playerparticles/gui/GuiInventoryDefault.java +++ b/src/main/java/dev/esophose/playerparticles/gui/GuiInventoryDefault.java @@ -49,14 +49,25 @@ public class GuiInventoryDefault extends GuiInventory { localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-saved-groups", StringPlaceholders.single("amount", pplayer.getParticleGroups().size() - 1)), localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-fixed-effects", StringPlaceholders.single("amount", pplayer.getFixedEffectIds().size())), " ", - localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-commands-info") + localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-commands-info"), + " ", + localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-toggle-visibility-" + (pplayer.canSeeParticles() ? "on" : "off")), + localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-toggle-visibility-info") }; currentIconMeta.setLore(GuiActionButton.parseLore(this.pplayer, currentIconLore)); currentIconMeta.setOwner(pplayer.getPlayer().getName()); headIcon.setItemMeta(currentIconMeta); } - this.inventory.setItem(13, headIcon); + GuiActionButton headButton = new GuiActionButton( + 13, + headIcon, + (button, isShiftClick) -> { + PlayerParticlesAPI.getInstance().togglePlayerParticleVisibility(pplayer.getPlayer(), pplayer.canSeeParticles()); + guiManager.transition(new GuiInventoryDefault(pplayer)); + } + ); + this.actionButtons.add(headButton); // Define what slots to put the icons at based on what other slots are visible boolean manageGroupsVisible = PlayerParticles.getInstance().getManager(PermissionManager.class).canPlayerSaveGroups(pplayer); diff --git a/src/main/java/dev/esophose/playerparticles/locale/EnglishLocale.java b/src/main/java/dev/esophose/playerparticles/locale/EnglishLocale.java index 22580a5..d0719b5 100644 --- a/src/main/java/dev/esophose/playerparticles/locale/EnglishLocale.java +++ b/src/main/java/dev/esophose/playerparticles/locale/EnglishLocale.java @@ -251,6 +251,9 @@ public class EnglishLocale implements Locale { this.put("#28", "GUI Info Messages"); this.put("gui-commands-info", "Find info about commands with &b/pp help"); + this.put("gui-toggle-visibility-on", "Particles are currently &avisible"); + this.put("gui-toggle-visibility-off", "Particles are currently &chidden"); + this.put("gui-toggle-visibility-info", "Click to toggle particle visibility"); this.put("gui-back-button", "Go Back"); this.put("gui-next-page-button", "Next Page (%start%/%end%)"); this.put("gui-previous-page-button", "Previous Page (%start%/%end%)"); diff --git a/src/main/java/dev/esophose/playerparticles/locale/FrenchLocale.java b/src/main/java/dev/esophose/playerparticles/locale/FrenchLocale.java index 7f3946c..293dc56 100644 --- a/src/main/java/dev/esophose/playerparticles/locale/FrenchLocale.java +++ b/src/main/java/dev/esophose/playerparticles/locale/FrenchLocale.java @@ -251,6 +251,9 @@ public class FrenchLocale implements Locale { this.put("#28", "GUI Info Messages"); this.put("gui-commands-info", "Affichez des informations avec &b/pp help"); + this.put("gui-toggle-visibility-on", "Les particules sont actuellement &avisibles"); + this.put("gui-toggle-visibility-off", "Les particules sont actuellement &ccachées"); + this.put("gui-toggle-visibility-info", "Cliquer pour basculer la visibilité des particules"); this.put("gui-back-button", "Retour en arrière"); this.put("gui-next-page-button", "Page Suivante (%start%/%end%)"); this.put("gui-previous-page-button", "Page Précédente (%start%/%end%)"); diff --git a/src/main/java/dev/esophose/playerparticles/locale/GermanLocale.java b/src/main/java/dev/esophose/playerparticles/locale/GermanLocale.java index 4dc8a15..7580a1b 100644 --- a/src/main/java/dev/esophose/playerparticles/locale/GermanLocale.java +++ b/src/main/java/dev/esophose/playerparticles/locale/GermanLocale.java @@ -251,6 +251,9 @@ public class GermanLocale implements Locale { this.put("#28", "GUI Info Messages"); this.put("gui-commands-info", "Informationen zu Befehlen finden Sie mit Hilfe von &b/pp help"); + this.put("gui-toggle-visibility-on", "Partikel sind derzeit &asichtbar"); + this.put("gui-toggle-visibility-off", "Partikel sind derzeit &causgeblendet"); + this.put("gui-toggle-visibility-info", "Klicken Sie, um die Sichtbarkeit der Partikel einzuschalten"); this.put("gui-back-button", "Zurück"); this.put("gui-next-page-button", "Nächste Seite (%start%/%end%)"); this.put("gui-previous-page-button", "Vorherige Seite (%start%/%end%)"); diff --git a/src/main/java/dev/esophose/playerparticles/locale/RussianLocale.java b/src/main/java/dev/esophose/playerparticles/locale/RussianLocale.java index 34b9ec0..c023e63 100644 --- a/src/main/java/dev/esophose/playerparticles/locale/RussianLocale.java +++ b/src/main/java/dev/esophose/playerparticles/locale/RussianLocale.java @@ -251,6 +251,9 @@ public class RussianLocale implements Locale { this.put("#28", "GUI Info Messages"); this.put("gui-commands-info", "Узнать подробнее о командах - &b/pp help"); + this.put("gui-toggle-visibility-on", "Частицы в настоящее время &aвидны"); + this.put("gui-toggle-visibility-off", "В настоящее время частицы &cскрыты"); + this.put("gui-toggle-visibility-info", "Нажмите, чтобы переключить видимость частиц"); this.put("gui-back-button", "Назад"); this.put("gui-next-page-button", "Следующая страница (%start%/%end%)"); this.put("gui-previous-page-button", "Предыдущая страница (%start%/%end%)"); diff --git a/src/main/java/dev/esophose/playerparticles/locale/SimplifiedChineseLocale.java b/src/main/java/dev/esophose/playerparticles/locale/SimplifiedChineseLocale.java index 549dc3d..c422e01 100644 --- a/src/main/java/dev/esophose/playerparticles/locale/SimplifiedChineseLocale.java +++ b/src/main/java/dev/esophose/playerparticles/locale/SimplifiedChineseLocale.java @@ -251,6 +251,9 @@ public class SimplifiedChineseLocale implements Locale { this.put("#28", "GUI Info Messages"); this.put("gui-commands-info", "输入 &b/pp help 查看指令帮助"); + this.put("gui-toggle-visibility-on", "粒子目前可见"); + this.put("gui-toggle-visibility-off", "粒子目前被隐藏"); + this.put("gui-toggle-visibility-info", "单击以切换粒子的可见性"); this.put("gui-back-button", "返回"); this.put("gui-next-page-button", "下一页 (%start%/%end%)"); this.put("gui-previous-page-button", "上一页 (%start%/%end%)"); diff --git a/src/main/java/dev/esophose/playerparticles/locale/VietnameseLocale.java b/src/main/java/dev/esophose/playerparticles/locale/VietnameseLocale.java index 0cb8ce5..4e9b965 100644 --- a/src/main/java/dev/esophose/playerparticles/locale/VietnameseLocale.java +++ b/src/main/java/dev/esophose/playerparticles/locale/VietnameseLocale.java @@ -251,6 +251,9 @@ public class VietnameseLocale implements Locale { this.put("#28", "GUI Info Messages"); this.put("gui-commands-info", "Hiển thị thêm các lệnh bằng cách gõ &b/pp help"); + this.put("gui-toggle-visibility-on", "Các hạt hiện có thể nhìn thấy được"); + this.put("gui-toggle-visibility-off", "Các hạt hiện đang bị ẩn"); + this.put("gui-toggle-visibility-info", "Nhấp để chuyển đổi chế độ hiển thị hạt"); this.put("gui-back-button", "Quay trở về"); this.put("gui-next-page-button", "Trang tiếp theo (%start%/%end%)"); this.put("gui-previous-page-button", "Trang trước (%start%/%end%)");