-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cd59fc2
commit 5c36a7f
Showing
8 changed files
with
59 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 20 additions & 10 deletions
30
src/main/kotlin/one/oktw/galaxy/proxy/resourcepack/ResourcePackHelper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,30 @@ | ||
package one.oktw.galaxy.proxy.resourcepack | ||
|
||
import com.velocitypowered.api.proxy.Player | ||
import com.velocitypowered.api.proxy.player.ResourcePackInfo | ||
import one.oktw.galaxy.proxy.Main.Companion.main | ||
import kotlin.math.max | ||
|
||
class ResourcePackHelper { | ||
companion object{ | ||
fun trySendResourcePack(player: Player, galaxy: String){ | ||
val resourcePack = main.config.galaxiesResourcePack[galaxy] ?: return | ||
companion object { | ||
fun updatePlayerResourcePacks(player: Player, galaxy: String) { | ||
val targetResourcePacks = main.config.galaxies[galaxy]?.ResourcePacks?.distinct()?.mapNotNull { main.config.resourcePacks[it]?.packInfo() } ?: return | ||
val appliedResourcePacks = player.appliedResourcePacks.toList().filterNotNull() | ||
|
||
player.clearResourcePacks() | ||
player.sendResourcePackOffer( | ||
main.proxy.createResourcePackBuilder(resourcePack.uri.toString()) | ||
.setHash(resourcePack.hash) | ||
.setShouldForce(true) | ||
.build() | ||
) | ||
var skipFurtherCheck = false | ||
val packsToQueue = mutableListOf<ResourcePackInfo>() | ||
val packsToRemove = mutableListOf<ResourcePackInfo>() | ||
|
||
for (index in 0..max(targetResourcePacks.size, appliedResourcePacks.size)) { | ||
if (targetResourcePacks.getOrNull(index)?.hash.contentEquals(appliedResourcePacks.getOrNull(index)?.hash) && !skipFurtherCheck) continue | ||
|
||
skipFurtherCheck = true | ||
if (index < appliedResourcePacks.size) packsToRemove.add(appliedResourcePacks[index]) | ||
if (index < targetResourcePacks.size) packsToQueue.add(targetResourcePacks[index]) | ||
} | ||
|
||
packsToRemove.forEach { pack -> player.removeResourcePacks(pack) } | ||
packsToQueue.forEach { pack -> player.sendResourcePacks(pack) } | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"base": "", | ||
"lobby": "" | ||
} |