1 package com.realtime.crossfire.jxclient.knowledge;
7 import java.util.ArrayList;
8 import java.util.Collection;
9 import java.util.Collections;
10 import java.util.Comparator;
11 import java.util.List;
12 import java.util.stream.Collectors;
13 import org.jetbrains.annotations.NotNull;
14 import org.jetbrains.annotations.Nullable;
26 private static final Comparator<KnowledgeItem>
KNOWLEDGE_COMPARATOR = (o1, o2) -> o1.getKnowledgeTitle().compareToIgnoreCase(o2.getKnowledgeTitle());
36 private final List<String>
types =
new ArrayList<>();
39 private final List<String>
names =
new ArrayList<>();
42 private final List<Integer>
faces =
new ArrayList<>();
45 private final List<Boolean>
attempt =
new ArrayList<>();
48 private final Collection<KnowledgeItem>
items =
new ArrayList<>();
61 @SuppressWarnings(
"FieldCanBeLocal")
70 public void metaserver() {
75 public void preConnecting(@NotNull
final String serverInfo) {
80 public void connecting(@NotNull
final String serverInfo) {
90 public void connecting(@NotNull
final ClientSocketState clientSocketState, @NotNull
final String param) {
95 public void connected() {
100 public void connectFailed(@NotNull
final String reason) {
126 public void addKnowledgeType(@NotNull
final String type, @NotNull
final String name,
final int face,
final boolean canAttempt) {
128 if (type.isEmpty()) {
129 names.add(
"All types");
136 listener.typeAdded(0);
153 if (index < 0 || index >=
faces.size()) {
156 return names.get(index);
160 if (index < 0 || index >=
faces.size()) {
163 return faces.get(index);
167 for (
int i = 0; i <
types.size(); i++) {
168 if (type.equals(
types.get(i))) {
176 public void addKnowledge(
final int index, @NotNull
final String type, @NotNull
final String title,
final int face) {
180 listener.knowledgeAdded(0);
197 }
catch (
final IndexOutOfBoundsException ignored) {
203 if (index < 0 || index >=
types.size()) {
207 final String filter =
types.get(index);
217 listener.knowledgeAdded(0);