当前位置: 首页>>代码示例>>Java>>正文


Java Player.isSprinting方法代码示例

本文整理汇总了Java中org.bukkit.entity.Player.isSprinting方法的典型用法代码示例。如果您正苦于以下问题:Java Player.isSprinting方法的具体用法?Java Player.isSprinting怎么用?Java Player.isSprinting使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.entity.Player的用法示例。


在下文中一共展示了Player.isSprinting方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: call

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public void call(Event event) {
	final Player player = profile.getPlayer();

	if (event instanceof PlayerMoveEvent) {
		if ((player.isSprinting() || player.isBlocking() || player.isConversing()) && player.isSneaking()) {
			callback(true);
			return;
		}
		callback(false);
	} else if (event instanceof AsyncPlayerChatEvent) {
		if ((player.isBlocking() || player.isSprinting() || player.isSneaking())) {
			callback(true);
			return;
		}
		callback(false);
	}
}
 
开发者ID:davidm98,项目名称:Crescent,代码行数:19,代码来源:ImpossibleA.java

示例2: onPlayerMove

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler
public void onPlayerMove(PlayerMoveEvent event) {
	final Player player = event.getPlayer();

	final Material from = event.getFrom().getBlock().getRelative(BlockFace.DOWN).getType();

	final Behaviour behaviour = Profile.getProfile(player.getUniqueId()).getBehaviour();

	final long current = System.currentTimeMillis();

	if (player.isSprinting()) {
		behaviour.getMotion().setLastSprint(current);
	}
	if (player.isFlying()) {
		behaviour.getMotion().setLastFly(current);
	}

	if (from.isSolid() || behaviour.getMotion().getLastY() == -1.0 || !behaviour.getMotion().isDescending()) {
		behaviour.getMotion().setLastY(player.getLocation().getY());
	}

	if (!behaviour.isOnGround()) {
		behaviour.getMotion().setLastYDiff(event.getTo().getY() - event.getFrom().getY());
	}
}
 
开发者ID:davidm98,项目名称:Crescent,代码行数:26,代码来源:BehaviourListeners.java

示例3: getTemper

import org.bukkit.entity.Player; //导入方法依赖的package包/类
private double getTemper(Player p, double _temper){
    long time=p.getWorld().getTime();
      //Material.
      if(_temper>=0.5)
    	  _temper-=0.5;
      else _temper-=0.5;
      if(time>=12000L&&time<22200L)
    	  _temper-=Math.random()*0.5;
      else
    	  _temper+=Math.random()*0.5;
      if(p.getWorld().hasStorm())
    	  _temper-=Math.random()*0.5;
      _temper+=getBlocks(p);
      _temper+=getInv(p);
      if(p.getWorld().getBlockAt(p.getLocation()).getLightLevel()<=5)
    	  _temper-=0.5*(5-p.getWorld().getBlockAt(p.getLocation()).getLightLevel()*0.1);
      if(p.isSprinting())
    	  _temper+=Math.random()*0.02;
      
	return _temper;
}
 
开发者ID:SchoolUniform,项目名称:RealSurvival,代码行数:22,代码来源:TestCMD.java

示例4: call

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public void call(Event event) {
	if (event instanceof InventoryClickEvent) {
		// The player has clicked.

		final Player player = profile.getPlayer();

		if (player.isSprinting() || player.isSneaking() || player.isBlocking() || player.isSleeping()
				|| player.isConversing()) {
			// The player has clicked in their inventory impossibly.
			callback(true);
		}
	}
}
 
开发者ID:davidm98,项目名称:Crescent,代码行数:15,代码来源:InventoryTweaksA.java

示例5: isCritical

import org.bukkit.entity.Player; //导入方法依赖的package包/类
/**
 * @return Whether the hit is a critical hit or not.
 */
private boolean isCritical() {
	final Player player = profile.getPlayer();
	final Behaviour behaviour = profile.getBehaviour();
	return player.getFallDistance() > 0.0 && !behaviour.isOnLadder() && !behaviour.isOnVine()
			&& !behaviour.isInWater() && !player.hasPotionEffect(PotionEffectType.BLINDNESS)
			&& !player.isInsideVehicle() && !player.isSprinting() && !((Entity) player).isOnGround();
}
 
