import:
org.bukkit.attribute.AttributeModifier
org.bukkit.attribute.AttributeModifier$Operation # ADD_NUMBER / ADD_SCALAR / MULTIPLY_SCALAR_1
org.bukkit.inventory.EquipmentSlot # CHEST/ FEET/ HAND/ HEAD/ LEGS/ OFF_HAND
java.util.UUID

#> @param p 플레이어
#> @param item::hand 새로운 메인 아이템
#> @param item::off_hand 새로운 보조 아이템
#> @return 공격량
function Player_attackDamage(p:player, item::hand:object="", item::off_hand:object="") :: number:
set {_base} to attack damage attribute of {_p}
set {_value::*} to 0, 1, 1
set {_item::hand} to tool of {_p} if {_item::hand} is text
set {_item::off_hand} to off hand tool of {_p} if {_item::off_hand} is text
set {_item::head} to helmet of {_p}
set {_item::chest} to chestplate of {_p}
set {_item::legs} to leggings of {_p}
set {_item::feet} to boots of {_p}
loop {_item::*}:
set {_item} to loop-value
{_item} is not air
set {_slot} to EquipmentSlot.valueOf(loop-index in upper case)
set {_modifier::*} to fxPlayer_attackDamageModifiers({_item}, {_slot})
if {_modifier::*} is set:
set {_value::1} to {_value::1}+{_modifier::1} if {_modifier::1} is not 0
set {_value::2} to {_value::2}+{_modifier::2} if {_modifier::2} is not 1
set {_value::3} to {_value::3}*{_modifier::3} if {_modifier::3} is not 1
delete {_modifier::*}
else if loop-index is "hand":
set {_attack} to fxPlayer_itemAttackDamage({_item})
set {_base} to {_attack} if {_attack} is not 0
loop potion effects of {_p}:
set {_effect::*} to Parser(loop-value)
if {_effect::1} is strength:
add {_effect::2} * 3 to {_base}
else if {_effect::1} is weakness:
remove {_effect::2}*4 from {_base}
set {_ench} to 0
if {_item::hand} is not air:
loop enchantments of {_item::hand}:
set {_enchData::*} to Parser(loop-value)
if {_enchData::1} is sharpness: # 1.0/1.5/2.0/2.5/3.0
add {_enchData::2}*0.5+0.5 to {_ench}
return ({_base}+{_value::1})*{_value::2}*{_value::3}+{_ench}


#> @invisible
function fxPlayer_attackDamageModifiers(item:item, slot:object) :: numbers:
set {_value::*} to 0, 1, 1
set {_modifier::*} to (...{_item}.getItemMeta().getAttributeModifiers(attack damage)) where [ input.getSlot() is {_slot} ]
stop if {_modifier::*} is not set
loop {_modifier::*}:
set {_operation} to loop-value.getOperation()
set {_amount} to loop-value.getAmount()
if {_operation} is Operation.ADD_NUMBER:
set {_value::1} to {_value::1}+{_amount}
else if {_operation} is Operation.ADD_SCALAR:
set {_value::2} to {_value::2}+{_amount}
else if {_operation} is Operation.MULTIPLY_SCALAR_1:
set {_value::3} to {_value::3}*(1+{_amount})
return {_value::*}


aliases:
damage_1.0 = wooden hoe, stone hoe, golden hoe, iron hoe, diamond hoe, netherite hoe
damage_2.0 = wooden pickaxe, golden pickaxe
damage_2.5 = wooden shovel, golden shovel
damage_3.0 = stone pickaxe
damage_3.5 = stone shovel
damage_4.0 = wooden sword, golden sword, iron pickaxe
damage_4.5 = iron shovel
damage_5.0 = stone sword, diamond pickaxe
damage_5.5 = diamond shovel
damage_6.0 = iron sword, netherite pickaxe
damage_6.5 = netherite shovel
damage_7.0 = wooden axe, diamond sword, golden axe
damage_8.0 = netherite sword
damage_9.0 = stone axe, iron axe, diamond axe
damage_10.0 = netherite axe


#> @invisible
function fxPlayer_itemAttackDamage(item:item) :: number:
return 1.0 if {_item} is damage_1.0
return 2.0 if {_item} is damage_2.0
return 2.5 if {_item} is damage_2.5
return 3.0 if {_item} is damage_3.0
return 3.5 if {_item} is damage_3.5
return 4.0 if {_item} is damage_4.0
return 4.5 if {_item} is damage_4.5
return 5.0 if {_item} is damage_5.0
return 5.5 if {_item} is damage_5.5
return 6.0 if {_item} is damage_6.0
return 6.5 if {_item} is damage_6.5
return 7.0 if {_item} is damage_7.0
return 8.0 if {_item} is damage_8.0
return 9.0 if {_item} is damage_9.0
return 10.0 if {_item} is damage_10.0
return 0

#> Chunk = [ x, y, world ]
#> Potion Effect = [ potion effect type, tier ]
#> Enchantment = [ enchantment, tier ]
#> @param value Chunk or Potion Effect, Enchantment
#> @return Parsing Data
function Parser(value:object) :: objects:
return "%{_value}%" parsed as "chunk (%integer%,%integer%) of %world%" if {_value} is a chunk
return "%{_value}%" parsed as "potion effect of %potion effect type% of tier %integer% for %timespan%" if {_value} is a potion effect
return "%{_value}%" parsed as "%enchantment% %integer%" if {_value} is a enchantment type


대충 개노가다해서 플레이어가 장비한 아이템의 데미지를 구하고





on join with priority low:
Infoboard_update(player)


on swap item with priority low:
Infoboard_update(player, off hand tool, tool)


on drop with priority low:
Infoboard_update(player)


on pick up with priority low:
hotbar slot of player is air
loop integers from 0 to index of hotbar slot of player - 1:
slot loop-integer of inventory of player is air
stop
Infoboard_update(player, event-item)


on tool change with priority low:
Infoboard_update(player, tool)


on inventory close with priority low:
Infoboard_update(player)


function Infoboard_update(p:player, hand:object="", off_hand:object=""):
set {_attackDamage} to Player_attackDamage({_p}, {_hand}, {_off_hand})
set {_lines::1} to "공격력: %{_attackDamage}%"
Scoreboard_sidebar({_p}, "정보", {_lines::*})


대충 이벤트와 스까주면 장비가 바뀔때 바로 적용됨




7fed8274a88260eb3febe9e5479f766e27ce74c30b743c064649c3c2d0542b0f65d3ef

금검 4



7fed8274a88260eb3febe9e5479f766e27ce7fc30b743c064649c3c2d0542b095083aa

철검 6



7fed8274a88260eb3febe9e5479f766916150bf5c7a2551eb9bd872eb5173d1a6996

7fed8274a88260eb3febe9e5479f766916150cf5c7a2551eb9bd872eb5173f17d33b47

어트리뷰트 잔뜩 붙인거 168



7fed8274a88260eb3febe9e5479f766916160ff5c7a2551eb9bd872eb513381912

7fed8274a88260eb3febe9e5479f7669161605f5c7a2551eb9bd872eb5173f1ccdfe45

방어구 적용하면 216


계산하는 부분은

+플레이어 기본 공격력

+무기 기본 공격력

+장비 어트리뷰트 (왼손, 오른손, 머리, 몸통, 다리, 신발)

+포션 힘, 나약함

+무기 인첸트 날카로움


실제 마크 알고리즘 그대로고

살충, 강타, 찌르기, 휩쓸기 인첸트는 조건부라 제외함


reflect 애드온 필요