Java 类org.bukkit.event.player.PlayerTeleportEvent.TeleportCause 实例源码

项目:Uranium    文件:CraftEntity.java   
public boolean teleport(Location location, TeleportCause cause) {
    if (entity.ridingEntity != null || entity.riddenByEntity != null || entity.isDead) {
        return false;
    }

    // Spigot start
    net.minecraft.world.WorldServer newWorld = ((CraftWorld) location.getWorld()).getHandle();
    if (newWorld != entity.worldObj) {
        entity.teleportTo(location, cause.isPortal());
        return true;
    }
    // Spigot
    entity.setPositionAndRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
    // entity.setLocation() throws no event, and so cannot be cancelled
    return true;
}
项目:SkyWarsReloaded    文件:CreateMapCmd.java   
@Override
public boolean run() {
    Location spawn = SkyWarsReloaded.getCfg().getSpawn();
    if (spawn == null) {
        sender.sendMessage(ChatColor.RED + "YOU MUST SET SPAWN BEFORE YOU CAN CREATE A MAP");
        return true;
    }
    String worldName = args[1].toLowerCase();
    if (!SkyWarsReloaded.getMC().mapExists(worldName.toLowerCase())) {
        World newWorld = SkyWarsReloaded.getWC().createEmptyWorld(worldName);
        if (newWorld == null) {
            sender.sendMessage(new Messaging.MessageFormatter().format("error.map.world.exists"));
            return true;
        }
        SkyWarsReloaded.getMC().addEditMap(worldName);
        sender.sendMessage(new Messaging.MessageFormatter().setVariable("mapname", worldName).format("maps.created"));
        if (sender instanceof Player) {
            Player player = (Player) sender;
            player.teleport(new Location(newWorld, 0, 21, 0), TeleportCause.PLUGIN);
        }
        return true;
    } else {
        sender.sendMessage(new Messaging.MessageFormatter().format("error.map-exists"));
        return true;
    }
}
项目:SkyWarsReloaded    文件:SpectatorListener.java   
final void repellExpOrb(final Player player, final ExperienceOrb orb) {
    final Location pLoc = player.getLocation();
    final Location oLoc = orb.getLocation();
    final Vector dir = oLoc.toVector().subtract(pLoc.toVector());
    final double dx = Math.abs(dir.getX());
    final double dz = Math.abs(dir.getZ());
    if ( (dx == 0.0) && (dz == 0.0)){
        // Special case probably never happens
        dir.setX(0.001);
    }
    if ((dx < 3.0) && (dz < 3.0)){
        final Vector nDir = dir.normalize();
        final Vector newV = nDir.clone().multiply(0.3);
        newV.setY(0);
        orb.setVelocity(newV);
        if ((dx < 1.0) && (dz < 1.0)){
            // maybe oLoc
            orb.teleport(oLoc.clone().add(nDir.multiply(1.0)), TeleportCause.PLUGIN);
        } 
        if ((dx < 0.5) && (dz < 0.5)){
            orb.remove();
        } 
    } 
}
项目:Chambers    文件:VillagerManager.java   
/**
 * Spawns a Villager of the given VillagerType at the provided Location
 * 
 * @param type - the Type of the Villager you wish to Spawn
 * @param location - the Location at which you want the Villager to be
 * @return Villager - the Villager that you had set at the provided Location if you wish to use it
 */