开发者ID:davidm98,项目名称:Crescent,代码行数:11,代码来源:CriticalsA.java

示例6: run

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public void run() {
	Set<UUID> players=rs.getPlayerDatas().keySet();
	for(UUID ps:players){
		Player p = rs.getServer().getPlayer(ps);
		if(p==null||p.isDead())continue;
		if ((p.hasPermission("RealSurvival.unlimited")||p.hasPermission("RealSurvival.Admin"))&&!TestCMD.contains(p)) 
	    	  continue;
	      PlayerData pd=rs.getPlayerData(p);
	      if(p.isSneaking())
	    	  if(pd.getPhysical_strength()<rs.getSneaking())
	    		  p.setSneaking(false);
	    	  else{
	    		  pd.changePS(-rs.getSneaking());
	    		  continue;
	    	  }
	      else if(p.isSprinting())
	    	  if(pd.getPhysical_strength()<rs.getSprinting())
	    		  p.setSprinting(false);
	    	  else{
	    		  pd.changePS(-rs.getSprinting());
	    		  continue;
	    	  }
	      else
	    	  pd.changePS(rs.getPhysical_strength_add());
	    }
}
 
开发者ID:SchoolUniform,项目名称:RealSurvival,代码行数:28,代码来源:PhysicalStrengthTask.java

