add random methods

This commit is contained in:
spacerocket62 2020-11-05 20:39:27 -08:00
parent e4d097aa51
commit ba494f6892
5 changed files with 27 additions and 4 deletions

View File

@ -2,6 +2,8 @@ package me.totalfreedom.plex.command.impl;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import com.google.common.collect.ImmutableList;
import me.totalfreedom.plex.command.PlexCommand; import me.totalfreedom.plex.command.PlexCommand;
import me.totalfreedom.plex.command.annotation.CommandParameters; import me.totalfreedom.plex.command.annotation.CommandParameters;
import me.totalfreedom.plex.command.annotation.CommandPermissions; import me.totalfreedom.plex.command.annotation.CommandPermissions;
@ -66,6 +68,6 @@ public class AdventureCMD extends PlexCommand
{ {
return PlexUtils.getPlayerNameList(); return PlexUtils.getPlayerNameList();
} }
return Collections.emptyList(); return ImmutableList.of();
} }
} }

View File

@ -2,6 +2,8 @@ package me.totalfreedom.plex.command.impl;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import com.google.common.collect.ImmutableList;
import me.totalfreedom.plex.command.PlexCommand; import me.totalfreedom.plex.command.PlexCommand;
import me.totalfreedom.plex.command.annotation.CommandParameters; import me.totalfreedom.plex.command.annotation.CommandParameters;
import me.totalfreedom.plex.command.annotation.CommandPermissions; import me.totalfreedom.plex.command.annotation.CommandPermissions;
@ -65,6 +67,6 @@ public class CreativeCMD extends PlexCommand
{ {
return PlexUtils.getPlayerNameList(); return PlexUtils.getPlayerNameList();
} }
return Collections.emptyList(); return ImmutableList.of();
} }
} }

View File

@ -2,6 +2,8 @@ package me.totalfreedom.plex.command.impl;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import com.google.common.collect.ImmutableList;
import me.totalfreedom.plex.command.PlexCommand; import me.totalfreedom.plex.command.PlexCommand;
import me.totalfreedom.plex.command.annotation.CommandParameters; import me.totalfreedom.plex.command.annotation.CommandParameters;
import me.totalfreedom.plex.command.annotation.CommandPermissions; import me.totalfreedom.plex.command.annotation.CommandPermissions;
@ -62,6 +64,6 @@ public class SpectatorCMD extends PlexCommand
{ {
return PlexUtils.getPlayerNameList(); return PlexUtils.getPlayerNameList();
} }
return Collections.emptyList(); return ImmutableList.of();
} }
} }

View File

@ -2,6 +2,8 @@ package me.totalfreedom.plex.command.impl;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import com.google.common.collect.ImmutableList;
import me.totalfreedom.plex.command.PlexCommand; import me.totalfreedom.plex.command.PlexCommand;
import me.totalfreedom.plex.command.annotation.CommandParameters; import me.totalfreedom.plex.command.annotation.CommandParameters;
import me.totalfreedom.plex.command.annotation.CommandPermissions; import me.totalfreedom.plex.command.annotation.CommandPermissions;
@ -65,6 +67,6 @@ public class SurvivalCMD extends PlexCommand
{ {
return PlexUtils.getPlayerNameList(); return PlexUtils.getPlayerNameList();
} }
return Collections.emptyList(); return ImmutableList.of();
} }
} }

View File

@ -13,6 +13,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Random; import java.util.Random;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.ThreadLocalRandom;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import me.totalfreedom.plex.Plex; import me.totalfreedom.plex.Plex;
import me.totalfreedom.plex.config.Config; import me.totalfreedom.plex.config.Config;
@ -225,4 +226,18 @@ public class PlexUtils
String uuidString = (String)profile.get("uuid"); String uuidString = (String)profile.get("uuid");
return UUID.fromString(uuidString); return UUID.fromString(uuidString);
} }
public static int randomNum()
{
return ThreadLocalRandom.current().nextInt();
}
public static int randomNum(int limit)
{
return ThreadLocalRandom.current().nextInt(limit);
}
public static int randomNum(int start, int limit)
{
return ThreadLocalRandom.current().nextInt(start, limit);
}
} }