public Villager spawnVillager(VillagerType type, Location location) {
    if (!location.getChunk().isLoaded()) {
        location.getChunk().load();
    }
    Villager villager = (Villager) location.getWorld().spawnEntity(location, EntityType.VILLAGER);
    villager.setAdult();
    villager.setAgeLock(true);
    villager.setProfession(Profession.FARMER);
    villager.setRemoveWhenFarAway(false);
    villager.setCustomName(type.getColor() + type.getName());
    villager.setCustomNameVisible(true);
    villager.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, -6, true), true);
    villager.teleport(location, TeleportCause.PLUGIN);
    villager.setHealth(20.0D);
    return villager;
}
项目:GriefPreventionFlags    文件:FlagDef_NoEnderPearl.java   
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerTeleport(PlayerTeleportEvent event)
{
    if(event.getCause() != TeleportCause.ENDER_PEARL) return;

    Flag flag = this.GetFlagInstanceAtLocation(event.getFrom(), event.getPlayer());
    if(flag != null)
    {
        event.setCancelled(true);
    }

    flag = this.GetFlagInstanceAtLocation(event.getTo(), event.getPlayer());
    if(flag != null)
    {
        event.setCancelled(true);
    }
}
项目:GriefPreventionFlags    文件:FlagDef_NoChorusFruit.java   
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerTeleport(PlayerTeleportEvent event)
{
    if(event.getCause() != TeleportCause.CHORUS_FRUIT) return;

    Flag flag = this.GetFlagInstanceAtLocation(event.getFrom(), event.getPlayer());
    if(flag != null)
    {
        event.setCancelled(true);
    }

    flag = this.GetFlagInstanceAtLocation(event.getTo(), event.getPlayer());
    if(flag != null)
    {
        event.setCancelled(true);
    }
}
项目:ThermosRebased    文件:CraftEntity.java   
public boolean teleport(Location location, TeleportCause cause) {
    if (entity.ridingEntity != null || entity.riddenByEntity != null || entity.isDead) {
        return false;
    }

    // Spigot start
    net.minecraft.world.WorldServer newWorld = ((CraftWorld) location.getWorld()).getHandle();
    if (newWorld != entity.worldObj) {
        entity.teleportTo(location, cause.isPortal());
        return true;
    }
    // Spigot
    entity.setPositionAndRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
    // entity.setLocation() throws no event, and so cannot be cancelled
    return true;
}
项目:Breakpoint    文件:CTFListener.java   
@Override
public void onPlayerTeleport(PlayerTeleportEvent event, BPPlayer bpPlayer)
{
    TeleportCause cause = event.getCause();

    if(cause == TeleportCause.ENDER_PEARL)
    {
        CTFGame game = getGame();
        FlagManager flm = game.getFlagManager();

        if(flm.isHoldingFlag(bpPlayer))
        {
            Player player = bpPlayer.getPlayer();
            event.setCancelled(true);
            player.sendMessage(MessageType.OTHER_WARNPEARL.getTranslation().getValue());
        }
    }
}
项目:iZenith-PVP    文件:TeleportListener.java   
@EventHandler
public void onTeleport(final PlayerTeleportEvent e) {
    final Player p = e.getPlayer();
    if (e.getCause().equals(TeleportCause.SPECTATE)
            && !(p.hasPermission("essentials.tp"))){ 
        e.setCancelled(true);
        p.sendMessage(ChatColor.RED + "You do not have permission to /tp");
    }

    if (!e.getFrom().getWorld().equals(e.getTo().getWorld())) {
        MultiverseCore mv = (MultiverseCore) Bukkit.getServer()
                .getPluginManager().getPlugin("Multiverse-Core");
        MVWorldManager wm = mv.getMVWorldManager();
        MultiverseWorld toWorld = wm.getMVWorld(e.getTo().getWorld()
                .getName());
        MultiverseWorld fromWorld = wm.getMVWorld(e.getFrom().getWorld()
                .getName());
        if (toWorld != fromWorld
                && !p.getGameMode().equals(toWorld.getGameMode())) {
            p.setGameMode(toWorld.getGameMode());
        }
    }
}
项目:Skellett    文件:EffNpcTeleport.java   
@Override
protected void execute(Event e) {
    if (teleportcause == null && teleportcausestring == null && location != null) {
        npc.getSingle(e).teleport(location.getSingle(e), TeleportCause.PLUGIN);
    } else if (location != null) {
        if (marker == 1) {
            npc.getSingle(e).teleport(location.getSingle(e), teleportcause.getSingle(e));
        } else {
            TeleportCause t = TeleportCause.valueOf(teleportcausestring.getSingle(e).replace("\"", "").trim().replace(" ", "_").toUpperCase());
            try {
                t = TeleportCause.valueOf(t.toString().replace("\"", "").trim().replace(" ", "_").toUpperCase());
            } catch (IllegalArgumentException error) {
                Skript.error(t.toString() + " Unknown teleortcause type");
                return;
            }
            if (t != null) {
                npc.getSingle(e).teleport(location.getSingle(e), t);
            }
        }
    }
}
项目:Thermos    文件:CraftEntity.java   
public boolean teleport(Location location, TeleportCause cause) {
       if (entity.ridingEntity != null || entity.riddenByEntity != null || entity.isDead) {
           return false;
       }

       // Spigot start
       net.minecraft.world.WorldServer newWorld = ((CraftWorld) location.getWorld()).getHandle();
       if (newWorld != entity.worldObj) {
           entity.teleportTo(location, cause.isPortal());
           return true;
       }
       // Spigot end
       entity.setPositionAndRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
//entity.worldObj.entityJoinedWorld(entity, false); // PaperSpigot - Prevent Server from thinking a player teleporting within the world has joined the world
       // entity.setLocation() throws no event, and so cannot be cancelled
       return true;
   }
