# -------------------------------------------------- # SkArmorEvent v. 1.2 (1.9.4 - 1.13.1) # Skrypt na eventy wywołujące się przy zakładaniu i zdejmowaniu zbroi # # by Kormic # -------------------------------------------------- import: org.bukkit.Material custom event "onArmorEquip": pattern: sk(ae|ArmorEvent) armo[u]r (equip|wear) event-values: player, item check: continue custom event "onArmorUnequip": pattern: sk(ae|ArmorEvent) armo[u]r un(equip|wear) event-values: player, item check: continue function skArmorEventCheckArmor(p: player, i: item) :: boolean: {_i} is not any armor: return false if {_i} is any helmet: {_p}'s helmet is not air return false else if {_i} is any chestplate: {_p}'s chestplate is not air return false else if {_i} is any leggings: {_p}'s leggings is not air return false else if {_i} is any boots: {_p}'s boots is not air return false return true function skArmorEventHotbarButtonCheckArmor(p: player, i: item type, s: slot, n: number) :: boolean: slot {_n} of {_p}'s inventory is {_i} set {_hb} to "%slot {_n} of {_p}'s inventory%" parsed as item if skArmorEventIsCancelled({_p}, {_hb}, "onArmorEquip") is true: return true {_s} is not air set {_hb} to {_s} if skArmorEventIsCancelled({_p}, {_hb}, "onArmorUnequip") is true: return true return false function skArmorEventIsCancelled(p: player, i: item, n: text) :: boolean: set {_e::player} to {_p} set {_e::item} to {_i} set {_event} to custom event "%{_n}%" with {_e::*} call event {_event} if {_event} is cancelled: return true return false function skArmorEventChangeCoordinates(n: numbers, loc: location) :: locations: set {_loc::1} and {_loc::2} to {_loc} add {_n::1} to x-loc of {_loc::1} add {_n::2} to y-loc of {_loc::1} add {_n::3} to z-loc of {_loc::1} add {_n::4} to x-loc of {_loc::2} add {_n::5} to y-loc of {_loc::2} add {_n::6} to z-loc of {_loc::2} loop 30 times: play water drip at {_loc::1} play lava drip at {_loc::2} return {_loc::*} on right click: player's tool's type is any armor set {_b::*} to "dispenser", "dropper", "chest", "furnace", "hopper", "crafting table", "workbench", "anvil", "bed", "door", "repeater", "comparator", "button", "lever", "wooden trapdoor", "fence gate", "daylight detector" and "sign" loop {_b::*}: "%clicked block%" contains loop-value stop set {_i} to player's tool if skArmorEventCheckArmor(player, {_i}) is false: stop if skArmorEventIsCancelled(player, {_i}, "onArmorEquip") is true: cancel event on inventory click: clicked inventory is player's inventory player's current inventory's type is crafting table inventory if click type is left mouse button or right mouse button: clicked slot is between 36 and 39 set {_i} to "%event-slot%" parsed as item if player's cursor slot is any armor: set {_i} to player's cursor slot if skArmorEventIsCancelled(player, {_i}, "onArmorEquip") is true: cancel event else if player's cursor slot is air: {_i} is not air if skArmorEventIsCancelled(player, {_i}, "onArmorUnequip") is true: cancel event else if click type is left mouse button with shift or right mouse button with shift: set {_i} to "%event-slot%" parsed as item if clicked slot is between 36 and 39: {_i} is not air if skArmorEventIsCancelled(player, {_i}, "onArmorUnequip") is true: cancel event if skArmorEventCheckArmor(player, {_i}) is false: stop if skArmorEventIsCancelled(player, {_i}, "onArmorEquip") is true: cancel event else if click type is number key: set {_i} to "%event-slot%" parsed as item if clicked slot is between 36 and 39: if {_i} is not air: slot (hotbar button) of player's inventory is air if skArmorEventIsCancelled(player, {_i}, "onArmorUnequip") is true: cancel event stop if clicked slot is 39: if skArmorEventHotbarButtonCheckArmor(player, any helmet, player's helmet, hotbar button) is true: cancel event else if clicked slot is 38: if skArmorEventHotbarButtonCheckArmor(player, any chestplate, player's chestplate, hotbar button) is true: cancel event else if clicked slot is 37: if skArmorEventHotbarButtonCheckArmor(player, any leggings, player's leggings, hotbar button) is true: cancel event else if clicked slot is 36: if skArmorEventHotbarButtonCheckArmor(player, any boots, player's boots, hotbar button) is true: cancel event on dispense: event-block.getType() != Material.DROPPER event-item's type is any armor set {_i} to event-item size of (all players in radius 3 around event-block) >= 1 if facing of event-block is above: set {_loc::*} to skArmorEventChangeCoordinates((0.8, 0.5, 0.8, -0.8, 1.8, -0.8), location of event-block) else if facing of event-block is below: set {_loc::*} to skArmorEventChangeCoordinates((0.8, -0.5, 0.8, -0.8, -1.8, -0.8), location of event-block) else if facing of event-block is north: set {_loc::*} to skArmorEventChangeCoordinates((-0.8, -0.5, -0.5, 0.8, 0.49, -1.8), location of event-block) else if facing of event-block is south: set {_loc::*} to skArmorEventChangeCoordinates((-0.8, -0.5, 0.5, 0.8, 0.49, 1.8), location of event-block) else if facing of event-block is east: set {_loc::*} to skArmorEventChangeCoordinates((0.5, -0.5, -0.8, 1.8, 0.49, 0.8), location of event-block) else if facing of event-block is west: set {_loc::*} to skArmorEventChangeCoordinates((-0.5, -0.5, -0.8, -1.8, 0.49, 0.8), location of event-block) loop all players in radius 3 around event-block: if skArmorEventCheckArmor(loop-player, {_i}) is false: stop if x-loc of location of loop-player is not between x-loc of {_loc::1} and x-loc of {_loc::2}: continue if y-loc of location of loop-player is not between y-loc of {_loc::1} and y-loc of {_loc::2}: continue if z-loc of location of loop-player is not between z-loc of {_loc::1} and z-loc of {_loc::2}: continue if skArmorEventIsCancelled(loop-player, {_i}, "onArmorEquip") is true: if event-item's type is any helmet: set player's helmet to air else if event-item's type is any chestplate: set player's chestplate to air else if event-item's type is any leggings: set player's leggings to air else if event-item's type is any boots: set player's boots to air drop event-item at player exit loop