mirror of
https://github.com/TotalFreedomMC/PlayerParticles.git
synced 2025-02-11 03:29:53 +00:00
Added PlaceholderAPI support
This commit is contained in:
parent
5f0b4905ae
commit
2d7c78a06c
15 changed files with 115 additions and 69 deletions
|
@ -17,6 +17,7 @@ repositories {
|
|||
|
||||
maven { url = 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/' }
|
||||
maven { url = 'https://repo.codemc.org/repository/maven-public' }
|
||||
maven { url = 'http://repo.extendedclip.com/content/repositories/placeholderapi/' }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
@ -24,7 +25,8 @@ dependencies {
|
|||
compile 'org.slf4j:slf4j-nop:1.7.25'
|
||||
compile 'com.zaxxer:HikariCP:3.2.0'
|
||||
compile 'com.googlecode.json-simple:json-simple:1.1.1'
|
||||
shadow 'org.xerial:sqlite-jdbc:3.23.1'
|
||||
compile 'me.clip:placeholderapi:2.10.4'
|
||||
shadow 'org.xerial:sqlite-jdbc:3.23.1'
|
||||
shadow 'org.spigotmc:spigot-api:1.15-R0.1-SNAPSHOT'
|
||||
}
|
||||
|
||||
|
|
|
@ -1,14 +1,5 @@
|
|||
=== v7.0 ===
|
||||
* The config will no longer reset for each and every update
|
||||
+ Added settings for each effect located in the /effects folder
|
||||
+ Added settings for each style located in the /styles folder
|
||||
+ All command and parameter names can now be edited in the new commands.yml file
|
||||
+ Added support for what I'm calling language packs
|
||||
- Language packs have the ability to overwrite any message in the plugin
|
||||
+ Added language settings for all material names which can be changed in a languge pack
|
||||
* The command '/pp fixed clear <radius>' now accepts an optional location/world as '/pp fixed clear <radius> [<x> <y> <z> [world]]'
|
||||
+ Added support for 1.15 particles, the future is now
|
||||
+ Added support for 1.8.8 for those who refuse to accept the future (this is the only version of 1.8.x that will be supported, I will eventually drop support for it again in the future)
|
||||
* Coming soon
|
||||
=== v6.6 ===
|
||||
+ Added support for Minecraft 1.15
|
||||
+ Added 1.15 effects: 'dripping_honey', 'falling_honey', 'falling_nectar', and 'landing_honey'
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
/*
|
||||
* TODO: v7.0
|
||||
* * Refactored and cleaned up code to remove static abuse
|
||||
* * Changed the plugin's package name
|
||||
* * Added an API, accessible through the dev.esophose.playerparticles.api.PlayerParticlesAPI class
|
||||
* + Add ability to create/manage fixed effects from the GUI
|
||||
* * Convert fixed effect ids into names
|
||||
|
@ -14,6 +12,13 @@
|
|||
* + Added setting to disable particles while in combat
|
||||
*/
|
||||
|
||||
/*
|
||||
* * Refactored and cleaned up code to remove static abuse
|
||||
* * Changed the package names
|
||||
* + Config and lang files will no longer reset every update
|
||||
* + Added PlaceholderAPI support (no placeholders, just placeholder replacing in messages)
|
||||
*/
|
||||
|
||||
package dev.esophose.playerparticles;
|
||||
|
||||
import dev.esophose.playerparticles.gui.hook.PlayerChatHook;
|
||||
|
|
|
@ -129,7 +129,7 @@ public class RemoveCommandModule implements CommandModule {
|
|||
}
|
||||
|
||||
public boolean requiresEffects() {
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean canConsoleExecute() {
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package dev.esophose.playerparticles.gui;
|
||||
|
||||
import dev.esophose.playerparticles.gui.GuiInventoryEditData.ColorData;
|
||||
import dev.esophose.playerparticles.hook.PlaceholderAPIHook;
|
||||
import dev.esophose.playerparticles.particles.PPlayer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.bukkit.ChatColor;
|
||||
|
@ -93,10 +95,11 @@ public class GuiActionButton {
|
|||
|
||||
/**
|
||||
* Gets the ItemStack icon that goes into the GUI
|
||||
*
|
||||
*
|
||||
* @param pplayer The PPlayer that is viewing the icon
|
||||
* @return The icon ItemStack for the GUI
|
||||
*/
|
||||
public ItemStack getIcon() {
|
||||
public ItemStack getIcon(PPlayer pplayer) {
|
||||
ItemStack itemStack;
|
||||
if (this.icons != null) {
|
||||
itemStack = new ItemStack(this.icons[this.iconIndex]);
|
||||
|
@ -110,8 +113,8 @@ public class GuiActionButton {
|
|||
|
||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||
if (itemMeta != null) {
|
||||
itemMeta.setDisplayName(this.name);
|
||||
itemMeta.setLore(parseLore(this.lore));
|
||||
itemMeta.setDisplayName(PlaceholderAPIHook.applyPlaceholders(pplayer.getPlayer(), this.name));
|
||||
itemMeta.setLore(parseLore(pplayer, this.lore));
|
||||
itemMeta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES, ItemFlag.HIDE_POTION_EFFECTS);
|
||||
itemStack.setItemMeta(itemMeta);
|
||||
}
|
||||
|
@ -149,11 +152,12 @@ public class GuiActionButton {
|
|||
* Builds lore from a list of Strings
|
||||
* Parses \n as a new lore line
|
||||
* Ignores empty lore lines
|
||||
*
|
||||
*
|
||||
* @param pplayer The PPlayer viewing the lore
|
||||
* @param lore The lines of lore
|
||||
* @return A parsed list of lore text
|
||||
*/
|
||||
public static List<String> parseLore(String... lore) {
|
||||
public static List<String> parseLore(PPlayer pplayer, String... lore) {
|
||||
List<String> parsedLore = new ArrayList<>();
|
||||
for (String line : lore) {
|
||||
// Try to maintain the color going to the next line if it's split
|
||||
|
@ -167,7 +171,7 @@ public class GuiActionButton {
|
|||
String[] splitLines = line.split("\n");
|
||||
for (String parsedLine : splitLines) {
|
||||
if (ChatColor.stripColor(parsedLine).isEmpty()) continue;
|
||||
parsedLore.add(lineColor + parsedLine);
|
||||
parsedLore.add(PlaceholderAPIHook.applyPlaceholders(pplayer.getPlayer(), lineColor + parsedLine));
|
||||
}
|
||||
}
|
||||
return parsedLore;
|
||||
|
|
|
@ -5,6 +5,8 @@ import dev.esophose.playerparticles.particles.PPlayer;
|
|||
import dev.esophose.playerparticles.util.ParticleUtils;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -122,7 +124,7 @@ public abstract class GuiInventory implements InventoryHolder {
|
|||
*/
|
||||
protected void populate() {
|
||||
for (GuiActionButton button : this.actionButtons) {
|
||||
this.inventory.setItem(button.getSlot(), button.getIcon());
|
||||
this.inventory.setItem(button.getSlot(), button.getIcon(this.pplayer));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -133,7 +135,7 @@ public abstract class GuiInventory implements InventoryHolder {
|
|||
for (GuiActionButton button : this.actionButtons) {
|
||||
if (button.isTickable()) {
|
||||
button.onTick();
|
||||
this.inventory.setItem(button.getSlot(), button.getIcon());
|
||||
this.inventory.setItem(button.getSlot(), button.getIcon(this.pplayer));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -160,10 +162,5 @@ public abstract class GuiInventory implements InventoryHolder {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
public interface GuiInventoryEditFinishedCallback {
|
||||
void execute();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ public class GuiInventoryDefault extends GuiInventory {
|
|||
" ",
|
||||
localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-commands-info")
|
||||
};
|
||||
currentIconMeta.setLore(GuiActionButton.parseLore(currentIconLore));
|
||||
currentIconMeta.setLore(GuiActionButton.parseLore(this.pplayer, currentIconLore));
|
||||
currentIconMeta.setOwner(pplayer.getPlayer().getName());
|
||||
headIcon.setItemMeta(currentIconMeta);
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ public class GuiInventoryDefault extends GuiInventory {
|
|||
localeManager.getLocaleMessage("gui-color-icon-name") + localeManager.getLocaleMessage("gui-edit-primary-effect"),
|
||||
new String[]{localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-edit-primary-effect-description")},
|
||||
(button, isShiftClick) -> {
|
||||
List<GuiInventoryEditFinishedCallback> callbacks = new ArrayList<>();
|
||||
List<Runnable> callbacks = new ArrayList<>();
|
||||
callbacks.add(() -> guiManager.transition(new GuiInventoryDefault(pplayer)));
|
||||
callbacks.add(() -> guiManager.transition(new GuiInventoryEditEffect(pplayer, editingParticle, 1, callbacks, 1)));
|
||||
callbacks.add(() -> {
|
||||
|
@ -140,7 +140,7 @@ public class GuiInventoryDefault extends GuiInventory {
|
|||
guiManager.transition(new GuiInventoryDefault(pplayer));
|
||||
});
|
||||
|
||||
callbacks.get(1).execute();
|
||||
callbacks.get(1).run();
|
||||
});
|
||||
this.actionButtons.add(editPrimaryEffect);
|
||||
|
||||
|
@ -162,7 +162,7 @@ public class GuiInventoryDefault extends GuiInventory {
|
|||
(button, isShiftClick) -> {
|
||||
if (!canEditPrimaryStyleAndData) return;
|
||||
|
||||
List<GuiInventoryEditFinishedCallback> callbacks = new ArrayList<>();
|
||||
List<Runnable> callbacks = new ArrayList<>();
|
||||
callbacks.add(() -> guiManager.transition(new GuiInventoryDefault(pplayer)));
|
||||
callbacks.add(() -> guiManager.transition(new GuiInventoryEditStyle(pplayer, editingParticle, 1, callbacks, 1)));
|
||||
callbacks.add(() -> {
|
||||
|
@ -178,7 +178,7 @@ public class GuiInventoryDefault extends GuiInventory {
|
|||
guiManager.transition(new GuiInventoryDefault(pplayer));
|
||||
});
|
||||
|
||||
callbacks.get(1).execute();
|
||||
callbacks.get(1).run();
|
||||
});
|
||||
this.actionButtons.add(editPrimaryStyle);
|
||||
|
||||
|
@ -205,7 +205,7 @@ public class GuiInventoryDefault extends GuiInventory {
|
|||
(button, isShiftClick) -> {
|
||||
if (!canEditPrimaryStyleAndData || !doesEffectUseData) return;
|
||||
|
||||
List<GuiInventoryEditFinishedCallback> callbacks = new ArrayList<>();
|
||||
List<Runnable> callbacks = new ArrayList<>();
|
||||
callbacks.add(() -> guiManager.transition(new GuiInventoryDefault(pplayer)));
|
||||
callbacks.add(() -> guiManager.transition(new GuiInventoryEditData(pplayer, editingParticle, 1, callbacks, 1)));
|
||||
callbacks.add(() -> {
|
||||
|
@ -224,7 +224,7 @@ public class GuiInventoryDefault extends GuiInventory {
|
|||
guiManager.transition(new GuiInventoryDefault(pplayer));
|
||||
});
|
||||
|
||||
callbacks.get(1).execute();
|
||||
callbacks.get(1).run();
|
||||
});
|
||||
this.actionButtons.add(editPrimaryData);
|
||||
|
||||
|
|
|
@ -139,7 +139,7 @@ public class GuiInventoryEditData extends GuiInventory {
|
|||
}
|
||||
}
|
||||
|
||||
public GuiInventoryEditData(PPlayer pplayer, ParticlePair editingParticle, int pageNumber, List<GuiInventoryEditFinishedCallback> callbackList, int callbackListPosition) {
|
||||
public GuiInventoryEditData(PPlayer pplayer, ParticlePair editingParticle, int pageNumber, List<Runnable> callbackList, int callbackListPosition) {
|
||||
super(pplayer, Bukkit.createInventory(pplayer.getPlayer(), INVENTORY_SIZE, PlayerParticles.getInstance().getManager(LocaleManager.class).getLocaleMessage("gui-select-data")));
|
||||
|
||||
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
|
||||
|
@ -167,7 +167,7 @@ public class GuiInventoryEditData extends GuiInventory {
|
|||
GuiIcon.BACK.get(),
|
||||
localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-back-button"),
|
||||
new String[]{},
|
||||
(button, isShiftClick) -> callbackList.get(callbackListPosition - 1).execute());
|
||||
(button, isShiftClick) -> callbackList.get(callbackListPosition - 1).run());
|
||||
this.actionButtons.add(backButton);
|
||||
|
||||
this.populate();
|
||||
|
@ -181,7 +181,7 @@ public class GuiInventoryEditData extends GuiInventory {
|
|||
* @param callbackList The List of GuiInventoryEditFinishedCallbacks
|
||||
* @param callbackListPosition The index of the callbackList we're currently at
|
||||
*/
|
||||
private void populateColorData(ParticlePair editingParticle, int pageNumber, List<GuiInventoryEditFinishedCallback> callbackList, int callbackListPosition) {
|
||||
private void populateColorData(ParticlePair editingParticle, int pageNumber, List<Runnable> callbackList, int callbackListPosition) {
|
||||
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
|
||||
|
||||
int index = 10;
|
||||
|
@ -197,7 +197,7 @@ public class GuiInventoryEditData extends GuiInventory {
|
|||
new String[]{localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-select-data-description", StringPlaceholders.single("data", formattedDisplayColor))},
|
||||
(button, isShiftClick) -> {
|
||||
editingParticle.setColor(colorData.getOrdinaryColor());
|
||||
callbackList.get(callbackListPosition + 1).execute();
|
||||
callbackList.get(callbackListPosition + 1).run();
|
||||
});
|
||||
this.actionButtons.add(setColorButton);
|
||||
|
||||
|
@ -216,7 +216,7 @@ public class GuiInventoryEditData extends GuiInventory {
|
|||
new String[]{localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-select-data-description", StringPlaceholders.single("data", localeManager.getLocaleMessage("rainbow")))},
|
||||
(button, isShiftClick) -> {
|
||||
editingParticle.setColor(new OrdinaryColor(999, 999, 999));
|
||||
callbackList.get(callbackListPosition + 1).execute();
|
||||
callbackList.get(callbackListPosition + 1).run();
|
||||
});
|
||||
this.actionButtons.add(setRainbowColorButton);
|
||||
|
||||
|
@ -231,7 +231,7 @@ public class GuiInventoryEditData extends GuiInventory {
|
|||
new String[]{localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-select-data-description", StringPlaceholders.single("data", localeManager.getLocaleMessage("random")))},
|
||||
(button, isShiftClick) -> {
|
||||
editingParticle.setColor(new OrdinaryColor(998, 998, 998));
|
||||
callbackList.get(callbackListPosition + 1).execute();
|
||||
callbackList.get(callbackListPosition + 1).run();
|
||||
});
|
||||
this.actionButtons.add(setRandomColorButton);
|
||||
}
|
||||
|
@ -244,7 +244,7 @@ public class GuiInventoryEditData extends GuiInventory {
|
|||
* @param pageNumber The current page number
|
||||
* @param callbackListPosition The index of the callbackList we're currently at
|
||||
*/
|
||||
private void populateNoteData(ParticlePair editingParticle, int pageNumber, List<GuiInventoryEditFinishedCallback> callbackList, int callbackListPosition) {
|
||||
private void populateNoteData(ParticlePair editingParticle, int pageNumber, List<Runnable> callbackList, int callbackListPosition) {
|
||||
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
|
||||
GuiManager guiManager = PlayerParticles.getInstance().getManager(GuiManager.class);
|
||||
|
||||
|
@ -269,7 +269,7 @@ public class GuiInventoryEditData extends GuiInventory {
|
|||
new String[]{formattedDescription},
|
||||
(button, isShiftClick) -> {
|
||||
editingParticle.setNoteColor(new NoteColor(noteIndex));
|
||||
callbackList.get(callbackListPosition + 1).execute();
|
||||
callbackList.get(callbackListPosition + 1).run();
|
||||
});
|
||||
this.actionButtons.add(setColorButton);
|
||||
|
||||
|
@ -289,7 +289,7 @@ public class GuiInventoryEditData extends GuiInventory {
|
|||
new String[]{localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-select-data-description", StringPlaceholders.single("data", localeManager.getLocaleMessage("rainbow")))},
|
||||
(button, isShiftClick) -> {
|
||||
editingParticle.setNoteColor(new NoteColor(99));
|
||||
callbackList.get(callbackListPosition + 1).execute();
|
||||
callbackList.get(callbackListPosition + 1).run();
|
||||
});
|
||||
this.actionButtons.add(setRainbowColorButton);
|
||||
|
||||
|
@ -305,7 +305,7 @@ public class GuiInventoryEditData extends GuiInventory {
|
|||
new String[]{localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-select-data-description", StringPlaceholders.single("data", localeManager.getLocaleMessage("random")))},
|
||||
(button, isShiftClick) -> {
|
||||
editingParticle.setNoteColor(new NoteColor(98));
|
||||
callbackList.get(callbackListPosition + 1).execute();
|
||||
callbackList.get(callbackListPosition + 1).run();
|
||||
});
|
||||
this.actionButtons.add(setRandomColorButton);
|
||||
|
||||
|
@ -340,7 +340,7 @@ public class GuiInventoryEditData extends GuiInventory {
|
|||
* @param pageNumber The current page number
|
||||
* @param callbackListPosition The index of the callbackList we're currently at
|
||||
*/
|
||||
private void populateItemData(ParticlePair editingParticle, int pageNumber, List<GuiInventoryEditFinishedCallback> callbackList, int callbackListPosition) {
|
||||
private void populateItemData(ParticlePair editingParticle, int pageNumber, List<Runnable> callbackList, int callbackListPosition) {
|
||||
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
|
||||
GuiManager guiManager = PlayerParticles.getInstance().getManager(GuiManager.class);
|
||||
|
||||
|
@ -361,7 +361,7 @@ public class GuiInventoryEditData extends GuiInventory {
|
|||
new String[]{localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-select-data-description", StringPlaceholders.single("data", material.name().toLowerCase()))},
|
||||
(button, isShiftClick) -> {
|
||||
editingParticle.setItemMaterial(material);
|
||||
callbackList.get(callbackListPosition + 1).execute();
|
||||
callbackList.get(callbackListPosition + 1).run();
|
||||
});
|
||||
this.actionButtons.add(setRainbowColorButton);
|
||||
|
||||
|
@ -404,7 +404,7 @@ public class GuiInventoryEditData extends GuiInventory {
|
|||
* @param pageNumber The current page number
|
||||
* @param callbackListPosition The index of the callbackList we're currently at
|
||||
*/
|
||||
private void populateBlockData(ParticlePair editingParticle, int pageNumber, List<GuiInventoryEditFinishedCallback> callbackList, int callbackListPosition) {
|
||||
private void populateBlockData(ParticlePair editingParticle, int pageNumber, List<Runnable> callbackList, int callbackListPosition) {
|
||||
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
|
||||
GuiManager guiManager = PlayerParticles.getInstance().getManager(GuiManager.class);
|
||||
|
||||
|
@ -425,7 +425,7 @@ public class GuiInventoryEditData extends GuiInventory {
|
|||
new String[]{localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-select-data-description", StringPlaceholders.single("data", material.name().toLowerCase()))},
|
||||
(button, isShiftClick) -> {
|
||||
editingParticle.setBlockMaterial(material);
|
||||
callbackList.get(callbackListPosition + 1).execute();
|
||||
callbackList.get(callbackListPosition + 1).run();
|
||||
});
|
||||
this.actionButtons.add(setRainbowColorButton);
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ import org.bukkit.Bukkit;
|
|||
|
||||
public class GuiInventoryEditEffect extends GuiInventory {
|
||||
|
||||
public GuiInventoryEditEffect(PPlayer pplayer, ParticlePair editingParticle, int pageNumber, List<GuiInventoryEditFinishedCallback> callbackList, int callbackListPosition) {
|
||||
public GuiInventoryEditEffect(PPlayer pplayer, ParticlePair editingParticle, int pageNumber, List<Runnable> callbackList, int callbackListPosition) {
|
||||
super(pplayer, Bukkit.createInventory(pplayer.getPlayer(), INVENTORY_SIZE, PlayerParticles.getInstance().getManager(LocaleManager.class).getLocaleMessage("gui-select-effect")));
|
||||
|
||||
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
|
||||
|
@ -41,7 +41,7 @@ public class GuiInventoryEditEffect extends GuiInventory {
|
|||
new String[]{localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-select-effect-description", StringPlaceholders.single("effect", ParticleUtils.formatName(effect.getName())))},
|
||||
(button, isShiftClick) -> {
|
||||
editingParticle.setEffect(effect);
|
||||
callbackList.get(callbackListPosition + 1).execute();
|
||||
callbackList.get(callbackListPosition + 1).run();
|
||||
});
|
||||
this.actionButtons.add(selectButton);
|
||||
|
||||
|
@ -59,7 +59,7 @@ public class GuiInventoryEditEffect extends GuiInventory {
|
|||
GuiIcon.BACK.get(),
|
||||
localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-back-button"),
|
||||
new String[]{},
|
||||
(button, isShiftClick) -> callbackList.get(callbackListPosition - 1).execute());
|
||||
(button, isShiftClick) -> callbackList.get(callbackListPosition - 1).run());
|
||||
this.actionButtons.add(backButton);
|
||||
|
||||
// Previous page button
|
||||
|
|
|
@ -47,7 +47,7 @@ public class GuiInventoryEditParticle extends GuiInventory {
|
|||
localeManager.getLocaleMessage("gui-color-icon-name") + localeManager.getLocaleMessage("gui-edit-effect"),
|
||||
new String[]{localeManager.getLocaleMessage("gui-color-subtext") + localeManager.getLocaleMessage("gui-edit-effect-description")},
|
||||
(button, isShiftClick) -> {
|
||||
List<GuiInventoryEditFinishedCallback> callbacks = new ArrayList<>();
|
||||
List<Runnable> callbacks = new ArrayList<>();
|
||||
callbacks.add(() -> guiManager.transition(new GuiInventoryEditParticle(pplayer, editingParticle)));
|
||||
callbacks.add(() -> guiManager.transition(new GuiInventoryEditEffect(pplayer, editingParticle, 1, callbacks, 1)));
|
||||
callbacks.add(() -> {
|
||||
|
@ -63,7 +63,7 @@ public class GuiInventoryEditParticle extends GuiInventory {
|
|||
guiManager.transition(new GuiInventoryEditParticle(pplayer, editingParticle));
|
||||
});
|
||||
|
||||
callbacks.get(1).execute();
|
||||
callbacks.get(1).run();
|
||||
});
|
||||
this.actionButtons.add(editEffectButton);
|
||||
|
||||
|
@ -73,7 +73,7 @@ public class GuiInventoryEditParticle extends GuiInventory {
|
|||
localeManager.getLocaleMessage("gui-color-icon-name") + localeManager.getLocaleMessage("gui-edit-style"),
|
||||
new String[]{localeManager.getLocaleMessage("gui-color-subtext") + localeManager.getLocaleMessage("gui-edit-style-description")},
|
||||
(button, isShiftClick) -> {
|
||||
List<GuiInventoryEditFinishedCallback> callbacks = new ArrayList<>();
|
||||
List<Runnable> callbacks = new ArrayList<>();
|
||||
callbacks.add(() -> guiManager.transition(new GuiInventoryEditParticle(pplayer, editingParticle)));
|
||||
callbacks.add(() -> guiManager.transition(new GuiInventoryEditStyle(pplayer, editingParticle, 1, callbacks, 1)));
|
||||
callbacks.add(() -> {
|
||||
|
@ -89,7 +89,7 @@ public class GuiInventoryEditParticle extends GuiInventory {
|
|||
guiManager.transition(new GuiInventoryEditParticle(pplayer, editingParticle));
|
||||
});
|
||||
|
||||
callbacks.get(1).execute();
|
||||
callbacks.get(1).run();
|
||||
});
|
||||
this.actionButtons.add(editStyleButton);
|
||||
|
||||
|
@ -102,7 +102,7 @@ public class GuiInventoryEditParticle extends GuiInventory {
|
|||
new String[]{localeManager.getLocaleMessage("gui-color-unavailable") + localeManager.getLocaleMessage("gui-edit-data-unavailable")},
|
||||
(button, isShiftClick) -> {
|
||||
if (usesData) {
|
||||
List<GuiInventoryEditFinishedCallback> callbacks = new ArrayList<>();
|
||||
List<Runnable> callbacks = new ArrayList<>();
|
||||
callbacks.add(() -> guiManager.transition(new GuiInventoryEditParticle(pplayer, editingParticle)));
|
||||
callbacks.add(() -> guiManager.transition(new GuiInventoryEditData(pplayer, editingParticle, 1, callbacks, 1)));
|
||||
callbacks.add(() -> {
|
||||
|
@ -121,7 +121,7 @@ public class GuiInventoryEditParticle extends GuiInventory {
|
|||
guiManager.transition(new GuiInventoryEditParticle(pplayer, editingParticle));
|
||||
});
|
||||
|
||||
callbacks.get(1).execute();
|
||||
callbacks.get(1).run();
|
||||
}
|
||||
});
|
||||
this.actionButtons.add(editDataButton);
|
||||
|
|
|
@ -15,7 +15,7 @@ import org.bukkit.Bukkit;
|
|||
|
||||
public class GuiInventoryEditStyle extends GuiInventory {
|
||||
|
||||
public GuiInventoryEditStyle(PPlayer pplayer, ParticlePair editingParticle, int pageNumber, List<GuiInventoryEditFinishedCallback> callbackList, int callbackListPosition) {
|
||||
public GuiInventoryEditStyle(PPlayer pplayer, ParticlePair editingParticle, int pageNumber, List<Runnable> callbackList, int callbackListPosition) {
|
||||
super(pplayer, Bukkit.createInventory(pplayer.getPlayer(), INVENTORY_SIZE, PlayerParticles.getInstance().getManager(LocaleManager.class).getLocaleMessage("gui-select-style")));
|
||||
|
||||
LocaleManager localeManager = PlayerParticles.getInstance().getManager(LocaleManager.class);
|
||||
|
@ -41,7 +41,7 @@ public class GuiInventoryEditStyle extends GuiInventory {
|
|||
new String[]{localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-select-style-description", StringPlaceholders.single("style", ParticleUtils.formatName(style.getName())))},
|
||||
(button, isShiftClick) -> {
|
||||
editingParticle.setStyle(style);
|
||||
callbackList.get(callbackListPosition + 1).execute();
|
||||
callbackList.get(callbackListPosition + 1).run();
|
||||
});
|
||||
this.actionButtons.add(selectButton);
|
||||
|
||||
|
@ -59,7 +59,7 @@ public class GuiInventoryEditStyle extends GuiInventory {
|
|||
GuiIcon.BACK.get(),
|
||||
localeManager.getLocaleMessage("gui-color-info") + localeManager.getLocaleMessage("gui-back-button"),
|
||||
new String[]{},
|
||||
(button, isShiftClick) -> callbackList.get(callbackListPosition - 1).execute());
|
||||
(button, isShiftClick) -> callbackList.get(callbackListPosition - 1).run());
|
||||
this.actionButtons.add(backButton);
|
||||
|
||||
// Previous page button
|
||||
|
|
|
@ -90,7 +90,7 @@ public class GuiInventoryManageParticles extends GuiInventory {
|
|||
(button, isShiftClick) -> {
|
||||
if (!canCreate) return;
|
||||
ParticlePair editingParticle = ParticlePair.getNextDefault(pplayer);
|
||||
List<GuiInventoryEditFinishedCallback> callbacks = new ArrayList<>();
|
||||
List<Runnable> callbacks = new ArrayList<>();
|
||||
callbacks.add(() -> guiManager.transition(new GuiInventoryManageParticles(pplayer)));
|
||||
callbacks.add(() -> guiManager.transition(new GuiInventoryEditEffect(pplayer, editingParticle, 1, callbacks, 1)));
|
||||
callbacks.add(() -> guiManager.transition(new GuiInventoryEditStyle(pplayer, editingParticle, 1, callbacks, 2)));
|
||||
|
@ -98,7 +98,7 @@ public class GuiInventoryManageParticles extends GuiInventory {
|
|||
if (editingParticle.getEffect().hasProperty(ParticleProperty.COLORABLE) || editingParticle.getEffect().hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) {
|
||||
guiManager.transition(new GuiInventoryEditData(pplayer, editingParticle, 1, callbacks, 3));
|
||||
} else {
|
||||
callbacks.get(4).execute();
|
||||
callbacks.get(4).run();
|
||||
}
|
||||
});
|
||||
callbacks.add(() -> {
|
||||
|
@ -110,7 +110,7 @@ public class GuiInventoryManageParticles extends GuiInventory {
|
|||
// Reopen the manage particle inventory
|
||||
guiManager.transition(new GuiInventoryManageParticles(pplayer));
|
||||
});
|
||||
callbacks.get(1).execute();
|
||||
callbacks.get(1).run();
|
||||
});
|
||||
this.actionButtons.add(createNewParticle);
|
||||
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
package dev.esophose.playerparticles.hook;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
|
||||
public final class PlaceholderAPIHook {
|
||||
|
||||
private static Boolean enabled;
|
||||
|
||||
/**
|
||||
* @return true if PlaceholderAPI is enabled, otherwise false
|
||||
*/
|
||||
public static boolean enabled() {
|
||||
if (enabled != null)
|
||||
return enabled;
|
||||
return enabled = Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies placeholders from PlaceholderAPI to strings
|
||||
*
|
||||
* @param player The Player to apply placeholders with
|
||||
* @param text The text to replace placeholders
|
||||
* @return A string with replaced placeholders
|
||||
*/
|
||||
public static String applyPlaceholders(Player player, String text) {
|
||||
if (enabled())
|
||||
return PlaceholderAPI.setPlaceholders(player, text);
|
||||
return text;
|
||||
}
|
||||
|
||||
}
|
|
@ -2,6 +2,7 @@ package dev.esophose.playerparticles.manager;
|
|||
|
||||
import dev.esophose.playerparticles.PlayerParticles;
|
||||
import dev.esophose.playerparticles.config.CommentedFileConfiguration;
|
||||
import dev.esophose.playerparticles.hook.PlaceholderAPIHook;
|
||||
import dev.esophose.playerparticles.locale.EnglishLocale;
|
||||
import dev.esophose.playerparticles.locale.FrenchLocale;
|
||||
import dev.esophose.playerparticles.locale.GermanLocale;
|
||||
|
@ -17,6 +18,7 @@ import java.io.IOException;
|
|||
import java.util.Map;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class LocaleManager extends Manager {
|
||||
|
||||
|
@ -126,7 +128,7 @@ public class LocaleManager extends Manager {
|
|||
* @param stringPlaceholders The placeholders to apply
|
||||
*/
|
||||
public void sendMessage(PPlayer pplayer, String messageKey, StringPlaceholders stringPlaceholders) {
|
||||
this.sendMessage(pplayer.getMessageDestination(), messageKey, stringPlaceholders);
|
||||
pplayer.getMessageDestination().sendMessage(this.parsePlaceholders(pplayer.getPlayer(), this.getLocaleMessage("prefix") + this.getLocaleMessage(messageKey, stringPlaceholders)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -146,7 +148,7 @@ public class LocaleManager extends Manager {
|
|||
* @param messageKey The message key of the Locale to send
|
||||
*/
|
||||
public void sendMessage(PPlayer pplayer, String messageKey) {
|
||||
this.sendMessage(pplayer.getMessageDestination(), messageKey);
|
||||
this.sendMessage(pplayer, messageKey);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -168,7 +170,7 @@ public class LocaleManager extends Manager {
|
|||
* @param stringPlaceholders The placeholders to apply
|
||||
*/
|
||||
public void sendSimpleMessage(PPlayer pplayer, String messageKey, StringPlaceholders stringPlaceholders) {
|
||||
this.sendSimpleMessage(pplayer.getMessageDestination(), messageKey, stringPlaceholders);
|
||||
pplayer.getMessageDestination().sendMessage(this.parsePlaceholders(pplayer.getPlayer(), this.getLocaleMessage(messageKey, stringPlaceholders)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -188,7 +190,7 @@ public class LocaleManager extends Manager {
|
|||
* @param messageKey The message key of the Locale to send
|
||||
*/
|
||||
public void sendSimpleMessage(PPlayer pplayer, String messageKey) {
|
||||
this.sendSimpleMessage(pplayer.getMessageDestination(), messageKey);
|
||||
this.sendMessage(pplayer, messageKey, StringPlaceholders.empty());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -208,7 +210,18 @@ public class LocaleManager extends Manager {
|
|||
* @param message The message to send
|
||||
*/
|
||||
public void sendCustomMessage(PPlayer pplayer, String message) {
|
||||
this.sendCustomMessage(pplayer.getMessageDestination(), message);
|
||||
this.sendCustomMessage(pplayer.getMessageDestination(), this.parsePlaceholders(pplayer.getPlayer(), message));
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces PlaceholderAPI placeholders if PlaceholderAPI is enabled
|
||||
*
|
||||
* @param player The Player to replace with
|
||||
* @param message The message
|
||||
* @return A placeholder-replaced message
|
||||
*/
|
||||
private String parsePlaceholders(Player player, String message) {
|
||||
return PlaceholderAPIHook.applyPlaceholders(player, message);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ api-version: 1.13
|
|||
description: Display particles around your player and blocks using customized styles and data!
|
||||
author: Esophose
|
||||
website: https://www.spigotmc.org/resources/playerparticles.40261/
|
||||
softdepend: [PlaceholderAPI]
|
||||
commands:
|
||||
pp:
|
||||
description: The main PlayerParticles command. By default, opens the GUI.
|
||||
|
|
Loading…
Reference in a new issue