fixed serverutils
This commit is contained in:
@@ -1,18 +1,13 @@
|
||||
package fun.ogre.ogredupealias.utils;
|
||||
|
||||
import fun.ogre.ogredupealias.OgreDupeAlias;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
@@ -23,7 +18,7 @@ public class ServerUtils {
|
||||
}
|
||||
|
||||
public static List<Player> getStaff() {
|
||||
return getPlayers().stream().filter(Player -> Player.hasPermission("oda.chat.seeflags")).toList();
|
||||
return getPlayers().stream().filter(Player::isOp).toList();
|
||||
}
|
||||
|
||||
public static void forEachPlayer(Consumer<Player> consumer) {
|
||||
@@ -51,24 +46,16 @@ public class ServerUtils {
|
||||
public static void forEachSpecified(Consumer<Player> consumer, Player... players) {
|
||||
Arrays.stream(players).forEach(consumer);
|
||||
}
|
||||
public static void forEachPlayerRun(Predicate<Player> condition, Consumer<Player> task) {
|
||||
forEachPlayer(p -> {
|
||||
if (condition.test(p)) {
|
||||
task.accept(p);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void sendActionBar(Player p, String msg) {
|
||||
p.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(msg));
|
||||
}
|
||||
|
||||
public static boolean hasBlockBelow(Player player, Material material) {
|
||||
for (int y = player.getLocation().getBlockY() - 1; y >= player.getLocation().getBlockY() - 12; y--) {
|
||||
if (player.getWorld().getBlockAt(player.getLocation().getBlockX(), y, player.getLocation().getBlockZ()).getType() == material) {
|
||||
return true;
|
||||
public static void forEachPlayerRun(Predicate<Player> condition, Consumer<Player> action) {
|
||||
forEachPlayer(p -> {
|
||||
if (condition.test(p)) {
|
||||
action.accept(p);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user