fix stream
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user