You need to save outside of this method that has already been warned about the player. A Map perfect for this. Even better is WeakHashMap in case you don't want to skip those Entities
private final Set<EntityPlayer> playersInRange = Collections .newSetFromMap(new WeakHashMap<EntityPlayer, Boolean>()); void onMove() { if (Camb.radar) { for (Entity e : (List<Entity>) mc.theWorld.loadedEntityList) { if (e instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) e; if (player == mc.thePlayer || mc.thePlayer.getDistanceToEntity(e) > 20.0) { // make sure player is (no longer) in set playersInRange.remove(player); continue; } if (!playersInRange.contains(player)) { playersInRange.add(player); mc.thePlayer.addChatMessage("\2479[CAMB] \247e" + player.getEntityName() + " has entered your 20 block radius!"); } } } } }
You can also save time with them to re-notify of every X time.
private static final long WAIT_BETWEEN_ALERTS = 30000; private final WeakHashMap<EntityPlayer, Long> map = new WeakHashMap<EntityPlayer, Long>(); void onMove() { if (Camb.radar) { for (Entity e : (List<Entity>) mc.theWorld.loadedEntityList) { if (e instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) e; if (player == mc.thePlayer || mc.thePlayer.getDistanceToEntity(e) > 20.0) {
source share