本文整理汇总了Java中org.bukkit.entity.Entity.setPassenger方法的典型用法代码示例。如果您正苦于以下问题:Java Entity.setPassenger方法的具体用法?Java Entity.setPassenger怎么用?Java Entity.setPassenger使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.entity.Entity
的用法示例。
在下文中一共展示了Entity.setPassenger方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onPlayerMove
import org.bukkit.entity.Entity; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onPlayerMove(final PlayerMoveEvent event) {
final Location from = event.getFrom();
final Location to = event.getTo();
if (from.getBlockX() == to.getBlockX() && from.getBlockZ() == to.getBlockZ()) {
return;
}
if (!isWithinBorder(to) && isWithinBorder(from)) {
final Player player = event.getPlayer();
player.sendMessage(ChatColor.RED + "You cannot go past the border.");
event.setTo(from);
final Entity vehicle = player.getVehicle();
if (vehicle != null) {
vehicle.eject();
vehicle.teleport(from);
vehicle.setPassenger((Entity)player);
}
}
}
示例2: onPlayerInteractEntity
import org.bukkit.entity.Entity; //导入方法依赖的package包/类
@EventHandler
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
Player p = event.getPlayer();
Entity t = event.getRightClicked();
PetInstance pet = PetInstance.get(t);
if (pet == null)
return;
if (pet.getOwner().equalsIgnoreCase(p.getName())) {
if (t.getPassenger() != null) {
t.eject();
t.setPassenger(null);
}
else {
if (!p.isInsideVehicle())
t.setPassenger(p);
}
}
else {
Chat.player(p, "&2[Pets] &cBuy pets at www.mczone.co/shop");
}
}
示例3: setPassenger
import org.bukkit.entity.Entity; //导入方法依赖的package包/类
@Override
public boolean setPassenger(Entity passenger) {
return passenger.setPassenger(passenger);
}