mirror of
https://github.com/TotalFreedomMC/PlayerParticles.git
synced 2025-07-29 17:02:46 +00:00
GUI Finished, remove message when opening the GUI with /pp, note data range is now 0-24
This commit is contained in:
parent
98a570a236
commit
b1e23b6812
30 changed files with 934 additions and 117 deletions
2
pom.xml
2
pom.xml
|
@ -23,8 +23,6 @@
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>1.8</source>
|
<source>1.8</source>
|
||||||
<target>1.8</target>
|
<target>1.8</target>
|
||||||
<fork>true</fork>
|
|
||||||
<executable>C:\Program Files\Java\jdk1.8.0_161\bin\javac</executable>
|
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
/*
|
/*
|
||||||
* TODO: v5.3
|
* TODO: v5.3 (actually v6)
|
||||||
* + Add new style 'tornado'
|
* + Add new style 'tornado'
|
||||||
|
* + Add new style 'doubleorbit'
|
||||||
* * Adjust PParticles to use a Vector instead of a Location
|
* * Adjust PParticles to use a Vector instead of a Location
|
||||||
* * Setting in config.yml to disable non-event styles while the player is moving
|
* * Setting in config.yml to disable non-event styles while the player is moving
|
||||||
* * Finish rewriting the GUI
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.esophose.playerparticles;
|
package com.esophose.playerparticles;
|
||||||
|
|
|
@ -73,7 +73,7 @@ public class AddCommandModule implements CommandModule {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (note < 0 || note > 23) {
|
if (note < 0 || note > 24) {
|
||||||
LangManager.sendMessage(pplayer, Lang.DATA_INVALID_NOTE);
|
LangManager.sendMessage(pplayer, Lang.DATA_INVALID_NOTE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -143,10 +143,10 @@ public class AddCommandModule implements CommandModule {
|
||||||
List<String> matches = new ArrayList<String>();
|
List<String> matches = new ArrayList<String>();
|
||||||
|
|
||||||
if (args.length <= 1) { // Effect name
|
if (args.length <= 1) { // Effect name
|
||||||
if (args.length == 0) matches = PermissionManager.getEffectsUserHasPermissionFor(p);
|
if (args.length == 0) matches = PermissionManager.getEffectNamesUserHasPermissionFor(p);
|
||||||
else StringUtil.copyPartialMatches(args[0], PermissionManager.getEffectsUserHasPermissionFor(p), matches);
|
else StringUtil.copyPartialMatches(args[0], PermissionManager.getEffectNamesUserHasPermissionFor(p), matches);
|
||||||
} else if (args.length == 2) { // Style name
|
} else if (args.length == 2) { // Style name
|
||||||
StringUtil.copyPartialMatches(args[1], PermissionManager.getStylesUserHasPermissionFor(p), matches);
|
StringUtil.copyPartialMatches(args[1], PermissionManager.getStyleNamesUserHasPermissionFor(p), matches);
|
||||||
} else if (args.length >= 3) { // Data
|
} else if (args.length >= 3) { // Data
|
||||||
ParticleEffect effect = ParticleEffect.fromName(args[0]);
|
ParticleEffect effect = ParticleEffect.fromName(args[0]);
|
||||||
if (effect != null) {
|
if (effect != null) {
|
||||||
|
@ -154,7 +154,7 @@ public class AddCommandModule implements CommandModule {
|
||||||
List<String> possibleValues = new ArrayList<String>();
|
List<String> possibleValues = new ArrayList<String>();
|
||||||
if (effect == ParticleEffect.NOTE) { // Note data
|
if (effect == ParticleEffect.NOTE) { // Note data
|
||||||
if (args.length == 3) {
|
if (args.length == 3) {
|
||||||
possibleValues.add("<0-23>");
|
possibleValues.add("<0-24>");
|
||||||
possibleValues.add("rainbow");
|
possibleValues.add("rainbow");
|
||||||
}
|
}
|
||||||
} else { // Color data
|
} else { // Color data
|
||||||
|
|
|
@ -45,8 +45,8 @@ public class DataCommandModule implements CommandModule {
|
||||||
public List<String> onTabComplete(PPlayer pplayer, String[] args) {
|
public List<String> onTabComplete(PPlayer pplayer, String[] args) {
|
||||||
List<String> matches = new ArrayList<String>();
|
List<String> matches = new ArrayList<String>();
|
||||||
if (args.length <= 1) {
|
if (args.length <= 1) {
|
||||||
if (args.length == 0) matches = PermissionManager.getEffectsUserHasPermissionFor(pplayer.getPlayer());
|
if (args.length == 0) matches = PermissionManager.getEffectNamesUserHasPermissionFor(pplayer.getPlayer());
|
||||||
else StringUtil.copyPartialMatches(args[0], PermissionManager.getEffectsUserHasPermissionFor(pplayer.getPlayer()), matches);
|
else StringUtil.copyPartialMatches(args[0], PermissionManager.getEffectNamesUserHasPermissionFor(pplayer.getPlayer()), matches);
|
||||||
}
|
}
|
||||||
return matches;
|
return matches;
|
||||||
}
|
}
|
||||||
|
|
|
@ -154,7 +154,7 @@ public class EditCommandModule implements CommandModule {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (note < 0 || note > 23) {
|
if (note < 0 || note > 24) {
|
||||||
LangManager.sendMessage(pplayer, Lang.DATA_INVALID_NOTE);
|
LangManager.sendMessage(pplayer, Lang.DATA_INVALID_NOTE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -253,11 +253,11 @@ public class EditCommandModule implements CommandModule {
|
||||||
switch (args[1].toLowerCase()) {
|
switch (args[1].toLowerCase()) {
|
||||||
case "effect":
|
case "effect":
|
||||||
if (args.length == 3)
|
if (args.length == 3)
|
||||||
StringUtil.copyPartialMatches(args[2], PermissionManager.getEffectsUserHasPermissionFor(p), matches);
|
StringUtil.copyPartialMatches(args[2], PermissionManager.getEffectNamesUserHasPermissionFor(p), matches);
|
||||||
break;
|
break;
|
||||||
case "style":
|
case "style":
|
||||||
if (args.length == 3)
|
if (args.length == 3)
|
||||||
StringUtil.copyPartialMatches(args[2], PermissionManager.getStylesUserHasPermissionFor(p), matches);
|
StringUtil.copyPartialMatches(args[2], PermissionManager.getStyleNamesUserHasPermissionFor(p), matches);
|
||||||
break;
|
break;
|
||||||
case "data":
|
case "data":
|
||||||
ParticleEffect effect = pplayer.getActiveParticle(id).getEffect();
|
ParticleEffect effect = pplayer.getActiveParticle(id).getEffect();
|
||||||
|
@ -265,7 +265,7 @@ public class EditCommandModule implements CommandModule {
|
||||||
List<String> possibleValues = new ArrayList<String>();
|
List<String> possibleValues = new ArrayList<String>();
|
||||||
if (effect == ParticleEffect.NOTE) { // Note data
|
if (effect == ParticleEffect.NOTE) { // Note data
|
||||||
if (args.length == 3) {
|
if (args.length == 3) {
|
||||||
possibleValues.add("<0-23>");
|
possibleValues.add("<0-24>");
|
||||||
possibleValues.add("rainbow");
|
possibleValues.add("rainbow");
|
||||||
}
|
}
|
||||||
} else { // Color data
|
} else { // Color data
|
||||||
|
|
|
@ -15,7 +15,7 @@ public class EffectsCommandModule implements CommandModule {
|
||||||
public void onCommandExecute(PPlayer pplayer, String[] args) {
|
public void onCommandExecute(PPlayer pplayer, String[] args) {
|
||||||
Player p = pplayer.getPlayer();
|
Player p = pplayer.getPlayer();
|
||||||
|
|
||||||
List<String> effectList = PermissionManager.getEffectsUserHasPermissionFor(p);
|
List<String> effectList = PermissionManager.getEffectNamesUserHasPermissionFor(p);
|
||||||
if (effectList.isEmpty()) {
|
if (effectList.isEmpty()) {
|
||||||
LangManager.sendMessage(p, Lang.EFFECT_LIST_EMPTY);
|
LangManager.sendMessage(p, Lang.EFFECT_LIST_EMPTY);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -201,7 +201,7 @@ public class FixedCommandModule implements CommandModule {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (note < 0 || note > 23) {
|
if (note < 0 || note > 24) {
|
||||||
LangManager.sendMessage(p, Lang.FIXED_CREATE_DATA_ERROR);
|
LangManager.sendMessage(p, Lang.FIXED_CREATE_DATA_ERROR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -445,9 +445,9 @@ public class FixedCommandModule implements CommandModule {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.length == 5) {
|
if (args.length == 5) {
|
||||||
StringUtil.copyPartialMatches(args[4], PermissionManager.getEffectsUserHasPermissionFor(p), matches);
|
StringUtil.copyPartialMatches(args[4], PermissionManager.getEffectNamesUserHasPermissionFor(p), matches);
|
||||||
} else if (args.length == 6) {
|
} else if (args.length == 6) {
|
||||||
StringUtil.copyPartialMatches(args[5], PermissionManager.getStylesUserHasPermissionFor(p), matches);
|
StringUtil.copyPartialMatches(args[5], PermissionManager.getStyleNamesUserHasPermissionFor(p), matches);
|
||||||
} else if (args.length >= 7) {
|
} else if (args.length >= 7) {
|
||||||
ParticleEffect effect = ParticleEffect.fromName(args[4]);
|
ParticleEffect effect = ParticleEffect.fromName(args[4]);
|
||||||
if (effect != null) {
|
if (effect != null) {
|
||||||
|
@ -455,7 +455,7 @@ public class FixedCommandModule implements CommandModule {
|
||||||
List<String> possibleValues = new ArrayList<String>();
|
List<String> possibleValues = new ArrayList<String>();
|
||||||
if (effect == ParticleEffect.NOTE) { // Note data
|
if (effect == ParticleEffect.NOTE) { // Note data
|
||||||
if (args.length == 7) {
|
if (args.length == 7) {
|
||||||
possibleValues.add("<0-23>");
|
possibleValues.add("<0-24>");
|
||||||
possibleValues.add("rainbow");
|
possibleValues.add("rainbow");
|
||||||
}
|
}
|
||||||
} else { // Color data
|
} else { // Color data
|
||||||
|
|
|
@ -26,7 +26,7 @@ public class GUICommandModule implements CommandModule {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PermissionManager.getEffectsUserHasPermissionFor(pplayer.getPlayer()).isEmpty()) {
|
if (PermissionManager.getEffectNamesUserHasPermissionFor(pplayer.getPlayer()).isEmpty()) {
|
||||||
if (byDefault) {
|
if (byDefault) {
|
||||||
LangManager.sendMessage(pplayer, Lang.COMMAND_ERROR_UNKNOWN);
|
LangManager.sendMessage(pplayer, Lang.COMMAND_ERROR_UNKNOWN);
|
||||||
} else {
|
} else {
|
||||||
|
@ -35,10 +35,6 @@ public class GUICommandModule implements CommandModule {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (byDefault) {
|
|
||||||
LangManager.sendMessage(pplayer, Lang.GUI_BY_DEFAULT);
|
|
||||||
}
|
|
||||||
|
|
||||||
GuiHandler.openDefault(pplayer);
|
GuiHandler.openDefault(pplayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -102,7 +102,7 @@ public class ParticleCommandHandler implements CommandExecutor, TabCompleter {
|
||||||
CommandModule commandModule = findMatchingCommand(commandName);
|
CommandModule commandModule = findMatchingCommand(commandName);
|
||||||
|
|
||||||
if (commandModule != null) {
|
if (commandModule != null) {
|
||||||
if (commandModule.requiresEffects() && PermissionManager.getEffectsUserHasPermissionFor(p).isEmpty()) {
|
if (commandModule.requiresEffects() && PermissionManager.getEffectNamesUserHasPermissionFor(p).isEmpty()) {
|
||||||
LangManager.sendMessage(p, Lang.COMMAND_ERROR_NO_EFFECTS);
|
LangManager.sendMessage(p, Lang.COMMAND_ERROR_NO_EFFECTS);
|
||||||
} else {
|
} else {
|
||||||
String[] cmdArgs = new String[0];
|
String[] cmdArgs = new String[0];
|
||||||
|
|
|
@ -15,7 +15,7 @@ public class StylesCommandModule implements CommandModule {
|
||||||
public void onCommandExecute(PPlayer pplayer, String[] args) {
|
public void onCommandExecute(PPlayer pplayer, String[] args) {
|
||||||
Player p = pplayer.getPlayer();
|
Player p = pplayer.getPlayer();
|
||||||
|
|
||||||
List<String> styleNames = PermissionManager.getStylesUserHasPermissionFor(p);
|
List<String> styleNames = PermissionManager.getStyleNamesUserHasPermissionFor(p);
|
||||||
String toSend = "";
|
String toSend = "";
|
||||||
for (String name : styleNames) {
|
for (String name : styleNames) {
|
||||||
toSend += name + ", ";
|
toSend += name + ", ";
|
||||||
|
|
|
@ -6,29 +6,80 @@ import org.bukkit.Material;
|
||||||
import org.bukkit.inventory.ItemFlag;
|
import org.bukkit.inventory.ItemFlag;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
import org.bukkit.material.Dye;
|
||||||
|
|
||||||
|
import com.esophose.playerparticles.gui.GuiInventoryEditData.ColorData;
|
||||||
|
|
||||||
public class GuiActionButton {
|
public class GuiActionButton {
|
||||||
|
|
||||||
private int slot;
|
private int slot;
|
||||||
private Material[] icons;
|
private Material[] icons;
|
||||||
private String[] names;
|
private ColorData[] colors;
|
||||||
|
private String name;
|
||||||
private String[] lore;
|
private String[] lore;
|
||||||
private GuiActionButtonClickCallback onClick;
|
private GuiActionButtonClickCallback onClick;
|
||||||
private int iconIndex;
|
private int iconIndex;
|
||||||
|
|
||||||
public GuiActionButton(int slot, Material[] icons, String[] names, String[] lore, GuiActionButtonClickCallback onClick) {
|
/**
|
||||||
|
* Constructor for creating animated icons
|
||||||
|
*
|
||||||
|
* @param slot The slot ID of the inventory
|
||||||
|
* @param icons The Materials that this icon will cycle through
|
||||||
|
* @param name The name that this icon will use
|
||||||
|
* @param lore The lore of this icon
|
||||||
|
* @param onClick The callback to execute when this button is clicked
|
||||||
|
*/
|
||||||
|
public GuiActionButton(int slot, Material[] icons, String name, String[] lore, GuiActionButtonClickCallback onClick) {
|
||||||
this.slot = slot;
|
this.slot = slot;
|
||||||
this.icons = icons;
|
this.icons = icons;
|
||||||
this.names = names;
|
this.colors = null;
|
||||||
|
this.name = name;
|
||||||
this.lore = lore;
|
this.lore = lore;
|
||||||
this.onClick = onClick;
|
this.onClick = onClick;
|
||||||
|
|
||||||
if (icons.length != names.length)
|
|
||||||
throw new IllegalArgumentException("icons and names must have the same length!");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor for creating non-animated icons
|
||||||
|
*
|
||||||
|
* @param slot The slot ID of the inventory
|
||||||
|
* @param icons The Materials that this icon will use
|
||||||
|
* @param name The name that this icon will use
|
||||||
|
* @param lore The lore of this icon
|
||||||
|
* @param onClick The callback to execute when this button is clicked
|
||||||
|
*/
|
||||||
public GuiActionButton(int slot, Material icon, String name, String[] lore, GuiActionButtonClickCallback onClick) {
|
public GuiActionButton(int slot, Material icon, String name, String[] lore, GuiActionButtonClickCallback onClick) {
|
||||||
this(slot, new Material[] { icon }, new String[] { name }, lore, onClick);
|
this(slot, new Material[] { icon }, name, lore, onClick);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor for creating animated icons using dyes
|
||||||
|
*
|
||||||
|
* @param slot The slot ID of the inventory
|
||||||
|
* @param iconColors The ColorData that this icon will cycle through
|
||||||
|
* @param name The name that this icon will use
|
||||||
|
* @param lore The lore of this icon
|
||||||
|
* @param onClick The callback to execute when this button is clicked
|
||||||
|
*/
|
||||||
|
public GuiActionButton(int slot, ColorData[] iconColors, String name, String[] lore, GuiActionButtonClickCallback onClick) {
|
||||||
|
this.slot = slot;
|
||||||
|
this.icons = null;
|
||||||
|
this.colors = iconColors;
|
||||||
|
this.name = name;
|
||||||
|
this.lore = lore;
|
||||||
|
this.onClick = onClick;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor for creating non-animated icons using dyes
|
||||||
|
*
|
||||||
|
* @param slot The slot ID of the inventory
|
||||||
|
* @param iconColor The ColorData that this icon will use
|
||||||
|
* @param name The name that this icon will use
|
||||||
|
* @param lore The lore of this icon
|
||||||
|
* @param onClick The callback to execute when this button is clicked
|
||||||
|
*/
|
||||||
|
public GuiActionButton(int slot, ColorData iconColor, String name, String[] lore, GuiActionButtonClickCallback onClick) {
|
||||||
|
this(slot, new ColorData[] { iconColor }, name, lore, onClick);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -45,11 +96,22 @@ public class GuiActionButton {
|
||||||
*
|
*
|
||||||
* @return The icon ItemStack for the GUI
|
* @return The icon ItemStack for the GUI
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public ItemStack getIcon() {
|
public ItemStack getIcon() {
|
||||||
ItemStack itemStack = new ItemStack(icons[this.iconIndex]);
|
ItemStack itemStack;
|
||||||
|
if (this.icons != null) {
|
||||||
|
itemStack = new ItemStack(this.icons[this.iconIndex]);
|
||||||
|
} else {
|
||||||
|
if (this.colors[0].getMaterial() != null) { // Use Materials
|
||||||
|
itemStack = new ItemStack(this.colors[this.iconIndex].getMaterial());
|
||||||
|
} else { // Use Dyes
|
||||||
|
itemStack = new Dye(this.colors[this.iconIndex].getDyeColor()).toItemStack(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||||
|
|
||||||
itemMeta.setDisplayName(this.names[this.iconIndex]);
|
itemMeta.setDisplayName(this.name);
|
||||||
itemMeta.setLore(Arrays.asList(this.lore));
|
itemMeta.setLore(Arrays.asList(this.lore));
|
||||||
itemMeta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES, ItemFlag.HIDE_POTION_EFFECTS);
|
itemMeta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES, ItemFlag.HIDE_POTION_EFFECTS);
|
||||||
|
|
||||||
|
@ -72,7 +134,7 @@ public class GuiActionButton {
|
||||||
* Ticked at an interval to allow the icon/name to update
|
* Ticked at an interval to allow the icon/name to update
|
||||||
*/
|
*/
|
||||||
public void onTick() {
|
public void onTick() {
|
||||||
this.iconIndex = (this.iconIndex + 1) % this.names.length;
|
this.iconIndex = (this.iconIndex + 1) % (this.icons != null ? this.icons.length : this.colors.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -81,7 +143,7 @@ public class GuiActionButton {
|
||||||
* @return If this GuiActionButton has more than one icon/name
|
* @return If this GuiActionButton has more than one icon/name
|
||||||
*/
|
*/
|
||||||
public boolean isTickable() {
|
public boolean isTickable() {
|
||||||
return this.icons.length > 1;
|
return this.icons != null ? this.icons.length > 1 : this.colors.length > 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -3,14 +3,12 @@ package com.esophose.playerparticles.gui;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.DyeColor;
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.ItemFlag;
|
import org.bukkit.inventory.ItemFlag;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.bukkit.material.Dye;
|
|
||||||
|
|
||||||
import com.esophose.playerparticles.particles.PPlayer;
|
import com.esophose.playerparticles.particles.PPlayer;
|
||||||
import com.esophose.playerparticles.util.ParticleUtils;
|
import com.esophose.playerparticles.util.ParticleUtils;
|
||||||
|
@ -18,17 +16,17 @@ import com.esophose.playerparticles.util.ParticleUtils;
|
||||||
public abstract class GuiInventory {
|
public abstract class GuiInventory {
|
||||||
|
|
||||||
protected enum BorderColor {
|
protected enum BorderColor {
|
||||||
WHITE(DyeColor.WHITE, "WHITE_STAINED_GLASS_PANE"),
|
WHITE(0, "WHITE_STAINED_GLASS_PANE"),
|
||||||
ORANGE(DyeColor.ORANGE, "ORANGE_STAINED_GLASS_PANE"),
|
ORANGE(1, "ORANGE_STAINED_GLASS_PANE"),
|
||||||
RED(DyeColor.RED, "RED_STAINED_GLASS_PANE"),
|
RED(14, "RED_STAINED_GLASS_PANE"),
|
||||||
BROWN(DyeColor.BROWN, "BROWN_STAINED_GLASS_PANE"),
|
BROWN(12, "BROWN_STAINED_GLASS_PANE"),
|
||||||
GREEN(DyeColor.GREEN, "GREEN_STAINED_GLASS_PANE");
|
GREEN(13, "GREEN_STAINED_GLASS_PANE");
|
||||||
|
|
||||||
private DyeColor dyeColor;
|
private short data;
|
||||||
private Material material;
|
private Material material;
|
||||||
|
|
||||||
private BorderColor(DyeColor dyeColor, String materialName) {
|
private BorderColor(int data, String materialName) {
|
||||||
this.dyeColor = dyeColor;
|
this.data = (short)data;
|
||||||
this.material = ParticleUtils.closestMatch(materialName);
|
this.material = ParticleUtils.closestMatch(materialName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,8 +35,8 @@ public abstract class GuiInventory {
|
||||||
ItemStack borderIcon;
|
ItemStack borderIcon;
|
||||||
if (this.material != null) { // Use 1.13 materials
|
if (this.material != null) { // Use 1.13 materials
|
||||||
borderIcon = new ItemStack(this.material, 1);
|
borderIcon = new ItemStack(this.material, 1);
|
||||||
} else { // Use < 1.13 dye colors
|
} else { // Use < 1.13 data values
|
||||||
borderIcon = new Dye(this.dyeColor).toItemStack(1);
|
borderIcon = new ItemStack(Material.GLASS_PANE, 1, this.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemMeta meta = borderIcon.getItemMeta();
|
ItemMeta meta = borderIcon.getItemMeta();
|
||||||
|
@ -128,9 +126,11 @@ public abstract class GuiInventory {
|
||||||
/**
|
/**
|
||||||
* Handles clicks of GuiActionButtons
|
* Handles clicks of GuiActionButtons
|
||||||
*
|
*
|
||||||
* @param event The InventoryClickEvent triggered when the player clicks a GuiActionButton
|
* @param event The InventoryClickEvent triggered when the player clicks in a GuiInventory
|
||||||
*/
|
*/
|
||||||
public void onClick(InventoryClickEvent event) {
|
public void onClick(InventoryClickEvent event) {
|
||||||
|
if (event.getClickedInventory() == null || !event.getClickedInventory().equals(this.inventory)) return;
|
||||||
|
|
||||||
int slot = event.getSlot();
|
int slot = event.getSlot();
|
||||||
boolean isShiftClick = event.isShiftClick();
|
boolean isShiftClick = event.isShiftClick();
|
||||||
|
|
||||||
|
@ -141,5 +141,10 @@ public abstract class GuiInventory {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@FunctionalInterface
|
||||||
|
public static interface GuiInventoryEditFinishedCallback {
|
||||||
|
public void execute();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ import org.bukkit.inventory.meta.SkullMeta;
|
||||||
|
|
||||||
import com.esophose.playerparticles.manager.LangManager;
|
import com.esophose.playerparticles.manager.LangManager;
|
||||||
import com.esophose.playerparticles.manager.LangManager.Lang;
|
import com.esophose.playerparticles.manager.LangManager.Lang;
|
||||||
import com.esophose.playerparticles.manager.SettingManager.GUIIcon;
|
import com.esophose.playerparticles.manager.SettingManager.GuiIcon;
|
||||||
import com.esophose.playerparticles.particles.PPlayer;
|
import com.esophose.playerparticles.particles.PPlayer;
|
||||||
import com.esophose.playerparticles.util.ParticleUtils;
|
import com.esophose.playerparticles.util.ParticleUtils;
|
||||||
|
|
||||||
|
@ -36,7 +36,9 @@ public class GuiInventoryDefault extends GuiInventory {
|
||||||
String[] currentIconLore = new String[] {
|
String[] currentIconLore = new String[] {
|
||||||
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_ACTIVE_PARTICLES, pplayer.getActiveParticles().size()),
|
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_ACTIVE_PARTICLES, pplayer.getActiveParticles().size()),
|
||||||
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_SAVED_GROUPS, pplayer.getParticleGroups().size()),
|
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_SAVED_GROUPS, pplayer.getParticleGroups().size()),
|
||||||
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_FIXED_EFFECTS, pplayer.getFixedEffectIds().size())
|
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_FIXED_EFFECTS, pplayer.getFixedEffectIds().size()),
|
||||||
|
"",
|
||||||
|
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_COMMANDS_INFO)
|
||||||
};
|
};
|
||||||
currentIconMeta.setLore(Arrays.asList(currentIconLore));
|
currentIconMeta.setLore(Arrays.asList(currentIconLore));
|
||||||
currentIconMeta.setOwner(pplayer.getPlayer().getName());
|
currentIconMeta.setOwner(pplayer.getPlayer().getName());
|
||||||
|
@ -46,32 +48,32 @@ public class GuiInventoryDefault extends GuiInventory {
|
||||||
|
|
||||||
// Manage Your Particles button
|
// Manage Your Particles button
|
||||||
GuiActionButton manageYourParticlesButton = new GuiActionButton(38,
|
GuiActionButton manageYourParticlesButton = new GuiActionButton(38,
|
||||||
GUIIcon.PARTICLES.get(),
|
GuiIcon.PARTICLES.get(),
|
||||||
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.GUI_MANAGE_YOUR_PARTICLES),
|
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.GUI_MANAGE_YOUR_PARTICLES),
|
||||||
new String[] { LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_MANAGE_YOUR_PARTICLES_DESCRIPTION) },
|
new String[] { LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_MANAGE_YOUR_PARTICLES_DESCRIPTION) },
|
||||||
(button, isShiftClick) -> {
|
(button, isShiftClick) -> {
|
||||||
GuiHandler.transition(new GuiInventoryManageParticles(pplayer));
|
GuiHandler.transition(new GuiInventoryManageParticles(pplayer));
|
||||||
});
|
});
|
||||||
this.actionButtons.add(manageYourParticlesButton);
|
this.actionButtons.add(manageYourParticlesButton);
|
||||||
|
|
||||||
// Manage Your Groups button
|
// Manage Your Groups button
|
||||||
GuiActionButton manageYourGroupsButton = new GuiActionButton(40,
|
GuiActionButton manageYourGroupsButton = new GuiActionButton(40,
|
||||||
GUIIcon.GROUPS.get(),
|
GuiIcon.GROUPS.get(),
|
||||||
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.GUI_MANAGE_YOUR_GROUPS),
|
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.GUI_MANAGE_YOUR_GROUPS),
|
||||||
new String[] { LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_MANAGE_YOUR_GROUPS_DESCRIPTION) },
|
new String[] { LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_MANAGE_YOUR_GROUPS_DESCRIPTION) },
|
||||||
(button, isShiftClick) -> {
|
(button, isShiftClick) -> {
|
||||||
GuiHandler.transition(new GuiInventoryManageGroups(pplayer));
|
GuiHandler.transition(new GuiInventoryManageGroups(pplayer));
|
||||||
});
|
});
|
||||||
this.actionButtons.add(manageYourGroupsButton);
|
this.actionButtons.add(manageYourGroupsButton);
|
||||||
|
|
||||||
// Load Preset Groups
|
// Load Preset Groups
|
||||||
GuiActionButton loadPresetGroups = new GuiActionButton(42,
|
GuiActionButton loadPresetGroups = new GuiActionButton(42,
|
||||||
GUIIcon.PRESET_GROUPS.get(),
|
GuiIcon.PRESET_GROUPS.get(),
|
||||||
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.GUI_LOAD_A_PRESET_GROUP),
|
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.GUI_LOAD_A_PRESET_GROUP),
|
||||||
new String[] { LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_LOAD_A_PRESET_GROUP_DESCRIPTION) },
|
new String[] { LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_LOAD_A_PRESET_GROUP_DESCRIPTION) },
|
||||||
(button, isShiftClick) -> {
|
(button, isShiftClick) -> {
|
||||||
GuiHandler.transition(new GuiInventoryLoadPresetGroups(pplayer));
|
GuiHandler.transition(new GuiInventoryLoadPresetGroups(pplayer));
|
||||||
});
|
});
|
||||||
this.actionButtons.add(loadPresetGroups);
|
this.actionButtons.add(loadPresetGroups);
|
||||||
|
|
||||||
this.populate();
|
this.populate();
|
||||||
|
|
324
src/com/esophose/playerparticles/gui/GuiInventoryEditData.java
Normal file
324
src/com/esophose/playerparticles/gui/GuiInventoryEditData.java
Normal file
|
@ -0,0 +1,324 @@
|
||||||
|
package com.esophose.playerparticles.gui;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.DyeColor;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import com.esophose.playerparticles.manager.LangManager;
|
||||||
|
import com.esophose.playerparticles.manager.LangManager.Lang;
|
||||||
|
import com.esophose.playerparticles.manager.SettingManager.GuiIcon;
|
||||||
|
import com.esophose.playerparticles.particles.PPlayer;
|
||||||
|
import com.esophose.playerparticles.particles.ParticleEffect;
|
||||||
|
import com.esophose.playerparticles.particles.ParticleEffect.NoteColor;
|
||||||
|
import com.esophose.playerparticles.particles.ParticleEffect.OrdinaryColor;
|
||||||
|
import com.esophose.playerparticles.particles.ParticleEffect.ParticleProperty;
|
||||||
|
import com.esophose.playerparticles.particles.ParticlePair;
|
||||||
|
import com.esophose.playerparticles.util.ParticleUtils;
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public class GuiInventoryEditData extends GuiInventory {
|
||||||
|
|
||||||
|
private static Random RANDOM = new Random();
|
||||||
|
private static List<Material> BLOCK_MATERIALS, ITEM_MATERIALS;
|
||||||
|
private static ColorData[] colorMapping;
|
||||||
|
private static ColorData[] rainbowColorMapping;
|
||||||
|
private static ColorData[] noteColorMapping;
|
||||||
|
|
||||||
|
static {
|
||||||
|
colorMapping = new ColorData[] {
|
||||||
|
new ColorData(DyeColor.RED, ParticleUtils.closestMatch("ROSE_RED"), new OrdinaryColor(255, 0, 0), Lang.GUI_EDIT_DATA_COLOR_RED),
|
||||||
|
new ColorData(DyeColor.ORANGE, ParticleUtils.closestMatch("ORANGE_DYE"), new OrdinaryColor(255, 140, 0), Lang.GUI_EDIT_DATA_COLOR_ORANGE),
|
||||||
|
new ColorData(DyeColor.YELLOW, ParticleUtils.closestMatch("DANDELION_YELLOW"), new OrdinaryColor(255, 255, 0), Lang.GUI_EDIT_DATA_COLOR_YELLOW),
|
||||||
|
new ColorData(DyeColor.LIME, ParticleUtils.closestMatch("LIME_DYE"), new OrdinaryColor(50, 205, 50), Lang.GUI_EDIT_DATA_COLOR_LIME_GREEN),
|
||||||
|
new ColorData(DyeColor.GREEN, ParticleUtils.closestMatch("CACTUS_GREEN"), new OrdinaryColor(0, 128, 0), Lang.GUI_EDIT_DATA_COLOR_GREEN),
|
||||||
|
new ColorData(DyeColor.BLUE, ParticleUtils.closestMatch("LAPIS_LAZULI"), new OrdinaryColor(0, 0, 255), Lang.GUI_EDIT_DATA_COLOR_BLUE),
|
||||||
|
new ColorData(DyeColor.CYAN, ParticleUtils.closestMatch("CYAN_DYE"), new OrdinaryColor(0, 139, 139), Lang.GUI_EDIT_DATA_COLOR_CYAN),
|
||||||
|
new ColorData(DyeColor.LIGHT_BLUE, ParticleUtils.closestMatch("LIGHT_BLUE_DYE"), new OrdinaryColor(173, 216, 230), Lang.GUI_EDIT_DATA_COLOR_LIGHT_BLUE),
|
||||||
|
new ColorData(DyeColor.PURPLE, ParticleUtils.closestMatch("PURPLE_DYE"), new OrdinaryColor(138, 43, 226), Lang.GUI_EDIT_DATA_COLOR_PURPLE),
|
||||||
|
new ColorData(DyeColor.MAGENTA, ParticleUtils.closestMatch("MAGENTA_DYE"), new OrdinaryColor(202, 31, 123), Lang.GUI_EDIT_DATA_COLOR_MAGENTA),
|
||||||
|
new ColorData(DyeColor.PINK, ParticleUtils.closestMatch("PINK_DYE"), new OrdinaryColor(255, 182, 193), Lang.GUI_EDIT_DATA_COLOR_PINK),
|
||||||
|
new ColorData(DyeColor.BROWN, ParticleUtils.closestMatch("COCOA_BEANS"), new OrdinaryColor(139, 69, 19), Lang.GUI_EDIT_DATA_COLOR_BROWN),
|
||||||
|
new ColorData(DyeColor.BLACK, ParticleUtils.closestMatch("INK_SAC"), new OrdinaryColor(0, 0, 0), Lang.GUI_EDIT_DATA_COLOR_BLACK),
|
||||||
|
new ColorData(DyeColor.GRAY, ParticleUtils.closestMatch("GRAY_DYE"), new OrdinaryColor(128, 128, 128), Lang.GUI_EDIT_DATA_COLOR_GRAY),
|
||||||
|
new ColorData(DyeColor.getByDyeData((byte)7), ParticleUtils.closestMatch("LIGHT_GRAY_DYE"), new OrdinaryColor(192, 192, 192), Lang.GUI_EDIT_DATA_COLOR_LIGHT_GRAY),
|
||||||
|
new ColorData(DyeColor.WHITE, ParticleUtils.closestMatch("BONE_MEAL"), new OrdinaryColor(255, 255, 255), Lang.GUI_EDIT_DATA_COLOR_WHITE),
|
||||||
|
};
|
||||||
|
|
||||||
|
rainbowColorMapping = new ColorData[] {
|
||||||
|
colorMapping[0], // Red
|
||||||
|
colorMapping[1], // Orange
|
||||||
|
colorMapping[2], // Yellow
|
||||||
|
colorMapping[3], // Lime
|
||||||
|
colorMapping[7], // Light Blue
|
||||||
|
colorMapping[5], // Blue
|
||||||
|
colorMapping[8] // Purple
|
||||||
|
};
|
||||||
|
|
||||||
|
// Note: This is supposed to be a rainbow but there's actually a bug in Minecraft since 1.8 that makes a bunch of them gray
|
||||||
|
noteColorMapping = new ColorData[] {
|
||||||
|
colorMapping[7], // Light Blue
|
||||||
|
colorMapping[7], // Light Blue
|
||||||
|
colorMapping[13], // Gray
|
||||||
|
colorMapping[10], // Pink
|
||||||
|
colorMapping[9], // Magenta
|
||||||
|
colorMapping[9], // Magenta
|
||||||
|
colorMapping[0], // Red
|
||||||
|
colorMapping[2], // Yellow
|
||||||
|
colorMapping[2], // Yellow
|
||||||
|
colorMapping[14], // Light Gray
|
||||||
|
colorMapping[13], // Gray
|
||||||
|
colorMapping[6], // Cyan
|
||||||
|
colorMapping[6], // Cyan
|
||||||
|
colorMapping[6], // Cyan
|
||||||
|
colorMapping[5], // Blue
|
||||||
|
colorMapping[8], // Purple
|
||||||
|
colorMapping[8], // Purple
|
||||||
|
colorMapping[8], // Purple
|
||||||
|
colorMapping[13], // Gray
|
||||||
|
colorMapping[4], // Green
|
||||||
|
colorMapping[3], // Lime
|
||||||
|
colorMapping[2], // Yellow
|
||||||
|
colorMapping[4], // Green
|
||||||
|
colorMapping[7], // Light Blue
|
||||||
|
colorMapping[7] // Light Blue
|
||||||
|
};
|
||||||
|
|
||||||
|
BLOCK_MATERIALS = new ArrayList<Material>();
|
||||||
|
ITEM_MATERIALS = new ArrayList<Material>();
|
||||||
|
|
||||||
|
Inventory tempInventory = Bukkit.createInventory(null, 9);
|
||||||
|
for (Material mat : Material.values()) {
|
||||||
|
// Verify an ItemStack of the material can be placed into an inventory. In 1.12 and up this can easily be checked with mat.isItem(), but that doesn't exist pre-1.12
|
||||||
|
tempInventory.clear();
|
||||||
|
tempInventory.setItem(0, new ItemStack(mat, 1));
|
||||||
|
ItemStack itemStack = tempInventory.getItem(0);
|
||||||
|
if (itemStack != null) {
|
||||||
|
if (mat.isBlock()) {
|
||||||
|
BLOCK_MATERIALS.add(mat);
|
||||||
|
} else if (!mat.isBlock()) {
|
||||||
|
ITEM_MATERIALS.add(mat);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public GuiInventoryEditData(PPlayer pplayer, ParticlePair editingParticle, List<GuiInventoryEditFinishedCallback> callbackList, int callbackListPosition) {
|
||||||
|
super(pplayer, Bukkit.createInventory(pplayer.getPlayer(), INVENTORY_SIZE, LangManager.getText(Lang.GUI_SELECT_DATA)));
|
||||||
|
|
||||||
|
ParticleEffect pe = editingParticle.getEffect();
|
||||||
|
if (pe.hasProperty(ParticleProperty.COLORABLE)) {
|
||||||
|
if (pe == ParticleEffect.NOTE) { // Note data
|
||||||
|
this.populateNoteData(editingParticle, callbackList, callbackListPosition);
|
||||||
|
} else { // Color data
|
||||||
|
this.populateColorData(editingParticle, callbackList, callbackListPosition);
|
||||||
|
}
|
||||||
|
} else if (pe.hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) {
|
||||||
|
if (pe == ParticleEffect.ITEM) { // Item data
|
||||||
|
this.populateItemData(editingParticle, callbackList, callbackListPosition);
|
||||||
|
} else { // Block data
|
||||||
|
this.populateBlockData(editingParticle, callbackList, callbackListPosition);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Back Button
|
||||||
|
GuiActionButton backButton = new GuiActionButton(INVENTORY_SIZE - 1, GuiIcon.BACK.get(), LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_BACK_BUTTON), new String[] {}, (button, isShiftClick) -> {
|
||||||
|
callbackList.get(callbackListPosition - 1).execute();
|
||||||
|
});
|
||||||
|
this.actionButtons.add(backButton);
|
||||||
|
|
||||||
|
this.populate();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void populateColorData(ParticlePair editingParticle, List<GuiInventoryEditFinishedCallback> callbackList, int callbackListPosition) {
|
||||||
|
int index = 10;
|
||||||
|
int nextWrap = 17;
|
||||||
|
for (int i = 0; i < colorMapping.length; i++) {
|
||||||
|
ColorData colorData = colorMapping[i];
|
||||||
|
String formattedDisplayColor = ChatColor.RED.toString() + colorData.getOrdinaryColor().getRed() + " " + ChatColor.GREEN + colorData.getOrdinaryColor().getGreen() + " " + ChatColor.AQUA + colorData.getOrdinaryColor().getBlue();
|
||||||
|
|
||||||
|
// Color Data Buttons
|
||||||
|
GuiActionButton setColorButton = new GuiActionButton(index,
|
||||||
|
colorData,
|
||||||
|
colorData.getName(),
|
||||||
|
new String[] { LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_SELECT_DATA_DESCRIPTION, formattedDisplayColor) },
|
||||||
|
(button, isShiftClick) -> {
|
||||||
|
editingParticle.setColor(colorData.getOrdinaryColor());
|
||||||
|
callbackList.get(callbackListPosition + 1).execute();
|
||||||
|
});
|
||||||
|
this.actionButtons.add(setColorButton);
|
||||||
|
|
||||||
|
index++;
|
||||||
|
if (index == nextWrap) { // Loop around border
|
||||||
|
nextWrap += 9;
|
||||||
|
index += 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Rainbow Color Data Button
|
||||||
|
GuiActionButton setRainbowColorButton = new GuiActionButton(40,
|
||||||
|
rainbowColorMapping,
|
||||||
|
LangManager.getText(Lang.RAINBOW),
|
||||||
|
new String[] { LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_SELECT_DATA_DESCRIPTION, LangManager.getText(Lang.RAINBOW)) },
|
||||||
|
(button, isShiftClick) -> {
|
||||||
|
editingParticle.setColor(new OrdinaryColor(999, 999, 999));
|
||||||
|
callbackList.get(callbackListPosition + 1).execute();
|
||||||
|
});
|
||||||
|
this.actionButtons.add(setRainbowColorButton);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void populateNoteData(ParticlePair editingParticle, List<GuiInventoryEditFinishedCallback> callbackList, int callbackListPosition) {
|
||||||
|
for (int i = 0; i < noteColorMapping.length; i++) {
|
||||||
|
ColorData colorData = noteColorMapping[i];
|
||||||
|
String formattedDisplayName = LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.GUI_SELECT_DATA_NOTE, i) + " (" + colorData.getName() + LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + ")";
|
||||||
|
String formattedDescription = LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_SELECT_DATA_DESCRIPTION, LangManager.getText(Lang.GUI_SELECT_DATA_NOTE, i));
|
||||||
|
|
||||||
|
// Note Color Buttons
|
||||||
|
int noteIndex = i;
|
||||||
|
GuiActionButton setColorButton = new GuiActionButton(i,
|
||||||
|
colorData,
|
||||||
|
formattedDisplayName,
|
||||||
|
new String[] { formattedDescription },
|
||||||
|
(button, isShiftClick) -> {
|
||||||
|
editingParticle.setNoteColor(new NoteColor(noteIndex));
|
||||||
|
callbackList.get(callbackListPosition + 1).execute();
|
||||||
|
});
|
||||||
|
this.actionButtons.add(setColorButton);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Rainbow Color Data Button
|
||||||
|
GuiActionButton setRainbowColorButton = new GuiActionButton(40,
|
||||||
|
rainbowColorMapping,
|
||||||
|
LangManager.getText(Lang.RAINBOW),
|
||||||
|
new String[] { LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_SELECT_DATA_DESCRIPTION, LangManager.getText(Lang.RAINBOW)) },
|
||||||
|
(button, isShiftClick) -> {
|
||||||
|
editingParticle.setNoteColor(new NoteColor(99));
|
||||||
|
callbackList.get(callbackListPosition + 1).execute();
|
||||||
|
});
|
||||||
|
this.actionButtons.add(setRainbowColorButton);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void populateItemData(ParticlePair editingParticle, List<GuiInventoryEditFinishedCallback> callbackList, int callbackListPosition) {
|
||||||
|
List<Material> materialBag = new ArrayList<Material>();
|
||||||
|
while (materialBag.size() < 36) { // Grab 36 random materials that are an item
|
||||||
|
Material randomMaterial = ITEM_MATERIALS.get(RANDOM.nextInt(ITEM_MATERIALS.size()));
|
||||||
|
if (!materialBag.contains(randomMaterial)) materialBag.add(randomMaterial);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < materialBag.size(); i++) {
|
||||||
|
// Item Data Button
|
||||||
|
Material material = materialBag.get(i);
|
||||||
|
GuiActionButton setRainbowColorButton = new GuiActionButton(i,
|
||||||
|
material,
|
||||||
|
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + material.name().toLowerCase(),
|
||||||
|
new String[] { LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_SELECT_DATA_DESCRIPTION, material.name().toLowerCase()) },
|
||||||
|
(button, isShiftClick) -> {
|
||||||
|
editingParticle.setItemMaterial(material);
|
||||||
|
callbackList.get(callbackListPosition + 1).execute();
|
||||||
|
});
|
||||||
|
this.actionButtons.add(setRainbowColorButton);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Randomize Button, re-randomizes the icons
|
||||||
|
GuiActionButton randomizeButton = new GuiActionButton(45,
|
||||||
|
GuiIcon.RANDOMIZE.get(),
|
||||||
|
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.GUI_SELECT_DATA_RANDOMIZE_ITEMS),
|
||||||
|
new String[] { LangManager.getText(Lang.GUI_COLOR_SUBTEXT) + LangManager.getText(Lang.GUI_SELECT_DATA_RANDOMIZE_ITEMS_DESCRIPTION) },
|
||||||
|
(block, isShiftClick) -> {
|
||||||
|
callbackList.get(callbackListPosition).execute(); // Just reopen the same inventory
|
||||||
|
});
|
||||||
|
this.actionButtons.add(randomizeButton);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void populateBlockData(ParticlePair editingParticle, List<GuiInventoryEditFinishedCallback> callbackList, int callbackListPosition) {
|
||||||
|
List<Material> materialBag = new ArrayList<Material>();
|
||||||
|
while (materialBag.size() < 36) { // Grab 36 random materials that are an item
|
||||||
|
Material randomMaterial = BLOCK_MATERIALS.get(RANDOM.nextInt(BLOCK_MATERIALS.size()));
|
||||||
|
if (!materialBag.contains(randomMaterial)) materialBag.add(randomMaterial);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < materialBag.size(); i++) {
|
||||||
|
// Item Data Button
|
||||||
|
Material material = materialBag.get(i);
|
||||||
|
GuiActionButton setRainbowColorButton = new GuiActionButton(i,
|
||||||
|
material,
|
||||||
|
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + material.name().toLowerCase(),
|
||||||
|
new String[] { LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_SELECT_DATA_DESCRIPTION, material.name().toLowerCase()) },
|
||||||
|
(button, isShiftClick) -> {
|
||||||
|
editingParticle.setBlockMaterial(material);
|
||||||
|
callbackList.get(callbackListPosition + 1).execute();
|
||||||
|
});
|
||||||
|
this.actionButtons.add(setRainbowColorButton);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Randomize Button, re-randomizes the icons
|
||||||
|
GuiActionButton randomizeButton = new GuiActionButton(45,
|
||||||
|
GuiIcon.RANDOMIZE.get(),
|
||||||
|
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.GUI_SELECT_DATA_RANDOMIZE_BLOCKS),
|
||||||
|
new String[] { LangManager.getText(Lang.GUI_COLOR_SUBTEXT) + LangManager.getText(Lang.GUI_SELECT_DATA_RANDOMIZE_BLOCKS_DESCRIPTION) },
|
||||||
|
(block, isShiftClick) -> {
|
||||||
|
callbackList.get(callbackListPosition).execute(); // Just reopen the same inventory
|
||||||
|
});
|
||||||
|
this.actionButtons.add(randomizeButton);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A data class used for storing information about the color data
|
||||||
|
*/
|
||||||
|
protected static class ColorData {
|
||||||
|
private DyeColor dyeColor;
|
||||||
|
private Material material;
|
||||||
|
private OrdinaryColor ordinaryColor;
|
||||||
|
private Lang name;
|
||||||
|
|
||||||
|
public ColorData(DyeColor dyeColor, Material material, OrdinaryColor ordinaryColor, Lang name) {
|
||||||
|
this.dyeColor = dyeColor;
|
||||||
|
this.material = material;
|
||||||
|
this.ordinaryColor = ordinaryColor;
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the DyeColor
|
||||||
|
*
|
||||||
|
* @return The DyeColor
|
||||||
|
*/
|
||||||
|
public DyeColor getDyeColor() {
|
||||||
|
return this.dyeColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Material representing this color
|
||||||
|
*
|
||||||
|
* @return The Material
|
||||||
|
*/
|
||||||
|
public Material getMaterial() {
|
||||||
|
return this.material;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the OrdinaryColor representing this color
|
||||||
|
*
|
||||||
|
* @return The OrdinaryColor
|
||||||
|
*/
|
||||||
|
public OrdinaryColor getOrdinaryColor() {
|
||||||
|
return this.ordinaryColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the name of this color
|
||||||
|
*
|
||||||
|
* @return The name of this color
|
||||||
|
*/
|
||||||
|
public String getName() {
|
||||||
|
return LangManager.getText(this.name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,44 @@
|
||||||
|
package com.esophose.playerparticles.gui;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
|
import com.esophose.playerparticles.manager.LangManager;
|
||||||
|
import com.esophose.playerparticles.manager.LangManager.Lang;
|
||||||
|
import com.esophose.playerparticles.manager.PermissionManager;
|
||||||
|
import com.esophose.playerparticles.manager.SettingManager.GuiIcon;
|
||||||
|
import com.esophose.playerparticles.particles.PPlayer;
|
||||||
|
import com.esophose.playerparticles.particles.ParticleEffect;
|
||||||
|
import com.esophose.playerparticles.particles.ParticlePair;
|
||||||
|
|
||||||
|
public class GuiInventoryEditEffect extends GuiInventory {
|
||||||
|
|
||||||
|
public GuiInventoryEditEffect(PPlayer pplayer, ParticlePair editingParticle, List<GuiInventoryEditFinishedCallback> callbackList, int callbackListPosition) {
|
||||||
|
super(pplayer, Bukkit.createInventory(pplayer.getPlayer(), INVENTORY_SIZE, LangManager.getText(Lang.GUI_SELECT_EFFECT)));
|
||||||
|
|
||||||
|
// Select Effect Buttons
|
||||||
|
List<ParticleEffect> effectsUserHasPermissionFor = PermissionManager.getEffectsUserHasPermissionFor(pplayer.getPlayer());
|
||||||
|
for (int i = 0; i < effectsUserHasPermissionFor.size(); i++) {
|
||||||
|
ParticleEffect effect = effectsUserHasPermissionFor.get(i);
|
||||||
|
GuiActionButton selectButton = new GuiActionButton(i,
|
||||||
|
GuiIcon.EFFECT.get(effect.getName()),
|
||||||
|
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + effect.getName(),
|
||||||
|
new String[] { LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_SELECT_EFFECT_DESCRIPTION, effect.getName()) },
|
||||||
|
(button, isShiftClick) -> {
|
||||||
|
editingParticle.setEffect(effect);
|
||||||
|
callbackList.get(callbackListPosition + 1).execute();
|
||||||
|
});
|
||||||
|
this.actionButtons.add(selectButton);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Back Button
|
||||||
|
GuiActionButton backButton = new GuiActionButton(INVENTORY_SIZE - 1, GuiIcon.BACK.get(), LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_BACK_BUTTON), new String[] {}, (button, isShiftClick) -> {
|
||||||
|
callbackList.get(callbackListPosition - 1).execute();
|
||||||
|
});
|
||||||
|
this.actionButtons.add(backButton);
|
||||||
|
|
||||||
|
this.populate();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,127 @@
|
||||||
|
package com.esophose.playerparticles.gui;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
|
import com.esophose.playerparticles.manager.DataManager;
|
||||||
|
import com.esophose.playerparticles.manager.LangManager;
|
||||||
|
import com.esophose.playerparticles.manager.LangManager.Lang;
|
||||||
|
import com.esophose.playerparticles.manager.SettingManager.GuiIcon;
|
||||||
|
import com.esophose.playerparticles.particles.PPlayer;
|
||||||
|
import com.esophose.playerparticles.particles.ParticleEffect.ParticleProperty;
|
||||||
|
import com.esophose.playerparticles.particles.ParticleGroup;
|
||||||
|
import com.esophose.playerparticles.particles.ParticlePair;
|
||||||
|
|
||||||
|
public class GuiInventoryEditParticle extends GuiInventory {
|
||||||
|
|
||||||
|
public GuiInventoryEditParticle(PPlayer pplayer, ParticlePair editingParticle) {
|
||||||
|
super(pplayer, Bukkit.createInventory(pplayer.getPlayer(), INVENTORY_SIZE, LangManager.getText(Lang.GUI_EDITING_PARTICLE, editingParticle.getId())));
|
||||||
|
|
||||||
|
this.fillBorder(BorderColor.RED);
|
||||||
|
|
||||||
|
// Particle Info Icon
|
||||||
|
String particleInfo = LangManager.getText(Lang.GUI_PARTICLE_INFO, editingParticle.getId(), editingParticle.getEffect().getName(), editingParticle.getStyle().getName(), editingParticle.getDataString());
|
||||||
|
GuiActionButton particleInfoIcon = new GuiActionButton(13,
|
||||||
|
GuiIcon.PARTICLES.get(),
|
||||||
|
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.GUI_PARTICLE_NAME, editingParticle.getId()),
|
||||||
|
new String[] { LangManager.getText(Lang.GUI_COLOR_INFO) + particleInfo },
|
||||||
|
(button, isShiftClick) -> {});
|
||||||
|
this.actionButtons.add(particleInfoIcon);
|
||||||
|
|
||||||
|
// Edit Effect Button
|
||||||
|
GuiActionButton editEffectButton = new GuiActionButton(38,
|
||||||
|
GuiIcon.EDIT_EFFECT.get(),
|
||||||
|
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.GUI_EDIT_EFFECT),
|
||||||
|
new String[] { LangManager.getText(Lang.GUI_COLOR_SUBTEXT) + LangManager.getText(Lang.GUI_EDIT_EFFECT_DESCRIPTION) },
|
||||||
|
(button, isShiftClick) -> {
|
||||||
|
List<GuiInventoryEditFinishedCallback> callbacks = new ArrayList<GuiInventoryEditFinishedCallback>();
|
||||||
|
callbacks.add(() -> GuiHandler.transition(new GuiInventoryEditParticle(pplayer, editingParticle)));
|
||||||
|
callbacks.add(() -> GuiHandler.transition(new GuiInventoryEditEffect(pplayer, editingParticle, callbacks, 1)));
|
||||||
|
callbacks.add(() -> {
|
||||||
|
ParticleGroup group = pplayer.getActiveParticleGroup();
|
||||||
|
for (ParticlePair particle : group.getParticles()) {
|
||||||
|
if (particle.getId() == editingParticle.getId()) {
|
||||||
|
particle.setEffect(editingParticle.getEffect());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DataManager.saveParticleGroup(pplayer.getUniqueId(), group);
|
||||||
|
|
||||||
|
GuiHandler.transition(new GuiInventoryEditParticle(pplayer, editingParticle));
|
||||||
|
});
|
||||||
|
|
||||||
|
callbacks.get(1).execute();
|
||||||
|
});
|
||||||
|
this.actionButtons.add(editEffectButton);
|
||||||
|
|
||||||
|
// Edit Style Button
|
||||||
|
GuiActionButton editStyleButton = new GuiActionButton(40,
|
||||||
|
GuiIcon.EDIT_STYLE.get(),
|
||||||
|
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.GUI_EDIT_STYLE),
|
||||||
|
new String[] { LangManager.getText(Lang.GUI_COLOR_SUBTEXT) + LangManager.getText(Lang.GUI_EDIT_STYLE_DESCRIPTION) },
|
||||||
|
(button, isShiftClick) -> {
|
||||||
|
List<GuiInventoryEditFinishedCallback> callbacks = new ArrayList<GuiInventoryEditFinishedCallback>();
|
||||||
|
callbacks.add(() -> GuiHandler.transition(new GuiInventoryEditParticle(pplayer, editingParticle)));
|
||||||
|
callbacks.add(() -> GuiHandler.transition(new GuiInventoryEditStyle(pplayer, editingParticle, callbacks, 1)));
|
||||||
|
callbacks.add(() -> {
|
||||||
|
ParticleGroup group = pplayer.getActiveParticleGroup();
|
||||||
|
for (ParticlePair particle : group.getParticles()) {
|
||||||
|
if (particle.getId() == editingParticle.getId()) {
|
||||||
|
particle.setStyle(editingParticle.getStyle());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DataManager.saveParticleGroup(pplayer.getUniqueId(), group);
|
||||||
|
|
||||||
|
GuiHandler.transition(new GuiInventoryEditParticle(pplayer, editingParticle));
|
||||||
|
});
|
||||||
|
|
||||||
|
callbacks.get(1).execute();
|
||||||
|
});
|
||||||
|
this.actionButtons.add(editStyleButton);
|
||||||
|
|
||||||
|
// Edit Data Button
|
||||||
|
boolean usesData = editingParticle.getEffect().hasProperty(ParticleProperty.COLORABLE) || editingParticle.getEffect().hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA);
|
||||||
|
GuiActionButton editDataButton = new GuiActionButton(42,
|
||||||
|
GuiIcon.EDIT_DATA.get(),
|
||||||
|
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.GUI_EDIT_DATA),
|
||||||
|
usesData ? new String[] { LangManager.getText(Lang.GUI_COLOR_SUBTEXT) + LangManager.getText(Lang.GUI_EDIT_DATA_DESCRIPTION) } :
|
||||||
|
new String[] { LangManager.getText(Lang.GUI_COLOR_UNAVAILABLE) + LangManager.getText(Lang.GUI_EDIT_DATA_UNAVAILABLE) },
|
||||||
|
(button, isShiftClick) -> {
|
||||||
|
if (usesData) {
|
||||||
|
List<GuiInventoryEditFinishedCallback> callbacks = new ArrayList<GuiInventoryEditFinishedCallback>();
|
||||||
|
callbacks.add(() -> GuiHandler.transition(new GuiInventoryEditParticle(pplayer, editingParticle)));
|
||||||
|
callbacks.add(() -> GuiHandler.transition(new GuiInventoryEditData(pplayer, editingParticle, callbacks, 1)));
|
||||||
|
callbacks.add(() -> {
|
||||||
|
ParticleGroup group = pplayer.getActiveParticleGroup();
|
||||||
|
for (ParticlePair particle : group.getParticles()) {
|
||||||
|
if (particle.getId() == editingParticle.getId()) {
|
||||||
|
particle.setColor(editingParticle.getColor());
|
||||||
|
particle.setNoteColor(editingParticle.getNoteColor());
|
||||||
|
particle.setItemMaterial(editingParticle.getItemMaterial());
|
||||||
|
particle.setBlockMaterial(editingParticle.getBlockMaterial());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DataManager.saveParticleGroup(pplayer.getUniqueId(), group);
|
||||||
|
|
||||||
|
GuiHandler.transition(new GuiInventoryEditParticle(pplayer, editingParticle));
|
||||||
|
});
|
||||||
|
|
||||||
|
callbacks.get(1).execute();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.actionButtons.add(editDataButton);
|
||||||
|
|
||||||
|
// Back Button
|
||||||
|
GuiActionButton backButton = new GuiActionButton(INVENTORY_SIZE - 1, GuiIcon.BACK.get(), LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_BACK_BUTTON), new String[] {}, (button, isShiftClick) -> {
|
||||||
|
GuiHandler.transition(new GuiInventoryManageParticles(pplayer));
|
||||||
|
});
|
||||||
|
this.actionButtons.add(backButton);
|
||||||
|
|
||||||
|
this.populate();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,44 @@
|
||||||
|
package com.esophose.playerparticles.gui;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
|
import com.esophose.playerparticles.manager.LangManager;
|
||||||
|
import com.esophose.playerparticles.manager.LangManager.Lang;
|
||||||
|
import com.esophose.playerparticles.manager.PermissionManager;
|
||||||
|
import com.esophose.playerparticles.manager.SettingManager.GuiIcon;
|
||||||
|
import com.esophose.playerparticles.particles.PPlayer;
|
||||||
|
import com.esophose.playerparticles.particles.ParticlePair;
|
||||||
|
import com.esophose.playerparticles.styles.api.ParticleStyle;
|
||||||
|
|
||||||
|
public class GuiInventoryEditStyle extends GuiInventory {
|
||||||
|
|
||||||
|
public GuiInventoryEditStyle(PPlayer pplayer, ParticlePair editingParticle, List<GuiInventoryEditFinishedCallback> callbackList, int callbackListPosition) {
|
||||||
|
super(pplayer, Bukkit.createInventory(pplayer.getPlayer(), INVENTORY_SIZE, LangManager.getText(Lang.GUI_SELECT_STYLE)));
|
||||||
|
|
||||||
|
// Select Style Buttons
|
||||||
|
List<ParticleStyle> stylesUserHasPermissionFor = PermissionManager.getStylesUserHasPermissionFor(pplayer.getPlayer());
|
||||||
|
for (int i = 0; i < stylesUserHasPermissionFor.size(); i++) {
|
||||||
|
ParticleStyle style = stylesUserHasPermissionFor.get(i);
|
||||||
|
GuiActionButton selectButton = new GuiActionButton(i,
|
||||||
|
GuiIcon.STYLE.get(style.getName()),
|
||||||
|
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + style.getName(),
|
||||||
|
new String[] { LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_SELECT_EFFECT_DESCRIPTION, style.getName()) },
|
||||||
|
(button, isShiftClick) -> {
|
||||||
|
editingParticle.setStyle(style);
|
||||||
|
callbackList.get(callbackListPosition + 1).execute();
|
||||||
|
});
|
||||||
|
this.actionButtons.add(selectButton);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Back Button
|
||||||
|
GuiActionButton backButton = new GuiActionButton(INVENTORY_SIZE - 1, GuiIcon.BACK.get(), LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_BACK_BUTTON), new String[] {}, (button, isShiftClick) -> {
|
||||||
|
callbackList.get(callbackListPosition - 1).execute();
|
||||||
|
});
|
||||||
|
this.actionButtons.add(backButton);
|
||||||
|
|
||||||
|
this.populate();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -10,7 +10,7 @@ import org.bukkit.Material;
|
||||||
import com.esophose.playerparticles.manager.DataManager;
|
import com.esophose.playerparticles.manager.DataManager;
|
||||||
import com.esophose.playerparticles.manager.LangManager;
|
import com.esophose.playerparticles.manager.LangManager;
|
||||||
import com.esophose.playerparticles.manager.LangManager.Lang;
|
import com.esophose.playerparticles.manager.LangManager.Lang;
|
||||||
import com.esophose.playerparticles.manager.SettingManager.GUIIcon;
|
import com.esophose.playerparticles.manager.SettingManager.GuiIcon;
|
||||||
import com.esophose.playerparticles.particles.PPlayer;
|
import com.esophose.playerparticles.particles.PPlayer;
|
||||||
import com.esophose.playerparticles.particles.ParticleGroup;
|
import com.esophose.playerparticles.particles.ParticleGroup;
|
||||||
import com.esophose.playerparticles.particles.ParticlePair;
|
import com.esophose.playerparticles.particles.ParticlePair;
|
||||||
|
@ -61,7 +61,7 @@ public class GuiInventoryLoadPresetGroups extends GuiInventory {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Back Button
|
// Back Button
|
||||||
GuiActionButton backButton = new GuiActionButton(INVENTORY_SIZE - 1, GUIIcon.BACK.get(), LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_BACK_BUTTON), new String[] {}, (button, isShiftClick) -> {
|
GuiActionButton backButton = new GuiActionButton(INVENTORY_SIZE - 1, GuiIcon.BACK.get(), LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_BACK_BUTTON), new String[] {}, (button, isShiftClick) -> {
|
||||||
GuiHandler.transition(new GuiInventoryDefault(pplayer));
|
GuiHandler.transition(new GuiInventoryDefault(pplayer));
|
||||||
});
|
});
|
||||||
this.actionButtons.add(backButton);
|
this.actionButtons.add(backButton);
|
||||||
|
|
|
@ -8,7 +8,7 @@ import org.bukkit.Bukkit;
|
||||||
import com.esophose.playerparticles.manager.DataManager;
|
import com.esophose.playerparticles.manager.DataManager;
|
||||||
import com.esophose.playerparticles.manager.LangManager;
|
import com.esophose.playerparticles.manager.LangManager;
|
||||||
import com.esophose.playerparticles.manager.LangManager.Lang;
|
import com.esophose.playerparticles.manager.LangManager.Lang;
|
||||||
import com.esophose.playerparticles.manager.SettingManager.GUIIcon;
|
import com.esophose.playerparticles.manager.SettingManager.GuiIcon;
|
||||||
import com.esophose.playerparticles.particles.PPlayer;
|
import com.esophose.playerparticles.particles.PPlayer;
|
||||||
import com.esophose.playerparticles.particles.ParticleGroup;
|
import com.esophose.playerparticles.particles.ParticleGroup;
|
||||||
import com.esophose.playerparticles.particles.ParticlePair;
|
import com.esophose.playerparticles.particles.ParticlePair;
|
||||||
|
@ -42,7 +42,7 @@ public class GuiInventoryManageGroups extends GuiInventory {
|
||||||
lore[i] = LangManager.getText(Lang.GUI_COLOR_UNAVAILABLE) + LangManager.getText(Lang.GUI_SHIFT_CLICK_TO_DELETE);
|
lore[i] = LangManager.getText(Lang.GUI_COLOR_UNAVAILABLE) + LangManager.getText(Lang.GUI_SHIFT_CLICK_TO_DELETE);
|
||||||
|
|
||||||
// Load Group Buttons
|
// Load Group Buttons
|
||||||
GuiActionButton groupButton = new GuiActionButton(index, GUIIcon.GROUPS.get(), LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + group.getName(), lore, (button, isShiftClick) -> {
|
GuiActionButton groupButton = new GuiActionButton(index, GuiIcon.GROUPS.get(), LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + group.getName(), lore, (button, isShiftClick) -> {
|
||||||
if (isShiftClick) {
|
if (isShiftClick) {
|
||||||
DataManager.removeParticleGroup(pplayer.getUniqueId(), group);
|
DataManager.removeParticleGroup(pplayer.getUniqueId(), group);
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ public class GuiInventoryManageGroups extends GuiInventory {
|
||||||
|
|
||||||
// Save Group Button
|
// Save Group Button
|
||||||
GuiActionButton saveGroupButton = new GuiActionButton(40,
|
GuiActionButton saveGroupButton = new GuiActionButton(40,
|
||||||
GUIIcon.CREATE.get(),
|
GuiIcon.CREATE.get(),
|
||||||
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.GUI_SAVE_GROUP),
|
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.GUI_SAVE_GROUP),
|
||||||
new String[] {
|
new String[] {
|
||||||
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_SAVE_GROUP_DESCRIPTION),
|
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_SAVE_GROUP_DESCRIPTION),
|
||||||
|
@ -80,7 +80,7 @@ public class GuiInventoryManageGroups extends GuiInventory {
|
||||||
this.actionButtons.add(saveGroupButton);
|
this.actionButtons.add(saveGroupButton);
|
||||||
|
|
||||||
// Back Button
|
// Back Button
|
||||||
GuiActionButton backButton = new GuiActionButton(INVENTORY_SIZE - 1, GUIIcon.BACK.get(), LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_BACK_BUTTON), new String[] {}, (button, isShiftClick) -> {
|
GuiActionButton backButton = new GuiActionButton(INVENTORY_SIZE - 1, GuiIcon.BACK.get(), LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_BACK_BUTTON), new String[] {}, (button, isShiftClick) -> {
|
||||||
GuiHandler.transition(new GuiInventoryDefault(pplayer));
|
GuiHandler.transition(new GuiInventoryDefault(pplayer));
|
||||||
});
|
});
|
||||||
this.actionButtons.add(backButton);
|
this.actionButtons.add(backButton);
|
||||||
|
|
|
@ -1,11 +1,19 @@
|
||||||
package com.esophose.playerparticles.gui;
|
package com.esophose.playerparticles.gui;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import java.util.ArrayList;
|
||||||
import org.bukkit.Material;
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
|
import com.esophose.playerparticles.manager.DataManager;
|
||||||
import com.esophose.playerparticles.manager.LangManager;
|
import com.esophose.playerparticles.manager.LangManager;
|
||||||
import com.esophose.playerparticles.manager.LangManager.Lang;
|
import com.esophose.playerparticles.manager.LangManager.Lang;
|
||||||
|
import com.esophose.playerparticles.manager.SettingManager.GuiIcon;
|
||||||
import com.esophose.playerparticles.particles.PPlayer;
|
import com.esophose.playerparticles.particles.PPlayer;
|
||||||
|
import com.esophose.playerparticles.particles.ParticleGroup;
|
||||||
|
import com.esophose.playerparticles.particles.ParticlePair;
|
||||||
|
import com.esophose.playerparticles.particles.ParticleEffect.ParticleProperty;
|
||||||
|
|
||||||
public class GuiInventoryManageParticles extends GuiInventory {
|
public class GuiInventoryManageParticles extends GuiInventory {
|
||||||
|
|
||||||
|
@ -14,10 +22,101 @@ public class GuiInventoryManageParticles extends GuiInventory {
|
||||||
|
|
||||||
this.fillBorder(BorderColor.ORANGE);
|
this.fillBorder(BorderColor.ORANGE);
|
||||||
|
|
||||||
GuiActionButton testButton = new GuiActionButton(0, new Material[] { Material.BLAZE_POWDER, Material.BLAZE_ROD }, new String[] { "Test 2!", "Look at that!" } , new String[] { "To be continued..." }, (button, isShiftClick) -> {
|
// Manage/Delete Particle Buttons
|
||||||
|
List<ParticlePair> particles = pplayer.getActiveParticles();
|
||||||
|
particles.sort(Comparator.comparingInt(ParticlePair::getId));
|
||||||
|
|
||||||
|
int index = 10;
|
||||||
|
int nextWrap = 17;
|
||||||
|
int maxIndex = 35;
|
||||||
|
for (ParticlePair particle : particles) {
|
||||||
|
GuiActionButton selectButton = new GuiActionButton(index,
|
||||||
|
GuiIcon.PARTICLES.get(),
|
||||||
|
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.GUI_PARTICLE_NAME, particle.getId()),
|
||||||
|
new String[] {
|
||||||
|
LangManager.getText(Lang.GUI_COLOR_SUBTEXT) + LangManager.getText(Lang.GUI_CLICK_TO_EDIT_PARTICLE, particles.size()),
|
||||||
|
LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_PARTICLE_INFO, particle.getId(), particle.getEffect().getName(), particle.getStyle().getName(), particle.getDataString()),
|
||||||
|
LangManager.getText(Lang.GUI_COLOR_UNAVAILABLE) + LangManager.getText(Lang.GUI_SHIFT_CLICK_TO_DELETE)
|
||||||
|
},
|
||||||
|
(button, isShiftClick) -> {
|
||||||
|
if (!isShiftClick) {
|
||||||
|
GuiHandler.transition(new GuiInventoryEditParticle(pplayer, particle));
|
||||||
|
} else {
|
||||||
|
// Delete particle
|
||||||
|
ParticleGroup activeGroup = pplayer.getActiveParticleGroup();
|
||||||
|
for (ParticlePair pp : activeGroup.getParticles()) {
|
||||||
|
if (pp.getId() == particle.getId()) {
|
||||||
|
activeGroup.getParticles().remove(pp);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DataManager.saveParticleGroup(pplayer.getUniqueId(), activeGroup);
|
||||||
|
|
||||||
|
// Update inventory to reflect deletion
|
||||||
|
this.actionButtons.remove(button);
|
||||||
|
this.inventory.setItem(button.getSlot(), null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.actionButtons.add(selectButton);
|
||||||
|
|
||||||
|
index++;
|
||||||
|
if (index == nextWrap) { // Loop around border
|
||||||
|
nextWrap += 9;
|
||||||
|
index += 2;
|
||||||
|
}
|
||||||
|
if (index > maxIndex) break; // Overflowed the available space
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create New Particle Button
|
||||||
|
GuiActionButton createNewParticle = new GuiActionButton(38,
|
||||||
|
GuiIcon.CREATE.get(),
|
||||||
|
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.GUI_CREATE_PARTICLE),
|
||||||
|
new String[] { LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_CREATE_PARTICLE_DESCRIPTION) },
|
||||||
|
(button, isShiftClick) -> {
|
||||||
|
ParticlePair editingParticle = ParticlePair.getNextDefault(pplayer);
|
||||||
|
List<GuiInventoryEditFinishedCallback> callbacks = new ArrayList<GuiInventoryEditFinishedCallback>();
|
||||||
|
callbacks.add(() -> GuiHandler.transition(new GuiInventoryManageParticles(pplayer)));
|
||||||
|
callbacks.add(() -> GuiHandler.transition(new GuiInventoryEditEffect(pplayer, editingParticle, callbacks, 1)));
|
||||||
|
callbacks.add(() -> GuiHandler.transition(new GuiInventoryEditStyle(pplayer, editingParticle, callbacks, 2)));
|
||||||
|
callbacks.add(() -> {
|
||||||
|
if (editingParticle.getEffect().hasProperty(ParticleProperty.COLORABLE) || editingParticle.getEffect().hasProperty(ParticleProperty.REQUIRES_MATERIAL_DATA)) {
|
||||||
|
GuiHandler.transition(new GuiInventoryEditData(pplayer, editingParticle, callbacks, 3));
|
||||||
|
} else {
|
||||||
|
callbacks.get(4).execute();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
callbacks.add(() -> {
|
||||||
|
// Save new particle
|
||||||
|
ParticleGroup group = pplayer.getActiveParticleGroup();
|
||||||
|
group.getParticles().add(editingParticle);
|
||||||
|
DataManager.saveParticleGroup(pplayer.getUniqueId(), group);
|
||||||
|
|
||||||
|
// Reopen the manage particle inventory
|
||||||
|
GuiHandler.transition(new GuiInventoryManageParticles(pplayer));
|
||||||
|
});
|
||||||
|
callbacks.get(1).execute();
|
||||||
|
});
|
||||||
|
this.actionButtons.add(createNewParticle);
|
||||||
|
|
||||||
|
// Reset Particles Button
|
||||||
|
GuiActionButton resetParticles = new GuiActionButton(42,
|
||||||
|
GuiIcon.RESET.get(),
|
||||||
|
LangManager.getText(Lang.GUI_COLOR_ICON_NAME) + LangManager.getText(Lang.GUI_RESET_PARTICLES),
|
||||||
|
new String[] { LangManager.getText(Lang.GUI_COLOR_UNAVAILABLE) + LangManager.getText(Lang.GUI_RESET_PARTICLES_DESCRIPTION) },
|
||||||
|
(button, isShiftClick) -> {
|
||||||
|
// Reset particles
|
||||||
|
DataManager.saveParticleGroup(pplayer.getUniqueId(), ParticleGroup.getDefaultGroup());
|
||||||
|
|
||||||
|
// Reopen this same inventory to refresh it
|
||||||
|
GuiHandler.transition(new GuiInventoryManageParticles(pplayer));
|
||||||
|
});
|
||||||
|
this.actionButtons.add(resetParticles);
|
||||||
|
|
||||||
|
// Back Button
|
||||||
|
GuiActionButton backButton = new GuiActionButton(INVENTORY_SIZE - 1, GuiIcon.BACK.get(), LangManager.getText(Lang.GUI_COLOR_INFO) + LangManager.getText(Lang.GUI_BACK_BUTTON), new String[] {}, (button, isShiftClick) -> {
|
||||||
GuiHandler.transition(new GuiInventoryDefault(pplayer));
|
GuiHandler.transition(new GuiInventoryDefault(pplayer));
|
||||||
});
|
});
|
||||||
this.actionButtons.add(testButton);
|
this.actionButtons.add(backButton);
|
||||||
|
|
||||||
this.populate();
|
this.populate();
|
||||||
}
|
}
|
||||||
|
|
|
@ -176,11 +176,11 @@ public class LangManager {
|
||||||
|
|
||||||
// GUI
|
// GUI
|
||||||
GUI_DISABLED,
|
GUI_DISABLED,
|
||||||
GUI_BY_DEFAULT,
|
|
||||||
GUI_COLOR_ICON_NAME,
|
GUI_COLOR_ICON_NAME,
|
||||||
GUI_COLOR_INFO,
|
GUI_COLOR_INFO,
|
||||||
GUI_COLOR_SUBTEXT,
|
GUI_COLOR_SUBTEXT,
|
||||||
GUI_COLOR_UNAVAILABLE,
|
GUI_COLOR_UNAVAILABLE,
|
||||||
|
GUI_COMMANDS_INFO,
|
||||||
GUI_BACK_BUTTON,
|
GUI_BACK_BUTTON,
|
||||||
GUI_CLICK_TO_LOAD,
|
GUI_CLICK_TO_LOAD,
|
||||||
GUI_SHIFT_CLICK_TO_DELETE,
|
GUI_SHIFT_CLICK_TO_DELETE,
|
||||||
|
@ -197,7 +197,48 @@ public class LangManager {
|
||||||
GUI_LOAD_A_PRESET_GROUP_DESCRIPTION,
|
GUI_LOAD_A_PRESET_GROUP_DESCRIPTION,
|
||||||
GUI_SAVE_GROUP,
|
GUI_SAVE_GROUP,
|
||||||
GUI_SAVE_GROUP_DESCRIPTION,
|
GUI_SAVE_GROUP_DESCRIPTION,
|
||||||
GUI_SAVE_GROUP_DESCRIPTION_2;
|
GUI_SAVE_GROUP_DESCRIPTION_2,
|
||||||
|
GUI_RESET_PARTICLES,
|
||||||
|
GUI_RESET_PARTICLES_DESCRIPTION,
|
||||||
|
GUI_PARTICLE_NAME,
|
||||||
|
GUI_CLICK_TO_EDIT_PARTICLE,
|
||||||
|
GUI_EDITING_PARTICLE,
|
||||||
|
GUI_EDIT_EFFECT,
|
||||||
|
GUI_EDIT_EFFECT_DESCRIPTION,
|
||||||
|
GUI_EDIT_STYLE,
|
||||||
|
GUI_EDIT_STYLE_DESCRIPTION,
|
||||||
|
GUI_EDIT_DATA,
|
||||||
|
GUI_EDIT_DATA_DESCRIPTION,
|
||||||
|
GUI_EDIT_DATA_UNAVAILABLE,
|
||||||
|
GUI_CREATE_PARTICLE,
|
||||||
|
GUI_CREATE_PARTICLE_DESCRIPTION,
|
||||||
|
GUI_SELECT_EFFECT,
|
||||||
|
GUI_SELECT_EFFECT_DESCRIPTION,
|
||||||
|
GUI_SELECT_STYLE,
|
||||||
|
GUI_SELECT_STYLE_DESCRIPTION,
|
||||||
|
GUI_SELECT_DATA,
|
||||||
|
GUI_SELECT_DATA_DESCRIPTION,
|
||||||
|
GUI_SELECT_DATA_NOTE,
|
||||||
|
GUI_SELECT_DATA_RANDOMIZE_ITEMS,
|
||||||
|
GUI_SELECT_DATA_RANDOMIZE_ITEMS_DESCRIPTION,
|
||||||
|
GUI_SELECT_DATA_RANDOMIZE_BLOCKS,
|
||||||
|
GUI_SELECT_DATA_RANDOMIZE_BLOCKS_DESCRIPTION,
|
||||||
|
GUI_EDIT_DATA_COLOR_RED,
|
||||||
|
GUI_EDIT_DATA_COLOR_ORANGE,
|
||||||
|
GUI_EDIT_DATA_COLOR_YELLOW,
|
||||||
|
GUI_EDIT_DATA_COLOR_LIME_GREEN,
|
||||||
|
GUI_EDIT_DATA_COLOR_GREEN,
|
||||||
|
GUI_EDIT_DATA_COLOR_BLUE,
|
||||||
|
GUI_EDIT_DATA_COLOR_CYAN,
|
||||||
|
GUI_EDIT_DATA_COLOR_LIGHT_BLUE,
|
||||||
|
GUI_EDIT_DATA_COLOR_PURPLE,
|
||||||
|
GUI_EDIT_DATA_COLOR_MAGENTA,
|
||||||
|
GUI_EDIT_DATA_COLOR_PINK,
|
||||||
|
GUI_EDIT_DATA_COLOR_BROWN,
|
||||||
|
GUI_EDIT_DATA_COLOR_BLACK,
|
||||||
|
GUI_EDIT_DATA_COLOR_GRAY,
|
||||||
|
GUI_EDIT_DATA_COLOR_LIGHT_GRAY,
|
||||||
|
GUI_EDIT_DATA_COLOR_WHITE;
|
||||||
// @formatter:on
|
// @formatter:on
|
||||||
|
|
||||||
private String message;
|
private String message;
|
||||||
|
|
|
@ -92,7 +92,7 @@ public class ParticleManager extends BukkitRunnable implements Listener {
|
||||||
|
|
||||||
if (hue % 5 == 0) { // Only increment note by 4 notes per second
|
if (hue % 5 == 0) { // Only increment note by 4 notes per second
|
||||||
note++;
|
note++;
|
||||||
note %= 24;
|
note %= 25;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Loop over backwards so we can remove pplayers if need be
|
// Loop over backwards so we can remove pplayers if need be
|
||||||
|
|
|
@ -175,7 +175,7 @@ public class PermissionManager {
|
||||||
* @param p The player to get effect names for
|
* @param p The player to get effect names for
|
||||||
* @return A String List of all effect names the given player has permission for
|
* @return A String List of all effect names the given player has permission for
|
||||||
*/
|
*/
|
||||||
public static List<String> getEffectsUserHasPermissionFor(Player p) {
|
public static List<String> getEffectNamesUserHasPermissionFor(Player p) {
|
||||||
List<String> list = new ArrayList<String>();
|
List<String> list = new ArrayList<String>();
|
||||||
for (ParticleEffect pe : ParticleEffect.getSupportedEffects())
|
for (ParticleEffect pe : ParticleEffect.getSupportedEffects())
|
||||||
if (hasEffectPermission(p, pe))
|
if (hasEffectPermission(p, pe))
|
||||||
|
@ -189,13 +189,41 @@ public class PermissionManager {
|
||||||
* @param p The player to get style names for
|
* @param p The player to get style names for
|
||||||
* @return A String List of all style names the given player has permission for
|
* @return A String List of all style names the given player has permission for
|
||||||
*/
|
*/
|
||||||
public static List<String> getStylesUserHasPermissionFor(Player p) {
|
public static List<String> getStyleNamesUserHasPermissionFor(Player p) {
|
||||||
List<String> list = new ArrayList<String>();
|
List<String> list = new ArrayList<String>();
|
||||||
for (ParticleStyle ps : ParticleStyleManager.getStyles())
|
for (ParticleStyle ps : ParticleStyleManager.getStyles())
|
||||||
if (hasStylePermission(p, ps))
|
if (hasStylePermission(p, ps))
|
||||||
list.add(ps.getName());
|
list.add(ps.getName());
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a List of all effects a player has permission for
|
||||||
|
*
|
||||||
|
* @param p The player to get effects for
|
||||||
|
* @return A List of all effects the given player has permission for
|
||||||
|
*/
|
||||||
|
public static List<ParticleEffect> getEffectsUserHasPermissionFor(Player p) {
|
||||||
|
List<ParticleEffect> list = new ArrayList<ParticleEffect>();
|
||||||
|
for (ParticleEffect pe : ParticleEffect.getSupportedEffects())
|
||||||
|
if (hasEffectPermission(p, pe))
|
||||||
|
list.add(pe);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a List of all styles a player has permission for
|
||||||
|
*
|
||||||
|
* @param p The player to get styles for
|
||||||
|
* @return A List of all styles the given player has permission for
|
||||||
|
*/
|
||||||
|
public static List<ParticleStyle> getStylesUserHasPermissionFor(Player p) {
|
||||||
|
List<ParticleStyle> list = new ArrayList<ParticleStyle>();
|
||||||
|
for (ParticleStyle ps : ParticleStyleManager.getStyles())
|
||||||
|
if (hasStylePermission(p, ps))
|
||||||
|
list.add(ps);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if a player has permission to created fixed effects
|
* Checks if a player has permission to created fixed effects
|
||||||
|
|
|
@ -21,8 +21,7 @@ public class SettingManager {
|
||||||
LONG,
|
LONG,
|
||||||
DOUBLE,
|
DOUBLE,
|
||||||
STRING,
|
STRING,
|
||||||
STRING_LIST,
|
STRING_LIST
|
||||||
MATERIAL
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -100,15 +99,6 @@ public class SettingManager {
|
||||||
case STRING_LIST:
|
case STRING_LIST:
|
||||||
this.value = PlayerParticles.getPlugin().getConfig().getStringList(configPath);
|
this.value = PlayerParticles.getPlugin().getConfig().getStringList(configPath);
|
||||||
break;
|
break;
|
||||||
case MATERIAL:
|
|
||||||
String materialName = PlayerParticles.getPlugin().getConfig().getString(configPath);
|
|
||||||
Material material = ParticleUtils.closestMatch(materialName);
|
|
||||||
if (material == null) {
|
|
||||||
material = Material.BARRIER;
|
|
||||||
PlayerParticles.getPlugin().getLogger().severe("Invalid block/item name for '" + this.name().toLowerCase().replace('_', '-') + "' in config.yml: '" + materialName + "'");
|
|
||||||
}
|
|
||||||
this.value = material;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this.value;
|
return this.value;
|
||||||
|
@ -179,7 +169,10 @@ public class SettingManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum GUIIcon {
|
/**
|
||||||
|
* Used for grabbing/caching configurable GUI Icons from the config.yml
|
||||||
|
*/
|
||||||
|
public enum GuiIcon {
|
||||||
PARTICLES,
|
PARTICLES,
|
||||||
GROUPS,
|
GROUPS,
|
||||||
PRESET_GROUPS,
|
PRESET_GROUPS,
|
||||||
|
@ -189,13 +182,14 @@ public class SettingManager {
|
||||||
EDIT_STYLE,
|
EDIT_STYLE,
|
||||||
EDIT_DATA,
|
EDIT_DATA,
|
||||||
RANDOMIZE,
|
RANDOMIZE,
|
||||||
|
RESET,
|
||||||
|
|
||||||
EFFECT,
|
EFFECT,
|
||||||
STYLE;
|
STYLE;
|
||||||
|
|
||||||
private Map<String, Material> materials;
|
private Map<String, Material> materials;
|
||||||
|
|
||||||
private GUIIcon() {
|
private GuiIcon() {
|
||||||
this.materials = new HashMap<String, Material>();
|
this.materials = new HashMap<String, Material>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -312,10 +312,10 @@ public enum ParticleEffect {
|
||||||
*/
|
*/
|
||||||
private List<Player> getPlayersInRange(Location center, boolean isFixedEffect) {
|
private List<Player> getPlayersInRange(Location center, boolean isFixedEffect) {
|
||||||
List<Player> players = new ArrayList<Player>();
|
List<Player> players = new ArrayList<Player>();
|
||||||
int range = isFixedEffect ? PSetting.PARTICLE_RENDER_RANGE_PLAYER.getInt() : PSetting.PARTICLE_RENDER_RANGE_FIXED_EFFECT.getInt();
|
int range = !isFixedEffect ? PSetting.PARTICLE_RENDER_RANGE_PLAYER.getInt() : PSetting.PARTICLE_RENDER_RANGE_FIXED_EFFECT.getInt();
|
||||||
|
|
||||||
for (Player p : Bukkit.getOnlinePlayers())
|
for (Player p : Bukkit.getOnlinePlayers())
|
||||||
if (p.getWorld().equals(center.getWorld()) && center.distanceSquared(p.getLocation()) <= range * range)
|
if (p.getWorld().equals(center.getWorld()) && center.distanceSquared(p.getLocation()) <= range * range)
|
||||||
players.add(p);
|
players.add(p);
|
||||||
|
|
||||||
return players;
|
return players;
|
||||||
|
|
|
@ -260,15 +260,33 @@ public class ParticlePair {
|
||||||
public ParticlePair clone() {
|
public ParticlePair clone() {
|
||||||
return new ParticlePair(this.ownerUUID, this.id, this.effect, this.style, this.itemMaterial, this.blockMaterial, this.color, this.noteColor);
|
return new ParticlePair(this.ownerUUID, this.id, this.effect, this.style, this.itemMaterial, this.blockMaterial, this.color, this.noteColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a ParticlePair with the default values applied
|
* Gets a ParticlePair with the default values applied
|
||||||
|
* Used for getting internal default values in the cases that null is specified
|
||||||
*
|
*
|
||||||
* @return A ParticlePair with default values
|
* @return A ParticlePair with default values
|
||||||
*/
|
*/
|
||||||
public static ParticlePair getDefault() {
|
private static ParticlePair getDefault() {
|
||||||
return new ParticlePair(null, // @formatter:off
|
return new ParticlePair(null, // @formatter:off
|
||||||
-1,
|
-1,
|
||||||
|
ParticleEffect.FLAME,
|
||||||
|
DefaultStyles.NORMAL,
|
||||||
|
ParticleUtils.closestMatchWithFallback("IRON_SHOVEL", "IRON_SPADE"),
|
||||||
|
Material.STONE,
|
||||||
|
new OrdinaryColor(0, 0, 0),
|
||||||
|
new NoteColor(0)); // @formatter:on
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a ParticlePair for a PPlayer with the default values applied
|
||||||
|
*
|
||||||
|
* @param pplayer The PPlayer that will own this ParticlePair
|
||||||
|
* @return A ParticlePair with default values
|
||||||
|
*/
|
||||||
|
public static ParticlePair getNextDefault(PPlayer pplayer) {
|
||||||
|
return new ParticlePair(pplayer.getUniqueId(), // @formatter:off
|
||||||
|
pplayer.getNextActiveParticleId(),
|
||||||
ParticleEffect.FLAME,
|
ParticleEffect.FLAME,
|
||||||
DefaultStyles.NORMAL,
|
DefaultStyles.NORMAL,
|
||||||
ParticleUtils.closestMatchWithFallback("IRON_SHOVEL", "IRON_SPADE"),
|
ParticleUtils.closestMatchWithFallback("IRON_SHOVEL", "IRON_SPADE"),
|
||||||
|
@ -277,22 +295,4 @@ public class ParticlePair {
|
||||||
new NoteColor(0)); // @formatter:on
|
new NoteColor(0)); // @formatter:on
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets a ParticlePair with the default values applied
|
|
||||||
*
|
|
||||||
* @param ownerUUID The owner of this ParticlePair
|
|
||||||
* @return A ParticlePair with default values
|
|
||||||
*/
|
|
||||||
@Deprecated // TODO: REMOVE ONCE NEW GUI IS DONE
|
|
||||||
public static ParticlePair getDefault(UUID ownerUUID) {
|
|
||||||
return new ParticlePair(ownerUUID, // @formatter:off
|
|
||||||
1,
|
|
||||||
ParticleEffect.FLAME,
|
|
||||||
DefaultStyles.NORMAL,
|
|
||||||
ParticleUtils.closestMatchWithFallback("IRON_SHOVEL", "IRON_SPADE"),
|
|
||||||
Material.STONE,
|
|
||||||
new OrdinaryColor(0, 0, 0),
|
|
||||||
new NoteColor(0)); // @formatter:on
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ public class ParticleStyleWings implements ParticleStyle {
|
||||||
public List<PParticle> getParticles(ParticlePair particle, Location location) {
|
public List<PParticle> getParticles(ParticlePair particle, Location location) {
|
||||||
List<PParticle> particles = new ArrayList<PParticle>();
|
List<PParticle> particles = new ArrayList<PParticle>();
|
||||||
if (spawnTimer == 0) {
|
if (spawnTimer == 0) {
|
||||||
for (double t = 0; t < Math.PI * 2; t += Math.PI / 64) {
|
for (double t = 0; t < Math.PI * 2; t += Math.PI / 48) {
|
||||||
double x = Math.sin(t) * (Math.pow(Math.E, Math.cos(t)) - 2 * Math.cos(t * 4) - Math.pow(Math.sin(t / 12), 5)) / 2;
|
double x = Math.sin(t) * (Math.pow(Math.E, Math.cos(t)) - 2 * Math.cos(t * 4) - Math.pow(Math.sin(t / 12), 5)) / 2;
|
||||||
double y = Math.cos(t) * (Math.pow(Math.E, Math.cos(t)) - 2 * Math.cos(t * 4) - Math.pow(Math.sin(t / 12), 5)) / 2;
|
double y = Math.cos(t) * (Math.pow(Math.E, Math.cos(t)) - 2 * Math.cos(t * 4) - Math.pow(Math.sin(t / 12), 5)) / 2;
|
||||||
Vector v = VectorUtils.rotateAroundAxisY(new Vector(x, y, -0.3), -Math.toRadians(location.getYaw()));
|
Vector v = VectorUtils.rotateAroundAxisY(new Vector(x, y, -0.3), -Math.toRadians(location.getYaw()));
|
||||||
|
|
|
@ -59,10 +59,20 @@ public class ParticleUtils {
|
||||||
return mat;
|
return mat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets all block materials in the game
|
||||||
|
*
|
||||||
|
* @return A List of all block material names available in the game
|
||||||
|
*/
|
||||||
public static List<String> getAllBlockMaterials() {
|
public static List<String> getAllBlockMaterials() {
|
||||||
return blockMaterials;
|
return blockMaterials;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets all item materials in the game
|
||||||
|
*
|
||||||
|
* @return A List of all item material names available in the game
|
||||||
|
*/
|
||||||
public static List<String> getAllItemMaterials() {
|
public static List<String> getAllItemMaterials() {
|
||||||
return itemMaterials;
|
return itemMaterials;
|
||||||
}
|
}
|
||||||
|
|
|
@ -158,6 +158,8 @@ gui-icon:
|
||||||
- BOOK
|
- BOOK
|
||||||
randomize:
|
randomize:
|
||||||
- HOPPER
|
- HOPPER
|
||||||
|
reset:
|
||||||
|
- BARRIER
|
||||||
effect:
|
effect:
|
||||||
ambient_entity_effect:
|
ambient_entity_effect:
|
||||||
- BEACON
|
- BEACON
|
||||||
|
|
|
@ -113,11 +113,11 @@ data-usage-none: '&eThe effect &b{0} &edoes not use any data!'
|
||||||
data-usage-block: '&eThe effect &b{0} &erequires &bblock &edata! &bFormat: <blockName>'
|
data-usage-block: '&eThe effect &b{0} &erequires &bblock &edata! &bFormat: <blockName>'
|
||||||
data-usage-item: '&eThe effect &b{0} &erequires &bitem &edata! &bFormat: <itemName>'
|
data-usage-item: '&eThe effect &b{0} &erequires &bitem &edata! &bFormat: <itemName>'
|
||||||
data-usage-color: '&eThe effect &b{0} &erequires &bcolor &edata! &bFormat: <<0-255> <0-255> <0-255>>|<rainbow>'
|
data-usage-color: '&eThe effect &b{0} &erequires &bcolor &edata! &bFormat: <<0-255> <0-255> <0-255>>|<rainbow>'
|
||||||
data-usage-note: '&eThe effect &b{0} &erequires &bnote &edata! &bFormat: <0-23>|<rainbow>'
|
data-usage-note: '&eThe effect &b{0} &erequires &bnote &edata! &bFormat: <0-24>|<rainbow>'
|
||||||
data-invalid-block: '&cThe &bblock &cdata you entered is invalid! &bFormat: <blockName>'
|
data-invalid-block: '&cThe &bblock &cdata you entered is invalid! &bFormat: <blockName>'
|
||||||
data-invalid-item: '&cThe &bitem &cdata you entered is invalid! &bFormat: <itemName>'
|
data-invalid-item: '&cThe &bitem &cdata you entered is invalid! &bFormat: <itemName>'
|
||||||
data-invalid-color: '&cThe &bcolor &cdata you entered is invalid! &bFormat: <<0-255> <0-255> <0-255>>|<rainbow>'
|
data-invalid-color: '&cThe &bcolor &cdata you entered is invalid! &bFormat: <<0-255> <0-255> <0-255>>|<rainbow>'
|
||||||
data-invalid-note: '&cThe &bnote &cdata you entered is invalid! &bFormat: <0-23>|<rainbow>'
|
data-invalid-note: '&cThe &bnote &cdata you entered is invalid! &bFormat: <0-24>|<rainbow>'
|
||||||
data-invalid-material-not-item: '&cThe &bitem &cmaterial &b{0} &cyou entered is not an item!'
|
data-invalid-material-not-item: '&cThe &bitem &cmaterial &b{0} &cyou entered is not an item!'
|
||||||
data-invalid-material-not-block: '&cThe &bblock &cmaterial &b{0} &cyou entered is not a block!'
|
data-invalid-material-not-block: '&cThe &bblock &cmaterial &b{0} &cyou entered is not a block!'
|
||||||
data-invalid-material-item: '&cThe &bitem &cmaterial &b{0} you entered does not exist!'
|
data-invalid-material-item: '&cThe &bitem &cmaterial &b{0} you entered does not exist!'
|
||||||
|
@ -162,11 +162,11 @@ fixed-invalid-command: '&cInvalid sub-command for &b/pp fixed&c!'
|
||||||
|
|
||||||
# GUI
|
# GUI
|
||||||
gui-disabled: '&cThe server administrator has disabled the GUI!'
|
gui-disabled: '&cThe server administrator has disabled the GUI!'
|
||||||
gui-by-default: '&eWe opened the GUI for you because you did not specify a command. View other commands with &b/pp help&e or use &b/pp gui&e to avoid this message.'
|
|
||||||
gui-color-icon-name: '&a'
|
gui-color-icon-name: '&a'
|
||||||
gui-color-info: '&e'
|
gui-color-info: '&e'
|
||||||
gui-color-subtext: '&b'
|
gui-color-subtext: '&b'
|
||||||
gui-color-unavailable: '&c'
|
gui-color-unavailable: '&c'
|
||||||
|
gui-commands-info: 'Find info about commands with &b/pp help'
|
||||||
gui-back-button: 'Go Back'
|
gui-back-button: 'Go Back'
|
||||||
gui-click-to-load: 'Click to load the following {0} particle(s):'
|
gui-click-to-load: 'Click to load the following {0} particle(s):'
|
||||||
gui-shift-click-to-delete: 'Shift click to delete'
|
gui-shift-click-to-delete: 'Shift click to delete'
|
||||||
|
@ -184,3 +184,44 @@ gui-load-a-preset-group-description: 'Load a premade particle group'
|
||||||
gui-save-group: 'Save New Group'
|
gui-save-group: 'Save New Group'
|
||||||
gui-save-group-description: 'You can save a new group using the following command:'
|
gui-save-group-description: 'You can save a new group using the following command:'
|
||||||
gui-save-group-description-2: '/pp group save <groupName>'
|
gui-save-group-description-2: '/pp group save <groupName>'
|
||||||
|
gui-reset-particles: 'Reset Your Particles'
|
||||||
|
gui-reset-particles-description: 'Deletes all your active particles'
|
||||||
|
gui-particle-name: 'Particle #{0}'
|
||||||
|
gui-click-to-edit-particle: 'Click to edit the effect, style, or data of this particle'
|
||||||
|
gui-editing-particle: 'Editing Particle #{0}'
|
||||||
|
gui-edit-effect: 'Edit Effect'
|
||||||
|
gui-edit-effect-description: 'Click to edit the effect of this particle'
|
||||||
|
gui-edit-style: 'Edit Style'
|
||||||
|
gui-edit-style-description: 'Click to edit the style of this particle'
|
||||||
|
gui-edit-data: 'Edit Data'
|
||||||
|
gui-edit-data-description: 'Click to edit the data of this particle'
|
||||||
|
gui-edit-data-unavailable: 'The effect of this particle does not use any data'
|
||||||
|
gui-create-particle: 'Create A New Particle'
|
||||||
|
gui-create-particle-description: 'Create a new particle with an effect, style, and data'
|
||||||
|
gui-select-effect: 'Select Particle Effect'
|
||||||
|
gui-select-effect-description: 'Sets the particle effect to &b{0}'
|
||||||
|
gui-select-style: 'Select Particle Style'
|
||||||
|
gui-select-style-description: 'Sets the particle style to &b{0}'
|
||||||
|
gui-select-data: 'Select Particle Data'
|
||||||
|
gui-select-data-description: 'Sets the particle data to &b{0}'
|
||||||
|
gui-select-data-note: 'note #{0}'
|
||||||
|
gui-select-data-randomize-items: 'Randomize Items'
|
||||||
|
gui-select-data-randomize-items-description: 'Randomizes the items displayed'
|
||||||
|
gui-select-data-randomize-blocks: 'Randomize Blocks'
|
||||||
|
gui-select-data-randomize-blocks-description: 'Randomizes the blocks displayed'
|
||||||
|
gui-edit-data-color-red: '&cred'
|
||||||
|
gui-edit-data-color-orange: '&6orange'
|
||||||
|
gui-edit-data-color-yellow: '&eyellow'
|
||||||
|
gui-edit-data-color-lime-green: '&alime green'
|
||||||
|
gui-edit-data-color-green: '&2green'
|
||||||
|
gui-edit-data-color-blue: '&1blue'
|
||||||
|
gui-edit-data-color-cyan: '&3cyan'
|
||||||
|
gui-edit-data-color-light-blue: '&blight blue'
|
||||||
|
gui-edit-data-color-purple: '&5purple'
|
||||||
|
gui-edit-data-color-magenta: '&dmagenta'
|
||||||
|
gui-edit-data-color-pink: '&dpink'
|
||||||
|
gui-edit-data-color-brown: '&6brown'
|
||||||
|
gui-edit-data-color-black: '&8black'
|
||||||
|
gui-edit-data-color-gray: '&8gray'
|
||||||
|
gui-edit-data-color-light-gray: '&7light gray'
|
||||||
|
gui-edit-data-color-white: '&fwhite'
|
Loading…
Add table
Add a link
Reference in a new issue