forgot to push
This commit is contained in:
parent
9953388b92
commit
263e3e7768
@ -0,0 +1,29 @@
|
||||
package mineplex.core.common.util;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.java.sk89q.jnbt.NBTInputStream;
|
||||
import com.java.sk89q.jnbt.NamedTag;
|
||||
|
||||
public class UtilOfflinePlayer
|
||||
{
|
||||
public static ItemStack loadOfflineInventory(File file)
|
||||
{
|
||||
try (NBTInputStream stream = new NBTInputStream(new FileInputStream(file)))
|
||||
{
|
||||
NamedTag tag = stream.readNamedTag();
|
||||
|
||||
System.out.println(tag);
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package mineplex.core.common.util;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class UtilStreams
|
||||
{
|
||||
public static boolean IsEmpty(Stream<?> stream)
|
||||
{
|
||||
return Sum(stream) != 0;
|
||||
}
|
||||
|
||||
public static int Sum(Stream<?> stream)
|
||||
{
|
||||
return stream.mapToInt(v -> 1).sum();
|
||||
}
|
||||
|
||||
public static Object[] ToArray(Stream<? extends Object> stream)
|
||||
{
|
||||
return stream.toArray();
|
||||
}
|
||||
|
||||
public static <T> T Get(int index, Stream<T> stream)
|
||||
{
|
||||
if (Sum(stream) < index + 1)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return (T) ToArray(stream)[index];
|
||||
}
|
||||
|
||||
public static <T> T GetFirst(Stream<T> stream)
|
||||
{
|
||||
return Get(0, stream);
|
||||
}
|
||||
|
||||
public static <T> T GetLast(Stream<T> stream)
|
||||
{
|
||||
return Get(Sum(stream) + 1, stream);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user