@EventHandler
public void onSignElevator(PlayerInteractEvent e) {
if (e.getClickedBlock() == null) {
return;
}
Block block = e.getClickedBlock();
BlockState state = block.getState();
if (state instanceof Sign) {
if(e.getAction() == Action.RIGHT_CLICK_BLOCK) {
Sign sign = (Sign)state;
double zdif = Math.abs(e.getPlayer().getLocation().getZ() - block.getLocation().getZ());
double xdif = Math.abs(e.getPlayer().getLocation().getX() - block.getLocation().getX());
String lineZero = sign.getLine(0);
String lineOne = sign.getLine(1);
if(ChatColor.stripColor(lineZero).equalsIgnoreCase("[Elevator]")) {
if(zdif < 1.5D && xdif < 1.5D ) {
if (ChatColor.stripColor(lineOne).equalsIgnoreCase("Up")) {
e.getPlayer().teleport(this.teleportSpotUp(block.getLocation(), block.getLocation().getBlockY(), 254));
}
if (ChatColor.stripColor(lineOne).equalsIgnoreCase("Down")) {
e.getPlayer().teleport(this.teleportSpotDown(block.getLocation(), block.getLocation().getBlockY(), 1));
}
} else {
e.getPlayer().sendMessage(ChatColor.RED + "You must be standing next to the sign!");
}
}
e.setCancelled(true);
return;
}
}
}
ElevatorListener.java 文件源码
java
阅读 25
收藏 0
点赞 0
评论 0
项目:HCFCore
作者:
评论列表
文章目录