Paste #18132: Untitled Paste

Date: 2015/07/15 05:42:37 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


dessentials_command_butcher:
  type: command
  name: butcher
  description: Butchers all mobs/animals within a radius. Radius defaults to 25 if empty.
  usage: /butcher [{mobs}/animals/ambient] [radius]
  permission: denizen.essentials.admin.butcher
  ## TODO type: all
  types: li@mobs|animals|ambient
  mobs: li@spider|creeper|cave_spider|slime|zombie|skeleton|witch|silverfish|enderman
  animals: li@bat|chicken|cow|pig|rabbit|sheep|squid|mushroom_cow
  ambient: li@ocelot|wolf|iron_golem|horse|villager
  script:
  - if <context.server> {
    - narrate "<&c>This command is for players only."
    - queue clear
  }
  - define type mobs
  - define radius 25
  if <context.args.size> == 1 {
    - define type <context.args.get[1]||null>
  }
  else if <context.args.size> == 2 {
    - define type <context.args.get[1]||null>
    - define radius <context.args.get[2].as_int||null>
  }
  - if !<script.yaml_key[types].contains[<def[type]>]> {
    - narrate "<&c>Invalid type."
    - queue clear
  }
  - if <def[radius]> == null {
    - narrate "<&c>Invalid radius."
    - queue clear
  }
  - define butcher <player.location.find.entities[<script.yaml_key[<def[type]>]>].within[<def[radius]>]>
  - narrate "<&2>Removing <&b><def[butcher].size><&2> entities within <&b><def[radius]><&2> blocks of type <&b><def[type]><&2>."
  - remove <def[butcher]>