package team.unstudio.udpl.util;

import java.util.function.Predicate;

import org.bukkit.Bukkit;

public final class ServerUtils {

	private ServerUtils(){}
	
	public static String[] getOnlinePlayerNames(){
		return Bukkit.getOnlinePlayers().stream().map(player->player.getName()).toArray(String[]::new);
	}
	
	public static String[] getOnlinePlayerNamesWithFilter(Predicate<String> filter){
		return Bukkit.getOnlinePlayers().stream().map(player->player.getName()).filter(filter).toArray(String[]::new);
	}
	
	public static String getMinecraftVersion(){
		return Bukkit.getBukkitVersion().substring(0, Bukkit.getBukkitVersion().indexOf("-"));
	}
}

@@ -25,24 +25,77 @@
 pl.util;%0D%0A%0D%0A
+import java.lang.reflect.InvocationTargetException;%0D%0A
 import java.
@@ -120,16 +120,16 @@
 icate;%0D%0A
-
 %0D%0Aimport
@@ -567,32 +567,84 @@
 ::new);%0D%0A%09%7D%0D%0A%09%0D%0A
+%09private static String MINECRAFT_VERSION = null;%0D%0A%0D%0A
 %09public static S
@@ -674,98 +674,624 @@
 on()
+ 
 %7B%0D%0A%09%09
-return Bukkit.getBukkitVersion().substring(0, Bukkit.getBukkitVersion().indexOf(%22-%22))
+if (MINECRAFT_VERSION == null) %7B%0D%0A%09%09%09try %7B%0D%0A%09%09%09%09MINECRAFT_VERSION = (String) ReflectionUtils%0D%0A%09%09%09%09%09%09.invokeMethod(ReflectionUtils.getValue(Bukkit.getServer(), true, %22console%22), %22getVersion%22);%0D%0A%09%09%09%7D catch (IllegalAccessException %7C IllegalArgumentException %7C InvocationTargetException%0D%0A%09%09%09%09%09%7C NoSuchMethodException %7C NoSuchFieldException %7C SecurityException e) %7B%0D%0A%09%09%09%09String bukkitVersion = Bukkit.getBukkitVersion();%0D%0A%09%09%09%09int index = Bukkit.getBukkitVersion().indexOf(%22-%22);%0D%0A%09%09%09%09MINECRAFT_VERSION = bukkitVersion.substring(0, index == -1 ? bukkitVersion.length() : index);%0D%0A%09%09%09%7D%0D%0A%09%09%7D%0D%0A%09%09return MINECRAFT_VERSION
 ;%0D%0A%09

Update ServerUtils