本文整理汇总了Java中org.bukkit.entity.Player.getVehicle方法的典型用法代码示例。如果您正苦于以下问题:Java Player.getVehicle方法的具体用法?Java Player.getVehicle怎么用?Java Player.getVehicle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.entity.Player
的用法示例。
在下文中一共展示了Player.getVehicle方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onPlayerMove
import org.bukkit.entity.Player; //导入方法依赖的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: executePlayer
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public void executePlayer(final Player p, PlayerDataRPG pd, String[] args) {
if (p.getWorld().getName().equalsIgnoreCase(SakiRPG.TUTORIAL_WORLD)) {
p.sendMessage(ChatColor.GRAY + "> " + ChatColor.GREEN + "Sorry! You can't use this command in the tutorial!");
p.sendMessage(ChatColor.GRAY + "> " + ChatColor.AQUA + "Please finish the tutorial first. Feel free to ask for help!");
return;
}
if (pd.riding || p.getVehicle() != null) {
pd.sendMessage(ChatColor.RED + "You are already on a horse!");
return;
}
if (lastCommand.containsKey(p.getName()) && System.currentTimeMillis() - lastCommand.get(p.getName()) < 5000) {
p.sendMessage(ChatColor.RED + "You can only summon your horse once every 5 seconds.");
} else {
lastCommand.put(p.getName(), System.currentTimeMillis());
if (pd.inCombat()) {
pd.sendMessage(ChatColor.RED + "Horses cannot be used while in combat.");
return;
}
if (pd.horseSpeed == 0 && pd.horseJump == 0) { // no horse
pd.sendMessage(ChatColor.RED + "You don't own a horse. Talk to a " + ChatColor.AQUA + "Horse Dealer" + ChatColor.RED + " to get one!");
} else {
HorseManager.createHorse(p, pd);
}
}
}
示例3: hoverCheck
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public boolean hoverCheck(Player player, MovingData data) {
result.reset();
// Check if we are actually hovering.
double vertical = data.getVerticalSpeed();
boolean actuallyHovering = data.getLastVerticalSpeed() == 0.0 && vertical == 0.0 && player.getVehicle() == null;
if (actuallyHovering) {
// check how long we've been hovering for.
if (data.getAirTicks() >= maxHover) {
// too long, flag.
getCheck().setCheckName("Flight " + ChatColor.GRAY + "(Hover)");
result.set(checkViolation(player, "hovering off the ground, hover"));
}
}
return result.failed();
}
示例4: hoverCheck
import org.bukkit.entity.Player; //导入方法依赖的package包/类
private boolean hoverCheck(Player player, MovingData data) {
result.reset();
// Check if we are actually hovering.
double vertical = data.getVerticalSpeed();
boolean actuallyHovering = data.getLastVerticalSpeed() == 0.0 && vertical == 0.0 && player.getVehicle() == null;
if (actuallyHovering) {
// check how long we've been hovering for.
if (data.getAirTicks() >= maxHover) {
// too long, flag.
getCheck().setCheckName("Flight " + ChatColor.GRAY + "(Hover)");
result.set(checkViolation(player, "hovering off the ground, hover"));
}
}
return result.failed();
}
示例5: onPlayerFall
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true)
public void onPlayerFall(PlayerMoveEvent event) {
Player player = event.getPlayer();
if (!InventoryManager.playerIsLoaded(player) || player.isFlying()
|| player.getVehicle() != null) {
return;
}
PlayerWrapper playerWrapper = InventoryManager.get(player);
boolean endFalling = false;
if (!player.isOnGround()) {
if (playerIsSneakOnLadder(player) || isPlayerCanFall(player)) {
playerWrapper.onFall();
} else if (!player.isGliding()) {
endFalling = true;
}
} else if (playerWrapper.isFalling()) {
endFalling = true;
}
if (endFalling) {
playerWrapper.setFalling(false);
}
}
示例6: onGameStart
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public void onGameStart() {
startLine.iterator().forEachRemaining(block -> {
block.setType(Material.AIR);
});
for(Player player : Bukkit.getOnlinePlayers()) {
if(!this.getAPI().getGameManager().isAlive(player)) continue;
if(player.getVehicle() != null) {
((Horse) player.getVehicle()).getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).setBaseValue(0.7D);
}
}
}
示例7: onDisable
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public void onDisable() {
this.getAPI().getGameManager().setGameState(GameState.FINISHED);
for(Player player : Bukkit.getOnlinePlayers()) {
if(player.getVehicle() != null) {
Entity vehicle = player.getVehicle();
vehicle.eject();
vehicle.remove();
}
this.getAPI().getGameManager().setAlive(player, false);
}
this.getAPI().getTranslationManager().kickPlayers("common.server-restarting");
removeCustomWorlds();
}
示例8: onPlayerMove
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler
public void onPlayerMove(PlayerMoveEvent e) {
Player p = e.getPlayer();
if (p.isInsideVehicle() && p.getVehicle() instanceof ArmorStand){
e.setCancelled(true);
}
}
示例9: isCritical
import org.bukkit.entity.Player; //导入方法依赖的package包/类
/**
* Check if an attack was a critical.
*
* @param player the player
* @return true, if the attack was registered as a critical.
*/
public static boolean isCritical(Player player) {
boolean onGround = ((Entity) player).isOnGround();
return !onGround && player.getFallDistance() > 0.0F && !LocationHelper.isInLiquid(player.getLocation())
&& (player.getLocation().getBlock().getType() != Material.LADDER
|| player.getLocation().getBlock().getType() != Material.VINE)
&& player.getVehicle() == null && !player.hasPotionEffect(PotionEffectType.BLINDNESS);
}
示例10: isImmune
import org.bukkit.entity.Player; //导入方法依赖的package包/类
/**
* Is the player in a state or situation that we should deem them not flying?
* @param player
* @return immune
*/
private static boolean isImmune(Player player) {
return player.getGameMode() != GameMode.SURVIVAL
|| Utils.getRank(player).isAtLeast(EnumRank.MEDIA) // Don't bypass this check.
|| player.isGliding() // Not using Elytra
|| player.hasPotionEffect(PotionEffectType.LEVITATION) // Doesn't have a levitation potion
|| player.getVehicle() != null // Not in a vehicle
|| player.getVelocity().getY() > 0 // Not being launched up
|| player.getNearbyEntities(1, 2, 1).stream().anyMatch(e -> e.getType() == EntityType.BOAT) // Not standing on a boat.
|| player.getLocation().getBlock().isLiquid(); // Not in water.
}
示例11: homeTeleport
import org.bukkit.entity.Player; //导入方法依赖的package包/类
/**
* Teleport player to a home location. If one cannot be found a search is done to
* find a safe place.
* @param player
* @param number - home location to do to
* @return true if successful, false if not
*/
@SuppressWarnings("deprecation")
public boolean homeTeleport(final Player player, int number) {
Location home;
if (DEBUG)
plugin.getLogger().info("home teleport called for #" + number);
home = getSafeHomeLocation(player.getUniqueId(), number);
if (DEBUG)
plugin.getLogger().info("home get safe loc = " + home);
// Check if the player is a passenger in a boat
if (player.isInsideVehicle()) {
Entity boat = player.getVehicle();
if (boat instanceof Boat) {
player.leaveVehicle();
// Remove the boat so they don't lie around everywhere
boat.remove();
player.getInventory().addItem(new ItemStack(Material.BOAT, 1));
player.updateInventory();
}
}
if (home == null) {
if (DEBUG)
plugin.getLogger().info("Fixing home location using safe spot teleport");
// Try to fix this teleport location and teleport the player if possible
new SafeSpotTeleport(plugin, player, plugin.getPlayers().getHomeLocation(player.getUniqueId(), number), number);
return true;
}
if (DEBUG)
plugin.getLogger().info("DEBUG: home loc = " + home + " teleporting");
//home.getChunk().load();
player.teleport(home);
//player.sendBlockChange(home, Material.GLOWSTONE, (byte)0);
if (number ==1 ) {
Util.sendMessage(player, ChatColor.GREEN + plugin.getLocale(player.getUniqueId()).get("island.teleport").replace("[label]", Settings.ISLANDCOMMAND));
} else {
Util.sendMessage(player, ChatColor.GREEN + plugin.getLocale(player.getUniqueId()).get("island.teleported").replace("[number]", String.valueOf(number)));
}
// Exit spectator mode if in it
if (player.getGameMode().equals(GameMode.SPECTATOR)) {
player.setGameMode(GameMode.SURVIVAL);
}
return true;
}
示例12: onSit
import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler
public void onSit(PlayerInteractEvent e){
Player p = e.getPlayer();
Block b;
if (e.getItem() == null){
if (e.getAction() == Action.RIGHT_CLICK_BLOCK){
if(p.getInventory().getItemInMainHand() != null) return;
b = e.getClickedBlock();
if (isStairs(b.getType())) {
if(!p.isSneaking() && p.getVehicle() != null) {
p.getVehicle().remove();
return;
}
p.setSneaking(false);
Location l = b.getLocation().add(0.5, -1.3, 0.3);
switch (b.getState().getData().toItemStack().getDurability()){
case 0: //west
l.setYaw(90f);
l.setZ(l.getZ() + 0.2);
break;
case 1: //east
l.setYaw(-90f);
l.setZ(l.getZ() + 0.2);
break;
case 2: //north
l.setYaw(-180f);
break;
case 3: //south
l.setYaw(0);
l.setZ(l.getZ() + 0.2);
break;
}
if (b.getState().getData().toItemStack().getDurability() >= 4) return;
ArmorStand as = (ArmorStand) p.getWorld().spawnEntity(l, EntityType.ARMOR_STAND);
as.teleport(l);
as.setVisible(false);
as.setGravity(false);
as.setMaxHealth(1);
as.setHealth(1);
as.setCustomName("wcc_silla");
as.setCustomNameVisible(false);
as.setPassenger(p);
e.setCancelled(true);
if (new Random().nextInt(10) + 1 >= 9) p.sendMessage(magic());
}
}
}
}
示例13: checkXZSpeed
import org.bukkit.entity.Player; //导入方法依赖的package包/类
public static void checkXZSpeed(Player player, double x, double z) {
if(player.getVehicle() == null && !player.isFlying() && !Flight.movingExempt.containsKey(player)) {
String reason = "";
double max = 0.25;
if(player.getLocation().getBlock().getType() == Material.SOUL_SAND) {
if(player.isSprinting()) {
reason = "on soulsand while sprinting";
max = 0.2;
} else if(player.hasPotionEffect(PotionEffectType.SPEED)) {
max = 0.16;
reason = "on soulsand with speed pot";
} else {
max = 0.13;
}
} else if(player.hasPotionEffect(PotionEffectType.SPEED)) {
if(player.isSprinting()) {
reason = "with speed pot while sprinting";
max = 0.95;
} else {
reason = "with speed pot";
max = 0.7;
}
} else if(player.isSprinting()) {
max = 0.65;
reason = "while sprinting";
}
float speed = player.getWalkSpeed();
max += speed > 0 ? player.getWalkSpeed() - 0.2f : 0;
if(x > max || z > max) {
speedViolation.put(player, speedViolation.containsKey(player) ? speedViolation.get(player) + 1 : 1);
if(speedViolation.get(player) > MagicNumbers.SPEED_MAX) {
for(Player pla : DynamicAC.instance.onlinestaff) {
pla.sendMessage(ChatColor.RED + "[DAC] " + ChatColor.GREEN + player.getName() + " failed " +
"Speed " + reason + "!");
}
DACManager.getUserManager().incrementUser(DACManager.getUserManager().getUser(player.getName()),
"Speed " + reason);
}
} else {
speedViolation.put(player, 0);
}
}
}