當前位置: 首頁>>代碼示例>>Java>>正文


Java PlayerTeleportEvent.TeleportCause方法代碼示例

本文整理匯總了Java中org.bukkit.event.player.PlayerTeleportEvent.TeleportCause方法的典型用法代碼示例。如果您正苦於以下問題:Java PlayerTeleportEvent.TeleportCause方法的具體用法?Java PlayerTeleportEvent.TeleportCause怎麽用?Java PlayerTeleportEvent.TeleportCause使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.event.player.PlayerTeleportEvent的用法示例。


在下文中一共展示了PlayerTeleportEvent.TeleportCause方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: teleport

import org.bukkit.event.player.PlayerTeleportEvent; //導入方法依賴的package包/類
/**
 * Teleports a {@link Player} to a {@link Location} with a delay.
 *
 * @param player
 *            the {@link Player} to teleport
 * @param location
 *            the {@link Location} to teleport to
 * @param millis
 *            the time in milliseconds until teleport
 * @param warmupMessage
 *            the message to send whilst waiting
 * @param cause
 *            the cause for teleporting
 * @return true if {@link Player} was successfully teleported
 */
public boolean teleport(Player player, Location location, long millis, String warmupMessage, PlayerTeleportEvent.TeleportCause cause) {
    cancelTeleport(player, null); // cancels any previous teleport for the player.

    boolean result;
    if (millis <= 0) { // if there is no delay, just instantly teleport.
        result = player.teleport(location, cause);
        clearCooldown(player.getUniqueId());
    } else {
        UUID uuid = player.getUniqueId();
        player.sendMessage(warmupMessage);
        destinationMap.put(uuid, location.clone());
        setCooldown(player, uuid, millis, true, null);
        result = true;
    }

    return result;
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:33,代碼來源:TeleportTimer.java

示例2: onTp

import org.bukkit.event.player.PlayerTeleportEvent; //導入方法依賴的package包/類
@EventHandler
public void onTp(PlayerTeleportEvent event) {

    Player player = event.getPlayer();
    PlayerTeleportEvent.TeleportCause cause = event.getCause();

    if (cause.toString().equals("SPECTATE")) {
        if (!player.hasPermission("spectatetp.tp")) {
            event.setCancelled(true);
            if (!deny_message.equals("")) {
                player.sendMessage(deny_message);
            }
        }
    }

}
 
開發者ID:jonthesquirrel,項目名稱:SpectateTP,代碼行數:17,代碼來源:SpectateTP.java

示例3: teleport

import org.bukkit.event.player.PlayerTeleportEvent; //導入方法依賴的package包/類
@Override
public boolean teleport(Location location, PlayerTeleportEvent.TeleportCause cause) {
    if (getHealth() == 0) {
        return false;
    }

    return super.teleport(location, cause);
}
 
開發者ID:UraniumMC,項目名稱:Uranium,代碼行數:9,代碼來源:CraftLivingEntity.java

示例4: teleport

import org.bukkit.event.player.PlayerTeleportEvent; //導入方法依賴的package包/類
public void teleport(Location location, PlayerTeleportEvent.TeleportCause cause) {
    unstack();
    for (EEntity entity : entities) {
        entity.bukkit().teleport(location, cause);
    }
    stack();
}
 
開發者ID:GameBoxx,項目名稱:GameBoxx,代碼行數:8,代碼來源:EntityStack.java

示例5: onPlayerTeleport

import org.bukkit.event.player.PlayerTeleportEvent; //導入方法依賴的package包/類
@EventHandler
public void onPlayerTeleport(PlayerTeleportEvent e) { PlayerTeleportEvent.TeleportCause cause = e.getCause();
  Player player = e.getPlayer();
  if (((redTeam.contains(player)) || (blueTeam.contains(player))) && 
    (cause == PlayerTeleportEvent.TeleportCause.ENDER_PEARL))
    e.setCancelled(true);
}
 
開發者ID:Dragonzslayer,項目名稱:TeamTag-plugin,代碼行數:8,代碼來源:main.java

示例6: teleport

import org.bukkit.event.player.PlayerTeleportEvent; //導入方法依賴的package包/類
@Override
public boolean teleport(Location location, PlayerTeleportEvent.TeleportCause cause) {
    if (this.getPassenger() != null || this.isDead()) {
        return false;
    }
    if (this.eject()) {
        getHandle().setTransform(LocationConverter.toTransform(location));
        // CraftBukkit apparently does not throw an event when this method is called
        return true;
    }
    return false;
}
 
開發者ID:LapisBlue,項目名稱:Pore,代碼行數:13,代碼來源:PoreEntity.java

示例7: teleport

import org.bukkit.event.player.PlayerTeleportEvent; //導入方法依賴的package包/類
@Override
public boolean teleport(Location location, PlayerTeleportEvent.TeleportCause cause) {
    net.minecraft.entity.player.EntityPlayerMP entity = getHandle();

    if (getHealth() == 0 || entity.isDead) {
        return false;
    }

    if (entity.playerNetServerHandler == null || entity.playerNetServerHandler.isDisconnected()) {
        return false;
    }

    // Spigot Start
    // if (entity.vehicle != null || entity.passenger != null) {
    // return false;
    // }
    // Spigot End

    // From = Players current Location
    Location from = this.getLocation();
    // To = Players new Location if Teleport is Successful
    Location to = location;
    // Create & Call the Teleport Event.
    PlayerTeleportEvent event = new PlayerTeleportEvent(this, from, to, cause);
    server.getPluginManager().callEvent(event);

    // Return False to inform the Plugin that the Teleport was unsuccessful/cancelled.
    if (event.isCancelled()) {
        return false;
    }
    
    // Spigot Start
    eject();
    leaveVehicle();
    // Spigot End

    // Update the From Location
    from = event.getFrom();
    // Grab the new To Location dependent on whether the event was cancelled.
    to = event.getTo();
    // Grab the To and From World Handles.
    net.minecraft.world.WorldServer fromWorld = ((CraftWorld) from.getWorld()).getHandle();
    net.minecraft.world.WorldServer toWorld = ((CraftWorld) to.getWorld()).getHandle();

    // Close any foreign inventory
    if (getHandle().openContainer != getHandle().inventoryContainer) {
        getHandle().closeScreen();
    }

    // Check if the fromWorld and toWorld are the same.
    if (fromWorld == toWorld) {
        entity.playerNetServerHandler.teleport(to);
    } else {
        server.getHandle().respawnPlayer(entity, toWorld.dimension, cause, to); // Cauldron
    }
    return true;
}
 
開發者ID:UraniumMC,項目名稱:Uranium,代碼行數:58,代碼來源:CraftPlayer.java

示例8: DelayedPlayerTeleportEvent

import org.bukkit.event.player.PlayerTeleportEvent; //導入方法依賴的package包/類
public DelayedPlayerTeleportEvent(Player player, Location from, Location to, PlayerTeleportEvent.TeleportCause cause) {
    this.player = PlayerModule.getInstance().getPlayer(player);
    this.from = from;
    this.to = to;
    this.cause = cause;
}
 
開發者ID:ThEWiZ76,項目名稱:KingdomFactions,代碼行數:7,代碼來源:DelayedPlayerTeleportEvent.java

示例9: teleport

import org.bukkit.event.player.PlayerTeleportEvent; //導入方法依賴的package包/類
@Override
public boolean teleport(Location location, PlayerTeleportEvent.TeleportCause teleportCause) {
    return implementation.teleport(location, teleportCause);
}
 
開發者ID:shawlaf,項目名稱:Banmanager,代碼行數:5,代碼來源:CraftBanmanagerUser.java

示例10: teleport

import org.bukkit.event.player.PlayerTeleportEvent; //導入方法依賴的package包/類
@Override
public boolean teleport( Location location, PlayerTeleportEvent.TeleportCause teleportCause ) {
    return this.teleport( location );
}
 
開發者ID:lukas81298,項目名稱:FlexMC,代碼行數:5,代碼來源:FlexEntity.java

示例11: teleport

import org.bukkit.event.player.PlayerTeleportEvent; //導入方法依賴的package包/類
@Override
public boolean teleport( Location location, PlayerTeleportEvent.TeleportCause teleportCause ) {
    return false;
}
 
開發者ID:lukas81298,項目名稱:FlexMC,代碼行數:5,代碼來源:TempPlayer.java

示例12: teleport

import org.bukkit.event.player.PlayerTeleportEvent; //導入方法依賴的package包/類
@Override
public boolean teleport(Location location, PlayerTeleportEvent.TeleportCause cause) {
    return player.teleport(location, cause);
}
 
開發者ID:CyR1en,項目名稱:Minecordbot,代碼行數:5,代碼來源:DiscordPlayerCommandSender.java

示例13: teleport

import org.bukkit.event.player.PlayerTeleportEvent; //導入方法依賴的package包/類
@Override
public boolean teleport(Location location, PlayerTeleportEvent.TeleportCause cause) {
    if (!Sponge.isServerAvailable()) return false;
    return getSpongeEntity().setLocation(convertToSpongeLocation(location));
}
 
開發者ID:Proximyst,項目名稱:Bukkit2Sponge,代碼行數:6,代碼來源:LinkedEntity.java

示例14: teleport

import org.bukkit.event.player.PlayerTeleportEvent; //導入方法依賴的package包/類
@Override
public boolean teleport(Location location, PlayerTeleportEvent.TeleportCause cause) {
    return false;
}
 
開發者ID:Proximyst,項目名稱:Bukkit2Sponge,代碼行數:5,代碼來源:LinkedPlayer.java

示例15: teleport

import org.bukkit.event.player.PlayerTeleportEvent; //導入方法依賴的package包/類
@Override
public boolean teleport(Location location, PlayerTeleportEvent.TeleportCause cause) {
    net.minecraft.entity.player.EntityPlayerMP entity = getHandle();

    if (getHealth() == 0 || entity.isDead) {
        return false;
    }

    if (entity.playerNetServerHandler == null || entity.playerNetServerHandler.isDisconnected()) {
        return false;
    }

    // Spigot Start
    // if (entity.vehicle != null || entity.passenger != null) {
    // return false;
    // }
    // Spigot End

    // From = Players current Location
    Location from = this.getLocation();
    // To = Players new Location if Teleport is Successful
    Location to = location;
    // Create & Call the Teleport Event.
    PlayerTeleportEvent event = new PlayerTeleportEvent(this, from, to, cause);
    server.getPluginManager().callEvent(event);

    // Return False to inform the Plugin that the Teleport was unsuccessful/cancelled.
    if (event.isCancelled()) {
        return false;
    }
    
    // Spigot Start
    eject();
    leaveVehicle();
    // Spigot End

    // Update the From Location
    from = event.getFrom();
    // Grab the new To Location dependent on whether the event was cancelled.
    to = event.getTo();
    // Grab the To and From World Handles.
    net.minecraft.world.WorldServer fromWorld = ((CraftWorld) from.getWorld()).getHandle();
    net.minecraft.world.WorldServer toWorld = ((CraftWorld) to.getWorld()).getHandle();

    // Close any foreign inventory
    if (getHandle().openContainer != getHandle().inventoryContainer) {
        getHandle().closeScreen();
    }

    // Check if the fromWorld and toWorld are the same.
    if (fromWorld == toWorld) {
        entity.playerNetServerHandler.teleport(to);
    } else {
        server.getHandle().respawnPlayer(entity, toWorld.dimension, false, to); // Cauldron
    }
    return true;
}
 
開發者ID:CyberdyneCC,項目名稱:ThermosRebased,代碼行數:58,代碼來源:CraftPlayer.java


注:本文中的org.bukkit.event.player.PlayerTeleportEvent.TeleportCause方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。