Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Item resolvers #335

Merged
merged 2 commits into from
Nov 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -7,10 +7,12 @@ public class NamespacedId {

public static final String AURASKILLS = "auraskills";
private final String namespace;
private final String originalKey;
private final String key;

private NamespacedId(String namespace, String key) {
this.namespace = namespace.toLowerCase(Locale.ROOT);
this.originalKey = key;
this.key = key.toLowerCase(Locale.ROOT);
}

@@ -33,6 +35,15 @@ public String getKey() {
return key;
}

/**
* Gets the original key portion of the NamespacedId, which is the key in the case it was created with.
*
* @return the original key
*/
public String getOriginalKey() {
return originalKey;
}

/**
* Returns the full String representation of the NamespacedId, with a / separating the
* namespace and the key.
Original file line number Diff line number Diff line change
@@ -32,11 +32,18 @@ public MythicMobsHook(AuraSkills plugin, ConfigurationNode config) {
this.plugin = plugin;
this.damageHandler = new DamageHandler();

registerItemProvider();

// Wait for loot manager to be created, but add parser before it is loaded
plugin.getScheduler().executeSync(() ->
plugin.getLootTableManager().getLootManager().registerCustomEntityParser(new MythicEntityLootParser(plugin)));
}

private void registerItemProvider() {
plugin.getItemRegistry().registerExternalItemProvider("mythicmobs",
(id) -> MythicBukkit.inst().getItemManager().getItemStack(id));
}

@EventHandler
public void onMythicSkillDamage(MythicDamageEvent event) {
// This is always some sort of skill/mechanic damage.
Original file line number Diff line number Diff line change
@@ -58,9 +58,14 @@ public ItemStack getItem(NamespacedId key) {
ItemStack item = items.get(key);
if (item != null) {
return item.clone();
} else {
return null;
}

ExternalItemProvider provider = externalItemProviders.get(key.getNamespace());
if (provider != null) {
return provider.getItem(key.getOriginalKey());
}

return null;
}

public Map<NamespacedId, ItemStack> getItems() {