我一直在编写一个插件来移动某人,当他们右键单击带有某些文本的标志时,却要找到我需要将Block类转换为sign类并使用getTextOnLine();
函数的文本这是我的Java代码
公共类CowShooter扩展EZPlugin实现PluginListener {
@Override
public boolean enable() {
Canary.hooks().registerListener(this, this);
return super.enable(); // Call parent class's version too.
}
@HookHandler
public void SignChangeHook(BlockRightClickHook event) {
Player player = event.getPlayer();
Block block = event.getBlockClicked();
if (block.getType() == BlockType.SignPost || block.getType() == BlockType.WallSign) {
错误的代码
Sign sign = event.getBlockClicked();
if (sign.getTextOnLine(1) == "TP") {
Location loc = player.getLocation();
int playerX = (int) loc.getX();
int playerY = (int) loc.getY();
int playerZ = (int) loc.getZ();
loc.setY(playerY+10);
player.teleportTo(loc);
}
}
}
}
以下是源代码在Source code for canarymod
中的文件夹答案 0 :(得分:0)
获取块的坐标并将其设置在符号类
中ListFragment