本文整理匯總了Java中cn.nukkit.Player.isOnGround方法的典型用法代碼示例。如果您正苦於以下問題:Java Player.isOnGround方法的具體用法?Java Player.isOnGround怎麽用?Java Player.isOnGround使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類cn.nukkit.Player
的用法示例。
在下文中一共展示了Player.isOnGround方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getBreakTime
import cn.nukkit.Player; //導入方法依賴的package包/類
public double getBreakTime(Item item, Player player) {
Objects.requireNonNull(item, "getBreakTime: Item can not be null");
Objects.requireNonNull(player, "getBreakTime: Player can not be null");
double blockHardness = getHardness();
boolean correctTool = correctTool0(getToolType(), item);
boolean canHarvestWithHand = canHarvestWithHand();
int blockId = getId();
int itemToolType = toolType0(item);
int itemTier = item.getTier();
int efficiencyLoreLevel = Optional.ofNullable(item.getEnchantment(Enchantment.ID_EFFICIENCY))
.map(Enchantment::getLevel).orElse(0);
int hasteEffectLevel = Optional.ofNullable(player.getEffect(Effect.HASTE))
.map(Effect::getAmplifier).orElse(0);
boolean insideOfWaterWithoutAquaAffinity = player.isInsideOfWater() &&
Optional.ofNullable(player.getInventory().getHelmet().getEnchantment(Enchantment.ID_WATER_WORKER))
.map(Enchantment::getLevel).map(l -> l >= 1).orElse(false);
boolean outOfWaterButNotOnGround = (!player.isInsideOfWater()) && (!player.isOnGround());
return breakTime0(blockHardness, correctTool, canHarvestWithHand, blockId, itemToolType, itemTier,
efficiencyLoreLevel, hasteEffectLevel, insideOfWaterWithoutAquaAffinity, outOfWaterButNotOnGround);
}
示例2: run
import cn.nukkit.Player; //導入方法依賴的package包/類
public void run() {
while (true) {
try {
for (Player player : Server.getInstance().getOnlinePlayers().values()) {
if(!player.isOnGround()){
double y = player.y;
boolean flag = false;
thread.sleep(5*1000);
if(player.y == y){
flag = true;
}
if(player.y >= y) {
y = player.y;
if (player.move(0, -3, 0)) {
if (player.move(0, -3, 0)) {
if (player.y + 6 == y) {
flag = true;
}
}
}
}
if(flag){
player.setMotion(new Vector3(0,0,0));
player.teleport(player);
if(Flycount.containsKey(player.getName())){
if(Flycount.get(player.getName()) > 5){
player.kick(TextFormat.AQUA+"Cheat Type: "+TextFormat.RED+"Fly");
}
Flycount.put(player.getName(),Flycount.get(player.getName())+1);
}else{
Flycount.put(player.getName(),1);
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}