Package org.bukkit.entity

Examples of org.bukkit.entity.Entity


        //eh.getDataWatcher().watch(0, (byte) 0x04);
        sitting = true;
    }

    private void standInternal() {
        Entity vehicle = npc.getEntity().getVehicle();
        npc.despawn();
        npc.spawn(npc.getStoredLocation().clone().add(0, 0.5, 0));
        if (vehicle != null && vehicle.isValid()) {
            vehicle.setPassenger(null);
            vehicle.remove();
        }
        //PlayerAnimation.STOP_SITTING.play((Player)npc.getEntity());
        //eh.getDataWatcher().watch(0, (byte) 0x00);
        sitting = false;
    }
View Full Code Here


    }

    @EventHandler
    public void arrowDamage(EntityDamageByEntityEvent event) {
        // Get the damager
        Entity arrow = event.getDamager();

        // First, quickly confirm it's a projectile (relevant at all)
        if (!(arrow instanceof Projectile))
            return;

        // Second, more slowly check if we shot it
        if (!arrows.containsKey(arrow.getUniqueId()))
            return;

        // Replace its entry with the hit entity.
        arrows.remove(arrow.getUniqueId());
        arrows.put(arrow.getUniqueId(), new dEntity(event.getEntity()));
    }
View Full Code Here

    @Nullable
    @Override
    public com.sk89q.worldedit.entity.Entity createEntity(com.sk89q.worldedit.util.Location location, BaseEntity entity) {
        BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
        if (adapter != null) {
            Entity createdEntity = adapter.createEntity(BukkitAdapter.adapt(getWorld(), location), entity);
            if (createdEntity != null) {
                return new BukkitEntity(createdEntity);
            } else {
                return null;
            }
View Full Code Here

    while (entity != null){
      if (entity instanceof Player){
        // Scrap the case of players riding players for the moment.
        return (Player) entity;
      }
      final Entity passenger = entity.getPassenger();
      if (entity.equals(passenger)){
        // Just in case :9.
        break;
      }
      else{
View Full Code Here

  public static void outputDebugVehicleMove(final Player player, final Entity vehicle, final Location from, final Location to, final boolean fake) {
    final StringBuilder builder = new StringBuilder(250);
    final Location vLoc = vehicle.getLocation();
    final Location loc = player.getLocation();
    // TODO: Differentiate debug levels (needs setting up some policy + document in BuildParamteres)?
    final Entity actualVehicle = player.getVehicle();
    final boolean wrongVehicle = actualVehicle == null || actualVehicle.getEntityId() != vehicle.getEntityId();
    if (BuildParameters.debugLevel > 0) {
      builder.append("\n-------------- VEHICLE MOVE " + (fake ? "(fake)" : "") + "--------------\n");
      builder.append(player.getName() + " " + from.getWorld().getName() + ":\n");
      addMove(from, to, null, builder);
      builder.append("\n Vehicle: ");
      addLocation(vLoc, builder);
      builder.append("\n Player: ");
      addLocation(loc, builder);
    }
    else {
      builder.append(player.getName() + " " + from.getWorld().getName() + "veh." + (fake ? "(fake)" : "") + " ");
      addFormattedMove(from, to, null, builder);
      builder.append("\n Vehicle: ");
      addFormattedLocation(vLoc, builder);
      builder.append(" Player: ");
      addFormattedLocation(loc, builder);
    }
    builder.append("\n Vehicle type: " + vehicle.getType() + (wrongVehicle ? (actualVehicle == null ? " (exited?)" : " actual: " + actualVehicle.getType()) : ""));
    System.out.print(builder.toString());
  }
View Full Code Here

   *
   * @param event
   *                fired event
   */
  private void handlerAttackDefend(EntityDamageByEntityEvent event) {
    Entity attacker = event.getDamager();
    Entity defender = event.getEntity();
   
    // Maybe an arrow was thrown
    if (attacker != null && event.getDamager() instanceof Projectile && ((Projectile)event.getDamager()).getShooter() instanceof Player){
      attacker = ((Player)((Projectile)event.getDamager()).getShooter());
    }

    if (attacker != null && defender != null && attacker instanceof Player && defender instanceof Player) {
      // only let adversaries (same warzone, different team) attack each other
      Player a = (Player) attacker;
      Player d = (Player) defender;
      Warzone attackerWarzone = Warzone.getZoneByPlayerName(a.getName());
      Team attackerTeam = Team.getTeamByPlayerName(a.getName());
      Warzone defenderWarzone = Warzone.getZoneByPlayerName(d.getName());
      Team defenderTeam = Team.getTeamByPlayerName(d.getName());
     
      if ((attackerTeam != null && defenderTeam != null && attackerTeam != defenderTeam && attackerWarzone == defenderWarzone)
          || (attackerTeam != null && defenderTeam != null && attacker.getEntityId() == defender.getEntityId())) {
       
        LoadoutSelection defenderLoadoutState = defenderWarzone.getLoadoutSelections().get(d.getName());
        if (defenderLoadoutState != null && defenderLoadoutState.isStillInSpawn()) {
          War.war.badMsg(a, "pvp.target.spawn");
          event.setCancelled(true);
          return;
        }
       
        LoadoutSelection attackerLoadoutState = attackerWarzone.getLoadoutSelections().get(a.getName());
        if (attackerLoadoutState != null && attackerLoadoutState.isStillInSpawn()) {
          War.war.badMsg(a, "pvp.self.spawn");
          event.setCancelled(true);
          return;
        }
       
        // Make sure none of them are locked in by respawn timer
        if (defenderWarzone.isRespawning(d)) {
          War.war.badMsg(a, "pvp.target.respawn");
          event.setCancelled(true);
          return;
        } else if (attackerWarzone.isRespawning(a)) {
          War.war.badMsg(a, "pvp.self.respawn");
          event.setCancelled(true);
          return;
        }
       
        if (!attackerWarzone.getWarzoneConfig().getBoolean(WarzoneConfig.PVPINZONE)) {
          // spleef-like, non-pvp, zone
          event.setCancelled(true);
          return;
        }

        // Detect death, prevent it and respawn the player
        if (event.getDamage() >= d.getHealth()) {
          if (defenderWarzone.getReallyDeadFighters().contains(d.getName())) {
            // don't re-kill a dead person       
            return;
          }
          WarPlayerDeathEvent event1 = new WarPlayerDeathEvent(defenderWarzone, d, a, event.getCause());
          War.war.getServer().getPluginManager().callEvent(event1);
          if (!defenderWarzone.getWarzoneConfig().getBoolean(WarzoneConfig.REALDEATHS)) {
            // fast respawn, don't really die
            event.setCancelled(true);
          }
          if (d == a) {
            defenderWarzone.handleSuicide(d);
          } else {
            defenderWarzone.handleKill(a, d, event.getDamager());
          }
        } else if (defenderWarzone.isBombThief(d.getName()) && d.getLocation().distance(a.getLocation()) < 2) {
          // Close combat, close enough to detonate         
          Bomb bomb = defenderWarzone.getBombForThief(d.getName());
                   
          // Kill the bomber
          WarPlayerDeathEvent event1 = new WarPlayerDeathEvent(defenderWarzone, d, null, event.getCause());
          War.war.getServer().getPluginManager().callEvent(event1);
          defenderWarzone.handleDeath(d);
         
          if (defenderWarzone.getWarzoneConfig().getBoolean(WarzoneConfig.REALDEATHS)) {
            // and respawn him and remove from deadmen (cause realdeath + handleDeath means no respawn and getting queued up for onPlayerRespawn)
            defenderWarzone.getReallyDeadFighters().remove(d.getName());
            defenderWarzone.respawnPlayer(defenderTeam, d);
          }
         
          // Blow up bomb
          if (!defenderWarzone.getWarzoneConfig().getBoolean(WarzoneConfig.UNBREAKABLE)) {
            defenderWarzone.getWorld().createExplosion(a.getLocation(), 2F);
          }

          // bring back tnt
          bomb.getVolume().resetBlocks();
          bomb.addBombBlocks();
         
          // Notify everyone
          for (Team t : defenderWarzone.getTeams()) {
            t.sendAchievement(attackerTeam.getKind().getColor() + a.getName() + ChatColor.YELLOW + " made ",
                defenderTeam.getKind().getColor() + d.getName() + ChatColor.YELLOW + " blow up!", new ItemStack(Material.TNT), 10000);
            t.teamcast("pvp.kill.bomb", attackerTeam.getKind().getColor() + a.getName() + ChatColor.WHITE,
                defenderTeam.getKind().getColor() + d.getName() + ChatColor.WHITE);
          }
        }
      } else if (attackerTeam != null && defenderTeam != null && attackerTeam == defenderTeam && attackerWarzone == defenderWarzone && attacker.getEntityId() != defender.getEntityId()) {
        // same team, but not same person
        if (attackerWarzone.getWarzoneConfig().getBoolean(WarzoneConfig.FRIENDLYFIRE)) {
          War.war.badMsg(a, "pvp.ff.enabled"); // if ff is on, let the attack go through
        } else {
          War.war.badMsg(a, "pvp.ff.disabled");
          event.setCancelled(true); // ff is off
        }
      } else if (attackerTeam == null && defenderTeam == null && War.war.canPvpOutsideZones(a)) {
        // let normal PVP through is its not turned off or if you have perms
      } else if (attackerTeam == null && defenderTeam == null && !War.war.canPvpOutsideZones(a)) {
        if (!War.war.getWarConfig().getBoolean(WarConfig.DISABLEPVPMESSAGE)) {
          War.war.badMsg(a, "pvp.outside.permission");
        }
       
        event.setCancelled(true); // global pvp is off
      } else {
        if (attackerTeam == null) {
          War.war.badMsg(a, "pvp.self.notplaying");
        } else if (defenderTeam == null) {
          War.war.badMsg(a, "pvp.target.notplaying");
        } else if (attacker != null && defender != null && attacker.getEntityId() == defender.getEntityId()) {
          // You just hit yourself, probably with a bouncing arrow
        } else if (attackerTeam == defenderTeam) {
          War.war.badMsg(a, "pvp.ff.disabled");
        } else if (attackerWarzone != defenderWarzone) {
          War.war.badMsg(a, "pvp.target.otherzone");
View Full Code Here

   
    if (!War.war.isLoaded()) {     
      return;
    }

    Entity entity = event.getEntity();
    if (!(entity instanceof Player)) {
     
      return;
    }
    Player player = (Player) entity;
View Full Code Here

            && event.getRegainReason() != RegainReason.EATING
            && event.getRegainReason() != RegainReason.SATIATED)) {
      return;
    }

    Entity entity = event.getEntity();
    if (!(entity instanceof Player)) {
      return;
    }

    Player player = (Player) entity;
View Full Code Here

        }
    }
   
    @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
    public void onEntityDamage(final EntityDamageEvent event){
        final Entity entity = event.getEntity();
        if (!(entity instanceof Player)) return;
        final Player  player = (Player) entity;
        final CombinedConfig cc = CombinedConfig.getConfig(player);
        if (!cc.invulnerableCheck) return;
        final DamageCause cause = event.getCause();
View Full Code Here

     *            the event
     */
    @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
    public void onEntityDamage(final EntityDamageEvent event) {
     
      final Entity damaged = event.getEntity();
      final Player damagedPlayer = damaged instanceof Player ? (Player) damaged : null;
      final FightData damagedData = damagedPlayer == null ? null : FightData.getData(damagedPlayer);
      final boolean damagedIsDead = damaged.isDead();
      if (damagedPlayer != null && !damagedIsDead) {
            if (!damagedPlayer.isDead() && godMode.isEnabled(damagedPlayer) && godMode.check(damagedPlayer, BridgeHealth.getDamage(event), damagedData)){
                // It requested to "cancel" the players invulnerability, so set their noDamageTicks to 0.
              damagedPlayer.setNoDamageTicks(0);
            }
            if (BridgeHealth.getHealth(damagedPlayer) >= BridgeHealth.getMaxHealth(damagedPlayer)){
              // TODO: Might use the same FightData instance for GodMode.
              if (damagedData.fastHealBuffer < 0){
                // Reduce negative buffer with each full health.
                damagedData.fastHealBuffer /= 2;
              }
              // Set reference time.
              damagedData.fastHealRefTime = System.currentTimeMillis();
            }
        }
//      System.out.println(event.getCause());
      // Attacking entities.
        if (event instanceof EntityDamageByEntityEvent) {
            final EntityDamageByEntityEvent e = (EntityDamageByEntityEvent) event;
            final Entity damager = e.getDamager();
            final int tick = TickTask.getTick();
          if (damagedPlayer != null && !damagedIsDead){
              // TODO: check once more when to set this (!) in terms of order.
            FightData.getData(damagedPlayer).damageTakenByEntityTick = tick;
                if (hasThorns(damagedPlayer)){
                // TODO: Cleanup here.
                  // Remember the id of the attacker to allow counter damage.
                  damagedData.thornsId = damager.getEntityId();
              }
                else{
                  damagedData.thornsId = Integer.MIN_VALUE;
                }
          }
          final DamageCause damageCause = event.getCause();
          final Player player = damager instanceof Player ? (Player) damager : null;
          Player attacker = player;
          // TODO: deobfuscate.
          if (damager instanceof TNTPrimed) {
            final Entity source = ((TNTPrimed) damager).getSource();
            if (source instanceof Player) {
              attacker = (Player) source;
            }
          }
          if (attacker != null && (damageCause == DamageCause.BLOCK_EXPLOSION || damageCause == DamageCause.ENTITY_EXPLOSION)) {
View Full Code Here

TOP

Related Classes of org.bukkit.entity.Entity

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.