示例7: onPotionSplash

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler
public void onPotionSplash(final PotionSplashEvent event) {
    if (event.getEntity().getShooter() instanceof Player) {
        final Player shooter = (Player) event.getEntity().getShooter();

        if (shooter.isSprinting() && event.getIntensity(shooter) > 0.5D) {
            event.setIntensity(shooter, 1.0D);
        }
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:11,代码来源:PotListener.java

示例8: call

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public void call(Event event) {
	// Causes false positives.
	if (profile.getBehaviour().getMotion().isDescending()) {
		return;
	}

	if (event instanceof PlayerMoveEvent) {
		final Player player = profile.getPlayer();

		if (player.getGameMode() == GameMode.SPECTATOR || player.isInsideVehicle()) {
			/*
			 * If the player is in spectator mode, return out of the method
			 * as the speed function in this GameMode could cause false
			 * positives.
			 */
			return;
		}

		final PlayerMoveEvent pme = (PlayerMoveEvent) event;

		final int speedLevel = profile.getBehaviour().getPotionEffectLevel(PotionEffectType.SPEED);

		// Ignore if the player's speed is higher than two.
		if (speedLevel > 2) {
			return;
		}

		/*
		 * Ignore y for this check. We only want to check speed on the x and
		 * z axes.
		 */
		final Vector from = pme.getFrom().toVector().clone().setY(0.0),
				to = pme.getTo().toVector().clone().setY(0.0);

		double distance = to.distanceSquared(from);

		if (speedLevel > 0) {
			// Take into account speed potions.
			distance -= (distance / 100.0) * (speedLevel * 20.0);
		}

		/*
		 * Walking and flying (but not sprinting): 0.40, Sprinting and
		 * flying: 1.25
		 */
		final long current = System.currentTimeMillis();
		if ((player.isFlying() && player.isSprinting()) || (current
				- profile.getBehaviour().getMotion().getLastFly() <= 500
				&& current - profile.getBehaviour().getMotion()
						.getLastSprint() <= 500) /*
													 * Player is flying and
													 * sprinting and flying
													 * or has been in the
													 * last half a second.
													 */) {
			callback(distance > 1.25);
		} else {
			callback(distance > 0.40);
		}
	}
}
 
开发者ID:davidm98,项目名称:Crescent,代码行数:63,代码来源:SpeedA.java

示例9: onItemClick

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@EventHandler
public void onItemClick(PlayerInteractEvent event)
{
	Player player = event.getPlayer();
	ItemStack mainItem = player.getInventory().getItemInMainHand();
	ItemStack offItem = player.getInventory().getItemInOffHand();
	
	Score score_dualWieldMsg = tech_dualWieldMsg.getScore(player);
	
	if(mainItem.getType() == Material.GOLD_HOE)
	{
		if(dualWield.getScore(player).getScore() == 0)
		{
			if(event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_AIR)
			{
				if(player.isSprinting())
				{
					if(charge.getScore(player).getScore() == 0)
					{
						Random rand = new Random();
						
						ChargeForward(player, 3);
						
						if(player.getGameMode() == GameMode.SURVIVAL || player.getGameMode() == GameMode.ADVENTURE)
							player.setFoodLevel(player.getFoodLevel() - 1);
						
						int chance_reduceDur = rand.nextInt(10) + 1;
						switch(chance_reduceDur)
						{
							case 1:
								mainItem.setDurability((short)(mainItem.getDurability() + 1));
								break;
							default:
						}
						
						if(event.getItem().getDurability() >= 32)
						{
							player.getLocation().getWorld().playSound(player.getLocation(), Sound.ENTITY_ITEM_BREAK, 1.0F, rand.nextFloat() * 0.4F + 0.8F);
							player.getInventory().setItemInMainHand(null);
						}
						player.updateInventory();
					}
					else
					{
						player.sendMessage(ChatColor.RED + Survival.Words.get("Unable to Charge immediately"));
					}
				}
			}
		}
		else 
		{
			if(event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK)
				score_dualWieldMsg.setScore(score_dualWieldMsg.getScore() + 1);
			else if(event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK)
				score_dualWieldMsg.setScore(score_dualWieldMsg.getScore() + 2);
			if(score_dualWieldMsg.getScore() >= 2)
			{
				player.sendMessage(ChatColor.RED + Survival.Words.get("Unable to dual-wield with Giant Blade"));
			}
		}
	}
	else if(offItem.getType() == Material.GOLD_HOE)
	{
		if(dualWield.getScore(player).getScore() != 0)
		{
			if(event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK)
				score_dualWieldMsg.setScore(score_dualWieldMsg.getScore() + 1);
			else if(event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK)
				score_dualWieldMsg.setScore(score_dualWieldMsg.getScore() + 2);
			if(score_dualWieldMsg.getScore() >= 2)
			{
				player.sendMessage(ChatColor.RED + Survival.Words.get("Unable to dual-wield with Giant Blade"));
			}
		}
	}
	score_dualWieldMsg.setScore(0);
}
 
开发者ID:FattyMieo,项目名称:SurvivalPlus,代码行数:79,代码来源:GiantBlade.java

示例10: run

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public void run() {
	double _temper=-0.1;
	long time;
	Set<UUID> players=rs.getPlayerDatas().keySet();
	for(UUID ps:players){
		  Player p = rs.getServer().getPlayer(ps);
		  if(p==null||p.isDead())continue;
	      if ((p.hasPermission("RealSurvival.unlimited")||p.hasPermission("RealSurvival.Admin"))&&!TestCMD.contains(p)) 
	    	  continue;
	      PlayerData pd=rs.getPlayerData(p);
	      _temper=p.getWorld().getTemperature(p.getLocation().getBlockX(), p.getLocation().getBlockZ());
	      time=p.getWorld().getTime();
	      //12000-13800 ����
	      //13800-22200 ��ҹ
	      //22200-0          �ճ�
	      //0-12000          ����
	      //Material.
	      if(_temper>=0.5)
	    	  _temper-=0.5;
	      else _temper-=0.5;
	      if(time>=12000L&&time<22200L)
	    	  _temper-=Math.random()*0.5;
	      else
	    	  _temper+=Math.random()*0.5;
	      if(p.getWorld().hasStorm())
	    	  _temper-=Math.random()*0.5;
	      _temper+=getBlocks(p.getLocation());
	      _temper+=getInv(p);
	      if(p.getWorld().getBlockAt(p.getLocation()).getLightLevel()<=5)
	    	  _temper-=0.5*(5-p.getWorld().getBlockAt(p.getLocation()).getLightLevel()*0.1);
	      if(p.isSprinting())
	    	  _temper+=Math.random()*0.02;
	      
	      /*if(_temper>0.2)
	    	  pd.changeTemperature(0.2);
	      else if(_temper<0.2)
	    	  pd.changeTemperature(-0.2);
	      else*/
	    	  pd.changeTemperature(_temper*0.02);
	      continue;
    }
}
 
开发者ID:SchoolUniform,项目名称:RealSurvival,代码行数:44,代码来源:TemperatureTask.java

示例11: 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);
        }
    }
}
 
