Skip to content

Commit

Permalink
update command script source context
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Oct 30, 2019
1 parent c624f93 commit 86bd3a3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
public class InventoryUniquifier implements Property {

public static boolean describes(ObjectTag inventory) {
// All inventories can potentially have a uniquifier
return inventory instanceof InventoryTag
&& (((InventoryTag) inventory).getIdType() != null
&& (((InventoryTag) inventory).getIdType().equals("generic")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public class CommandScriptContainer extends ScriptContainer {
// # Available context:
// # <context.args> returns a list of input arguments.
// # <context.raw_args> returns all the arguments as raw text.
// # <context.server> returns whether the server is running the command (a player if false).
// # <context.source_type> returns the source of the command. Can be: PLAYER, SERVER, COMMAND_BLOCK, or COMMAND_MINECART.
// # <context.alias> returns the command alias being used.
// # <context.command_block_location> returns the command block's location (if the command was run from one).
// # <context.command_minecart> returns the EntityTag of the command minecart (if the command was run from one).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,22 @@ public boolean execute(CommandSender commandSender, String commandLabel, String[
player = PlayerTag.mirrorBukkitPlayer(pl);
}
context.put("server", new ElementTag(false));
context.put("source_type", new ElementTag("player"));
}
else {
context.put("server", new ElementTag(true));
if (commandSender instanceof BlockCommandSender) {
context.put("command_block_location", new LocationTag(((BlockCommandSender) commandSender).getBlock().getLocation()));
context.put("server", new ElementTag(false));
context.put("source_type", new ElementTag("command_block"));
}
else if (commandSender instanceof CommandMinecart) {
context.put("command_minecart", new EntityTag((CommandMinecart) commandSender));
context.put("server", new ElementTag(false));
context.put("source_type", new ElementTag("command_minecart"));
}
else {
context.put("server", new ElementTag(true));
context.put("source_type", new ElementTag("server"));
}
}
if (Depends.citizens != null && npc == null) {
Expand Down

0 comments on commit 86bd3a3

Please sign in to comment.