ResourcePack not sending to player


#1

I am trying to make the user download a resource pack with the player.sendResourcePack method but it is not sending at all at the moment.

My Code:

@Listener
public void onGamePreInitialization(GamePreInitializationEvent event) {                
	loadConfig();
	kickMessage = Text.of(confNode.getNode("Kick-Message").getString());
	
	//try to get resource pack zip file from packrequirements folder
	try {
		packURI = new URI(folder.toURI().toString() + confNode.getNode("Resource-Pack").getString());
	} catch (URISyntaxException e) {
		e.printStackTrace();
	}
	
	//setting the ResourcePack to the config specified pack
    try {
		sendPack = ResourcePacks.fromUri(packURI);
		logger.info("Loaded Resource pack from " + packURI);
	} catch (FileNotFoundException e) {
		e.printStackTrace();
	}
}

@Listener
public void onPlayerJoin(ClientConnectionEvent.Join event, @Root Player player) {
	
	//send pack to the player
	logger.info(sendPack.toString());
        player.sendResourcePack(sendPack);

This will load up and the final logger from onPlayerJoin method prints out

[20:57:38] [Server thread/INFO] [packrequirements]: SpongeURIResourcePack{id=e0622ad8-7eda-4e43-8e36-49599c9632f2, uri=file:/C:/Users/21cra/OneDrive/Documents/Servers/TestServer/./config/packrequirements/Madoku+Craft+(Version+26.0).zip}

the modpack listed is what is specified in the config on loadConfig() and that pack name is in the config folder at /config/packrequirements.

Any help is appreciated


#2

A pack URI cannot be a file URI like that. The pack must be downloadable over HTTP.


#3

Doesn’t this create problems when the pack does not download in time?


#4

I have no idea what you mean by ‘not download in time’. The pack just gets downloaded.


#5

Yeahhh just now noticing that. I thought the way the method worked was to download it locally then send it to the player instead of sending it directly from the URI to the player


#6

No. The URI is sent to the player and the player downloads it themselves.


#7

Yup now realizing after testing. Thanks