Ignore specified enchantment cannot be applied to itemstack, fixes #1483

This commit is contained in:
PikaMug 2020-12-05 03:00:12 -05:00
parent 58f6fb0da0
commit f06a15a3ec
3 changed files with 14 additions and 5 deletions

View File

@ -160,7 +160,7 @@ public class ItemStackPrompt extends QuestsEditorNumericPrompt {
if (context.getSessionData("tempName") != null) {
final String stackData = getItemData(context);
if (stackData != null) {
text += stackData;
text += "\n" + stackData;
if (context.getSessionData("tempMeta") != null) {
final LinkedHashMap<String, Object> map
= (LinkedHashMap<String, Object>) context.getSessionData("tempMeta");

View File

@ -83,8 +83,13 @@ public class QuestMainPrompt extends QuestsEditorNumericPrompt {
case 2:
case 3:
case 4:
case 5:
return ChatColor.BLUE;
case 5:
if (context.getForWhom() instanceof Player) {
return ChatColor.BLUE;
} else {
return ChatColor.GRAY;
}
case 6:
if (plugin.getDependencies().getWorldGuardApi() != null) {
return ChatColor.BLUE;
@ -131,9 +136,9 @@ public class QuestMainPrompt extends QuestsEditorNumericPrompt {
}
case 5:
if (context.getForWhom() instanceof Player) {
return ChatColor.GRAY + Lang.get("questEditorBlockStart");
} else {
return ChatColor.YELLOW + Lang.get("questEditorBlockStart");
} else {
return ChatColor.GRAY + Lang.get("questEditorBlockStart");
}
case 6:
if (plugin.getDependencies().getWorldGuardApi() != null) {

View File

@ -132,7 +132,11 @@ public class ItemListener implements Listener {
if (plugin.canUseQuests(evt.getEnchanter().getUniqueId())) {
final ItemStack enchantedItem = evt.getItem().clone();
enchantedItem.setAmount(1);
enchantedItem.addEnchantments(evt.getEnchantsToAdd());
try {
enchantedItem.addEnchantments(evt.getEnchantsToAdd());
} catch (final IllegalArgumentException e) {
// Ignore
}
final Quester quester = plugin.getQuester(evt.getEnchanter().getUniqueId());
for (final Quest quest : plugin.getQuests()) {
if (!quester.meetsCondition(quest, true)) {