Archived
0

fix stream

This commit is contained in:
2019-02-21 00:22:52 +03:00
parent ec21577586
commit 0fff60d086

View File

@@ -10,6 +10,7 @@ import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Collectors;
public class Faction {
@@ -149,16 +150,18 @@ public class Faction {
}
}
public List<Prisoner> getOnlineList() throws SQLException {
List<Prisoner> list = new ArrayList<>();
Iterator itr = Bukkit.getOnlinePlayers().iterator();
while (itr.hasNext()) {
Prisoner m = new Prisoner((Player) itr.next());
if (m.getFaction().getType().equals(me.getFaction().getType())) {
list.add(m);
public List<Prisoner> getOnlineList() {
return Bukkit.getOnlinePlayers().stream()
.map(Prisoner::new)
.filter(prisoner -> {
try {
return prisoner.getFaction().getType().equals(me.getFaction().getType());
} catch (SQLException e) {
e.printStackTrace();
return false;
}
}
return list;
})
.collect(Collectors.toList());
}
private void connect() throws SQLException {