-
-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reimplement item key parsing for loot
- Loading branch information
Showing
3 changed files
with
35 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/main/java/com/archyx/aureliumskills/loot/ItemKeyParser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.archyx.aureliumskills.loot; | ||
|
||
import com.archyx.aureliumskills.AureliumSkills; | ||
import com.archyx.aureliumskills.util.misc.Parser; | ||
import com.archyx.lootmanager.loot.parser.CustomItemParser; | ||
import org.bukkit.inventory.ItemStack; | ||
|
||
import java.util.Map; | ||
|
||
public class ItemKeyParser extends Parser implements CustomItemParser { | ||
|
||
private final AureliumSkills plugin; | ||
|
||
public ItemKeyParser(AureliumSkills plugin) { | ||
this.plugin = plugin; | ||
} | ||
|
||
@Override | ||
public boolean shouldUseParser(Map<?, ?> map) { | ||
return map.containsKey("key"); | ||
} | ||
|
||
@Override | ||
public ItemStack parseCustomItem(Map<?, ?> map) { | ||
String itemKey = getString(map, "key"); | ||
ItemStack item = plugin.getItemRegistry().getItem(itemKey); | ||
if (item != null) { | ||
return item; | ||
} else { | ||
throw new IllegalArgumentException("Item with key " + itemKey + " not found in item registry"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters