Java 类org.bukkit.event.player.PlayerToggleSneakEvent 实例源码

项目:WC    文件:IronElevators.java   
@EventHandler(priority = EventPriority.HIGH)
public void downElevator(PlayerToggleSneakEvent e) {
    Player p = e.getPlayer();
    Block b = p.getLocation().getBlock().getRelative(BlockFace.DOWN);
    if (p.hasPermission("ironelevators.use") && !p.isSneaking()
            && b.getType() == elevatorMaterial) {
        b = b.getRelative(BlockFace.DOWN, minElevation);
        int i = maxElevation; //16
        while (i > 0 && !(
                b.getType() == elevatorMaterial
                        && b.getRelative(BlockFace.UP).getType().isTransparent()
                        && b.getRelative(BlockFace.UP, 2).getType().isTransparent()
        )
                ) {
            //e.getPlayer().sendMessage("" + b.getLocation() + b.getType());
            i--;
            b = b.getRelative(BlockFace.DOWN);
        }
        if (i > 0) {
            Location l = p.getLocation();
            l.setY(l.getY() - maxElevation - 3 + i);
            p.teleport(l);
            p.getWorld().playSound(p.getLocation(), Sound.ENTITY_IRONGOLEM_ATTACK, 1, 1);
        }
    }
}
项目:PA    文件:IronElevators.java   
@EventHandler(priority = EventPriority.HIGH)
public void downElevator(PlayerToggleSneakEvent e) {
    Player p = e.getPlayer();
    Block b = p.getLocation().getBlock().getRelative(BlockFace.DOWN);
    if (!p.isSneaking() && b.getType() == elevatorMaterial) {
        b = b.getRelative(BlockFace.DOWN, minElevation);
        int i = maxElevation; //16
        while (i > 0 && !(b.getType() == elevatorMaterial && b.getRelative(BlockFace.UP).getType().isTransparent() && b.getRelative(BlockFace.UP, 2).getType().isTransparent())) {
            i--;
            b = b.getRelative(BlockFace.DOWN);
        }
        if (i > 0) {
            Location l = p.getLocation();
            l.setY(l.getY() - maxElevation - 2 + i);
            p.teleport(l);
            p.getWorld().playSound(p.getLocation(), Sound.ENTITY_IRONGOLEM_ATTACK, 1, 1);
        }
    }
}
项目:FlexMC    文件:EntityActionListener.java   
@Override
public void handle( ConnectionHandler connectionHandler, MessageC15EntityAction message ) {
    FlexPlayer player = connectionHandler.getPlayer();
    switch ( message.getActionId() ) {
        case 0:
            player.setSneaking( true );
            EventFactory.call( new PlayerToggleSneakEvent( player, true ) );
            break;
        case 1:
            player.setSneaking( false );
            EventFactory.call( new PlayerToggleSneakEvent( player, false ) );
            break;
        case 2:
            player.setSprinting( true );
            EventFactory.call( new PlayerToggleSprintEvent( player, true ) );
            break;
        case 3:
            player.setSprinting( false );
            EventFactory.call( new PlayerToggleSprintEvent( player, false ) );
            break;

        // todo handle other cases
    }
}
项目:Portals    文件:PlayerToggleSneak.java   
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled=true)
public void onPlayerToggleSneakEvent(PlayerToggleSneakEvent event) {

    Player player = event.getPlayer();
    Block block = player.getLocation().getBlock();

    /* Check if player starts sneaking on top of obsidian */
    if ( event.isSneaking() && PortalCheck.is_valid_portal(block) ) {

        Portals.instance.getLogger().info(player.getName() + " tried to use a portal by sneaking at"
                + " " + block.getWorld().getName()
                + " " + block.getX()
                + " " + block.getY()
                + " " + block.getZ()
                + ".");
        PortalUtils.teleport(player);

    }
}
项目:sensibletoolbox    文件:ElevatorListener.java   
@EventHandler
public void onPlayerSneak(PlayerToggleSneakEvent event) {
    if (event.isSneaking()) {
        Block b = event.getPlayer().getLocation().getBlock().getRelative(BlockFace.DOWN);
        Elevator e1 = LocationManager.getManager().get(b.getLocation(), Elevator.class);
        if (e1 != null) {
            Elevator e2 = e1.findOtherElevator(BlockFace.DOWN);
            if (e2 != null) {
                Block b1 = e2.getLocation().getBlock().getRelative(BlockFace.UP);
                if (!b1.getType().isSolid() && !b1.getRelative(BlockFace.UP).getType().isSolid()) {
                    Location dest = b1.getLocation().add(0.5, 0, 0.5);
                    dest.setPitch(event.getPlayer().getLocation().getPitch());
                    dest.setYaw(event.getPlayer().getLocation().getYaw());
                    event.getPlayer().teleport(dest);
                    event.getPlayer().playSound(event.getPlayer().getLocation(), Sound.PISTON_RETRACT, 1.0f, 1.8f);
                }
            }
        }

    }
}
项目:ZentrelaRPG    文件:SpellManager.java   
@EventHandler
public void onSneakEvent(PlayerToggleSneakEvent event) {
    Player p = event.getPlayer();
    if (!casters.containsKey(p.getUniqueId()))
        casters.put(p.getUniqueId(), new Caster());
    final Caster c = casters.get(p.getUniqueId());
    PlayerDataRPG pd = plugin.getPD(p);
    if (pd != null)
        pd.updateHealthManaDisplay();
    c.clear();
}
项目:AddGun    文件:RailGun.java   
/**
 * Keeps track of player sneaking; if they are sneaking, we track when the
 * snuck, or, clear if unsnuck.
 * 
 * @param event
 *            the sneak toggle event
 */
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void toggleSneakEvent(PlayerToggleSneakEvent event) {
    if (event.isSneaking()) {
        sneakingSince.computeIfAbsent(event.getPlayer().getUniqueId(), u -> {
            if (event.getPlayer().hasPermission("addgun.data")) { event.getPlayer().sendMessage(ChatColor.GOLD + " sneak started"); }
            return System.currentTimeMillis();
        });
    } else {
        if (sneakingSince.containsKey(event.getPlayer().getUniqueId()) && event.getPlayer().hasPermission("addgun.data")) { 
            event.getPlayer().sendMessage(ChatColor.GOLD + " sneak cleared");
        }
        sneakingSince.remove(event.getPlayer().getUniqueId());
    }
}
项目:SamaGamesAPI    文件:CameraManager.java   
@EventHandler
public void onPlayerToggleSneak(PlayerToggleSneakEvent event)
{
    Camera camera = this.getPlayerCamera(event.getPlayer());

    if (camera != null && camera.isFixed())
        event.setCancelled(true);
}
项目:SuperiorCraft    文件:Elevator.java   
@EventHandler
   public void onPlayerToggleSneakEvent(PlayerToggleSneakEvent e) {
    // Sneaking = !sneaking because of badly timed events

    for (Entity en : e.getPlayer().getWorld().getEntities()) {
        if (en.getCustomName() != null && en.getCustomName().equals(getName()) && en.getLocation().distance(e.getPlayer().getLocation()) <= 1.5 && en.getLocation().getY() < e.getPlayer().getLocation().getY()) {
            if (!e.getPlayer().isSneaking()) {
                //e.getPlayer().sendMessage("down");
                if (getElevatorDown(en, e.getPlayer()) != null) {e.getPlayer().teleport(getElevatorDown(en, e.getPlayer()).getLocation().add(0, 1, 0));}
            }
        }
    }
}
项目:RealSurvival    文件:PhysicalStrengthEvent.java   
@EventHandler
public void sneak(PlayerToggleSneakEvent e){
    if(rs.getPlayerData(e.getPlayer())==null)return;
    if(rs.getPlayerData(e.getPlayer()).getPhysical_strength()<rs.getSneaking()){
        e.setCancelled(true);
        e.getPlayer().setSneaking(false);
    }
}
项目:MCLibrary    文件:SneakingWizard.java   
@Override
protected Listener listener(Consumer<Player> callback) {
    return new Listener() {
        @EventHandler
        public void onSneak(PlayerToggleSneakEvent event) {
            if (!event.isSneaking() && player.equals(event.getPlayer())) {
                callback.accept(event.getPlayer());
            }
        }
    };
}
项目:RealisticSwimming    文件:RSneakListener.java   
@EventHandler
public void onPlayerToggleSneakEvent(PlayerToggleSneakEvent event){
    Player p = event.getPlayer();
    if(!p.isSneaking() && Config.enableSneak){
        p.setGliding(true);
    }
}
项目:SuperiorCraft    文件:Elevator.java   
@EventHandler
   public void onPlayerToggleSneakEvent(PlayerToggleSneakEvent e) {
    // Sneaking = !sneaking because of badly timed events

    for (Entity en : e.getPlayer().getWorld().getEntities()) {
        if (en.getCustomName() != null && en.getCustomName().equals(getName()) && en.getLocation().distance(e.getPlayer().getLocation()) <= 1.5 && en.getLocation().getY() < e.getPlayer().getLocation().getY()) {
            if (!e.getPlayer().isSneaking()) {
                //e.getPlayer().sendMessage("down");
                if (getElevatorDown(en, e.getPlayer()) != null) {e.getPlayer().teleport(getElevatorDown(en, e.getPlayer()).getLocation().add(0, 1, 0));}
            }
        }
    }
}
项目:Murder    文件:SpectatorListener.java   
@EventHandler
public void on(PlayerToggleSneakEvent event) {
    PlayerData playerData = plugin.playerManager.getData(event.getPlayer().getUniqueId());
    if (playerData != null) {
        if (playerData.isInGame() && playerData.isSpectator) {
            //Reset the gamemode when the player "leaves" their target
            event.getPlayer().setGameMode(GameMode.ADVENTURE);
            event.getPlayer().setAllowFlight(true);
            event.getPlayer().setFlying(true);
        }
    }
}
项目:TreysDoubleJump    文件:DoubleJump.java   
@EventHandler
public void onSneak(PlayerToggleSneakEvent e) {
    Player p = e.getPlayer();
    if (p.getGameMode() == GameMode.SPECTATOR) {
        return;
    }
    if (p.getGameMode() == GameMode.CREATIVE) {
        return;
    }
    if (!p.hasPermission("tdj.use")) {
        return;
    }
    if (!p.hasPermission("tdj.groundpound")) {
        return;
    }
    if (!Grounded.contains(p.getUniqueId().toString())) {
        return;
    }
    if (p.isOnGround()) {
        return;
    }
    if (FlightCommand.FlyingPlayers.contains(p.getUniqueId().toString())) {
        return;
    }
    if (DoubleJumpCommand.DisablePlayers.contains(p.getUniqueId().toString())) {
        return;
    }
    if (!ConfigManager.getConfig().getBoolean("GroundPound.Enabled")){
        return;
    }
    if (GroundPoundCommand.groundPoundDisabled.contains(p.getUniqueId().toString())) {
        return;
    }
    p.setVelocity(new Vector(0, -5, 0));
}
项目:HoloGUIApi    文件:PlayerToggleSneakEventListener.java   
@EventHandler
public void playerToggleSneakEvent(PlayerToggleSneakEvent event)
{
    Player player = event.getPlayer();
    PlayerData playerData = PlayerData.getPlayerData(player);

    playerData.setPlayerSneaking(event.isSneaking());
}
项目:AnnihilationPro    文件:Transporter.java   
@EventHandler(priority = EventPriority.HIGHEST,ignoreCancelled = true)
public void Teleport(PlayerToggleSneakEvent event)
{
    if(event.isSneaking())
    {
        Player player = event.getPlayer();
        Block b = player.getLocation().getBlock().getRelative(BlockFace.DOWN);
        if(b.getType() == Material.QUARTZ_ORE)
        {
            UUID owner = getBlocksOwner(b);
            if(owner != null)
            {
                AnniPlayer p = AnniPlayer.getPlayer(player.getUniqueId());
                if(p != null)
                {
                    Teleporter tele = teleporters.get(owner);
                    if(tele.isLinked() && tele.getOwner().getTeam() == p.getTeam() && tele.canUse())
                    {
                        Location loc;
                        //if(new Loc(b.getLocation()).isEqual(tele.getLoc1()))
                        if(tele.getLoc1().equals(b.getLocation()))
                            loc = tele.getLoc2().toLocation();
                        else
                            loc = tele.getLoc1().toLocation();
                        loc.setY(loc.getY()+1);
                        player.teleport(this.getMiddle(loc));
                        loc.getWorld().playEffect(loc, Effect.MOBSPAWNER_FLAMES, 1);
                        tele.getLoc1().toLocation().getWorld().playSound(tele.getLoc1().toLocation(), Sound.ENDERMAN_TELEPORT, 1F,(float)Math.random());
                        tele.getLoc2().toLocation().getWorld().playSound(tele.getLoc2().toLocation(), Sound.ENDERMAN_TELEPORT, 1F,(float)Math.random());
                        tele.delay();
                        event.setCancelled(true);
                    }
                }
            }
        }
    }
}
项目:WingCommander    文件:WingCommander.java   
/**
 * Handle player crouch.
 */
@EventHandler(ignoreCancelled = true)
public void onPlayerToggleSneak(PlayerToggleSneakEvent event) {
    Player player = event.getPlayer();
    if (isFlightCapable(player) && event.isSneaking()) {
        getState(player).onCrouch();
    }
}
项目:StarQuestCode    文件:Core.java   
@EventHandler
public void shift(PlayerToggleSneakEvent e) {

    if (e.isSneaking()) {
        sneakCache.add(e.getPlayer());
    } else {
        launchPlayer(e.getPlayer());
        sneakCache.remove(e.getPlayer());
        e.getPlayer().setLevel(0);
        e.getPlayer().setExp(0);
    }
}
项目:DDCustomPlugin    文件:DrunkenWizard.java   
public void onPlayerSneaks(PlayerToggleSneakEvent e) {
    Player player = e.getPlayer();
    if (player.getLocation().getBlock().equals(new Location(Bukkit.getWorld("Survival"), 179, 80, 227).getBlock()) || 
            player.getLocation().getBlock().equals(new Location(Bukkit.getWorld("Survival"), 173, 64, 227).getBlock())) {
        if (timeout.containsKey(player)) {
            if (timeout.get(player) + 5 > System.currentTimeMillis()/1000)
                return;
        }
        if (e.isSneaking()) {
            attemptTeleport(player);
        } else {
            cancelTeleport(player);
        }
    }
}
项目:DDCustomPlugin    文件:DonorShop.java   
public void onPlayerSneaks(PlayerToggleSneakEvent e) {
    Player player = e.getPlayer();
    if (player.getLocation().getBlock().equals(pressurePlate.getBlock())) {
        if (timeout.containsKey(player)) {
            if (timeout.get(player) + 5 > System.currentTimeMillis()/1000)
                return;
        }
        if (e.isSneaking()) {
            attemptTeleport(player);
        } else {
            cancelTeleport(player);
        }
    }
}
项目:ProtocolSupport    文件:FeatureEmulation.java   
@EventHandler
public void onShift(PlayerToggleSneakEvent event) {
    Player player = event.getPlayer();
    Connection connection = ProtocolSupportAPI.getConnection(player);
    if (
        player.isInsideVehicle() &&
        (connection != null) &&
        (connection.getVersion().getProtocolType() == ProtocolType.PC) &&
        connection.getVersion().isBeforeOrEq(ProtocolVersion.MINECRAFT_1_5_2)
    ) {
        player.leaveVehicle();
    }
}
项目:RBGArmor    文件:RBGArmor.java   
@EventHandler(ignoreCancelled = true)
public void onSneak(PlayerToggleSneakEvent e) {
    Player p = e.getPlayer();
    if (!workerz.containsKey(p.getUniqueId())) {
        // use a little CPU to prevent network abuse
        // if player has rgb armor, but no perms, and spam sneaks
        // they would trigger a TON of message sends (lines 131, 133)
        if(sneaks.containsKey(p.getUniqueId())) {
            long last = sneaks.get(p.getUniqueId());
            if(System.currentTimeMillis() - last < 5000) {
                return;
            }
            sneaks.remove(p.getUniqueId());
        }
        for (ItemStack is : p.getInventory().getArmorContents()) {
            ItemMeta meta;
            if (is != null && (meta = is.getItemMeta()) instanceof LeatherArmorMeta) {
                if (meta.hasLore()) {
                    Worker worker = getWorker(p, meta.getLore());
                    if (worker != null) {
                        this.initWorker(p, worker);
                        return;
                    }
                }
            }
        }
    }
}
项目:twerkoffplugin    文件:TwerkPlugin.java   
@EventHandler
public void onSneak(PlayerToggleSneakEvent e) {
    if (!e.isSneaking()) {
        if (activePlayers.containsKey(e.getPlayer().getName())) {
            activePlayers.put(e.getPlayer().getName(), activePlayers.get(e.getPlayer().getName()) + 1);
        }
    }
}
项目:Piggyback    文件:Events.java   
@EventHandler(priority=EventPriority.NORMAL, ignoreCancelled=false)
public void onPlayerToggleSneakEvent(PlayerToggleSneakEvent event) {
 Player player = event.getPlayer();
 if(player.getVehicle()!=null){
  Events.sendMountPacket(player);
 }    
}
项目:Ghosts    文件:PlayerListener.java   
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
private void onPlayerToggleSneak(PlayerToggleSneakEvent event) {
    Player player = event.getPlayer();

    if (Ghosts.p.getGhostManager().isGhost(player)) {
        PlayerManager.spook(player);
    }
}
项目:SuperSneak    文件:PlayerToggleSneakListener.java   
@EventHandler
public void onPlayerToggleSneak(PlayerToggleSneakEvent event) {
    if (event.getPlayer().hasPermission("supersneak.use")) {
        if (event.isSneaking()){
            event.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 9));
        } else {
            event.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 0, 0), true);
        }
    }
}
项目:Kineticraft    文件:Cutscenes.java   
@EventHandler(ignoreCancelled = true) // Prevent dismounting from the camera mount.
public void onSneak(PlayerToggleSneakEvent evt) {
    evt.setCancelled(isWatching(evt.getPlayer()) && evt.isSneaking());
}
项目:Minecraft-UAPI    文件:SkillListener.java   
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerToggleSneakEvent(PlayerToggleSneakEvent event) {
    User user = API.to(event.getPlayer());
    if (user == null) return;
    if (this.call(new SkillEventSneak(user, event.isSneaking())).isCancelled()) event.setCancelled(true);
}
项目:PlayerSQL    文件:EventExecutor.java   
@EventHandler(priority = LOWEST)
public void pre(PlayerToggleSneakEvent event) {
    handle(event);
}
项目:PlayerSQL    文件:EventExecutor.java   
@EventHandler(ignoreCancelled = true, priority = HIGHEST)
public void handle(PlayerToggleSneakEvent event) {
    if (isLocked(event.getPlayer().getUniqueId())) {
        event.setCancelled(true);
    }
}
项目:DDCustomPlugin    文件:CustomPlugin.java   
@EventHandler
    public void PlayerToggleSneak(PlayerToggleSneakEvent event) {
        if (donorShop != null)
            donorShop.onPlayerSneaks(event);
//      drunkenWizard.onPlayerSneaks(event);
    }