Try to fix NullPointerException for challenges

This commit is contained in:
0ddlyoko 2020-03-31 15:46:40 +02:00 committed by Brianna
parent 308d3a9661
commit 32f5383f3e
2 changed files with 9 additions and 7 deletions

View File

@ -54,8 +54,10 @@ public class ChallengeCategory {
lore = new ArrayList<>(); lore = new ArrayList<>();
try { try {
// If an Exception occurs, we don't handle it here but in parent class // If an Exception occurs, we don't handle it here but in parent class
System.out.println(strItem); CompatibleMaterial compatibleMaterial = CompatibleMaterial.getMaterial(strItem);
Material item = CompatibleMaterial.getMaterial(strItem).getMaterial(); if (compatibleMaterial == null)
throw new IllegalArgumentException("Item " + strItem + " isn't a correct material");
Material item = compatibleMaterial.getMaterial();
if (item == null) if (item == null)
throw new IllegalArgumentException("Item " + strItem + " isn't a correct material"); throw new IllegalArgumentException("Item " + strItem + " isn't a correct material");
ItemChallenge ic = new ItemChallenge(show, row, col, item, amount, lore); ItemChallenge ic = new ItemChallenge(show, row, col, item, amount, lore);

View File

@ -388,7 +388,7 @@ challenges:
id: 3 id: 3
name: '&2A Prickly Affair' name: '&2A Prickly Affair'
require: require:
- 'ITEM:cactus_green 48' - 'ITEM:green_dye 48'
reward: reward:
- 'CMD:eco give {player} 200' - 'CMD:eco give {player} 200'
- 'ITEM:sand 24' - 'ITEM:sand 24'
@ -398,7 +398,7 @@ challenges:
show: true show: true
row: 1 row: 1
col: 5 col: 5
item: cactus_green item: green_dye
amount: 1 amount: 1
lore: lore:
- '&c&lFor this challenge, you''ll need:' - '&c&lFor this challenge, you''ll need:'
@ -1368,8 +1368,8 @@ challenges:
id: 2 id: 2
name: '&2Artist' name: '&2Artist'
require: require:
- 'ITEM:rose_red 64' - 'ITEM:red_dye 64'
- 'ITEM:cactus_green 64' - 'ITEM:green_dye 64'
- 'ITEM:purple_dye 64' - 'ITEM:purple_dye 64'
- 'ITEM:cyan_dye 64' - 'ITEM:cyan_dye 64'
- 'ITEM:light_gray_dye 64' - 'ITEM:light_gray_dye 64'
@ -1393,7 +1393,7 @@ challenges:
show: true show: true
row: 1 row: 1
col: 4 col: 4
item: dandelion_yellow item: YELLOW_DYE
amount: 1 amount: 1
lore: lore:
- '&c&lFor this challenge, you''ll need:' - '&c&lFor this challenge, you''ll need:'