mirror of
https://gitlab.com/phoenix-dvpmt/mmoitems.git
synced 2025-01-03 06:37:47 +01:00
denizen basic support
This commit is contained in:
parent
295368ad06
commit
f5474ef520
BIN
lib/Denizen-1.2.1-b1744-REL.jar
Normal file
BIN
lib/Denizen-1.2.1-b1744-REL.jar
Normal file
Binary file not shown.
BIN
lib/Depenizen-2.0.0-b709.jar
Normal file
BIN
lib/Depenizen-2.0.0-b709.jar
Normal file
Binary file not shown.
26
pom.xml
26
pom.xml
@ -53,6 +53,11 @@
|
||||
|
||||
<repositories>
|
||||
|
||||
<repository>
|
||||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io</url>
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
<id>lumine</id>
|
||||
<url>https://mvn.lumine.io/repository/maven/</url>
|
||||
@ -73,11 +78,6 @@
|
||||
<url>https://repo.inventivetalent.org/content/groups/public/</url>
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io</url>
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
<id>placeholderapi</id>
|
||||
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
|
||||
@ -373,5 +373,21 @@
|
||||
<systemPath>${basedir}/lib/GlowAPI.jar</systemPath>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.denizenscript</groupId>
|
||||
<artifactId>denizen</artifactId>
|
||||
<version>1.2.1-b1744-REL</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/lib/Denizen-1.2.1-b1744-REL.jar</systemPath>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.denizenscript</groupId>
|
||||
<artifactId>depenizen</artifactId>
|
||||
<version>2.0.0-b709</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/lib/Depenizen-2.0.0-b709.jar</systemPath>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.Indyuce.mmoitems;
|
||||
|
||||
import com.denizenscript.depenizen.bukkit.Depenizen;
|
||||
import io.lumine.mythic.lib.api.item.NBTItem;
|
||||
import io.lumine.mythic.lib.api.util.ui.FriendlyFeedbackCategory;
|
||||
import io.lumine.mythic.lib.api.util.ui.FriendlyFeedbackMessage;
|
||||
@ -16,6 +17,7 @@ import net.Indyuce.mmoitems.api.util.NumericStatFormula;
|
||||
import net.Indyuce.mmoitems.api.util.message.FFPMMOItems;
|
||||
import net.Indyuce.mmoitems.command.MMOItemsCommandTreeRoot;
|
||||
import net.Indyuce.mmoitems.comp.*;
|
||||
import net.Indyuce.mmoitems.comp.denizen.DenizenBridge;
|
||||
import net.Indyuce.mmoitems.comp.eco.VaultSupport;
|
||||
import net.Indyuce.mmoitems.comp.enchants.AdvancedEnchantmentsHook;
|
||||
import net.Indyuce.mmoitems.comp.enchants.CrazyEnchantsStat;
|
||||
@ -139,6 +141,12 @@ public class MMOItems extends LuminePlugin {
|
||||
|
||||
if (Bukkit.getPluginManager().getPlugin("MythicEnchants") != null)
|
||||
enchantPlugins.add(new MythicEnchantsSupport());
|
||||
|
||||
if (Bukkit.getPluginManager().getPlugin("Depenizen") != null) {
|
||||
Depenizen depenizen = (Depenizen) Bukkit.getPluginManager().getPlugin("Depenizen");
|
||||
depenizen.registerBridge(getName(), () -> new DenizenBridge());
|
||||
getLogger().log(Level.INFO, "Hooked onto Denizen");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -251,7 +259,6 @@ public class MMOItems extends LuminePlugin {
|
||||
if (MMOItems.plugin.getConfig().getBoolean("iterate-whole-inventory"))
|
||||
getInventory().register(new OrnamentPlayerInventory());
|
||||
|
||||
|
||||
if (Bukkit.getPluginManager().getPlugin("CrazyEnchantments") != null) {
|
||||
getStats().register(new CrazyEnchantsStat());
|
||||
getLogger().log(Level.INFO, "Hooked onto CrazyEnchantments");
|
||||
|
@ -0,0 +1,74 @@
|
||||
package net.Indyuce.mmoitems.comp.denizen;
|
||||
|
||||
import com.denizenscript.denizen.objects.ItemTag;
|
||||
import com.denizenscript.denizencore.objects.ObjectFetcher;
|
||||
import com.denizenscript.denizencore.objects.ObjectTag;
|
||||
import com.denizenscript.denizencore.objects.core.MapTag;
|
||||
import com.denizenscript.denizencore.objects.properties.PropertyParser;
|
||||
import com.denizenscript.denizencore.tags.TagManager;
|
||||
import com.denizenscript.depenizen.bukkit.Bridge;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.Type;
|
||||
|
||||
/**
|
||||
* Basic integration with Denizen
|
||||
*/
|
||||
public class DenizenBridge extends Bridge {
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
|
||||
/*
|
||||
* This registers sub tags in the custom coded denizen tags
|
||||
*/
|
||||
/* ObjectFetcher.registerWithObjectFetcher(MMOItemTag.class, MMOItemTag.tagProcessor);*/
|
||||
ObjectFetcher.registerWithObjectFetcher(MMOItemTemplateTag.class, MMOItemTemplateTag.tagProcessor);
|
||||
|
||||
/*
|
||||
* Implement some properties to the already existing ItemTag
|
||||
*/
|
||||
PropertyParser.registerProperty(MMOItemsItemProperty.class, ItemTag.class);
|
||||
|
||||
/*
|
||||
* This implements a way to retrieve an MMOItem as itemStack.
|
||||
*
|
||||
* Usage:
|
||||
* <mmoitem_template[type=TYPE;id=ID_HERE]>
|
||||
*/
|
||||
TagManager.registerTagHandler("mmoitem_template", attribute -> {
|
||||
if (!attribute.hasContext(1)) {
|
||||
attribute.echoError("Please provide an item type and ID.");
|
||||
return null;
|
||||
}
|
||||
|
||||
MapTag map = attribute.contextAsType(1, MapTag.class);
|
||||
if (map == null) {
|
||||
attribute.echoError("Invalid MapTag input");
|
||||
return null;
|
||||
}
|
||||
|
||||
ObjectTag type = map.getObject("type");
|
||||
ObjectTag id = map.getObject("id");
|
||||
if (type == null || id == null) {
|
||||
attribute.echoError("Invalid MapTag input - missing 'type' or 'id'");
|
||||
return null;
|
||||
}
|
||||
|
||||
String typeName = type.toString().replace("-", "_").toUpperCase();
|
||||
Type parsedType = MMOItems.plugin.getTypes().get(typeName);
|
||||
if (parsedType == null) {
|
||||
attribute.echoError("Invalid type - cannot find type with name '" + typeName + "'");
|
||||
return null;
|
||||
}
|
||||
|
||||
// Format ID and return item
|
||||
String formattedId = id.toString().replace("-", "_").toUpperCase();
|
||||
if (!MMOItems.plugin.getTemplates().hasTemplate(parsedType, formattedId)) {
|
||||
attribute.echoError("Invalid template ID - cannot find template with name '" + formattedId + "'");
|
||||
return null;
|
||||
}
|
||||
|
||||
return new MMOItemTemplateTag(parsedType, formattedId);
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
package net.Indyuce.mmoitems.comp.denizen;
|
||||
|
||||
import com.denizenscript.denizen.objects.ItemTag;
|
||||
import com.denizenscript.denizencore.objects.ObjectTag;
|
||||
import com.denizenscript.denizencore.tags.Attribute;
|
||||
import com.denizenscript.denizencore.tags.ObjectTagProcessor;
|
||||
|
||||
@Deprecated
|
||||
public class MMOItemTag extends SimpleTag {
|
||||
private final ItemTag item;
|
||||
|
||||
@Deprecated
|
||||
public MMOItemTag(ItemTag item) {
|
||||
this.item = item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUnique() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getObjectType() {
|
||||
return "MMOItem";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String identify() {
|
||||
return "mmoitem@" + item.identify();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String identifySimple() {
|
||||
return identify();
|
||||
}
|
||||
|
||||
public static ObjectTagProcessor<MMOItemTag> tagProcessor = new ObjectTagProcessor<>();
|
||||
|
||||
@Override
|
||||
public ObjectTag getObjectAttribute(Attribute attribute) {
|
||||
return tagProcessor.getObjectAttribute(this, attribute);
|
||||
}
|
||||
|
||||
public static void registerTags() {
|
||||
|
||||
/*
|
||||
* Used to get the corresponding itemStack
|
||||
*
|
||||
* Usage:
|
||||
* <mmoitemTag.item>
|
||||
*
|
||||
* Returns:
|
||||
* ItemTag
|
||||
*/
|
||||
tagProcessor.registerTag("item", (attribute, object) -> object.item);
|
||||
}
|
||||
}
|
@ -0,0 +1,150 @@
|
||||
package net.Indyuce.mmoitems.comp.denizen;
|
||||
|
||||
import com.denizenscript.denizen.objects.ItemTag;
|
||||
import com.denizenscript.denizen.objects.PlayerTag;
|
||||
import com.denizenscript.denizencore.objects.ObjectTag;
|
||||
import com.denizenscript.denizencore.objects.core.ElementTag;
|
||||
import com.denizenscript.denizencore.objects.core.MapTag;
|
||||
import com.denizenscript.denizencore.tags.Attribute;
|
||||
import com.denizenscript.denizencore.tags.ObjectTagProcessor;
|
||||
import com.denizenscript.denizencore.tags.TagContext;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.ItemTier;
|
||||
import net.Indyuce.mmoitems.api.Type;
|
||||
import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerData;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class MMOItemTemplateTag extends SimpleTag {
|
||||
private final Type type;
|
||||
private final String id;
|
||||
|
||||
private static final Random random = new Random();
|
||||
|
||||
public MMOItemTemplateTag(Type type, String id) {
|
||||
this.type = type;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public MMOItemTemplate getTemplate() {
|
||||
return MMOItems.plugin.getTemplates().getTemplate(type, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUnique() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getObjectType() {
|
||||
return "MMOItemTemplate";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String identify() {
|
||||
return "mmoitem_template@" + type.getId() + "." + id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String identifySimple() {
|
||||
return identify();
|
||||
}
|
||||
|
||||
public static ObjectTagProcessor<MMOItemTemplateTag> tagProcessor = new ObjectTagProcessor<>();
|
||||
|
||||
@Override
|
||||
public ObjectTag getObjectAttribute(Attribute attribute) {
|
||||
return tagProcessor.getObjectAttribute(this, attribute);
|
||||
}
|
||||
|
||||
public static void registerTags() {
|
||||
|
||||
// Display template type name
|
||||
tagProcessor.registerTag("item_type", ((attribute, object) -> new ElementTag(object.type.getName())));
|
||||
|
||||
// Display template id
|
||||
tagProcessor.registerTag("item_id", ((attribute, object) -> new ElementTag(object.id)));
|
||||
|
||||
/*
|
||||
* Used to generate an item with custom tier and level.
|
||||
*
|
||||
* Usage:
|
||||
* <mmoitemTemplateTag.generate[player=playerTagHere;level=10;matchlevel=true;tier=TIER_NAME]
|
||||
* All arguments are optional. Level overrides the match-level option.
|
||||
*
|
||||
* Return:
|
||||
* MMOItemTag of the generated item.
|
||||
*/
|
||||
tagProcessor.registerTag("generate", (attribute, object) -> {
|
||||
if (!attribute.hasContext(1))
|
||||
return new ItemTag(object.getTemplate().newBuilder().build().newBuilder().build());
|
||||
|
||||
MapTag map = attribute.contextAsType(1, MapTag.class);
|
||||
if (map == null) {
|
||||
attribute.echoError("Invalid MapTag input");
|
||||
return null;
|
||||
}
|
||||
|
||||
ObjectTag playerTag = map.getObject("player");
|
||||
if (playerTag != null && !(playerTag instanceof PlayerTag)) {
|
||||
attribute.echoError("Bad player input type");
|
||||
return null;
|
||||
}
|
||||
|
||||
// Specified level
|
||||
ObjectTag levelTag = map.getObject("level");
|
||||
int level = -1;
|
||||
if (levelTag != null)
|
||||
try {
|
||||
level = Integer.valueOf(levelTag.toString());
|
||||
} catch (IllegalArgumentException exception) {
|
||||
attribute.echoError("Bad level input: " + levelTag.toString() + " is not a valid integer");
|
||||
return null;
|
||||
}
|
||||
|
||||
// Match level
|
||||
ObjectTag matchLevelTag = map.getObject("match-level");
|
||||
boolean matchLevel = matchLevelTag != null && Boolean.valueOf(matchLevelTag.toString());
|
||||
|
||||
// Item tier param
|
||||
ObjectTag tierTag = map.getObject("tier");
|
||||
ItemTier tier = null;
|
||||
if (tierTag != null)
|
||||
try {
|
||||
tier = MMOItems.plugin.getTiers().getOrThrow(tierTag.toString().toUpperCase().replace("-", "_"));
|
||||
} catch (IllegalArgumentException exception) {
|
||||
attribute.echoError(exception.getMessage());
|
||||
}
|
||||
|
||||
// Find item level
|
||||
int itemLevel = level >= 0 ? level : (matchLevel && playerTag != null ?
|
||||
MMOItems.plugin.getTemplates().rollLevel(PlayerData.get(((PlayerTag) playerTag).getPlayerEntity()).getRPG().getLevel()) : 1 + random.nextInt(100));
|
||||
|
||||
// Find item tier
|
||||
ItemTier itemTier = tier != null ? tier : MMOItems.plugin.getTemplates().rollTier();
|
||||
|
||||
// Build item
|
||||
return new ItemTag(object.getTemplate().newBuilder(itemLevel, itemTier).build().newBuilder().build());
|
||||
});
|
||||
}
|
||||
|
||||
public static MMOItemTemplateTag valueOf(String string, TagContext context) {
|
||||
if (string == null)
|
||||
return null;
|
||||
|
||||
try {
|
||||
String[] split = string.substring("mmoitem_template@".length()).split("\\.");
|
||||
String typeId = split[0];
|
||||
String itemId = split[1];
|
||||
|
||||
Type type = MMOItems.plugin.getTypes().getOrThrow(typeId);
|
||||
MMOItems.plugin.getTemplates().getTemplateOrThrow(type, itemId);
|
||||
|
||||
return new MMOItemTemplateTag(type, itemId);
|
||||
} catch (Exception exception) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,100 @@
|
||||
package net.Indyuce.mmoitems.comp.denizen;
|
||||
|
||||
import com.denizenscript.denizen.objects.ItemTag;
|
||||
import com.denizenscript.denizencore.objects.Mechanism;
|
||||
import com.denizenscript.denizencore.objects.ObjectTag;
|
||||
import com.denizenscript.denizencore.objects.core.ElementTag;
|
||||
import com.denizenscript.denizencore.objects.properties.Property;
|
||||
import com.denizenscript.denizencore.objects.properties.PropertyParser;
|
||||
import io.lumine.mythic.lib.api.item.NBTItem;
|
||||
import net.Indyuce.mmoitems.api.item.util.identify.IdentifiedItem;
|
||||
|
||||
public class MMOItemsItemProperty implements Property {
|
||||
private final ItemTag item;
|
||||
|
||||
public MMOItemsItemProperty(ItemTag item) {
|
||||
this.item = item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPropertyString() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPropertyId() {
|
||||
return "MMOItemsItem";
|
||||
}
|
||||
|
||||
public boolean isMMOItem() {
|
||||
return NBTItem.get(item.getItemStack()).hasTag("MMOITEMS_TYPE");
|
||||
}
|
||||
|
||||
public MMOItemTag getMMOItem() {
|
||||
return new MMOItemTag(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void adjust(Mechanism mechanism) {
|
||||
// None
|
||||
}
|
||||
|
||||
public static boolean describes(ObjectTag object) {
|
||||
return object instanceof ItemTag;
|
||||
}
|
||||
|
||||
public static MMOItemsItemProperty getFrom(ObjectTag object) {
|
||||
return object instanceof ItemTag ? new MMOItemsItemProperty((ItemTag) object) : null;
|
||||
}
|
||||
|
||||
public static final String[] handledMechs = new String[]{}; // None
|
||||
|
||||
public static void registerTags() {
|
||||
|
||||
/*
|
||||
* Used to check if an ItemTag is an item generated
|
||||
* using MMOItems or not
|
||||
*
|
||||
* Usage:
|
||||
* <player.item_in_hand.is_mmoitem>
|
||||
*
|
||||
* Returns:
|
||||
* Element tag containing a boolean
|
||||
*/
|
||||
PropertyParser.<MMOItemsItemProperty>registerTag("is_mmoitem", (attribute, object) -> new ElementTag(object.isMMOItem()));
|
||||
|
||||
/*
|
||||
* Used to check if an item is an unidentified item from MMOItems
|
||||
*
|
||||
* Usage:
|
||||
* <player.item_in_hand.is_unidentified_item>
|
||||
*
|
||||
* Returns:
|
||||
* Element tag containing a boolean
|
||||
*/
|
||||
PropertyParser.<MMOItemsItemProperty>registerTag("is_unidentified_item", (attribute, object) -> new ElementTag(NBTItem.get(object.item.getItemStack()).hasTag("MMOITEMS_UNIDENTIFIED_ITEM")));
|
||||
|
||||
/*
|
||||
* Used to identify an item
|
||||
*
|
||||
* Usage:
|
||||
* <player.item_in_hand.identify>
|
||||
*
|
||||
* Returns:
|
||||
* MMOItemTag corresponding to the identified item
|
||||
*/
|
||||
PropertyParser.<MMOItemsItemProperty>registerTag("identify", (attribute, object) -> new MMOItemTag(new ItemTag(new IdentifiedItem(NBTItem.get(object.item.getItemStack())).identify())));
|
||||
|
||||
/*
|
||||
* Used to access utility methods for manipulating
|
||||
* mmoitems
|
||||
*
|
||||
* Usage:
|
||||
* <player.item_in_hand.mmoitem>
|
||||
*
|
||||
* Returns:
|
||||
* MMOItemTag used to manipulate the item
|
||||
*/
|
||||
/* PropertyParser.<MMOItemsItemProperty>registerTag("mmoitem", (attribute, object) -> object.isMMOItem() ? object.getMMOItem() : null);*/
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package net.Indyuce.mmoitems.comp.denizen;
|
||||
|
||||
import com.denizenscript.denizencore.objects.ObjectTag;
|
||||
|
||||
public abstract class SimpleTag implements ObjectTag {
|
||||
|
||||
// No idea what this is
|
||||
private String prefix;
|
||||
|
||||
@Override
|
||||
public String getPrefix() {
|
||||
return prefix;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectTag setPrefix(String prefix) {
|
||||
this.prefix = prefix;
|
||||
return this;
|
||||
}
|
||||
}
|
@ -4,7 +4,7 @@ main: net.Indyuce.mmoitems.MMOItems
|
||||
author: Indyuce
|
||||
description: ${project.description}
|
||||
depend: [MythicLib]
|
||||
softdepend: [WorldGuard,Holograms,Residence,BossShopPro,SkillAPI,SkillsPro,MMOCore,MythicMobs,MMOInventory,PlaceholderAPI,TrHologram,Vault]
|
||||
softdepend: [WorldGuard,Residence,BossShopPro,SkillAPI,SkillsPro,MMOCore,MythicMobs,MMOInventory,PlaceholderAPI,Vault,Denizen]
|
||||
api-version: 1.13
|
||||
commands:
|
||||
mmoitems:
|
||||
|
Loading…
Reference in New Issue
Block a user