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
Showing
2 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
80 changes: 80 additions & 0 deletions
80
src/main/java/net/gnomeffinway/depenizen/commands/mythicmobs/MythicSpawnCommand.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,80 @@ | ||
package net.gnomeffinway.depenizen.commands.mythicmobs; | ||
|
||
import net.aufdemrand.denizen.objects.dLocation; | ||
import net.aufdemrand.denizencore.exceptions.CommandExecutionException; | ||
import net.aufdemrand.denizencore.exceptions.InvalidArgumentsException; | ||
import net.aufdemrand.denizencore.objects.Element; | ||
import net.aufdemrand.denizencore.objects.aH; | ||
import net.aufdemrand.denizencore.scripts.ScriptEntry; | ||
import net.aufdemrand.denizencore.scripts.commands.AbstractCommand; | ||
import net.elseland.xikage.MythicMobs.API.IMobsAPI; | ||
import net.elseland.xikage.MythicMobs.Mobs.MythicMob; | ||
import net.elseland.xikage.MythicMobs.MythicMobs; | ||
|
||
public class MythicSpawnCommand extends AbstractCommand { | ||
|
||
// <--[command] | ||
// @Name MythicSpawn | ||
// @Syntax mythicspawn [<name>] [<location>] | ||
// @Group Depenizen | ||
// @Plugin Depenizen, MythicMobs | ||
// @Required 2 | ||
// @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> | ||
|
||
// @Usage | ||
// Use to spawn a BarbarianMinion at a player's location. | ||
// - mythicspawn BarbarianMinion <player.location> | ||
|
||
// --> | ||
|
||
@Override | ||
public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException { | ||
|
||
for (aH.Argument arg : aH.interpret(scriptEntry.getArguments())) { | ||
|
||
if (!scriptEntry.hasObject("location") | ||
&& arg.matchesArgumentType(dLocation.class)) { | ||
scriptEntry.addObject("location", arg.asType(dLocation.class)); | ||
} | ||
|
||
else if (!scriptEntry.hasObject("name")) { | ||
scriptEntry.addObject("name", arg.asElement()); | ||
} | ||
|
||
else { | ||
arg.reportUnhandled(); | ||
} | ||
|
||
} | ||
|
||
if (!scriptEntry.hasObject("location") || !scriptEntry.hasObject("name")) { | ||
throw new InvalidArgumentsException("Must specify a name and location."); | ||
} | ||
} | ||
|
||
@Override | ||
public void execute(ScriptEntry scriptEntry) throws CommandExecutionException { | ||
|
||
Element name = scriptEntry.getElement("name"); | ||
dLocation location = scriptEntry.getdObject("location"); | ||
|
||
IMobsAPI api = MythicMobs.inst().getAPI().getMobAPI(); | ||
|
||
try { | ||
MythicMob mob = api.getMythicMob(name.asString()); | ||
api.spawnMythicMob(mob, location); | ||
} | ||
catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
|
||
} | ||
} |
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