am using some simple code, which should get data from config
my config looks like:
name: test
locationA: -457.0,5.0,-186.0
locationB: -454.0,5.0,-186.0
prisonfile: ./plugins/JB/test.prison
prisons:
- -454.0,4.0,-176.0
- -460.0,4.0,-176.0
- -457.0,5.0,-186.0
police:
- -460.0,5.0,-186.0
- -454.0,5.0,-186.0
- -457.0,5.0,-176.0
open: true
my code looks like:
public void enter(Player player, String lines, String lines2)
{
World world = player.getWorld();
HashMap<String, Object> prison = plugin.prisons.getPrison(world.getName(), false);
File configFile = new File(prison.get("config").toString());
FileConfiguration config = YamlConfiguration.loadConfiguration(configFile);
String listName = "police";
List<String> list = config.getStringList(listName);
Integer ListSize = list.size();
Random r = new Random();
int i1=r.nextInt(ListSize-1);
String[] parts = list.get(i1).split(",");
player.teleport(new Location(world, Float.parseFloat(parts[0]), Float.parseFloat(parts[1]), Float.parseFloat(parts[2])));
Code works corretly and teleporting me on random positions, but it always just port on first 2 positions and never port me on 3th one, i try to print out how many coordinations found ListSize in config and its 3 so i totaly dont understand.
p.s. i need to generate randoms between 0 and MaxNumber of positions