Skip to content

Commit

Permalink
target MythicMobs 4.5.9, add new event context and determine (currenc…
Browse files Browse the repository at this point in the history
…y), fixes #227
  • Loading branch information
mcmonkey4eva committed May 6, 2019
1 parent 5e6fd51 commit 28060bc
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 13 deletions.
2 changes: 1 addition & 1 deletion bukkit/pom.xml
Expand Up @@ -346,7 +346,7 @@
<dependency>
<groupId>io.lumine.xikage</groupId>
<artifactId>mythicmobs</artifactId>
<version>4.0.0</version>
<version>4.5.9</version>
<scope>system</scope>
<systemPath>${basedir}/src/main/resources/lib/MythicMobs.jar</systemPath>
</dependency>
Expand Down
Expand Up @@ -45,9 +45,11 @@ public class MythicMobsDeathEvent extends BukkitScriptEvent implements Listener
// <context.level> Returns the level of the MythicMob.
// <context.drops> Returns a list of items dropped.
// <context.xp> Returns the xp dropped.
// <context.currency> returns the currency dropped.
//
// @Determine
// Element(Number) to specify the new amount of XP to be dropped.
// "XP:" + Element(Number) to specify the new amount of XP to be dropped.
// "CURRENCY:" + Element(Decimal) to specify the new amount of currency to be dropped.
// dList(dItem) to specify new items to be dropped.
//
// @Plugin DepenizenBukkit, MythicMobs
Expand All @@ -66,6 +68,7 @@ public MythicMobsDeathEvent() {
public Element level;
public dList oldDrops;
public Element experience;
public Element currency;
public List<ItemStack> newDrops;

@Override
Expand Down Expand Up @@ -107,18 +110,23 @@ public String getName() {

@Override
public boolean applyDetermination(ScriptContainer container, String determination) {
String lower = CoreUtilities.toLowerCase(determination);

if (aH.matchesInteger(lower)) {
experience = new Element(lower);
return true;
}
else if (aH.Argument.valueOf(determination).matchesArgumentList(dItem.class)) {
List<dItem> items = dList.valueOf(determination).filter(dItem.class, container);
for (dItem i : items) {
newDrops.add(i.getItemStack());
if (isDefaultDetermination(determination)) {
aH.Argument arg = new aH.Argument(determination);
if (arg.matchesPrefix("currency") && arg.matchesPrimitive(aH.PrimitiveType.Double)) {
currency = new Element(determination);
return true;
}
else if (aH.matchesInteger(determination)) { // "xp" prefix, but not required for back support reasons.
experience = new Element(determination);
return true;
}
else if (aH.Argument.valueOf(determination).matchesArgumentList(dItem.class)) {
List<dItem> items = dList.valueOf(determination).filter(dItem.class, container);
for (dItem i : items) {
newDrops.add(i.getItemStack());
}
return true;
}
return true;
}
return super.applyDetermination(container, determination);
}
Expand All @@ -142,6 +150,9 @@ else if (name.equals("entity")) {
else if (name.equals("xp")) {
return experience;
}
else if (name.equals("currency")) {
return currency;
}
else if (name.equals("drops")) {
return oldDrops;
}
Expand All @@ -158,6 +169,7 @@ public void onMythicMobDeath(MythicMobDeathEvent event) {
killer = new dEntity(event.getKiller());
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()) {
Expand All @@ -169,5 +181,6 @@ public void onMythicMobDeath(MythicMobDeathEvent event) {
event.setDrops(newDrops);
}
event.setExp(experience.asInt());
event.setCurrency(currency.asDouble());
}
}
Binary file modified bukkit/src/main/resources/lib/MythicMobs.jar
Binary file not shown.

0 comments on commit 28060bc

Please sign in to comment.