mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-02 14:37:46 +01:00
Start work on firework effect - syntax in flux
This commit is contained in:
parent
4807fb39e5
commit
fdc262a205
@ -7,6 +7,9 @@ import java.util.List;
|
|||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import org.bukkit.Color;
|
import org.bukkit.Color;
|
||||||
|
import org.bukkit.DyeColor;
|
||||||
|
import org.bukkit.FireworkEffect;
|
||||||
|
import org.bukkit.FireworkEffect.Builder;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@ -31,6 +34,7 @@ public class MetaItemStack
|
|||||||
//TODO: TL this
|
//TODO: TL this
|
||||||
public void addStringMeta(final User user, final boolean allowUnsafe, final String string, final IEssentials ess) throws Exception
|
public void addStringMeta(final User user, final boolean allowUnsafe, final String string, final IEssentials ess) throws Exception
|
||||||
{
|
{
|
||||||
|
ess.getLogger().info("Adding meta to " + stack.getType().name());
|
||||||
final String[] split = splitPattern.split(string, 2);
|
final String[] split = splitPattern.split(string, 2);
|
||||||
if (split.length < 1)
|
if (split.length < 1)
|
||||||
{
|
{
|
||||||
@ -94,13 +98,47 @@ public class MetaItemStack
|
|||||||
meta.setTitle(title);
|
meta.setTitle(title);
|
||||||
stack.setItemMeta(meta);
|
stack.setItemMeta(meta);
|
||||||
}
|
}
|
||||||
|
else if (split.length > 1 && split[0].equalsIgnoreCase("power") && stack.getType() == Material.FIREWORK)
|
||||||
|
{
|
||||||
|
final int power = Integer.parseInt(split[1]);
|
||||||
|
final FireworkMeta meta = (FireworkMeta)stack.getItemMeta();
|
||||||
|
meta.setPower(power);
|
||||||
|
stack.setItemMeta(meta);
|
||||||
|
}
|
||||||
|
else if (split.length > 1 && split[0].equalsIgnoreCase("effect") && stack.getType() == Material.FIREWORK)
|
||||||
|
{
|
||||||
|
//TODO: Add validation messages
|
||||||
|
final FireworkMeta meta = (FireworkMeta)stack.getItemMeta();
|
||||||
|
Builder builder = FireworkEffect.builder();
|
||||||
|
|
||||||
|
String[] effectData = split[1].toUpperCase(Locale.ENGLISH).split("\\|");
|
||||||
|
|
||||||
|
builder.with(FireworkEffect.Type.valueOf(effectData[0]));
|
||||||
|
|
||||||
|
String[] primaryColorStrings = effectData[1].split(",");
|
||||||
|
List<Color> primaryColors = new ArrayList<Color>();
|
||||||
|
|
||||||
|
for (String primaryColorString : primaryColorStrings) {
|
||||||
|
primaryColors.add(DyeColor.valueOf(primaryColorString).getFireworkColor());
|
||||||
|
}
|
||||||
|
|
||||||
|
//if (effectData.length > 2) {
|
||||||
|
|
||||||
|
//}
|
||||||
|
|
||||||
|
builder.withColor(primaryColors);
|
||||||
|
|
||||||
|
final FireworkEffect effect = builder.build();
|
||||||
|
meta.addEffect(effect);
|
||||||
|
stack.setItemMeta(meta);
|
||||||
|
}
|
||||||
else if (split.length > 1 && (split[0].equalsIgnoreCase("color") || split[0].equalsIgnoreCase("colour"))
|
else if (split.length > 1 && (split[0].equalsIgnoreCase("color") || split[0].equalsIgnoreCase("colour"))
|
||||||
&& (stack.getType() == Material.LEATHER_BOOTS
|
&& (stack.getType() == Material.LEATHER_BOOTS
|
||||||
|| stack.getType() == Material.LEATHER_CHESTPLATE
|
|| stack.getType() == Material.LEATHER_CHESTPLATE
|
||||||
|| stack.getType() == Material.LEATHER_HELMET
|
|| stack.getType() == Material.LEATHER_HELMET
|
||||||
|| stack.getType() == Material.LEATHER_LEGGINGS))
|
|| stack.getType() == Material.LEATHER_LEGGINGS))
|
||||||
{
|
{
|
||||||
final String[] color = split[1].split("\\|");
|
final String[] color = split[1].split(",");
|
||||||
if (color.length == 3)
|
if (color.length == 3)
|
||||||
{
|
{
|
||||||
final int red = Util.isInt(color[0]) ? Integer.parseInt(color[0]) : 0;
|
final int red = Util.isInt(color[0]) ? Integer.parseInt(color[0]) : 0;
|
||||||
|
@ -222,7 +222,7 @@ kits:
|
|||||||
items:
|
items:
|
||||||
- 278 1 efficiency:1 durability:1 fortune:1 name:&4Gigadrill lore:The_drill_that_&npierces|the_heavens
|
- 278 1 efficiency:1 durability:1 fortune:1 name:&4Gigadrill lore:The_drill_that_&npierces|the_heavens
|
||||||
- 277 1 digspeed:3 name:Dwarf lore:Diggy|Diggy|Hole
|
- 277 1 digspeed:3 name:Dwarf lore:Diggy|Diggy|Hole
|
||||||
- 298 1 color:255|255|255 name:Top_Hat lore:Good_day,_Good_day
|
- 298 1 color:255,255,255 name:Top_Hat lore:Good_day,_Good_day
|
||||||
- 279:780 1
|
- 279:780 1
|
||||||
notch:
|
notch:
|
||||||
delay: 6000
|
delay: 6000
|
||||||
|
Loading…
Reference in New Issue
Block a user