开发者ID:Notoh,项目名称:DynamicAC,代码行数:46,代码来源:Speed.java

示例12: sprintFly

import org.bukkit.entity.Player; //导入方法依赖的package包/类
public static boolean sprintFly(Player player) {
    return player.isSprinting() || player.isFlying();
}
 
开发者ID:Notoh,项目名称:DynamicAC,代码行数:4,代码来源:Utilities.java

示例13: onEntityDamageByEntity

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
	public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
		if (!(event.getEntity() instanceof Player) || !(event.getDamager() instanceof Player)) {
			return;
		}

		if (event.isCancelled()) {
			return;
		}

		Player damaged = (Player) event.getEntity();
		Player damager = (Player) event.getDamager();
		
		if (damaged.getNoDamageTicks() > damaged.getMaximumNoDamageTicks() / 2D) {
			return;
		}
		
		Vector knockback = damaged.getLocation().toVector().subtract(damager.getLocation().toVector()).normalize();
		double horMultiplier = 1.1;
		double verMultiplier = 1.04;
		double sprintMultiplier = damager.isSprinting() ? 0.81D : 0.5D;
		double kbMultiplier = damager.getItemInHand() == null ? 0 : damager.getItemInHand().getEnchantmentLevel(Enchantment.KNOCKBACK) * 0.2D;
		@SuppressWarnings("deprecation")
		double airMultiplier = damaged.isOnGround() ? 1 : 0.94;

		knockback.setX((knockback.getX() * sprintMultiplier + kbMultiplier) * horMultiplier);
		knockback.setY(0.35D * airMultiplier * verMultiplier);
		knockback.setZ((knockback.getZ() * sprintMultiplier + kbMultiplier) * horMultiplier);
		
		try {
			// Send the velocity packet immediately instead of using setVelocity, which fixes the 'relog bug'
			Object entityPlayer = damaged.getClass().getMethod("getHandle").invoke(damaged);
			Object playerConnection = fieldPlayerConnection.get(entityPlayer);
			Object packet = packetVelocity.newInstance(damaged.getEntityId(), knockback.getX(), knockback.getY(), knockback.getZ());
			sendPacket.invoke(playerConnection, packet);
		} catch (SecurityException | IllegalArgumentException | IllegalAccessException | InvocationTargetException | NoSuchMethodException | InstantiationException e) {
			e.printStackTrace();
		}
		//Bukkit.getScheduler().scheduleSyncDelayedTask(core, new Runnable() {
			//public void run() {
				//double horMultiplier = KnockbackPatch.getInstance().getHorMultiplier();
				//double verMultiplier = KnockbackPatch.getInstance().getVerMultiplier();
				//double sprintMultiplier = damager.isSprinting() ? 0.8D : 0.5D;
				//double kbMultiplier = damager.getItemInHand() == null ? 0 : damager.getItemInHand().getEnchantmentLevel(Enchantment.KNOCKBACK) * 0.2D;
				//@SuppressWarnings("deprecation")
				//double airMultiplier = damaged.isOnGround() ? 1 : 0.8;
//
				//nockback.setX((knockback.getX() * sprintMultiplier + kbMultiplier) * horMultiplier);
				//knockback.setY(0.35D * airMultiplier * verMultiplier);
				//knockback.setZ((knockback.getZ() * sprintMultiplier + kbMultiplier) * horMultiplier);
				//
				//try {
			     	// Send the velocity packet immediately instead of using setVelocity, which fixes the 'relog bug'
				//	Object entityPlayer = damaged.getClass().getMethod("getHandle").invoke(damaged);
				//	Object playerConnection = fieldPlayerConnection.get(entityPlayer);
				//	Object packet = packetVelocity.newInstance(damaged.getEntityId(), knockback.getX(), knockback.getY(), knockback.getZ());
				//	sendPacket.invoke(playerConnection, packet);
		//		} catch (SecurityException | IllegalArgumentException | IllegalAccessException | InvocationTargetException | NoSuchMethodException | InstantiationException e) {
	//				e.printStackTrace();
			//	}
			//}
		//}, 2L);
	}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:64,代码来源:KnockBackListener.java


注:本文中的org.bukkit.entity.Player.isSprinting方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。