mirror of
https://github.com/PikaMug/Quests.git
synced 2024-12-19 15:48:10 +01:00
Attempt to handle legacy item names, fixes #539
This commit is contained in:
parent
ec5143c176
commit
9d7bfb22bf
@ -96,7 +96,6 @@ import me.blackvein.quests.util.ItemUtil;
|
|||||||
import me.blackvein.quests.util.Lang;
|
import me.blackvein.quests.util.Lang;
|
||||||
import me.blackvein.quests.util.LocaleQuery;
|
import me.blackvein.quests.util.LocaleQuery;
|
||||||
import me.blackvein.quests.util.MiscUtil;
|
import me.blackvein.quests.util.MiscUtil;
|
||||||
|
|
||||||
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
import me.clip.placeholderapi.PlaceholderAPIPlugin;
|
||||||
import net.aufdemrand.denizen.Denizen;
|
import net.aufdemrand.denizen.Denizen;
|
||||||
import net.aufdemrand.denizencore.scripts.ScriptRegistry;
|
import net.aufdemrand.denizencore.scripts.ScriptRegistry;
|
||||||
@ -2602,6 +2601,23 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
return exists;
|
return exists;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
private ItemStack processItemStack(String questName, String material, int amount, short durability) {
|
||||||
|
try {
|
||||||
|
return new ItemStack(Material.matchMaterial(material), amount, durability);
|
||||||
|
} catch (Exception e) {
|
||||||
|
try {
|
||||||
|
getLogger().warning(material + " is invalid for quest " + questName + "! You may need to update your quests.yml "
|
||||||
|
+ "in accordance with https://github.com/FlyingPikachu/Quests/wiki/Item-Formatting#list");
|
||||||
|
return new ItemStack(Material.matchMaterial(material, true), amount, durability);
|
||||||
|
} catch (Exception e2) {
|
||||||
|
getLogger().severe("Unable to use LEGACY_" + material + " for quest " + questName);
|
||||||
|
e2.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void processStages(Quest quest, FileConfiguration config, String questName) throws StageFailedException {
|
private void processStages(Quest quest, FileConfiguration config, String questName) throws StageFailedException {
|
||||||
ConfigurationSection questStages = config.getConfigurationSection("quests." + questName + ".stages.ordered");
|
ConfigurationSection questStages = config.getConfigurationSection("quests." + questName + ".stages.ordered");
|
||||||
for (String s2 : questStages.getKeys(false)) {
|
for (String s2 : questStages.getKeys(false)) {
|
||||||
@ -2666,10 +2682,10 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
for (String s : breaknames) {
|
for (String s : breaknames) {
|
||||||
ItemStack is;
|
ItemStack is;
|
||||||
if (breakdurability.get(breaknames.indexOf(s)) != -1) {
|
if (breakdurability.get(breaknames.indexOf(s)) != -1) {
|
||||||
is = new ItemStack(Material.matchMaterial(s), breakamounts.get(breaknames.indexOf(s)), breakdurability.get(breaknames.indexOf(s)));
|
is = processItemStack(questName, s, breakamounts.get(breaknames.indexOf(s)), breakdurability.get(breaknames.indexOf(s)));
|
||||||
} else {
|
} else {
|
||||||
// Legacy
|
// Legacy
|
||||||
is = new ItemStack(Material.matchMaterial(s), breakamounts.get(breaknames.indexOf(s)), (short) 0);
|
is = processItemStack(questName, s, breakamounts.get(breaknames.indexOf(s)), (short) 0);
|
||||||
}
|
}
|
||||||
if (Material.matchMaterial(s) != null) {
|
if (Material.matchMaterial(s) != null) {
|
||||||
oStage.blocksToBreak.add(is);
|
oStage.blocksToBreak.add(is);
|
||||||
@ -2705,10 +2721,10 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
for (String s : damagenames) {
|
for (String s : damagenames) {
|
||||||
ItemStack is;
|
ItemStack is;
|
||||||
if (damagedurability.get(damagenames.indexOf(s)) != -1) {
|
if (damagedurability.get(damagenames.indexOf(s)) != -1) {
|
||||||
is = new ItemStack(Material.matchMaterial(s), damageamounts.get(damagenames.indexOf(s)), damagedurability.get(damagenames.indexOf(s)));
|
is = processItemStack(questName, s, damageamounts.get(damagenames.indexOf(s)), damagedurability.get(damagenames.indexOf(s)));
|
||||||
} else {
|
} else {
|
||||||
// Legacy
|
// Legacy
|
||||||
is = new ItemStack(Material.matchMaterial(s), damageamounts.get(damagenames.indexOf(s)), (short) 0);
|
is = processItemStack(questName, s, damageamounts.get(damagenames.indexOf(s)), (short) 0);
|
||||||
}
|
}
|
||||||
if (Material.matchMaterial(s) != null) {
|
if (Material.matchMaterial(s) != null) {
|
||||||
oStage.blocksToDamage.add(is);
|
oStage.blocksToDamage.add(is);
|
||||||
@ -2744,10 +2760,10 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
for (String s : placenames) {
|
for (String s : placenames) {
|
||||||
ItemStack is;
|
ItemStack is;
|
||||||
if (placedurability.get(placenames.indexOf(s)) != -1) {
|
if (placedurability.get(placenames.indexOf(s)) != -1) {
|
||||||
is = new ItemStack(Material.matchMaterial(s), placeamounts.get(placenames.indexOf(s)), placedurability.get(placenames.indexOf(s)));
|
is = processItemStack(questName, s, placeamounts.get(placenames.indexOf(s)), placedurability.get(placenames.indexOf(s)));
|
||||||
} else {
|
} else {
|
||||||
// Legacy
|
// Legacy
|
||||||
is = new ItemStack(Material.matchMaterial(s), placeamounts.get(placenames.indexOf(s)), (short) 0);
|
is = processItemStack(questName, s, placeamounts.get(placenames.indexOf(s)), (short) 0);
|
||||||
}
|
}
|
||||||
if (Material.matchMaterial(s) != null) {
|
if (Material.matchMaterial(s) != null) {
|
||||||
oStage.blocksToPlace.add(is);
|
oStage.blocksToPlace.add(is);
|
||||||
@ -2783,10 +2799,10 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
for (String s : usenames) {
|
for (String s : usenames) {
|
||||||
ItemStack is;
|
ItemStack is;
|
||||||
if (usedurability.get(usenames.indexOf(s)) != -1) {
|
if (usedurability.get(usenames.indexOf(s)) != -1) {
|
||||||
is = new ItemStack(Material.matchMaterial(s), useamounts.get(usenames.indexOf(s)), usedurability.get(usenames.indexOf(s)));
|
is = processItemStack(questName, s, useamounts.get(usenames.indexOf(s)), usedurability.get(usenames.indexOf(s)));
|
||||||
} else {
|
} else {
|
||||||
// Legacy
|
// Legacy
|
||||||
is = new ItemStack(Material.matchMaterial(s), useamounts.get(usenames.indexOf(s)), (short) 0);
|
is = processItemStack(questName, s, useamounts.get(usenames.indexOf(s)), (short) 0);
|
||||||
}
|
}
|
||||||
if (Material.matchMaterial(s) != null) {
|
if (Material.matchMaterial(s) != null) {
|
||||||
oStage.blocksToUse.add(is);
|
oStage.blocksToUse.add(is);
|
||||||
@ -2822,10 +2838,10 @@ public class Quests extends JavaPlugin implements ConversationAbandonedListener
|
|||||||
for (String s : cutnames) {
|
for (String s : cutnames) {
|
||||||
ItemStack is;
|
ItemStack is;
|
||||||
if (cutdurability.get(cutnames.indexOf(s)) != -1) {
|
if (cutdurability.get(cutnames.indexOf(s)) != -1) {
|
||||||
is = new ItemStack(Material.matchMaterial(s), cutamounts.get(cutnames.indexOf(s)), cutdurability.get(cutnames.indexOf(s)));
|
is = processItemStack(questName, s, cutamounts.get(cutnames.indexOf(s)), cutdurability.get(cutnames.indexOf(s)));
|
||||||
} else {
|
} else {
|
||||||
// Legacy
|
// Legacy
|
||||||
is = new ItemStack(Material.matchMaterial(s), cutamounts.get(cutnames.indexOf(s)), (short) 0);
|
is = processItemStack(questName, s, cutamounts.get(cutnames.indexOf(s)), (short) 0);
|
||||||
}
|
}
|
||||||
if (Material.matchMaterial(s) != null) {
|
if (Material.matchMaterial(s) != null) {
|
||||||
oStage.blocksToCut.add(is);
|
oStage.blocksToCut.add(is);
|
||||||
|
Loading…
Reference in New Issue
Block a user