KryoNet weird bug

The server is sending to itself and not the clients.

synchronized (projectiles) {
			Iterator<Projectile> projectileIterator = projectiles.iterator();
			while (projectileIterator.hasNext()) {
				Projectile next = projectileIterator.next();
				if (next.isRemoved()) {
					RemoveProjectile remove = new RemoveProjectile();
					remove.id = next.id;
					remove.owner = next.owner;
					GameServer.getInstance().sendToAllTCP(remove);//this gets send to the server from the server
					projectileIterator.remove();
				}

				next.update();
			}
		}
public void sendToAllTCP(Object object) {
		server.sendToAllTCP(object);
	}

Some more code would be helpful, for example, what is the type of projectiles, what even is a RemoveProjectile? Kryonet has its own threads for sending packets, so maybe your synchronized block is affecting it? I would suggest to find a better way to store your projectiles (ArrayList, etc.) because Iterators aren’t thread-safe (they need synchronized methods/blocks).

This question is kind of vague without more code, so I can’t really answer it very well right now.

protected List<Projectile> projectiles = new ArrayList<Projectile>();
	

Remove Projectile class

public class RemoveProjectile implements Packet {

	public String owner;
	public int id;

	@Override
	public void handle(Connection connection, Server server) {
		throw new IllegalArgumentException(
				"Server cannot receive such packet, server is ment to only send it!");
	}

}

You’re going to need to show more code and explain more of your problem. As it stands, I have no idea what could go wrong because your code looks fine.

I would like to see your GameServer class please, maybe the issue lies in there.

I managed to fix it, I don’t remember what I exactly did but I just tried a bunch of stuff.