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

CraftEntity.java 文件源码 项目:Uranium 阅读 20 收藏 0 点赞 0 评论 0
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;
}
CreateMapCmd.java 文件源码 项目:SkyWarsReloaded 阅读 18 收藏 0 点赞 0 评论 0
@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;
    }
}
SpectatorListener.java 文件源码 项目:SkyWarsReloaded 阅读 21 收藏 0 点赞 0 评论 0
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();
        } 
    } 
}
VillagerManager.java 文件源码 项目:Chambers 阅读 17 收藏 0 点赞 0 评论 0
/**
 * 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;
}
FlagDef_NoEnderPearl.java 文件源码 项目:GriefPreventionFlags 阅读 22 收藏 0 点赞 0 评论 0
@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);
    }
}
FlagDef_NoChorusFruit.java 文件源码 项目:GriefPreventionFlags 阅读 23 收藏 0 点赞 0 评论 0
@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);
    }
}
CraftEntity.java 文件源码 项目:ThermosRebased 阅读 23 收藏 0 点赞 0 评论 0
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;
}
CTFListener.java 文件源码 项目:Breakpoint 阅读 21 收藏 0 点赞 0 评论 0
@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());
        }
    }
}
TeleportListener.java 文件源码 项目:iZenith-PVP 阅读 21 收藏 0 点赞 0 评论 0
@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());
        }
    }
}
EffNpcTeleport.java 文件源码 项目:Skellett 阅读 17 收藏 0 点赞 0 评论 0
@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);
            }
        }
    }
}
CraftEntity.java 文件源码 项目:Thermos 阅读 17 收藏 0 点赞 0 评论 0
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;
   }
CraftEntity.java 文件源码 项目:KCauldron 阅读 17 收藏 0 点赞 0 评论 0
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;
}
RPPlayerListener.java 文件源码 项目:RedProtect 阅读 32 收藏 0 点赞 0 评论 0
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);
        }
    }       
}
CraftEntity.java 文件源码 项目:FFoKC 阅读 23 收藏 0 点赞 0 评论 0
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;
}
EvGame.java 文件源码 项目:Ultra-Hardcore-1.8 阅读 25 收藏 0 点赞 0 评论 0
@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));
        }
    }
}
CTFListener.java 文件源码 项目:Breakpoint 阅读 25 收藏 0 点赞 0 评论 0
@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());
        }
    }
}
CraftEntity.java 文件源码 项目:Tweakkit-Server 阅读 20 收藏 0 点赞 0 评论 0
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;
}
PortalListener.java 文件源码 项目:CraftoPlugin 阅读 21 收藏 0 点赞 0 评论 0
@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() + "'");
}
ReturnComponent.java 文件源码 项目:CraftoPlugin 阅读 17 收藏 0 点赞 0 评论 0
@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);
}
SpawnComponent.java 文件源码 项目:CraftoPlugin 阅读 19 收藏 0 点赞 0 评论 0
@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); }

}
InternalTeleportManager.java 文件源码 项目:NucleusFramework 阅读 22 收藏 0 点赞 0 评论 0
@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);
}
ScheduledTeleport.java 文件源码 项目:NucleusFramework 阅读 20 收藏 0 点赞 0 评论 0
/**
 * 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;
}
JCGEventListener.java 文件源码 项目:NucleusFramework 阅读 21 收藏 0 点赞 0 评论 0
@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);
    }
}
CraftEntity.java 文件源码 项目:SpigotSource 阅读 21 收藏 0 点赞 0 评论 0
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;
}
CmdTpAccept.java 文件源码 项目:xEssentials-deprecated-bukkit 阅读 18 收藏 0 点赞 0 评论 0
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;
}
StaffSafeTeleportEvent.java 文件源码 项目:xEssentials-deprecated-bukkit 阅读 57 收藏 0 点赞 0 评论 0
@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!");
                }
            }
        }
    }
}
ArenaLobby.java 文件源码 项目:ZvP 阅读 16 收藏 0 点赞 0 评论 0
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);
   }
PlayerListener.java 文件源码 项目:ZvP 阅读 21 收藏 0 点赞 0 评论 0
@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;
        }
    }
    }
}
   }
Commandjump.java 文件源码 项目:Essentials 阅读 20 收藏 0 点赞 0 评论 0
@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();
}
Commandwarp.java 文件源码 项目:Essentials 阅读 15 收藏 0 点赞 0 评论 0
@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();

}


问题


面经


文章

微信
公众号

扫码关注公众号