worldeditのposをlocationとしてgetするfunction

import:
com.sk89q.worldedit.bukkit.BukkitAdapter
com.sk89q.worldedit.WorldEdit

function getPos(p: player, sel: integer) :: location:
set {_actor} to BukkitAdapter.adapt({_p})
set {_manager} to WorldEdit.getInstance().getSessionManager()
set {_localSession} to {_manager}.get({_actor})
set {_selectionWorld} to {_localSession}.getSelectionWorld()
if {_selectionWorld} is set:
set {_region} to {_localSession}.getSelection({_selectionWorld})
if {_sel} is 1:
set {_pos} to {_region}.getPos1()
else if {_sel} is 2:
set {_pos} to {_region}.getPos2()

set {_x} to {_pos}.getX()
set {_y} to {_pos}.getY()
set {_z} to {_pos}.getZ()
set {_world} to {_selectionWorld}.getWorld()

return location({_x}, {_y}, {_z}, {_world})
import:
com.sk89q.worldedit.bukkit.BukkitAdapter
com.sk89q.worldedit.WorldEdit

function getPos(p: player, sel: integer) :: location:
set {_actor} to BukkitAdapter.adapt({_p})
set {_manager} to WorldEdit.getInstance().getSessionManager()
set {_localSession} to {_manager}.get({_actor})
set {_selectionWorld} to {_localSession}.getSelectionWorld()
if {_selectionWorld} is set:
set {_region} to {_localSession}.getSelection({_selectionWorld})
if {_sel} is 1:
set {_pos} to {_region}.getPos1()
else if {_sel} is 2:
set {_pos} to {_region}.getPos2()

set {_x} to {_pos}.getX()
set {_y} to {_pos}.getY()
set {_z} to {_pos}.getZ()
set {_world} to {_selectionWorld}.getWorld()

return location({_x}, {_y}, {_z}, {_world})
前提: skript, skript-reflect, worldedit 両方選択していない状態や片方しか選択していない状態だとnoneが返されます
1 Reply
あお🦀
あお🦀3mo ago
1.19.4で動作確認
No description
Want results from more Discord servers?
Add your server