Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import:
- org.bukkit.Bukkit
- option nms-version:
- get:
- return Bukkit.getServer().getClass().getPackage().getName().split("\.")[3]
- import:
- net.minecraft.server.{@nms-version}.PacketPlayOutEntityDestroy
- # For some reason, 'last spawned entity' and 'last spawned entity' does not work for the packet.
- # Therefore there needs to be a way to store the the last spawned entity.
- on item spawn:
- set {LastSpawnedItem} to event-entity
- # Condition to check if a player owns a dropped item
- condition %player% cannot pickup[ item of[ entity] ]%entity%:
- check:
- set {_owners} to metadata value "Owner" of expression-2
- set {_owners::*} to {_owners} split by ","
- loop {_owners::*}:
- if "%expression-1%" is loop-value:
- set {_continue} to false
- {_continue} is not set
- continue
- # Example pickup event to prevent players from picking up other peoples items.
- on pickup:
- metadata value "Owner" of event-entity is set
- if player cannot pickup item of event-entity:
- cancel event
- # New effect to drop an item at location for specific players
- effect drop %itemstack% at %location% with offset %number%, %number%[,] and %number%(1¦ for %players%|2¦):
- trigger:
- set {_location} to expression-2
- add expression-3 to x coordinate of {_location}
- add expression-4 to y coordinate of {_location}
- add expression-5 to z coordinate of {_location}
- world of {_location}.dropItem({_location}, expression-1)
- if parse mark is 1:
- set {_owners} to ""
- set {_players::*} to all players
- loop expressions-6:
- set {_owners} to "%{_owners}%%loop-value%,"
- remove loop-value from {_players::*}
- set {_owners} to subtext of {_owners} from 1 to (length of {_owners} - 1)
- set metadata value "Owner" of {LastSpawnedItem} to {_owners}
- loop {_players::*}:
- loop-value.getHandle().playerConnection.sendPacket(new PacketPlayOutEntityDestroy({LastSpawnedItem}.getEntityId()))
- # Example command for dropping items to specific players
- command /dropitem:
- trigger:
- # Drop an item for one specific player
- drop 1 of stone at location of player with offset 0, 3 and 0 for player
- # Drop an item for all players
- drop 1 of stone at location of player with offset 0, 3 and 0
- # Drop an item for several but not all players
- add random player out of all players to {_players::*}
- add random player out of all players to {_players::*}
- add random player out of all players to {_players::*}
- 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