[Sovled]Issue using Sponge's .getRestry

Hi So I’m trying to make it so that I take a way a lot of Lines of code…so I’m trying to make the following:

public class NaturalSpawning {
 	  public void onEntitySpawn(SpawnEntityEvent event){
	  //This is the testing code v\  
 		  
 		  
 		  

 	  }
		int test = DayCounter.getWeeklyConfig();
		public String Config = "Config" + test;
		
 		public void Hostiles(Location<World> spawnLocation) {
 			//removed from list below ,"CAVE_SPIDER","CREEPER","ENDER_CRYSTAL","ENDERMAN","GHAST","MAGMA_CUBE","PIG_ZOMBIE","SILVERFISH","SKELETON","SLIME","SPIDER","WITCH","ZOMBIE"
 			//List<String> list = Arrays.asList("BLAZE","NONE");
 			
 			List<Class<? extends Entity>> classes = ImmutableList.of(
				Monster.class
			);
 			Collection<EntityType> cet = Sponge.getRegistry().getAllOf(EntityType.class).stream().filter(x -> classes.stream().anyMatch(y -> y.isAssignableFrom(x.getEntityClass()))).collect(Collectors.toList());
 			
 			List<EntityType>list = Arrays.asList(cet.iterator().next());
 			Random rand = new Random();
 			EntityType listResult = list.get(rand.nextInt(list.size()));
 			

			String week = "Week " + DayCounter.getCustWeek();
 			for (int i = 0; i< (ConfigurationManager.getInstance().getSpawnControl().getNode(listResult, week, "==========Natural Spawning==========", "# of Attempts: ").getInt()); i++){
				Sponge.getServer().getBroadcastChannel().send(Text.of("Attempt " + i));
 				Random roll = new Random();
 				int answer = roll.nextInt(100) + 1;
 				if (answer <= (ConfigurationManager.getInstance().getSpawnControl().getNode(listResult, week, "==========Natural Spawning==========", "% per Attempt: ").getInt())){
 					Extent extent = spawnLocation.getExtent();
 					Entity entity = extent.createEntity(listResult, spawnLocation.getPosition());
 						Entity creeper = entity;
 						extent.spawnEntity(creeper);
 						Sponge.getServer().getBroadcastChannel().send(Text.of("with a chance of " + answer));
 				}
 			}

 		};
}

Pretty much I’m trying to as you can see 'Randomly Select an Entity from the list of Monsters…however.it doesn’t seeem to be doing anything…so I need some help pointing out where the flaw is in the logic? as there is no Error message. Thanks!

Why didn’t you follow dualspires suggestion in [Solvejd]How to loop through a list for Configuration - #13 by dualspiral

Storing it as class references is more efficient, but maybe if you want modded support I could understand wanting to use strings.

Anyway, I’d suggest dumping the strings you are attempting to filter, my bet is you will find that you have the strings incorrect in your array… e.g. BLAZE should be MINECRAFT:BLAZE

That said, without some sort of validation and error reporting on the strings you get from the config, people are going to be very confused.

1 Like

yea it’ll be using strings…mainly because it was late and I’ve finished the Configuration…this is a different class that deals with spawning :wink: as I’m sure you notice :D.

PLEASE DISREGARD THIS THREAD!!! I found out I was making a very…basic mistake…the program was oding what it’s suppose to do…however I was calling the first node without a .getnames, and the second node as Weeks…instead of WEEKS. So as such it was going to the configuration file…not finding it and setting it to 0 as it should. Sorry for anyone’s time this may have wasted :smiley: but thank you.