Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ee9e465
commit 76d6e85
Showing
7 changed files
with
410 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
113 changes: 113 additions & 0 deletions
113
src/main/java/net/gnomeffinway/depenizen/events/MythicMobs/MythicMobsDeathEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
package net.gnomeffinway.depenizen.events.MythicMobs; | ||
|
||
import net.aufdemrand.denizen.BukkitScriptEntryData; | ||
import net.aufdemrand.denizen.events.BukkitScriptEvent; | ||
import net.aufdemrand.denizen.objects.dEntity; | ||
import net.aufdemrand.denizen.utilities.DenizenAPI; | ||
import net.aufdemrand.denizencore.objects.Element; | ||
import net.aufdemrand.denizencore.objects.dObject; | ||
import net.aufdemrand.denizencore.scripts.ScriptEntryData; | ||
import net.aufdemrand.denizencore.scripts.containers.ScriptContainer; | ||
import net.aufdemrand.denizencore.utilities.CoreUtilities; | ||
import net.elseland.xikage.MythicMobs.API.Bukkit.Events.MythicMobDeathEvent; | ||
import net.gnomeffinway.depenizen.objects.MythicMobs.MythicMobsMob; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
|
||
// <--[event] | ||
// @Events | ||
// on player jailed | ||
// on player unjailed | ||
// on player un-jailed | ||
// on player jail status changes | ||
// | ||
// @Regex ^on player [^\s]+$ | ||
// @Regex ^on mythicmob (dies|death)$ | ||
// | ||
// @Cancellable false | ||
// | ||
// @Triggers when a MythicMob dies. | ||
// | ||
// @Context | ||
// <context.mob> Returns the MythicMob that has been killed. | ||
// <context.entity> Returns the dEntity for the MythicMob. | ||
// <context.level> Returns the level of the MythicMob. | ||
// | ||
// @Plugin Depenizen, MythicMobs | ||
// | ||
// --> | ||
|
||
public class MythicMobsDeathEvent extends BukkitScriptEvent implements Listener { | ||
|
||
public MythicMobsDeathEvent() { | ||
instance = this; | ||
} | ||
|
||
MythicMobsDeathEvent instance; | ||
MythicMobDeathEvent event; | ||
MythicMobsMob mob; | ||
dEntity entity; | ||
dEntity killer; | ||
Element level; | ||
|
||
@Override | ||
public boolean couldMatch(ScriptContainer scriptContainer, String s) { | ||
String lower = CoreUtilities.toLowerCase(s); | ||
return lower.startsWith("mythicmob dies") || lower.startsWith("mythicmob death"); | ||
} | ||
|
||
@Override | ||
public boolean matches(ScriptContainer scriptContainer, String s) { | ||
return true; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "MythicMobsDeath"; | ||
} | ||
|
||
@Override | ||
public void init() { | ||
Bukkit.getServer().getPluginManager().registerEvents(this, DenizenAPI.getCurrentInstance()); | ||
} | ||
|
||
@Override | ||
public void destroy() { | ||
MythicMobDeathEvent.getHandlerList().unregister(this); | ||
} | ||
|
||
@Override | ||
public boolean applyDetermination(ScriptContainer container, String determination) { | ||
return super.applyDetermination(container, determination); | ||
} | ||
|
||
@Override | ||
public ScriptEntryData getScriptEntryData() { | ||
return new BukkitScriptEntryData(null, null); | ||
} | ||
|
||
@Override | ||
public dObject getContext(String name) { | ||
if (name.equals("mob")) { | ||
return mob; | ||
} | ||
else if (name.equals("killer")) { | ||
return killer; | ||
} | ||
else if (name.equals("entity")) { | ||
return entity; | ||
} | ||
return super.getContext(name); | ||
} | ||
|
||
@EventHandler | ||
public void onMythicMobDeath(MythicMobDeathEvent event) { | ||
mob = new MythicMobsMob(event.getMobInstance()); | ||
entity = new dEntity(event.getEntity()); | ||
killer = new dEntity(event.getKiller()); | ||
level = new Element(event.getMobLevel()); | ||
this.event = event; | ||
fire(); | ||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
...main/java/net/gnomeffinway/depenizen/extensions/MythicMobs/MythicMobsEntityExtension.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package net.gnomeffinway.depenizen.extensions.MythicMobs; | ||
|
||
import net.aufdemrand.denizen.objects.dEntity; | ||
import net.aufdemrand.denizencore.objects.Element; | ||
import net.aufdemrand.denizencore.objects.dObject; | ||
import net.aufdemrand.denizencore.tags.Attribute; | ||
import net.elseland.xikage.MythicMobs.API.IMobsAPI; | ||
import net.elseland.xikage.MythicMobs.MythicMobs; | ||
import net.gnomeffinway.depenizen.extensions.dObjectExtension; | ||
import net.gnomeffinway.depenizen.objects.MythicMobs.MythicMobsMob; | ||
|
||
public class MythicMobsEntityExtension extends dObjectExtension { | ||
|
||
IMobsAPI api = MythicMobs.inst().getAPI().getMobAPI(); | ||
|
||
public static boolean describes(dObject object) { | ||
return object instanceof dEntity; | ||
} | ||
|
||
public static MythicMobsEntityExtension getFrom(dObject object) { | ||
if (!describes(object)) { | ||
return null; | ||
} | ||
else { | ||
return new MythicMobsEntityExtension((dEntity) object); | ||
} | ||
} | ||
|
||
public MythicMobsEntityExtension(dEntity entity) { | ||
this.entity = entity; | ||
} | ||
|
||
dEntity entity; | ||
|
||
@Override | ||
public String getAttribute(Attribute attribute) { | ||
if (attribute == null) { | ||
return null; | ||
} | ||
|
||
// <--[tag] | ||
// @attribute <e@entity.is_mythicmob> | ||
// @returns Element(Boolean) | ||
// @description | ||
// Returns whether the entity is a MythicMob. | ||
// @plugin Depenizen, MythicMobs | ||
// --> | ||
if (attribute.startsWith("is_mythic_mob") || attribute.startsWith("is_mythicmob")) { | ||
return new Element(api.isMythicMob(entity.getBukkitEntity())).getAttribute(attribute.fulfill(1)); | ||
} | ||
|
||
// <--[tag] | ||
// @attribute <e@entity.mythicmob> | ||
// @returns MythicMobsMob | ||
// @description | ||
// Returns the MythicMob for this entity. | ||
// @plugin Depenizen, MythicMobs | ||
// --> | ||
else if ((attribute.startsWith("mythicmob") || attribute.startsWith("mythic_mob")) | ||
&& api.isMythicMob(entity.getBukkitEntity())) { | ||
return new MythicMobsMob(api.getMythicMobInstance(entity.getBukkitEntity())) | ||
.getAttribute(attribute.fulfill(1)); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
} |
Oops, something went wrong.