本文整理匯總了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);
}