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