使用 SpigotMC 更改新的双面标志后,如何从 PlayerInteract 事件上的标志读取文本?

问题描述 投票:0回答:1

当玩家单击标志时,我试图将标志上的文本作为字符串获取。随着《我的世界》中允许在两侧编辑标志的新变化,许多旧的方法已被弃用。对于新标志,您首先必须在阅读标志行之前使用 getSide() 。不幸的是,PlayerInteract 事件似乎没有提供返回 SignSide 的方法,最接近的是 BlockFace。

我当前的代码如下所示:

    @EventHandler(ignoreCancelled = true)
    void onPlayerInteract(PlayerInteractEvent event) {
        //Check that the player clicked a block
        if (event.getAction() != Action.RIGHT_CLICK_BLOCK) {
            return;
        }
        //Check that the block is a sign
        Block block = event.getClickedBlock();
        if (block == null) {
            return;
        }
        if (!(block.getState() instanceof Sign)) {
            return;
        }
        //Here is where I need to get the clicked face of the sign, and return a given
        //line on the sign as a String
    }

如果有人可以提供有关如何完成此操作的更多信息,我们将不胜感激。

java minecraft spigot
1个回答
0
投票

我自己回答这个问题,因为该功能现已添加到 spigot 中。请参阅此处了解更多信息:

https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/block/Sign.html#getSide(org.bukkit.block.sign.Side)

© www.soinside.com 2019 - 2024. All rights reserved.