Java Code Examples for org.bukkit.entity.Player#getFireTicks()
The following examples show how to use
org.bukkit.entity.Player#getFireTicks() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Melting.java From MineTinker with GNU General Public License v3.0 | 6 votes |
@EventHandler(ignoreCancelled = true) public void effect(MTEntityDamageEvent event) { Player player = event.getPlayer(); ItemStack tool = event.getTool(); if (!player.hasPermission("minetinker.modifiers.melting.use")) { return; } if (!modManager.hasMod(tool, this)) { return; } int ticks = player.getFireTicks(); if (ticks > 0 && cancelBurning) { player.setFireTicks(0); ChatWriter.logModifier(player, event, this, tool, "FireTicks(" + ticks + " -> 0)"); } }
Example 2
Source File: Splint.java From Slimefun4 with GNU General Public License v3.0 | 6 votes |
@Override public ItemUseHandler getItemHandler() { return e -> { Player p = e.getPlayer(); // Player is neither burning nor injured if (p.getFireTicks() <= 0 && p.getHealth() >= p.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue()) { return; } if (p.getGameMode() != GameMode.CREATIVE) { ItemUtils.consumeItem(e.getItem(), false); } p.getWorld().playSound(p.getLocation(), Sound.ENTITY_SKELETON_HURT, 1, 1); p.addPotionEffect(new PotionEffect(PotionEffectType.HEAL, 1, 0)); e.cancel(); }; }
Example 3
Source File: Bandage.java From Slimefun4 with GNU General Public License v3.0 | 6 votes |
@Override public ItemUseHandler getItemHandler() { return e -> { Player p = e.getPlayer(); // Player is neither burning nor injured if (p.getFireTicks() <= 0 && p.getHealth() >= p.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue()) { return; } if (p.getGameMode() != GameMode.CREATIVE) { ItemUtils.consumeItem(e.getItem(), false); } p.getWorld().playEffect(p.getLocation(), Effect.STEP_SOUND, Material.WHITE_WOOL); p.addPotionEffect(new PotionEffect(PotionEffectType.HEAL, 1, 1)); p.setFireTicks(0); e.cancel(); }; }
Example 4
Source File: PWIPlayer.java From PerWorldInventory with GNU General Public License v3.0 | 5 votes |
PWIPlayer(Player player, Group group, double bankBalance, double balance, boolean useAttributes) { this.uuid = player.getUniqueId(); this.name = player.getName(); this.location = player.getLocation(); this.group = group; this.saved = false; this.armor = player.getInventory().getArmorContents(); this.enderChest = player.getEnderChest().getContents(); this.inventory = player.getInventory().getContents(); this.canFly = player.getAllowFlight(); this.displayName = player.getDisplayName(); this.exhaustion = player.getExhaustion(); this.experience = player.getExp(); this.isFlying = player.isFlying(); this.foodLevel = player.getFoodLevel(); if (useAttributes) { this.maxHealth = player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getBaseValue(); } else { this.maxHealth = player.getMaxHealth(); } this.health = player.getHealth(); this.gamemode = player.getGameMode(); this.level = player.getLevel(); this.saturationLevel = player.getSaturation(); this.potionEffects = player.getActivePotionEffects(); this.fallDistance = player.getFallDistance(); this.fireTicks = player.getFireTicks(); this.maxAir = player.getMaximumAir(); this.remainingAir = player.getRemainingAir(); this.bankBalance = bankBalance; this.balance = balance; }
Example 5
Source File: Rag.java From Slimefun4 with GNU General Public License v3.0 | 5 votes |
@Override public ItemUseHandler getItemHandler() { return e -> { Player p = e.getPlayer(); // Player is neither burning nor injured if (p.getFireTicks() <= 0 && p.getHealth() >= p.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue()) { return; } if (p.getGameMode() != GameMode.CREATIVE) { ItemUtils.consumeItem(e.getItem(), false); } p.getWorld().playEffect(p.getLocation(), Effect.STEP_SOUND, Material.WHITE_WOOL); p.addPotionEffect(new PotionEffect(PotionEffectType.HEAL, 1, 0)); p.setFireTicks(0); e.cancel(); }; }
Example 6
Source File: PWIPlayer.java From PerWorldInventory with GNU General Public License v3.0 | 5 votes |
PWIPlayer(Player player, Group group, double bankBalance, double balance, boolean useAttributes) { this.uuid = player.getUniqueId(); this.name = player.getName(); this.location = player.getLocation(); this.group = group; this.saved = false; this.armor = player.getInventory().getArmorContents(); this.enderChest = player.getEnderChest().getContents(); this.inventory = player.getInventory().getContents(); this.canFly = player.getAllowFlight(); this.displayName = player.getDisplayName(); this.exhaustion = player.getExhaustion(); this.experience = player.getExp(); this.isFlying = player.isFlying(); this.foodLevel = player.getFoodLevel(); if (useAttributes) { this.maxHealth = player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getBaseValue(); } else { this.maxHealth = player.getMaxHealth(); } this.health = player.getHealth(); this.gamemode = player.getGameMode(); this.level = player.getLevel(); this.saturationLevel = player.getSaturation(); this.potionEffects = player.getActivePotionEffects(); this.fallDistance = player.getFallDistance(); this.fireTicks = player.getFireTicks(); this.maxAir = player.getMaximumAir(); this.remainingAir = player.getRemainingAir(); this.bankBalance = bankBalance; this.balance = balance; }
Example 7
Source File: EntityToggleGlideListener.java From ViaVersion with MIT License | 4 votes |
@EventHandler(priority = EventPriority.MONITOR) public void entityToggleGlide(EntityToggleGlideEvent event) { if (!(event.getEntity() instanceof Player)) return; Player player = (Player) event.getEntity(); if (!isOnPipe(player)) return; // Cancelling can only be done by updating the player's metadata if (event.isGliding() && event.isCancelled()) { PacketWrapper packet = new PacketWrapper(0x44, null, getUserConnection(player)); try { packet.write(Type.VAR_INT, player.getEntityId()); byte bitmask = 0; // Collect other metadata for the mitmask if (player.getFireTicks() > 0) { bitmask |= 0x01; } if (player.isSneaking()) { bitmask |= 0x02; } // 0x04 is unused if (player.isSprinting()) { bitmask |= 0x08; } if (swimmingMethodExists && player.isSwimming()) { bitmask |= 0x10; } if (player.hasPotionEffect(PotionEffectType.INVISIBILITY)) { bitmask |= 0x20; } if (player.isGlowing()) { bitmask |= 0x40; } // leave 0x80 as 0 to stop gliding packet.write(Types1_14.METADATA_LIST, Arrays.asList(new Metadata(0, MetaType1_14.Byte, bitmask))); packet.send(Protocol1_15To1_14_4.class); } catch (Exception e) { e.printStackTrace(); } } }
Example 8
Source File: DPlayerData.java From DungeonsXL with GNU General Public License v3.0 | 4 votes |
/** * Saves the player's data to the file. * * @param player the Player to save */ public void savePlayerState(Player player) { oldGameMode = player.getGameMode(); oldFireTicks = player.getFireTicks(); oldFoodLevel = player.getFoodLevel(); if (is1_9) { oldMaxHealth = player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getBaseValue(); } oldHealth = player.getHealth(); oldExp = player.getExp(); oldLvl = player.getLevel(); oldArmor = new ArrayList<>(Arrays.asList(player.getInventory().getArmorContents())); oldInventory = new ArrayList<>(Arrays.asList(player.getInventory().getContents())); if (is1_9) { oldOffHand = player.getInventory().getItemInOffHand(); } oldLocation = player.getLocation(); oldPotionEffects = player.getActivePotionEffects(); if (is1_9) { oldCollidabilityState = player.isCollidable(); oldInvulnerabilityState = player.isInvulnerable(); } oldFlyingState = player.getAllowFlight(); config.set(PREFIX_STATE_PERSISTENCE + "oldGameMode", oldGameMode.toString()); config.set(PREFIX_STATE_PERSISTENCE + "oldFireTicks", oldFireTicks); config.set(PREFIX_STATE_PERSISTENCE + "oldFoodLevel", oldFoodLevel); config.set(PREFIX_STATE_PERSISTENCE + "oldMaxHealth", oldMaxHealth); config.set(PREFIX_STATE_PERSISTENCE + "oldHealth", oldHealth); config.set(PREFIX_STATE_PERSISTENCE + "oldExp", oldExp); config.set(PREFIX_STATE_PERSISTENCE + "oldLvl", oldLvl); config.set(PREFIX_STATE_PERSISTENCE + "oldArmor", oldArmor); config.set(PREFIX_STATE_PERSISTENCE + "oldInventory", oldInventory); config.set(PREFIX_STATE_PERSISTENCE + "oldOffHand", oldOffHand); config.set(PREFIX_STATE_PERSISTENCE + "oldLocation", oldLocation); config.set(PREFIX_STATE_PERSISTENCE + "oldPotionEffects", oldPotionEffects); config.set(PREFIX_STATE_PERSISTENCE + "oldCollidabilityState", oldCollidabilityState); config.set(PREFIX_STATE_PERSISTENCE + "oldFlyingState", oldFlyingState); config.set(PREFIX_STATE_PERSISTENCE + "oldInvulnerabilityState", oldInvulnerabilityState); save(); }