Advertisement
Guest User

Untitled

a guest
Aug 21st, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.48 KB | None | 0 0
  1. import:
  2. org.bukkit.Bukkit
  3.  
  4. option nms-version:
  5. get:
  6. return Bukkit.getServer().getClass().getPackage().getName().split("\.")[3]
  7.  
  8. import:
  9. net.minecraft.server.{@nms-version}.PacketPlayOutEntityDestroy
  10.  
  11. # For some reason, 'last spawned entity' and 'last spawned entity' does not work for the packet.
  12. # Therefore there needs to be a way to store the the last spawned entity.
  13. on item spawn:
  14. set {LastSpawnedItem} to event-entity
  15.  
  16. # Condition to check if a player owns a dropped item
  17. condition %player% cannot pickup[ item of[ entity] ]%entity%:
  18. check:
  19. set {_owners} to metadata value "Owner" of expression-2
  20. set {_owners::*} to {_owners} split by ","
  21. loop {_owners::*}:
  22. if "%expression-1%" is loop-value:
  23. set {_continue} to false
  24. {_continue} is not set
  25. continue
  26.  
  27. # Example pickup event to prevent players from picking up other peoples items.
  28. on pickup:
  29. metadata value "Owner" of event-entity is set
  30. if player cannot pickup item of event-entity:
  31. cancel event
  32.  
  33. # New effect to drop an item at location for specific players
  34. effect drop %itemstack% at %location% with offset %number%, %number%[,] and %number%(1¦ for %players%|2¦):
  35. trigger:
  36. set {_location} to expression-2
  37. add expression-3 to x coordinate of {_location}
  38. add expression-4 to y coordinate of {_location}
  39. add expression-5 to z coordinate of {_location}
  40. world of {_location}.dropItem({_location}, expression-1)
  41. if parse mark is 1:
  42. set {_owners} to ""
  43. set {_players::*} to all players
  44. loop expressions-6:
  45. set {_owners} to "%{_owners}%%loop-value%,"
  46. remove loop-value from {_players::*}
  47. set {_owners} to subtext of {_owners} from 1 to (length of {_owners} - 1)
  48. set metadata value "Owner" of {LastSpawnedItem} to {_owners}
  49. loop {_players::*}:
  50. loop-value.getHandle().playerConnection.sendPacket(new PacketPlayOutEntityDestroy({LastSpawnedItem}.getEntityId()))
  51.  
  52. # Example command for dropping items to specific players
  53. command /dropitem:
  54. trigger:
  55. # Drop an item for one specific player
  56. drop 1 of stone at location of player with offset 0, 3 and 0 for player
  57. # Drop an item for all players
  58. drop 1 of stone at location of player with offset 0, 3 and 0
  59. # Drop an item for several but not all players
  60. add random player out of all players to {_players::*}
  61. add random player out of all players to {_players::*}
  62. add random player out of all players to {_players::*}
  63. drop 1 of stone at location of player with offset 0, 3, and 0 for {_players::*}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement