-
-
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.
Add item equipment support for entity loot
- The keys hand, off_hand, feet, legs, chest, and head are used to define equipment on the spawned entity - The item format is the same as regular item loot
- Loading branch information
Showing
7 changed files
with
72 additions
and
17 deletions.
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
9 changes: 8 additions & 1 deletion
9
...ain/java/dev/aurelium/auraskills/bukkit/hooks/mythicmobs/loot/MythicEntityLootParser.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
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
28 changes: 25 additions & 3 deletions
28
bukkit/src/main/java/dev/aurelium/auraskills/bukkit/loot/entity/EntityProperties.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 |
---|---|---|
@@ -1,26 +1,48 @@ | ||
package dev.aurelium.auraskills.bukkit.loot.entity; | ||
|
||
import dev.aurelium.auraskills.bukkit.AuraSkills; | ||
import dev.aurelium.auraskills.bukkit.util.ConfigurateItemParser; | ||
import org.bukkit.inventory.EquipmentSlot; | ||
import org.bukkit.inventory.ItemStack; | ||
import org.spongepowered.configurate.ConfigurationNode; | ||
|
||
import java.util.HashMap; | ||
import java.util.Locale; | ||
import java.util.Map; | ||
|
||
public record EntityProperties(String entityId, | ||
String name, | ||
Integer level, | ||
Double health, | ||
Double damage, | ||
Float horizontalVelocity, | ||
Float verticalVelocity) { | ||
Float verticalVelocity, | ||
Map<EquipmentSlot, ItemStack> equipment) { | ||
|
||
public static EntityProperties fromConfig(ConfigurationNode config) { | ||
public static EntityProperties fromConfig(ConfigurationNode config, AuraSkills plugin) { | ||
String[] id = config.node("entity").getString("").split(":"); | ||
|
||
// Parse equipment items for each slot | ||
var itemParser = new ConfigurateItemParser(plugin); | ||
|
||
Map<EquipmentSlot, ItemStack> equipment = new HashMap<>(); | ||
for (EquipmentSlot slot : EquipmentSlot.values()) { | ||
ConfigurationNode itemNode = config.node(slot.toString().toLowerCase(Locale.ROOT)); | ||
if (itemNode.empty()) continue; | ||
|
||
ItemStack item = itemParser.parseItem(itemNode); | ||
equipment.put(slot, item); | ||
} | ||
|
||
return new EntityProperties( | ||
id.length > 1 ? id[1] : id[0], | ||
config.node("name").getString(), | ||
config.node("level").empty() ? null : config.node("level").getInt(), | ||
config.node("health").empty() ? null : config.node("health").getDouble(), | ||
config.node("damage").empty() ? null : config.node("damage").getDouble(), | ||
config.node("velocity", "horizontal").empty() ? null : config.node("velocity", "horizontal").getFloat(), | ||
config.node("velocity", "vertical").empty() ? null : config.node("velocity", "vertical").getFloat() | ||
config.node("velocity", "vertical").empty() ? null : config.node("velocity", "vertical").getFloat(), | ||
equipment | ||
); | ||
} | ||
} |
9 changes: 8 additions & 1 deletion
9
bukkit/src/main/java/dev/aurelium/auraskills/bukkit/loot/entity/VanillaEntityParser.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
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
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