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

View File

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