daily pastebin goal
4%
SHARE
TWEET

Untitled

a guest Dec 16th, 2018 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # normal imports
  2. import:
  3.  
  4.   org.bukkit.Bukkit
  5.   org.bukkit.entity.Entity
  6.   org.bukkit.inventory.ItemStack
  7.  
  8.   ch.njol.skript.Skript
  9.   ch.njol.skript.util.Version
  10.   ch.njol.skript.aliases.ItemType
  11.  
  12.  
  13. option nms-version:
  14.   get:
  15.     return Bukkit.getServer().getClass().getPackage().getName().split("\.")[3]
  16.  
  17.  
  18. # NMS/CBO imports
  19. import:
  20.  
  21.   org.bukkit.craftbukkit.{@nms-version}.inventory.CraftItemStack
  22.   org.bukkit.craftbukkit.{@nms-version}.block.CraftBlock
  23.  
  24.   net.minecraft.server.{@nms-version}.ItemStack as NMSItemStack
  25.   net.minecraft.server.{@nms-version}.NBTTagCompound
  26.   net.minecraft.server.{@nms-version}.NBTTagList
  27.   net.minecraft.server.{@nms-version}.MojangsonParser
  28.   net.minecraft.server.{@nms-version}.BlockPosition
  29.  
  30.  
  31. condition [(minecraft|mc)] version is (greater|1¦less) than <.+>:
  32.   parse:
  33.     if regex-1.matches("\d\.\d{1,2}(?:\.\d{1,2})?") is false:
  34.       Skript.error("Invalid Minecraft version.")
  35.     else:
  36.       continue
  37.   get:
  38.     set {_compared-version} to new Version(regex-1)
  39.     set {_current-version} to Skript.getMinecraftVersion()
  40.     if parser mark is 1:
  41.       continue if {_current-version}.isSmallerThan({_compared-version})
  42.     else:
  43.       continue if {_current-version}.isLargerThan({_compared-version})
  44.  
  45.  
  46. # Methods that change in specific versions
  47. on script load:
  48.  
  49.   set {NBT::entity::save} to "e" if version is less than 1.12, else "save"
  50.  
  51. #local effect:
  52. #  patterns:
  53. #    append %strings% to %javaobjects%
  54. #    detach %strings% from %javaobjects%
  55. #    convert %javaobjects% to %strings%
  56. #  trigger:
  57. #    expressions-1 and expression-2 are an instance of NBTTagCompound
  58. #
  59. #    loop expression-1:
  60. #      loop expression-2:
  61. #          if matched pattern is 1:
  62. #            loop-value-1.a(MojangsonParser.parse(loop-value-2))
  63. #          else if matched pattern is 2:
  64. #            loop-value-1.remove(MojangsonParser.parse(loop-value-2))
  65. #          else:
  66. #            loop-value-1.setTag(MojangsonParser.parse(loop-value-3))
  67.  
  68.  
  69.  
  70. local itemtypes property item NBT:
  71.   get:
  72.     set {_item} to CraftItemStack.asNMSCopy(expression-1.getRandom())
  73.     set {_nbt} to {_item}.getTag() if {_item}.hasTag() is true, else new NBTTagCompound()
  74.     return {_nbt}
  75.  
  76.   add string:
  77.     set {_appended-nbt} to MojangsonParser.parse(change value)
  78.    
  79.     loop expressions-1:
  80.       set {_item} to CraftItemStack.asNMSCopy(loop-value.getRandom())
  81.    
  82.       if {_appended-nbt} is set:
  83.  
  84.         if {_item}.hasTag() is true:
  85.           {_item}.a({_appended-nbt})
  86.         else:
  87.           {_item}.setTag({_appended-nbt})
  88.  
  89.         set {_meta} to CraftItemStack.getItemMeta({_item})
  90.         loop-value.setItemMeta({_meta})
  91.      
  92.   remove string:
  93.     set {_removed-nbt} to MojangsonParser.parse(change value)
  94.    
  95.     loop expressions-1:
  96.       set {_item} to CraftItemStack.asNMSCopy(expression-1.getRandom())
  97.  
  98.       if {_removed-nbt} is set:
  99.         {_item}.hasTag() is true
  100.         {_item}.remove({_removed-nbt})
  101.  
  102.         set {_meta} to CraftItemStack.getItemMeta({_item})
  103.         loop-value.setItemMeta({_meta})
  104.  
  105.   set string:
  106.     set {_new-nbt} to MojangsonParser.parse(change value)
  107.    
  108.     loop expressions-1:  
  109.       set {_item} to CraftItemStack.asNMSCopy(loop-value.getRandom())
  110.  
  111.       if {_new-nbt} is set:
  112.         {_item}.setTag({_new-nbt})
  113.  
  114.         set {_meta} to CraftItemStack.getItemMeta({_item})
  115.         loop-value.setItemMeta({_meta})
  116.  
  117.  
  118. local entities property entity NBT:
  119.   get:
  120.     set {_entity} to expresion-1.getHandle()
  121.     set {_nbt} to new NBTTagCompound()
  122.    
  123.     if {_entity}.c({_nbt}) is false:
  124.       {_entity}..{NBT::entity::save}({_nbt})
  125.  
  126.     return {_nbt}
  127.  
  128.   add string:
  129.     set {_appended-nbt} to MojangsonParser.parse(change value)
  130.    
  131.     loop expressions-1:
  132.       set {_entity} to loop-value.getHandle()
  133.       set {_old-nbt} to entity nbt of loop-value
  134.       {_old-nbt}.a({_appended-nbt})
  135.       {_entity}.f({_appended-nbt})
  136.  
  137.   remove string:
  138.     set {_removed-nbt} to MojangsonParser.parse(change value)
  139.    
  140.     loop expressions-1:
  141.       set {_entity} to loop-value.getHandle()
  142.       set {_old-nbt} to entity nbt of loop-value
  143.       {_old-nbt}.remove({removed-nbt})
  144.       {_entity}.f({_removed-nbt})
  145.  
  146.   set string:
  147.     set {_new-nbt} to MojangsonParser.parse(change value)
  148.  
  149.     loop expressions-1:
  150.       set {_entity} to loop-value.getHandle()
  151.       {_entity}.f({_new-nbt})
  152.  
  153.  
  154. blocks, itemtypes, entities property NBT:
  155.   get:
  156.     if expression-1 is an instance of ItemType:
  157.       return item nbt of expression-1
  158.     else if expression-1 is an instance of Entity:
  159.       return entity nbt of expression-1
  160.  
  161.   set string:
  162.     if expressions-1 are an instance of ItemType:
  163.       set item nbt of expressions-1 to change value
  164.     else if expressions-1 are an instance of Entity:
  165.       set entity nbt of expressions-1 to change value
  166.  
  167.   add string:
  168.     if expressions-1 are an instance of ItemType:
  169.       add change value to item nbt of expressions-1
  170.     else if expressions-1 are an instance of Entity:
  171.       add change value to entity nbt of expressions-1
  172.  
  173.   remove string:
  174.     if expressions-1 are an instance of ItemType:
  175.       remove change value from item nbt of expressions-1
  176.     else if expressions-1 are an instance of Entity:
  177.       remove change value from entity nbt of expressions-1
  178.  
  179.  
  180. expression %itemtype% with nbt %string%:
  181.   get:
  182.     set {_item} to expression-1
  183.     set item nbt of {_item} to expression-2
  184.     return {_item}
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand