コード例 #1
0
ファイル: connector.java プロジェクト: theFra985/Reticle
	private boolean servePlayerList(PlayerListEvent event, List<String> tablist, HashMap<String, String> tablistnick) {
		if (reader.ProtocolVersion >= 47) {
			boolean ret = false;
			for (int i = 0, o = event.UUIDS.size(); i < o; i++) {
				String xUUID = event.UUIDS.get(i);
				if (!event.Onlines.get(o)) {
					if (tablist.contains(xUUID)) {
						tablist.remove(xUUID);
					}
					if (tablistnick.containsKey(xUUID)) {
						tablistnick.remove(xUUID);
					}
				}
			}

			for (int i = 0, o = event.UUIDS.size(); i < o; i++) {
				String xUUID = event.UUIDS.get(i);
				String xname = event.Nicks.get(i);
				boolean xonline = event.Onlines.get(i);
				boolean xchanged = event.Changed.get(i);
				if (tablist.contains(xUUID)) {
					// Already in tablist
					if (xchanged) {
						// Display name changed
						tablistnick.put(xUUID, xname);
						ret = true;
					} else if (!xonline) {
						// Remove us
						tablist.remove(xUUID);
						if (tablistnick.containsKey(xUUID)) {
							tablistnick.remove(xUUID);
						}
						ret = true;
					}
				} else {
					// We are not in tablist yet
					if (xchanged) {
						tablist.add(xUUID);
						tablistnick.put(xUUID, xname);
						ret = true;
					}
				}
			}
			return ret;
		} else {
			if (tablist.contains(event.name)) {
				// We are already in tablist
				if (event.online) {
					// And online (Correct)
				} else {
					// Bot not online (Suicide)
					tablist.remove(event.name);
					return true;
				}
			} else {
				// We are not in tablist yet
				if (event.online) {
					// But online (Must add)
					tablist.add(event.name);
					return true;
				} else {
					// And not online (correct)
				}
			}
		}
		return false;
	}