项目:KCauldron    文件:CraftEntity.java   
public boolean teleport(Location location, TeleportCause cause) {
    if (entity.ridingEntity != null || entity.riddenByEntity != null || entity.isDead) {
        return false;
    }

    // Spigot start
    net.minecraft.world.WorldServer newWorld = ((CraftWorld) location.getWorld()).getHandle();
    if (newWorld != entity.worldObj) {
        entity.teleportTo(location, cause.isPortal());
        return true;
    }
    // Spigot
    entity.setPositionAndRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
    // entity.setLocation() throws no event, and so cannot be cancelled
    return true;
}
项目:RedProtect    文件:RPPlayerListener.java   
private void deathListener(Player p, int index){
    RedProtect.get().logger.debug("Added index "+index);

    HashMap<Integer, Location> loc1 = new HashMap<>();
    if (!deathLocs.containsKey(p.getName())){
        loc1.put(index, p.getLocation());
        deathLocs.put(p.getName(), loc1);
    } else {
        loc1 = deathLocs.get(p.getName());

        loc1.put(index, p.getLocation());
        deathLocs.put(p.getName(), loc1);    

        if (loc1.size() == 2){
            Location from = deathLocs.get(p.getName()).get(0);
            Location to = deathLocs.get(p.getName()).get(1);
            deathLocs.remove(p.getName());
            PlayerTeleportEvent televent = new PlayerTeleportEvent(p, from, to, TeleportCause.PLUGIN);
            Bukkit.getPluginManager().callEvent(televent);
        }
    }       
}
项目:FFoKC    文件:CraftEntity.java   
public boolean teleport(Location location, TeleportCause cause) {
    if (entity.ridingEntity != null || entity.riddenByEntity != null || entity.isDead) {
        return false;
    }

    // Spigot start
    net.minecraft.world.WorldServer newWorld = ((CraftWorld) location.getWorld()).getHandle();
    if (newWorld != entity.worldObj) {
        entity.teleportTo(location, cause.isPortal());
        return true;
    }
    // Spigot
    entity.setPositionAndRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
    // entity.setLocation() throws no event, and so cannot be cancelled
    return true;
}
项目:Ultra-Hardcore-1.8    文件:EvGame.java   
@EventHandler
public void damager(EntityDamageEvent a) {
    if (eA.mC.cFa && eA.mA.i() > 3 && eA.mA.i() < 7 && a.getEntity() instanceof Player) {
        if (eA.mA.i() != 6 && a.getCause().equals(DamageCause.VOID)) {
            a.getEntity().teleport(a.getEntity().getWorld().getSpawnLocation().add(0.5, 1, 0.5), TeleportCause.PLUGIN);
            a.getEntity().setFallDistance(0f);
        }
        a.setCancelled(true);
        return;
    }
    if (eA.mC.cOa && eA.mA.i() == 7 && a.getEntity() instanceof Player) {
        UHCPlayer b = eA.mB.getPlayer(a.getEntity().getName());
        if (eA.mE.getIngamePlayers().contains(b.uB.getName())) {
            b.dmgStorage(eA.mE.gL, a.getDamage(), eA.mE.gF.source(a));
        }
    }
}
项目:Breakpoint    文件:CTFListener.java   
@Override
public void onPlayerTeleport(PlayerTeleportEvent event, BPPlayer bpPlayer)
{
    TeleportCause cause = event.getCause();

    if(cause == TeleportCause.ENDER_PEARL)
    {
        CTFGame game = getGame();
        FlagManager flm = game.getFlagManager();

        if(flm.isHoldingFlag(bpPlayer))
        {
            Player player = bpPlayer.getPlayer();
            event.setCancelled(true);
            player.sendMessage(MessageType.OTHER_WARNPEARL.getTranslation().getValue());
        }
    }
}
项目:Tweakkit-Server    文件:CraftEntity.java   
public boolean teleport(Location location, TeleportCause cause) {
    if (entity.passenger != null || entity.dead) {
        return false;
    }

    // If this entity is riding another entity, we must dismount before teleporting.
    entity.mount(null);

    // Spigot start
    if (!location.getWorld().equals(getWorld())) {
      entity.teleportTo(location, cause.equals(TeleportCause.NETHER_PORTAL));
      return true;
    }

    // entity.world = ((CraftWorld) location.getWorld()).getHandle();
    // Spigot end
    entity.setLocation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
    // entity.setLocation() throws no event, and so cannot be cancelled
    return true;
}
项目:CraftoPlugin    文件:PortalListener.java   
@EventHandler
public void onPlayerPortal(PlayerPortalEvent event) {
    if (!event.getCause().equals(TeleportCause.NETHER_PORTAL)) { return; }

    Location cornerLocation = PortalUtils.findCornerBlock(event.getFrom()).orElse(null);
    if (cornerLocation == null) { debug("Couldnt find cornerLoc for loc: " + Utility.toString(event.getFrom())); return; }

    Portal portal = this.module.storage.getPortal(cornerLocation).orElse(null);
    if (portal == null) { debug("Couldnt find portal for cornerLoc: " + Utility.toString(cornerLocation)); return; }

    CraftoPlayer player = CraftoPlayer.getPlayer(event.getPlayer()).orElse(null);

    if (!event.getPlayer().hasPermission("craftoplugin.portal.always-teleport")) {
        if (player != null && player.getPlaytime().toMinutes() < this.minPlaytime.toMinutes()) {
            debug(event.getPlayer().getName() + " failed to teleport because he doesn't have permission!");
            CraftoMessenger.sendFailure(event.getPlayer(), "Du kannst erst ab " + this.minPlaytime.toMinutes() + " Minuten Spielzeit das Portal nutzen!");
            event.setCancelled(true);
            return;
        }
    }

    event.useTravelAgent(false);
    event.setTo(portal.getDestination());

    debug("Teleported " + event.getPlayer().getName() + " to dest of portal '" + portal.getName() + "'");
}
项目:CraftoPlugin    文件:ReturnComponent.java   
@CommandHandler("return")
@Permission("craftoplugin.teleport.return")
public void returnCommand(final CommandSender cs, final String[] args) {
    if (!(cs instanceof Player)) { CraftoMessenger.sendFailure(cs, Messages.PLAYERS_ONLY); return; }
    Player sender = (Player)cs;
    Location destination = null;

    if (args.length > 0 && cs.hasPermission("craftoplugin.teleport.return.other")) {
        Optional<CraftoPlayer> target = CraftoPlayer.getPlayer(args[0]);
        if (target.isPresent()) { destination = this.returnLocationMap.get(target.get().getUniqueId()); }
    }
    else { destination = this.returnLocationMap.get(sender.getUniqueId()); }

    if (destination == null) { CraftoMessenger.sendFailure(cs, "Es konnte keine Returnposition gefunden werden!"); return; }

    final Location loc = this.returnLocationMap.get(sender.getUniqueId());
    this.module.teleport(sender, loc, TeleportCause.COMMAND, true);
}
项目:CraftoPlugin    文件:SpawnComponent.java   
@CommandHandler("spawn")
@Permission("craftoplugin.spawn.spawn")
@Description("Teleportiert dich zum Spawn")
public void spawnCommand(CommandSender cs, String[] args) {
    if (!(cs instanceof Player)) { CraftoMessenger.sendFailure(cs, Messages.PLAYERS_ONLY); return; }
    final Player sender = (Player)cs;

    if (!this.module.spawnLoc.isPresent()) { CraftoMessenger.sendFailure(cs, "Es konnte keine Spawnposition gefunden werden."); return; }
    final Location3w loc = new Location3w(this.module.spawnLoc.get());

    final Optional<TeleportModule> teleportModule = this.module.getModule(TeleportModule.class);
    if (teleportModule.isPresent()) {
        teleportModule.get().teleport(sender, loc, TeleportCause.COMMAND);
    }
    else { sender.teleport(loc); }

}
项目:NucleusFramework    文件:InternalTeleportManager.java   
@Override
public ITeleportResult teleport(Player player, Location location,
                        TeleportCause cause, TeleportMode mode) {
    PreCon.notNull(player);
    PreCon.notNull(location);
    PreCon.notNull(cause);
    PreCon.notNull(mode);

    if (META.has(player, TELEPORT_DENY_META_NAME))
        return new TeleportHandler(player, cause, mode);

    ScheduledTeleport scheduled = _scheduled.remove(player.getUniqueId());
    if (scheduled != null)
        scheduled.cancel();

    return new TeleportHandler(player, cause, mode).teleport(location);
}
项目:NucleusFramework    文件:ScheduledTeleport.java   
/**
 * Constructor.
 *
 * @param manager   The owning manager instance.
 * @param player    The player.
 * @param delay     The scheduled delay in ticks.
 * @param location  The location to teleport the player.
 * @param cause     The teleport cause.
 */
