Skip to content

Commit

Permalink
minor mm support cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed May 14, 2019
1 parent e4721cc commit 5db4ac4
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 21 deletions.
Expand Up @@ -23,17 +23,17 @@ public class MythicSpawnCommand extends AbstractCommand {
// @Stable untested
// @Short Spawns a MythicMob at a location.
// @Author Morphan1

//
// @Description
// This allows you to spawn a MythicMob at a location using the mob's internal name.

//
// @Tags
// <entry[saveName].spawned_mythicmob> returns the spawned MythicMobsMob.

//
// @Usage
// Use to spawn a BarbarianMinion at a player's location.
// - mythicspawn BarbarianMinion <player.location>

//
// -->

@Override
Expand Down
Expand Up @@ -66,7 +66,6 @@ public MythicMobsDeathEvent() {
public dEntity entity;
public dEntity killer;
public Element level;
public dList oldDrops;
public Element experience;
public Element currency;
public List<ItemStack> newDrops;
Expand Down Expand Up @@ -121,6 +120,9 @@ else if (aH.matchesInteger(determination)) { // "xp" prefix, but not required fo
return true;
}
else if (aH.Argument.valueOf(determination).matchesArgumentList(dItem.class)) {
if (newDrops == null) {
newDrops = new ArrayList<>();
}
List<dItem> items = dList.valueOf(determination).filter(dItem.class, container);
for (dItem i : items) {
newDrops.add(i.getItemStack());
Expand Down Expand Up @@ -154,6 +156,10 @@ else if (name.equals("currency")) {
return currency;
}
else if (name.equals("drops")) {
dList oldDrops = new dList();
for (ItemStack i : event.getDrops()) {
oldDrops.add(new dItem(i).identify());
}
return oldDrops;
}
else if (name.equals("level")) {
Expand All @@ -170,14 +176,10 @@ public void onMythicMobDeath(MythicMobDeathEvent event) {
level = new Element(event.getMobLevel());
experience = new Element(event.getExp());
currency = new Element(event.getCurrency());
oldDrops = new dList();
newDrops = new ArrayList<ItemStack>();
for (ItemStack i : event.getDrops()) {
oldDrops.add(new dItem(i).identify());
}
newDrops = null;
this.event = event;
fire(event);
if (!newDrops.isEmpty()) {
if (newDrops != null && !newDrops.isEmpty()) {
event.setDrops(newDrops);
}
event.setExp(experience.asInt());
Expand Down
Expand Up @@ -3,10 +3,9 @@
import com.denizenscript.depenizen.bukkit.support.plugins.MythicMobsSupport;
import net.aufdemrand.denizen.objects.dEntity;
import net.aufdemrand.denizencore.objects.*;
import net.aufdemrand.denizencore.objects.properties.Property;
import net.aufdemrand.denizencore.objects.properties.PropertyParser;
import net.aufdemrand.denizencore.tags.Attribute;
import net.aufdemrand.denizencore.tags.TagContext;
import net.aufdemrand.denizencore.utilities.CoreUtilities;
import net.aufdemrand.denizencore.utilities.debugging.dB;
import io.lumine.xikage.mythicmobs.adapters.AbstractEntity;
import io.lumine.xikage.mythicmobs.adapters.bukkit.BukkitEntity;
Expand Down Expand Up @@ -118,6 +117,7 @@ public String toString() {

@Override
public String getAttribute(Attribute attribute) {

if (attribute == null) {
return null;
}
Expand Down Expand Up @@ -274,11 +274,17 @@ else if (attribute.startsWith("type")) {
return new Element("Mythic Mob").getAttribute(attribute.fulfill(1));
}

String returned = CoreUtilities.autoPropertyTag(this, attribute);
if (returned != null) {
return returned;
}

return new Element(identify()).getAttribute(attribute);
}

@Override
public void adjust(Mechanism mechanism) {

// <--[mechanism]
// @object MythicMob
// @name global_cooldown
Expand Down Expand Up @@ -323,13 +329,7 @@ else if (mechanism.matches("target") && mechanism.requireObject(dEntity.class))
mob.setTarget(target);
}

// Iterate through this object's properties' mechanisms
for (Property property : PropertyParser.getProperties(this)) {
property.adjust(mechanism);
if (mechanism.fulfilled()) {
break;
}
}
CoreUtilities.autoPropertyMechanism(this, mechanism);

if (!mechanism.fulfilled()) {
mechanism.reportInvalid();
Expand All @@ -341,5 +341,4 @@ else if (mechanism.matches("target") && mechanism.requireObject(dEntity.class))
public void applyProperty(Mechanism mechanism) {
dB.echoError("Cannot apply properties to a MythicMob!");
}

}

0 comments on commit 5db4ac4

Please sign in to comment.