Skip to content

Commit

Permalink
Nexo挂钩基本完成,等待测试
Browse files Browse the repository at this point in the history
  • Loading branch information
YufiriaMazenta committed Jan 7, 2025
1 parent 9578614 commit a0c20fe
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package com.github.yufiriamazenta.craftorithm.item.impl;

import com.github.yufiriamazenta.craftorithm.item.ItemProvider;
import com.nexomc.nexo.api.NexoItems;
import com.nexomc.nexo.items.ItemBuilder;
import org.bukkit.OfflinePlayer;
import org.bukkit.inventory.ItemStack;

import java.util.Objects;

public enum NexoItemProvider implements ItemProvider {

INSTANCE;
Expand All @@ -15,17 +19,31 @@ public String namespace() {

@Override
public String getItemName(ItemStack itemStack, boolean ignoreAmount) {
return "";
if (!NexoItems.exists(itemStack))
return null;
String itemId = NexoItems.idFromItem(itemStack);
if (itemId == null) {
return null;
}
if (ignoreAmount) {
return itemId;
} else {
return itemId + " " + itemStack.getAmount() / Objects.requireNonNull(getItem(itemId)).getAmount();
}
}

@Override
public ItemStack getItem(String itemName) {
return null;
ItemBuilder itemBuilder = NexoItems.itemFromId(itemName);
if (itemBuilder == null) {
return null;
}
return itemBuilder.build();
}

@Override
public ItemStack getItem(String itemName, OfflinePlayer player) {
return null;
return getItem(itemName);
}

}
1 change: 1 addition & 0 deletions src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ softdepend:
- EcoItems
- ExecutableItems
- SCore
- Nexo
authors: [ YufiriaMazenta ]
folia-supported: true
website: https://github.com/YufiriaMazenta/Craftorithm
Expand Down

0 comments on commit a0c20fe

Please sign in to comment.