ScheduledTeleport(InternalTeleportManager manager, Player player, int delay,
                  Location location, TeleportCause cause, TeleportMode mode) {
    PreCon.notNull(manager);
    PreCon.notNull(player);
    PreCon.notNull(location);
    PreCon.notNull(cause);
    PreCon.notNull(mode);

    _manager = manager;
    _player = player;
    _delay = delay;
    _location = location;
    _agent = new FutureResultAgent<ITeleportResult>();
    _future = _agent.getFuture();
    _cause = cause;
    _mode = mode;
}
项目:NucleusFramework    文件:JCGEventListener.java   
@EventHandler(priority=EventPriority.MONITOR, ignoreCancelled = true)
private void onPlayerTeleport(PlayerTeleportEvent event) {

    if (event.getFrom() == null || event.getTo() == null)
        return;

    // player teleporting to a different world
    if (!event.getFrom().getWorld().equals(event.getTo().getWorld())) {

        PlayList.clearQueue(event.getPlayer());
    }

    if (event.getCause() != TeleportCause.UNKNOWN) {
        _regionManager.getPlayerWatcher()
                .updatePlayerLocation(event.getPlayer(), event.getTo(), RegionEventReason.TELEPORT);
    }
}
项目:SpigotSource    文件:CraftEntity.java   
public boolean teleport(Location location, TeleportCause cause) {
    if (entity.isVehicle() || entity.dead) {
        return false;
    }

    // If this entity is riding another entity, we must dismount before teleporting.
    entity.stopRiding();

    // Spigot start
    if (!location.getWorld().equals(getWorld())) {
      entity.teleportTo(location, cause.equals(TeleportCause.NETHER_PORTAL));
      return true;
    }

    // entity.world = ((CraftWorld) location.getWorld()).getHandle();
    // Spigot end
    entity.setLocation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
    entity.world.entityJoinedWorld(entity, false); // Spigot - register to new chunk
    // entity.setLocation() throws no event, and so cannot be cancelled
    return true;
}
项目:xEssentials-deprecated-bukkit    文件:CmdTpAccept.java   
public boolean execute(CommandSender sender, Command cmd, String[] args) {
    if(cmd.getName().equalsIgnoreCase("tpaccept")) {
        if(sender.hasPermission(PermissionKey.CMD_TP_ACCEPT.getPermission())) {
            if(pl.getManagers().getTpaManager().containsKey(sender.getName())) {
                Player p = (Player) sender;
                Player victem = pl.getManagers().getPlayerManager().getOfflinePlayer(pl.getManagers().getTpaManager().get(sender.getName())).getBukkitPlayer();
                if(victem instanceof Player) {
                    victem.teleport(p, TeleportCause.COMMAND);
                    sendMessageTo(victem, sender.getName() + " has successfully accepted your tpa request!");
                    sendMessage("you have successfully accepted " + victem.getName() + " his tpa request!");
                    pl.getManagers().getTpaManager().remove(sender.getName());
                } else {
                    sendMessage("the player went offline!");
                    pl.getManagers().getTpaManager().remove(sender.getName());
                }
            } else {
                sendMessage("you don't have tpa requests open!");
            }
        } else {
            getWarning(WarningType.NO_PERMISSION);
        }
    }
    return false;
}
项目:xEssentials-deprecated-bukkit    文件:StaffSafeTeleportEvent.java   
@EventHandler
public void onStaffTeleport(PlayerTeleportEvent e) {
    if(e.getCause() == TeleportCause.PLUGIN) {
        XPlayer xp = pl.getManagers().getPlayerManager().getPlayer(e.getPlayer().getName());
        if(xp.isStaff()) {
            if(xp.isVanished()) {
                return;
            } else if(xp.getBukkitPlayer().getGameMode() == GameMode.CREATIVE) {
                return;
            } else {
                if(staff.containsKey(e.getPlayer().getName())) {
                    Bukkit.getScheduler().cancelTask(staff.get(e.getPlayer().getName()));
                    staff.remove(e.getPlayer().getName());
                    staff.put(e.getPlayer().getName(), staffScheduler(e.getPlayer()));
                    sendMessage(e.getPlayer(), ChatColor.GRAY + "teleportation safety against damage has been " + ChatColor.GREEN + "enabled!");
                } else {
                    staff.put(e.getPlayer().getName(), staffScheduler(e.getPlayer()));
                    sendMessage(e.getPlayer(), ChatColor.GRAY + "teleportation safety against damage has been " + ChatColor.GREEN + "enabled!");
                }
            }
        }
    }
}
项目:ZvP    文件:ArenaLobby.java   
public void addPlayerToLobby(final ZvPPlayer player) {

BukkitTask kitSelectTask = Bukkit.getScheduler().runTaskLater(ZvP.getInstance(), new Runnable() {

    @Override
    public void run() {
    player.openKitSelectGUI();
    addPlayer(player);
    }
}, (int) Math.ceil(this.arena.getConfig().getJoinTime() / 4) * 20L);

this.openKitSelectTasks.put(player, kitSelectTask);
player.getPlayer().teleport(getRandomLocation(), TeleportCause.PLUGIN);
player.getPlayer().setGameMode(GameMode.SURVIVAL);
player.getArena().addPreLobbyPlayer(player);
player.setSpawnProtected(true); // INFO Messy workaround need cleaner solution
this.joinProcessRunning = true;

ZvP.getPluginLogger().log(this.getClass(), Level.INFO, "Player " + player.getName() + " joined PreLobby " + this.arena.getID(), true, true);
   }
