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