Skip to content

Commit

Permalink
Remove Explosion from Shoot command. As a replacement, Shoot sends fi…
Browse files Browse the repository at this point in the history
…nal location as context to task script, so you can use Explode there.
  • Loading branch information
davidcernat committed Jun 6, 2013
1 parent 101478d commit 43d50db
Showing 1 changed file with 8 additions and 15 deletions.
@@ -1,5 +1,8 @@
package net.aufdemrand.denizen.scripts.commands.core;

import java.util.HashMap;
import java.util.Map;

import net.aufdemrand.denizen.Settings;
import net.aufdemrand.denizen.exceptions.CommandExecutionException;
import net.aufdemrand.denizen.exceptions.InvalidArgumentsException;
Expand Down Expand Up @@ -39,7 +42,6 @@ public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException
Script newScript = null;
Boolean ride = false;
Boolean burn = false;
double explosion = -1;

// Set some defaults
if (scriptEntry.getPlayer() != null)
Expand Down Expand Up @@ -68,10 +70,6 @@ public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException
burn = true;
dB.echoDebug("...will burn.");

} else if (aH.matchesValueArg("explosion", arg, ArgumentType.Double)) {
explosion = aH.getDoubleFrom(arg);
dB.echoDebug("...will have an explosion radius of " + explosion);

} else throw new InvalidArgumentsException(Messages.ERROR_UNKNOWN_ARGUMENT, arg);
}

Expand All @@ -83,7 +81,6 @@ public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException
scriptEntry.addObject("script", newScript);
scriptEntry.addObject("ride", ride);
scriptEntry.addObject("burn", burn);
scriptEntry.addObject("explosion", explosion);
}

@Override
Expand Down Expand Up @@ -156,16 +153,12 @@ public void run() {

if (scriptEntry.getObject("script") != null)
{
Map<String, String> context = new HashMap<String, String>();
context.put("1", entity.getLocation().getX() + "," + entity.getLocation().getY() + "," + entity.getLocation().getZ() + "," + entity.getLocation().getWorld().getName());

((TaskScriptContainer) ((Script) scriptEntry.getObject("script")).
getContainer()).setSpeed(new Duration(
Duration.valueOf(Settings.ScriptQueueSpeed()).getSeconds()))
.runTaskScript(scriptEntry.getPlayer(), scriptEntry.getNPC(), null);
}

if ((Double) scriptEntry.getObject("explosion") > 0)
{
entity.getWorld().createExplosion(entity.getLocation(),
(Float) scriptEntry.getObject("explosion"));
getContainer()).setSpeed(new Duration(0))
.runTaskScript(scriptEntry.getPlayer(), scriptEntry.getNPC(), context);
}

}
Expand Down

0 comments on commit 43d50db

Please sign in to comment.