So, I've recently been looking a lot at lambdas and how to use them in plugins.
Say i wanted to send a message to all staff that a player needed help?
I could either do it this way:
for(Player p : Bukkit.getOnlinePlayers()) {
if(p.hasPermisson("example.helpop")) {
p.sendMessage("A player needs help");
}
}
this is pretty standard, but I could also do it this way:
Bukkit.getOnlinePlayers().stream()
.filter(p -> p.hasPermission("example.helpop"))
.forEach(Player::sendMessage("A player needs help");
Now what would be better to use and what would be more efficent?
Say i wanted to send a message to all staff that a player needed help?
I could either do it this way:
for(Player p : Bukkit.getOnlinePlayers()) {
if(p.hasPermisson("example.helpop")) {
p.sendMessage("A player needs help");
}
}
this is pretty standard, but I could also do it this way:
Bukkit.getOnlinePlayers().stream()
.filter(p -> p.hasPermission("example.helpop"))
.forEach(Player::sendMessage("A player needs help");
Now what would be better to use and what would be more efficent?
