- D1 Meta Docs - Denizen Script -
Home Page / Pi to one million places / Contact mcmonkey / Donate / Paste Scripts / Denizen Help /
You are browsing as a guest.
Login | Register


Click here to create your own public paste ~ ~ click to duplicate and edit this paste


TitleEdit of P#17203 - Edit of P#17201 - Edit of P#17199 - Edit of P#17197 - Edit of P#17193 - Untitled P
TypeDenizen Script
Date2015/06/30 19:42:44 UTC-07:00
ByGuest
OtherEdit of paste #17203 - click here to see edit details
Paste
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
4000
dessentials_command_enchant:
  type: command
  name: enchant
  description: Allows you to enchant the item in hand. Level is required.
  usage: /enchant <&lt>enchantment,level|...<&gt>
  permission: denizen.essentials.admin.enchant
  script:
  - if <context.server> {
    - narrate "<&c>This command is for players only!"
    - queue clear
  }
  - if !<server.has_permissions> && !<player.is_op> queue clear
  - if <context.args.size> != 1 {
    - narrate "<&c>/enchant <&lt>enchantment,level|...<&gt>"
    - queue clear
  }
  - define item <player.item_in_hand>
  - define current <def[item].enchantments.with_levels||li@>
  - define added <context.args.get[1].escaped.split[&pipe]>
  - define valid li@ARROW_DAMAGE|ARROW_FIRE|ARROW_INFINITE|ARROW_KNOCKBACK|DAMAGE_ALL|DAMAGE_ANTROPODS|DAMAGE_UNDEAD|DEPTH_STRIDER
  - define valid <def[valid].include[DIG_SPEED|DURABILITY|FIRE_ASPECT|KNOCKBACK|LOOT_BONUS_BLOCKS|LUCK|LURE|OXYGEN|PROTECTION_ENVIRONMENTAL]>
  - define valid <def[valid].include[PROTECTION_EXPLOSIONS|PROTECTION_FALL|PROTECTION_FIRE|PROTECTION_PROJECTILE|SILK_TOUCH|THORNS|WATER_WORKER]>
  - foreach <def[added]> {
    - define enchantment <def[value].split[,].get[1]>
    - if !<def[valid].contains[<def[enchantment]>]> {
      - narrate "<&c>Invalid enchantment <def[enchantment]>"
      - queue clear
    }
    - define level <def[value].split[,].get[2].as_int||null>
    - if <def[level]> == null || <def[level]> < 1 {
      - narrate "<&c>Invalid level or none specified."
      - queue clear
    }
    - define new <def[new].include[<dev[value]>]||<def[value]>>
  }
  - adjust <def[item]> enchantments:<def[new]>
  - inventory set o:<def[item]> d:<player.inventory> slot:<player.item_in_hand.slot>
  - narrate "Enchanted item with <def[item].enchantments.with_levels>"




RawRaw



Pastes made: 58443