mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-10 10:28:22 +01:00
Add banner meta. Resolves #8.
This commit is contained in:
parent
effad664d5
commit
090e0b6757
@ -320,6 +320,18 @@ public class ItemDb implements IConf, net.ess3.api.IItemDb {
|
||||
int rgb = leatherArmorMeta.getColor().asRGB();
|
||||
sb.append("color:").append(rgb).append(" ");
|
||||
break;
|
||||
case BANNER:
|
||||
BannerMeta bannerMeta = (BannerMeta) is.getItemMeta();
|
||||
if (bannerMeta != null) {
|
||||
int basecolor = bannerMeta.getBaseColor().getColor().asRGB();
|
||||
sb.append("basecolor:").append(basecolor).append(" ");
|
||||
for (org.bukkit.block.banner.Pattern p : bannerMeta.getPatterns()) {
|
||||
String type = p.getPattern().getIdentifier();
|
||||
int color = p.getColor().getColor().asRGB();
|
||||
sb.append(type).append(",").append(color).append(" ");
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return sb.toString().trim().replaceAll("§", "&");
|
||||
|
@ -11,6 +11,7 @@ import org.bukkit.Color;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.FireworkEffect;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.banner.PatternType;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.*;
|
||||
@ -189,12 +190,12 @@ public class MetaItemStack {
|
||||
final FireworkMeta meta = (FireworkMeta) stack.getItemMeta();
|
||||
meta.setPower(power > 3 ? 4 : power);
|
||||
stack.setItemMeta(meta);
|
||||
} else if (stack.getType() == Material.FIREWORK) //WARNING - Meta for fireworks will be ignored after this point.
|
||||
{
|
||||
} else if (stack.getType() == Material.FIREWORK) {//WARNING - Meta for fireworks will be ignored after this point.
|
||||
addFireworkMeta(sender, false, string, ess);
|
||||
} else if (stack.getType() == Material.POTION) //WARNING - Meta for potions will be ignored after this point.
|
||||
{
|
||||
} else if (stack.getType() == Material.POTION) { //WARNING - Meta for potions will be ignored after this point.
|
||||
addPotionMeta(sender, false, string, ess);
|
||||
} else if (stack.getType() == Material.BANNER) { //WARNING - Meta for banners will be ignored after this point.
|
||||
addBannerMeta(sender, false, string, ess);
|
||||
} else if (split.length > 1 && (split[0].equalsIgnoreCase("color") || split[0].equalsIgnoreCase("colour")) && (stack.getType() == Material.LEATHER_BOOTS || stack.getType() == Material.LEATHER_CHESTPLATE || stack.getType() == Material.LEATHER_HELMET || stack.getType() == Material.LEATHER_LEGGINGS)) {
|
||||
final String[] color = split[1].split("(\\||,)");
|
||||
if (color.length == 3) {
|
||||
@ -215,7 +216,6 @@ public class MetaItemStack {
|
||||
public void addFireworkMeta(final CommandSource sender, final boolean allowShortName, final String string, final IEssentials ess) throws Exception {
|
||||
if (stack.getType() == Material.FIREWORK) {
|
||||
final String[] split = splitPattern.split(string, 2);
|
||||
|
||||
if (split.length < 2) {
|
||||
return;
|
||||
}
|
||||
@ -401,6 +401,29 @@ public class MetaItemStack {
|
||||
return enchantment;
|
||||
}
|
||||
|
||||
public void addBannerMeta(final CommandSource sender, final boolean allowShortName, final String string, final IEssentials ess) throws Exception {
|
||||
if (stack.getType() == Material.BANNER && string != null) {
|
||||
final String[] split = splitPattern.split(string, 2);
|
||||
|
||||
if (split.length < 2) {
|
||||
throw new Exception(tl("invalidBanner", split[1]));
|
||||
}
|
||||
|
||||
final BannerMeta meta = (BannerMeta) stack.getItemMeta();
|
||||
if (split[0].equalsIgnoreCase("basecolor")) {
|
||||
Color color = Color.fromRGB(Integer.valueOf(split[1]));
|
||||
meta.setBaseColor(DyeColor.getByColor(color));
|
||||
} else if (PatternType.valueOf(split[0]) != null) {
|
||||
PatternType type = PatternType.valueOf(split[0]);
|
||||
DyeColor color = DyeColor.getByColor(Color.fromRGB(Integer.valueOf(split[1])));
|
||||
org.bukkit.block.banner.Pattern pattern = new org.bukkit.block.banner.Pattern(color, type);
|
||||
meta.addPattern(pattern);
|
||||
}
|
||||
|
||||
stack.setItemMeta(meta);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean hasMetaPermission(final CommandSource sender, final String metaPerm, final boolean graceful, final boolean includeBase, final IEssentials ess) throws Exception {
|
||||
final User user = sender != null && sender.isPlayer() ? ess.getUser(sender.getPlayer()) : null;
|
||||
return hasMetaPermission(user, metaPerm, graceful, includeBase);
|
||||
|
@ -560,4 +560,5 @@ createKit=\u00a74/createkit <kitname> <delay>
|
||||
createdKit=\u00a76Created kit \u00a7c{0} \u00a76with \u00a7c{1} \u00a76entries and delay \u00a7c{2}
|
||||
spectator=spectator
|
||||
kitContains=\u00a76Kit \u00a7c{0} \u00a76contains:
|
||||
kitItem=\u00a76- \u00a7f{0}
|
||||
kitItem=\u00a76- \u00a7f{0}
|
||||
invalidBanner=\u00a74Invalid banner syntax.
|
@ -560,4 +560,5 @@ cantGamemode=\u00a74You do not have permission to change to gamemode {0}
|
||||
createdKit=\u00a76Created kit \u00a7c{0} \u00a76with \u00a7c{1} \u00a76entries and delay \u00a7c{2}
|
||||
spectator=spectator
|
||||
kitContains=\u00a76Kit \u00a7c{0} \u00a76contains:
|
||||
kitItem=\u00a76- \u00a7f{0}
|
||||
kitItem=\u00a76- \u00a7f{0}
|
||||
invalidBanner=\u00a74Invalid banner syntax.
|
@ -560,4 +560,5 @@ cantGamemode=\u00a74You do not have permission to change to gamemode {0}
|
||||
createdKit=\u00a76Created kit \u00a7c{0} \u00a76with \u00a7c{1} \u00a76entries and delay \u00a7c{2}
|
||||
spectator=spectator
|
||||
kitContains=\u00a76Kit \u00a7c{0} \u00a76contains:
|
||||
kitItem=\u00a76- \u00a7f{0}
|
||||
kitItem=\u00a76- \u00a7f{0}
|
||||
invalidBanner=\u00a74Invalid banner syntax.
|
@ -560,4 +560,5 @@ cantGamemode=\u00a74You do not have permission to change to gamemode {0}
|
||||
createdKit=\u00a76Created kit \u00a7c{0} \u00a76with \u00a7c{1} \u00a76entries and delay \u00a7c{2}
|
||||
spectator=spectator
|
||||
kitContains=\u00a76Kit \u00a7c{0} \u00a76contains:
|
||||
kitItem=\u00a76- \u00a7f{0}
|
||||
kitItem=\u00a76- \u00a7f{0}
|
||||
invalidBanner=\u00a74Invalid banner syntax.
|
@ -559,4 +559,5 @@ cantGamemode=\u00a74You do not have permission to change to gamemode {0}
|
||||
createdKit=\u00a76Created kit \u00a7c{0} \u00a76with \u00a7c{1} \u00a76entries and delay \u00a7c{2}
|
||||
spectator=spectator
|
||||
kitContains=\u00a76Kit \u00a7c{0} \u00a76contains:
|
||||
kitItem=\u00a76- \u00a7f{0}
|
||||
kitItem=\u00a76- \u00a7f{0}
|
||||
invalidBanner=\u00a74Invalid banner syntax.
|
@ -560,4 +560,5 @@ cantGamemode=\u00a74You do not have permission to change to gamemode {0}
|
||||
createdKit=\u00a76Created kit \u00a7c{0} \u00a76with \u00a7c{1} \u00a76entries and delay \u00a7c{2}
|
||||
spectator=spectator
|
||||
kitContains=\u00a76Kit \u00a7c{0} \u00a76contains:
|
||||
kitItem=\u00a76- \u00a7f{0}
|
||||
kitItem=\u00a76- \u00a7f{0}
|
||||
invalidBanner=\u00a74Invalid banner syntax.
|
@ -560,4 +560,5 @@ cantGamemode=\u00a74You do not have permission to change to gamemode {0}
|
||||
createdKit=\u00a76Created kit \u00a7c{0} \u00a76with \u00a7c{1} \u00a76entries and delay \u00a7c{2}
|
||||
spectator=spectator
|
||||
kitContains=\u00a76Kit \u00a7c{0} \u00a76contains:
|
||||
kitItem=\u00a76- \u00a7f{0}
|
||||
kitItem=\u00a76- \u00a7f{0}
|
||||
invalidBanner=\u00a74Invalid banner syntax.
|
@ -560,4 +560,5 @@ cantGamemode=\u00a74You do not have permission to change to gamemode {0}
|
||||
createdKit=\u00a76Created kit \u00a7c{0} \u00a76with \u00a7c{1} \u00a76entries and delay \u00a7c{2}
|
||||
spectator=spectator
|
||||
kitContains=\u00a76Kit \u00a7c{0} \u00a76contains:
|
||||
kitItem=\u00a76- \u00a7f{0}
|
||||
kitItem=\u00a76- \u00a7f{0}
|
||||
invalidBanner=\u00a74Invalid banner syntax.
|
@ -560,4 +560,5 @@ cantGamemode=\u00a74You do not have permission to change to gamemode {0}
|
||||
createdKit=\u00a76Created kit \u00a7c{0} \u00a76with \u00a7c{1} \u00a76entries and delay \u00a7c{2}
|
||||
spectator=spectator
|
||||
kitContains=\u00a76Kit \u00a7c{0} \u00a76contains:
|
||||
kitItem=\u00a76- \u00a7f{0}
|
||||
kitItem=\u00a76- \u00a7f{0}
|
||||
invalidBanner=\u00a74Invalid banner syntax.
|
@ -560,4 +560,5 @@ cantGamemode=\u00a74You do not have permission to change to gamemode {0}
|
||||
createdKit=\u00a76Created kit \u00a7c{0} \u00a76with \u00a7c{1} \u00a76entries and delay \u00a7c{2}
|
||||
spectator=spectator
|
||||
kitContains=\u00a76Kit \u00a7c{0} \u00a76contains:
|
||||
kitItem=\u00a76- \u00a7f{0}
|
||||
kitItem=\u00a76- \u00a7f{0}
|
||||
invalidBanner=\u00a74Invalid banner syntax.
|
@ -560,4 +560,5 @@ cantGamemode=\u00a74You do not have permission to change to gamemode {0}
|
||||
createdKit=\u00a76Created kit \u00a7c{0} \u00a76with \u00a7c{1} \u00a76entries and delay \u00a7c{2}
|
||||
spectator=spectator
|
||||
kitContains=\u00a76Kit \u00a7c{0} \u00a76contains:
|
||||
kitItem=\u00a76- \u00a7f{0}
|
||||
kitItem=\u00a76- \u00a7f{0}
|
||||
invalidBanner=\u00a74Invalid banner syntax.
|
@ -560,4 +560,5 @@ cantGamemode=\u00a74You do not have permission to change to gamemode {0}
|
||||
createdKit=\u00a76Created kit \u00a7c{0} \u00a76with \u00a7c{1} \u00a76entries and delay \u00a7c{2}
|
||||
spectator=spectator
|
||||
kitContains=\u00a76Kit \u00a7c{0} \u00a76contains:
|
||||
kitItem=\u00a76- \u00a7f{0}
|
||||
kitItem=\u00a76- \u00a7f{0}
|
||||
invalidBanner=\u00a74Invalid banner syntax.
|
@ -560,4 +560,5 @@ cantGamemode=\u00a74You do not have permission to change to gamemode {0}
|
||||
createdKit=\u00a76Created kit \u00a7c{0} \u00a76with \u00a7c{1} \u00a76entries and delay \u00a7c{2}
|
||||
spectator=spectator
|
||||
kitContains=\u00a76Kit \u00a7c{0} \u00a76contains:
|
||||
kitItem=\u00a76- \u00a7f{0}
|
||||
kitItem=\u00a76- \u00a7f{0}
|
||||
invalidBanner=\u00a74Invalid banner syntax.
|
@ -560,4 +560,5 @@ cantGamemode=\u00a74You do not have permission to change to gamemode {0}
|
||||
createdKit=\u00a76Created kit \u00a7c{0} \u00a76with \u00a7c{1} \u00a76entries and delay \u00a7c{2}
|
||||
spectator=spectator
|
||||
kitContains=\u00a76Kit \u00a7c{0} \u00a76contains:
|
||||
kitItem=\u00a76- \u00a7f{0}
|
||||
kitItem=\u00a76- \u00a7f{0}
|
||||
invalidBanner=\u00a74Invalid banner syntax.
|
@ -560,4 +560,5 @@ cantGamemode=\u00a74You do not have permission to change to gamemode {0}
|
||||
createdKit=\u00a76Created kit \u00a7c{0} \u00a76with \u00a7c{1} \u00a76entries and delay \u00a7c{2}
|
||||
spectator=spectator
|
||||
kitContains=\u00a76Kit \u00a7c{0} \u00a76contains:
|
||||
kitItem=\u00a76- \u00a7f{0}
|
||||
kitItem=\u00a76- \u00a7f{0}
|
||||
invalidBanner=\u00a74Invalid banner syntax.
|
@ -560,4 +560,5 @@ cantGamemode=\u00a74You do not have permission to change to gamemode {0}
|
||||
createdKit=\u00a76Created kit \u00a7c{0} \u00a76with \u00a7c{1} \u00a76entries and delay \u00a7c{2}
|
||||
spectator=spectator
|
||||
kitContains=\u00a76Kit \u00a7c{0} \u00a76contains:
|
||||
kitItem=\u00a76- \u00a7f{0}
|
||||
kitItem=\u00a76- \u00a7f{0}
|
||||
invalidBanner=\u00a74Invalid banner syntax.
|
@ -560,4 +560,5 @@ cantGamemode=\u00a74You do not have permission to change to gamemode {0}
|
||||
createdKit=\u00a76Created kit \u00a7c{0} \u00a76with \u00a7c{1} \u00a76entries and delay \u00a7c{2}
|
||||
spectator=spectator
|
||||
kitContains=\u00a76Kit \u00a7c{0} \u00a76contains:
|
||||
kitItem=\u00a76- \u00a7f{0}
|
||||
kitItem=\u00a76- \u00a7f{0}
|
||||
invalidBanner=\u00a74Invalid banner syntax.
|
@ -560,4 +560,5 @@ cantGamemode=\u00a74You do not have permission to change to gamemode {0}
|
||||
createdKit=\u00a76Created kit \u00a7c{0} \u00a76with \u00a7c{1} \u00a76entries and delay \u00a7c{2}
|
||||
spectator=spectator
|
||||
kitContains=\u00a76Kit \u00a7c{0} \u00a76contains:
|
||||
kitItem=\u00a76- \u00a7f{0}
|
||||
kitItem=\u00a76- \u00a7f{0}
|
||||
invalidBanner=\u00a74Invalid banner syntax.
|
@ -560,4 +560,5 @@ cantGamemode=\u00a74You do not have permission to change to gamemode {0}
|
||||
createdKit=\u00a76Created kit \u00a7c{0} \u00a76with \u00a7c{1} \u00a76entries and delay \u00a7c{2}
|
||||
spectator=spectator
|
||||
kitContains=\u00a76Kit \u00a7c{0} \u00a76contains:
|
||||
kitItem=\u00a76- \u00a7f{0}
|
||||
kitItem=\u00a76- \u00a7f{0}
|
||||
invalidBanner=\u00a74Invalid banner syntax.
|
@ -560,4 +560,5 @@ cantGamemode=\u00a74You do not have permission to change to gamemode {0}
|
||||
createdKit=\u00a76Created kit \u00a7c{0} \u00a76with \u00a7c{1} \u00a76entries and delay \u00a7c{2}
|
||||
spectator=spectator
|
||||
kitContains=\u00a76Kit \u00a7c{0} \u00a76contains:
|
||||
kitItem=\u00a76- \u00a7f{0}
|
||||
kitItem=\u00a76- \u00a7f{0}
|
||||
invalidBanner=\u00a74Invalid banner syntax.
|
@ -560,4 +560,5 @@ cantGamemode=\u00a74You do not have permission to change to gamemode {0}
|
||||
createdKit=\u00a76Created kit \u00a7c{0} \u00a76with \u00a7c{1} \u00a76entries and delay \u00a7c{2}
|
||||
spectator=spectator
|
||||
kitContains=\u00a76Kit \u00a7c{0} \u00a76contains:
|
||||
kitItem=\u00a76- \u00a7f{0}
|
||||
kitItem=\u00a76- \u00a7f{0}
|
||||
invalidBanner=\u00a74Invalid banner syntax.
|
@ -560,4 +560,5 @@ cantGamemode=\u00a74You do not have permission to change to gamemode {0}
|
||||
createdKit=\u00a76Created kit \u00a7c{0} \u00a76with \u00a7c{1} \u00a76entries and delay \u00a7c{2}
|
||||
spectator=spectator
|
||||
kitContains=\u00a76Kit \u00a7c{0} \u00a76contains:
|
||||
kitItem=\u00a76- \u00a7f{0}
|
||||
kitItem=\u00a76- \u00a7f{0}
|
||||
invalidBanner=\u00a74Invalid banner syntax.
|
@ -560,4 +560,5 @@ cantGamemode=\u00a74You do not have permission to change to gamemode {0}
|
||||
createdKit=\u00a76Created kit \u00a7c{0} \u00a76with \u00a7c{1} \u00a76entries and delay \u00a7c{2}
|
||||
spectator=spectator
|
||||
kitContains=\u00a76Kit \u00a7c{0} \u00a76contains:
|
||||
kitItem=\u00a76- \u00a7f{0}
|
||||
kitItem=\u00a76- \u00a7f{0}
|
||||
invalidBanner=\u00a74Invalid banner syntax.
|
@ -560,4 +560,5 @@ cantGamemode=\u00a74You do not have permission to change to gamemode {0}
|
||||
createdKit=\u00a76Created kit \u00a7c{0} \u00a76with \u00a7c{1} \u00a76entries and delay \u00a7c{2}
|
||||
spectator=spectator
|
||||
kitContains=\u00a76Kit \u00a7c{0} \u00a76contains:
|
||||
kitItem=\u00a76- \u00a7f{0}
|
||||
kitItem=\u00a76- \u00a7f{0}
|
||||
invalidBanner=\u00a74Invalid banner syntax.
|
Loading…
Reference in New Issue
Block a user