Ejemplo n.º 1
0
 @Override
 public ScriptEntryData getScriptEntryData() {
   if (entity != null) {
     return new BukkitScriptEntryData(
         entity.isPlayer() ? entity.getDenizenPlayer() : null,
         entity.isCitizensNPC() ? entity.getDenizenNPC() : null);
   }
   return new BukkitScriptEntryData(null, null);
 }
Ejemplo n.º 2
0
 @Override
 public boolean matches(ScriptContainer scriptContainer, String s) {
   String lower = CoreUtilities.toLowerCase(s);
   String cmd = CoreUtilities.getXthArg(1, lower);
   String veh =
       cmd.equals("destroyed")
           ? CoreUtilities.getXthArg(0, lower)
           : CoreUtilities.getXthArg(2, lower);
   String ent = cmd.equals("destroys") ? CoreUtilities.getXthArg(0, lower) : "";
   if (!vehicle.matchesEntity(veh)) {
     return false;
   }
   if (ent.length() > 0) {
     if (entity == null || !entity.matchesEntity(ent)) {
       return false;
     }
   }
   return runInCheck(scriptContainer, s, lower, vehicle.getLocation());
 }
Ejemplo n.º 3
0
  @SuppressWarnings("unchecked")
  @Override
  public void execute(final ScriptEntry scriptEntry) throws CommandExecutionException {

    // Get objects
    List<dEntity> entities = (List<dEntity>) scriptEntry.getObject("entities");
    dEntity target = (dEntity) scriptEntry.getObject("target");
    boolean cancel = scriptEntry.hasObject("cancel");

    // Report to dB
    dB.report(
        scriptEntry,
        getName(),
        (cancel ? aH.debugObj("cancel", "true") : "")
            + aH.debugObj("entities", entities.toString())
            + (target != null ? aH.debugObj("target", target) : ""));

    // Go through all the entities and make them either attack
    // the target or stop attacking

    for (dEntity entity : entities) {
      if (entity.isCitizensNPC()) {
        Navigator nav = entity.getDenizenNPC().getCitizen().getNavigator();

        if (!cancel) {
          nav.setTarget(target.getBukkitEntity(), true);
        } else {
          // Only cancel navigation if the NPC is attacking something
          if (nav.isNavigating()
              && nav.getTargetType().equals(TargetType.ENTITY)
              && nav.getEntityTarget().isAggressive()) {

            nav.cancelNavigation();
          }
        }
      } else {
        if (!cancel) {
          entity.target(target.getLivingEntity());
        } else {
          entity.target(null);
        }
      }
    }
  }
Ejemplo n.º 4
0
 public void setRotation(BlockFace direction) {
   ((Hanging) entity.getBukkitEntity()).setFacingDirection(direction, true);
 }
Ejemplo n.º 5
0
 private BlockFace getRotation() {
   return ((Hanging) entity.getBukkitEntity()).getAttachedFace().getOppositeFace();
 }