Ejemplo n.º 1
0
 public static void checkRespawn(Player player) {
   String owner = player.getName();
   if (toRespawn.containsKey(owner)) {
     NPCManager.register(toRespawn.get(owner).getUID(), owner, NPCCreateReason.RESPAWN);
     CitizensManager.getNPC(toRespawn.get(owner).getUID()).teleport(player.getLocation());
   }
 }
Ejemplo n.º 2
0
 @Override
 public void addPermissions() {
   for (WaypointModifierType modifier : WaypointModifierType.values()) {
     CitizensManager.addPermission("waypoints.modifier." + modifier.name().toLowerCase());
   }
 }
Ejemplo n.º 3
0
  @Override
  public void run() {
    for (HumanNPC npc : CitizensManager.getList().values()) {
      if (npc.isType("guard")) {
        Guard guard = npc.getType("guard");
        if (guard.isAttacking()) {
          boolean cancel = false;
          if (!npc.getHandle().hasTarget() || !guard.isAggressive()) {
            cancel = true;
          } else if (npc.getHandle().hasTarget()
              && !LocationUtils.withinRange(
                  npc.getBaseLocation(),
                  npc.getHandle().getTarget().getLocation(),
                  guard.getProtectionRadius())) {
            cancel = true;
          } else if (npc.getHandle().hasTarget()
              && guard.isBodyguard()
              && Bukkit.getServer().getPlayer(npc.getOwner()) != null) {
            Player player = Bukkit.getServer().getPlayer(npc.getOwner());
            if (npc.getHandle().getTarget() != player
                && !LocationUtils.withinRange(
                    npc.getBaseLocation(), player.getLocation(), guard.getProtectionRadius())) {
              cancel = true;
            }
          }
          if (cancel) {
            npc.getHandle().cancelTarget();
            GuardManager.returnToBase(guard, npc);
            guard.setAttacking(false);
          }
        }

        if (LocationUtils.withinRange(npc.getLocation(), npc.getBaseLocation(), 3.5)) {
          if (guard.isReturning()) {
            guard.setReturning(false);
          }
          if (!guard.isAttacking() && npc.isPaused()) {
            npc.setPaused(false);
          }
        } else if (guard.isReturning()
            && npc.getHandle().getStationaryTicks()
                > SettingsManager.getInt("MaxStationaryReturnTicks")) {
          npc.teleport(npc.getBaseLocation());
          guard.setReturning(false);
        }
        if (guard.isAttacking() || guard.isReturning()) {
          continue;
        }
        if (guard.isBouncer()) {
          handleTarget(npc.getPlayer(), npc, guard);
        } else if (guard.isBodyguard()) {
          if (!npc.isPaused()) {
            npc.setPaused(true);
          }
          Player p = Bukkit.getServer().getPlayer(npc.getOwner());
          if (p != null) {
            handleTarget(p, npc, guard);
            if (LocationUtils.withinRange(
                npc.getLocation(), p.getLocation(), guard.getProtectionRadius())) {
              PathUtils.target(npc, p, false, -1, -1, 25);
            } else {
              npc.teleport(p.getLocation());
            }
          } else {
            if (CitizensManager.getNPC(npc.getUID()) != null) {
              toRespawn.put(
                  npc.getOwner(), new NPCLocation(npc.getLocation(), npc.getUID(), npc.getOwner()));
              NPCManager.despawn(npc.getUID(), NPCRemoveReason.DEATH);
            }
          }
        }
      }
    }
  }