mirror of
https://github.com/essentials/Essentials.git
synced 2025-08-18 20:41:37 +02:00
Clean up meta error messages.
Add enchant perm checks back.
This commit is contained in:
@@ -99,14 +99,14 @@ public class MetaItemStack
|
|||||||
}
|
}
|
||||||
if (validFirework)
|
if (validFirework)
|
||||||
{
|
{
|
||||||
if (!hasMetaPermission(sender, "firework", true, false, ess))
|
if (!hasMetaPermission(sender, "firework", true, ess))
|
||||||
{
|
{
|
||||||
throw new Exception(_("noMetaFirework"));
|
throw new Exception(_("noMetaFirework"));
|
||||||
}
|
}
|
||||||
FireworkEffect effect = builder.build();
|
FireworkEffect effect = builder.build();
|
||||||
FireworkMeta fmeta = (FireworkMeta)stack.getItemMeta();
|
FireworkMeta fmeta = (FireworkMeta)stack.getItemMeta();
|
||||||
fmeta.addEffect(effect);
|
fmeta.addEffect(effect);
|
||||||
if (fmeta.getEffects().size() > 1 && !hasMetaPermission(sender, "firework-multiple", true, false, ess))
|
if (fmeta.getEffects().size() > 1 && !hasMetaPermission(sender, "firework-multiple", true, ess))
|
||||||
{
|
{
|
||||||
throw new Exception(_("multipleCharges"));
|
throw new Exception(_("multipleCharges"));
|
||||||
}
|
}
|
||||||
@@ -122,14 +122,14 @@ public class MetaItemStack
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (split.length > 1 && split[0].equalsIgnoreCase("name") && hasMetaPermission(sender, "name", true, true, ess))
|
if (split.length > 1 && split[0].equalsIgnoreCase("name") && hasMetaPermission(sender, "name", false, ess))
|
||||||
{
|
{
|
||||||
final String displayName = Util.replaceFormat(split[1].replace('_', ' '));
|
final String displayName = Util.replaceFormat(split[1].replace('_', ' '));
|
||||||
final ItemMeta meta = stack.getItemMeta();
|
final ItemMeta meta = stack.getItemMeta();
|
||||||
meta.setDisplayName(displayName);
|
meta.setDisplayName(displayName);
|
||||||
stack.setItemMeta(meta);
|
stack.setItemMeta(meta);
|
||||||
}
|
}
|
||||||
else if (split.length > 1 && (split[0].equalsIgnoreCase("lore") || split[0].equalsIgnoreCase("desc")) && hasMetaPermission(sender, "lore", true, true, ess))
|
else if (split.length > 1 && (split[0].equalsIgnoreCase("lore") || split[0].equalsIgnoreCase("desc")) && hasMetaPermission(sender, "lore", false, ess))
|
||||||
{
|
{
|
||||||
final List<String> lore = new ArrayList<String>();
|
final List<String> lore = new ArrayList<String>();
|
||||||
for (String line : split[1].split("\\|"))
|
for (String line : split[1].split("\\|"))
|
||||||
@@ -140,7 +140,7 @@ public class MetaItemStack
|
|||||||
meta.setLore(lore);
|
meta.setLore(lore);
|
||||||
stack.setItemMeta(meta);
|
stack.setItemMeta(meta);
|
||||||
}
|
}
|
||||||
else if (split.length > 1 && (split[0].equalsIgnoreCase("player") || split[0].equalsIgnoreCase("owner")) && stack.getType() == Material.SKULL_ITEM && hasMetaPermission(sender, "head", true, true, ess))
|
else if (split.length > 1 && (split[0].equalsIgnoreCase("player") || split[0].equalsIgnoreCase("owner")) && stack.getType() == Material.SKULL_ITEM && hasMetaPermission(sender, "head", false, ess))
|
||||||
{
|
{
|
||||||
if (stack.getDurability() == 3)
|
if (stack.getDurability() == 3)
|
||||||
{
|
{
|
||||||
@@ -154,13 +154,13 @@ public class MetaItemStack
|
|||||||
throw new Exception(_("onlyPlayerSkulls"));
|
throw new Exception(_("onlyPlayerSkulls"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (split.length > 1 && split[0].equalsIgnoreCase("book") && stack.getType() == Material.WRITTEN_BOOK && hasMetaPermission(sender, "book", true, true, ess))
|
else if (split.length > 1 && split[0].equalsIgnoreCase("book") && stack.getType() == Material.WRITTEN_BOOK && hasMetaPermission(sender, "book", false, ess))
|
||||||
{
|
{
|
||||||
final BookMeta meta = (BookMeta)stack.getItemMeta();
|
final BookMeta meta = (BookMeta)stack.getItemMeta();
|
||||||
final IText input = new BookInput("book", true, ess);
|
final IText input = new BookInput("book", true, ess);
|
||||||
final BookPager pager = new BookPager(input);
|
final BookPager pager = new BookPager(input);
|
||||||
|
|
||||||
if (hasMetaPermission(sender, "chapter-" + split[1].toLowerCase(), true, true, ess))
|
if (hasMetaPermission(sender, "chapter", true, ess) || hasMetaPermission(sender, "chapter-" + split[1].toLowerCase(), true, ess))
|
||||||
{
|
{
|
||||||
List<String> pages = pager.getPages(split[1]);
|
List<String> pages = pager.getPages(split[1]);
|
||||||
meta.setPages(pages);
|
meta.setPages(pages);
|
||||||
@@ -173,21 +173,21 @@ public class MetaItemStack
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (split.length > 1 && split[0].equalsIgnoreCase("author") && stack.getType() == Material.WRITTEN_BOOK && hasMetaPermission(sender, "author", true, true, ess))
|
else if (split.length > 1 && split[0].equalsIgnoreCase("author") && stack.getType() == Material.WRITTEN_BOOK && hasMetaPermission(sender, "author", false, ess))
|
||||||
{
|
{
|
||||||
final String author = split[1];
|
final String author = split[1];
|
||||||
final BookMeta meta = (BookMeta)stack.getItemMeta();
|
final BookMeta meta = (BookMeta)stack.getItemMeta();
|
||||||
meta.setAuthor(author);
|
meta.setAuthor(author);
|
||||||
stack.setItemMeta(meta);
|
stack.setItemMeta(meta);
|
||||||
}
|
}
|
||||||
else if (split.length > 1 && split[0].equalsIgnoreCase("title") && stack.getType() == Material.WRITTEN_BOOK && hasMetaPermission(sender, "title", true, true, ess))
|
else if (split.length > 1 && split[0].equalsIgnoreCase("title") && stack.getType() == Material.WRITTEN_BOOK && hasMetaPermission(sender, "title", false, ess))
|
||||||
{
|
{
|
||||||
final String title = Util.replaceFormat(split[1].replace('_', ' '));
|
final String title = Util.replaceFormat(split[1].replace('_', ' '));
|
||||||
final BookMeta meta = (BookMeta)stack.getItemMeta();
|
final BookMeta meta = (BookMeta)stack.getItemMeta();
|
||||||
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 && hasMetaPermission(sender, "firework-power", true, true, ess))
|
else if (split.length > 1 && split[0].equalsIgnoreCase("power") && stack.getType() == Material.FIREWORK && hasMetaPermission(sender, "firework-power", false, ess))
|
||||||
{
|
{
|
||||||
final int power = Util.isInt(split[1]) ? Integer.parseInt(split[1]) : 0;
|
final int power = Util.isInt(split[1]) ? Integer.parseInt(split[1]) : 0;
|
||||||
final FireworkMeta meta = (FireworkMeta)stack.getItemMeta();
|
final FireworkMeta meta = (FireworkMeta)stack.getItemMeta();
|
||||||
@@ -225,7 +225,7 @@ public class MetaItemStack
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
parseEnchantmentStrings(sender, allowUnsafe, split);
|
parseEnchantmentStrings(sender, allowUnsafe, split, ess);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -244,14 +244,14 @@ public class MetaItemStack
|
|||||||
{
|
{
|
||||||
if (validFirework)
|
if (validFirework)
|
||||||
{
|
{
|
||||||
if (!hasMetaPermission(sender, "firework", true, false, ess))
|
if (!hasMetaPermission(sender, "firework", true, ess))
|
||||||
{
|
{
|
||||||
throw new Exception(_("noMetaFirework"));
|
throw new Exception(_("noMetaFirework"));
|
||||||
}
|
}
|
||||||
FireworkEffect effect = builder.build();
|
FireworkEffect effect = builder.build();
|
||||||
FireworkMeta fmeta = (FireworkMeta)stack.getItemMeta();
|
FireworkMeta fmeta = (FireworkMeta)stack.getItemMeta();
|
||||||
fmeta.addEffect(effect);
|
fmeta.addEffect(effect);
|
||||||
if (fmeta.getEffects().size() > 1 && !hasMetaPermission(sender, "firework-multiple", false, false, ess))
|
if (fmeta.getEffects().size() > 1 && !hasMetaPermission(sender, "firework-multiple", false, ess))
|
||||||
{
|
{
|
||||||
throw new Exception(_("multipleCharges"));
|
throw new Exception(_("multipleCharges"));
|
||||||
}
|
}
|
||||||
@@ -389,7 +389,7 @@ public class MetaItemStack
|
|||||||
{
|
{
|
||||||
PotionMeta pmeta = (PotionMeta)stack.getItemMeta();
|
PotionMeta pmeta = (PotionMeta)stack.getItemMeta();
|
||||||
pEffect = pEffectType.createEffect(duration, power);
|
pEffect = pEffectType.createEffect(duration, power);
|
||||||
if (pmeta.getCustomEffects().size() > 1 && !hasMetaPermission(sender, "potion-multiple", true, false, ess))
|
if (pmeta.getCustomEffects().size() > 1 && !hasMetaPermission(sender, "potion-multiple", true, ess))
|
||||||
{
|
{
|
||||||
throw new Exception(_("multiplePotionEffects"));
|
throw new Exception(_("multiplePotionEffects"));
|
||||||
}
|
}
|
||||||
@@ -402,11 +402,10 @@ public class MetaItemStack
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void parseEnchantmentStrings(final CommandSender sender, final boolean allowUnsafe, final String[] split) throws Exception
|
private void parseEnchantmentStrings(final CommandSender sender, final boolean allowUnsafe, final String[] split, final IEssentials ess) throws Exception
|
||||||
{
|
{
|
||||||
Enchantment enchantment = getEnchantment(null, split[0]);
|
final Enchantment enchantment = Enchantments.getByName(split[0]);
|
||||||
|
if (enchantment == null || !hasMetaPermission(sender, "enchant-" + enchantment.getName().toLowerCase(Locale.ENGLISH), false, ess))
|
||||||
if (enchantment == null)
|
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -488,7 +487,7 @@ public class MetaItemStack
|
|||||||
return enchantment;
|
return enchantment;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean hasMetaPermission(final CommandSender sender, final String metaPerm, final boolean graceful, final boolean message, final IEssentials ess) throws Exception
|
private boolean hasMetaPermission(final CommandSender sender, final String metaPerm, final boolean graceful, final IEssentials ess) throws Exception
|
||||||
{
|
{
|
||||||
final User user = ess.getUser(sender);
|
final User user = ess.getUser(sender);
|
||||||
if (user == null)
|
if (user == null)
|
||||||
@@ -503,10 +502,6 @@ public class MetaItemStack
|
|||||||
|
|
||||||
if (graceful)
|
if (graceful)
|
||||||
{
|
{
|
||||||
if (message)
|
|
||||||
{
|
|
||||||
user.sendMessage(_("noMetaPerm", metaPerm));
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Reference in New Issue
Block a user