项目:ZvP    文件:PlayerListener.java   
@EventHandler
   public void onPlayerMove(PlayerMoveEvent event) {
this.eventPlayer = event.getPlayer();

if (this.game.getPlayer(this.eventPlayer) != null) {
    ZvPPlayer zPlayer = this.game.getPlayer(this.eventPlayer);
    if (zPlayer.getArena().hasPreLobby()) {
    if (zPlayer.getArena().isWaiting()) {

        if (event.getTo().distanceSquared(event.getFrom()) > 0.0) {
        this.eventPlayer.teleport(event.getFrom(), TeleportCause.PLUGIN);
        return;
        }
    }
    }
}
   }
项目:Essentials    文件:Commandjump.java   
@Override
public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
    Location loc;
    final Location cloc = user.getPlayer().getLocation();

    try
    {
        loc = LocationUtil.getTarget(user.getPlayer());
        loc.setYaw(cloc.getYaw());
        loc.setPitch(cloc.getPitch());
        loc.setY(loc.getY() + 1);
    }
    catch (NullPointerException ex)
    {
        throw new Exception(_("§4That would hurt your computer's brain."), ex);
    }

    final Trade charge = new Trade(commandName, ess);
    charge.isAffordableFor(user);
    user.getTeleport().teleport(loc, charge, TeleportCause.COMMAND);
    throw new NoChargeException();
}
项目:Essentials    文件:Commandwarp.java   
@Override
protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
    if (args.length < 2 || args[0].matches("[0-9]+"))
    {
        warpList(sender, args);
        throw new NoChargeException();
    }
    IUser otherUser = ess.getUserMap().matchUser(args[1], false);
    if (otherUser == null)
    {
        throw new Exception(_("§4Player not found."));
    }
    otherUser.getTeleport().warp(args[0], null, TeleportCause.COMMAND);
    throw new NoChargeException();

}
项目:Essentials    文件:Commandtphere.java   
@Override
public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
    final IUser player = ess.getUserMap().matchUserExcludingHidden(args[0], user.getPlayer());
    if (!player.getData().isTeleportEnabled())
    {
        throw new Exception(_("§c{0} §4has teleportation disabled.", player.getPlayer().getDisplayName()));
    }
    ISettings settings = ess.getSettings();
    if (settings.getData().getGeneral().isPerGroupTeleport() && !Permissions.PERGROUPTELEPORT.isAuthorized(
            user, ess.getRanks().getMainGroup(player)))
    {
        throw new Exception(_("§4You do not have the §c{0}§4 permission.", "essentials.teleport.groups." + ess.getRanks().getMainGroup(player)));
    }

    user.getTeleport().teleportToMe(player, new Trade(commandName, ess), TeleportCause.COMMAND);
    user.sendMessage(_("§6Teleporting..."));
    player.sendMessage(_("§6Teleporting..."));
    throw new NoChargeException();
}
项目:Essentials    文件:Teleport.java   
private void teleport(Target target, Trade chargeFor, TeleportCause cause) throws Exception
{
    final double delay = ess.getRanks().getTeleportDelay(user);

    if (chargeFor != null)
    {
        chargeFor.isAffordableFor(user);
    }
    cooldown(true);
    if (delay <= 0 || Permissions.TELEPORT_TIMER_BYPASS.isAuthorized(user))
    {
        cooldown(false);
        now(target, cause);
        if (chargeFor != null)
        {
            chargeFor.charge(user);
        }
        return;
    }

    cancel();
    warnUser(user, delay);
    initTimer((long)(delay * 1000.0), target, chargeFor, cause);

    teleTimer = ess.getPlugin().scheduleSyncRepeatingTask(this, 10, 10);
}
项目:Essentials    文件:Teleport.java   
@Override
public void now(final Target target, final TeleportCause cause) throws Exception
{
    cancel();
    user.setLastLocation();
    final Location loc = LocationUtil.getSafeDestination(target.getLocation());
    ess.getPlugin().scheduleSyncDelayedTask(
            new Runnable()
            {
                @Override
                public void run()
                {
                    user.getPlayer().teleport(loc, cause);
                }
            });
}
项目:Essentials    文件:SignWarp.java   
@Override
protected boolean onSignInteract(final ISign sign, final IUser player, final String username, final IEssentials ess) throws SignException, ChargeException
{
    final String warpName = sign.getLine(1);
    final String group = sign.getLine(2);

    if ((!group.isEmpty() && ("§2Everyone".equals(group) || ess.getRanks().inGroup(player, group))) || (group.isEmpty() && Permissions.WARPS.isAuthorized(player, warpName)))
    {
        final Trade charge = getTrade(sign, 3, ess);
        try
        {
            player.getTeleport().warp(warpName, charge, TeleportCause.PLUGIN);
        }
        catch (Exception ex)
        {
            throw new SignException(ex.getMessage(), ex);
        }
        return true;
    }
    return false;
}
项目:Uranium    文件:CraftPlayer.java   
@Override
public void respawn()
{
    if ( getHealth() <= 0 && isOnline() )
    {
        server.getServer().getConfigurationManager().respawnPlayer( getHandle(), 0, TeleportCause.DEATH, null );
    }
}
项目:AntiCheat    文件:OrebfuscatorPlayerListener.java   
@EventHandler(priority=EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerTeleport(PlayerTeleportEvent event) {
    if (OrebfuscatorConfig.UseProximityHider) {
        if(event.getCause() != TeleportCause.END_PORTAL
                && event.getCause() != TeleportCause.NETHER_PORTAL
                )
        {
            ProximityHider.addPlayerToCheck(event.getPlayer(), null);
        }
    }
}
项目:AddGun    文件:StandardGun.java   
/**
 * Based on shooting the gun, jerks the player's head to the direction of firing
 * 
 * @param entity the entity shooting
 * @param direction the direction of shot
 */
public void knockback(LivingEntity entity, Vector direction) {
    if (entity instanceof Player) {
        Player p = (Player) entity;
        Vector begin = p.getEyeLocation().getDirection().clone();
        Vector end = begin.clone().getMidpoint(direction).getMidpoint(begin); // 25% of "direction" between start and where fire occurred.
        long kickback = Math.max(Math.min(this.cooldown / 3, (long) Animation.FRAME_DELAY * 3l), (long) Animation.FRAME_DELAY * 2l);
        long kickdown = Math.max((long) Animation.FRAME_DELAY * 2l, this.cooldown - kickback);
        AddGun.getPlugin().getPlayerListener().playAnimation(p, new Animation(p, begin, kickback, direction, kickdown, end));
    } else {
        entity.teleport(entity.getLocation().setDirection(direction), TeleportCause.PLUGIN);
    }
}
项目:ProjectAres    文件:PlayerMovementListener.java   
/**
 * Fire a CoarsePlayerMoveEvent that wraps the given event, only if it crosses
 * a block boundary, or the PoseFlags change.
 * @param event         The movement event to potentially wrap
 * @return True if the original event was not cancelled, and a coarse event was fired,
 *         and that coarse event was cancelled. In this case, the wrapped event won't
 *         actually be cancelled, but callers should treat it like it is.
 */
private boolean callCoarsePlayerMove(final PlayerMoveEvent event) {
    // Don't fire coarse events for teleports that are not "in-game"
    // e.g. /jumpto command
    if(event instanceof PlayerTeleportEvent) {
        PlayerTeleportEvent teleportEvent = (PlayerTeleportEvent) event;
        if(teleportEvent.getCause() != TeleportCause.ENDER_PEARL &&
           teleportEvent.getCause() != TeleportCause.UNKNOWN) {
            return false;
        }
    }

    // If the movement does not cross a block boundary, and no PoseFlags changed, we don't care about it
    final EntityLocation from = event.getEntityFrom();
    final EntityLocation to = event.getEntityTo();
    if(from.position().coarseEquals(to.position()) && from.poseFlags().equals(to.poseFlags())) {
        return false;
    }

    // Remember whether the original event was already cancelled
    boolean wasCancelled = event.isCancelled();

    CoarsePlayerMoveEvent generalEvent = new CoarsePlayerMoveEvent(event, event.getPlayer(), from, to);
    this.eventBus.callEvent(generalEvent);

    if(!wasCancelled && generalEvent.isCancelled()) {
        // When a coarse event is cancelled, we have our own logic for resetting the
        // player's position, so we un-cancel the event and instead modify its
        // to location to put the player where we want them.
        resetPosition(event);
        return true;
    } else {
        return false;
    }
}
项目:SkyWarsReloaded    文件:Game.java   
public void endGame() {
    gameState = GameState.ENDING;
    if (SkyWarsReloaded.getCfg().bungeeEnabled()&& !shutdown) {
        BungeeUtil.sendSignUpdateRequest(this);
    }
    if (SkyWarsReloaded.getCfg().signJoinMode() && !shutdown) {
        SkyWarsReloaded.getGC().updateSign(gameNumber);
    }
    for (GamePlayer gplayer: getPlayers()) {
        deletePlayer(gplayer, false, false);
    }
    if (SkyWarsReloaded.getCfg().spectatingEnabled()) {
        for (GamePlayer gPlayer: getSpectators()) {
            removeSpectator(gPlayer);
        }
    }
    for (Player player: mapWorld.getPlayers()) {
        if (player != null) {
            player.teleport(SkyWarsReloaded.getCfg().getSpawn(), TeleportCause.PLUGIN);
        }
    }

    for (Entity entity: mapWorld.getEntities()) {
        if (entity != null) {
            entity.remove();
        }
    }
    if (!SkyWarsReloaded.getCfg().spectatingEnabled() && !shutdown) {
            SkyWarsReloaded.get().getServer().getScheduler().scheduleSyncDelayedTask(SkyWarsReloaded.get(), new Runnable() {
                @Override
                public void run() {
                    deleteGame();
                }
            }, 20 * SkyWarsReloaded.getCfg().getTimeAfterGame());
    } else {
        deleteGame();
    }
}
项目:SkyWarsReloaded    文件:SaveMapCmd.java   
@Override
public boolean run() {
    Location spawn = SkyWarsReloaded.getCfg().getSpawn();
    if (spawn == null) {
        sender.sendMessage(ChatColor.RED + "YOU MUST SET SPAWN BEFORE YOU CAN SAVE A MAP");
        return true;
    }
    String worldName = args[1].toLowerCase();
    for (World world: SkyWarsReloaded.get().getServer().getWorlds()) {
        if (world.getName().equalsIgnoreCase(worldName)) {
            World editWorld = SkyWarsReloaded.get().getServer().getWorld(worldName);
            for (Player player: editWorld.getPlayers()) {
                player.teleport(spawn, TeleportCause.PLUGIN);
            }
            editWorld.save();
            SkyWarsReloaded.getWC().unloadWorld(worldName);
            File dataDirectory = new File (SkyWarsReloaded.get().getDataFolder(), "maps");
            File target = new File (dataDirectory, worldName);
            SkyWarsReloaded.getWC().deleteWorld(target);
            File source = new File (SkyWarsReloaded.get().getServer().getWorldContainer().getAbsolutePath(), worldName);
            SkyWarsReloaded.getWC().copyWorld(source, target);
            SkyWarsReloaded.getWC().deleteWorld(source);
            sender.sendMessage(new Messaging.MessageFormatter().setVariable("mapname", worldName).format("maps.saved"));
            if (SkyWarsReloaded.getMC().mapRegistered(worldName)) {
                sender.sendMessage(new Messaging.MessageFormatter().format("maps.register-reminder"));
            }
            return true;
        }
    }
    sender.sendMessage(new Messaging.MessageFormatter().setVariable("mapname", worldName).format("error.map-not-in-edit"));
    return true;
}