Search in sources :

Example 1 with CompatibilityBundle

use of net.glowstone.util.CompatibilityBundle in project Glowstone by GlowstoneMC.

the class GlowServer method aggregateLibraries.

private Set<Library> aggregateLibraries(String repository, String libraryFolder) {
    String bundleString = config.getString(Key.COMPATIBILITY_BUNDLE);
    CompatibilityBundle bundle = CompatibilityBundle.fromConfig(bundleString);
    if (bundle == null) {
        logger.log(Level.SEVERE, "Unrecognized compatibility bundle: \"" + bundleString + "\"");
        System.exit(1);
    }
    Map<LibraryKey, Library> bundleLibs = bundle.libraries;
    ListMultimap<LibraryKey, Library> configLibs = config.getMapList(Key.LIBRARIES_LIST).stream().map(Library::fromConfigMap).filter(library -> {
        if (bundleLibs.containsKey(library.getLibraryKey())) {
            logger.log(Level.WARNING, String.format("Library '%s' is already defined as part of bundle '%s'. This entry within" + " the 'libraries' config section will be ignored.", library.getLibraryKey().toString(), bundleString));
            return false;
        }
        return true;
    }).collect(Multimaps.toMultimap(Library::getLibraryKey, Function.identity(), MultimapBuilder.hashKeys().arrayListValues()::build));
    Set<String> conflicts = new HashSet<>();
    Set<String> duplicateLibs = new HashSet<>();
    Map<String, Naether> clients = new HashMap<>();
    clients.put(null, createNaetherWithRepository(repository, libraryFolder));
    for (Map.Entry<LibraryKey, List<Library>> entry : Multimaps.asMap(configLibs).entrySet()) {
        if (entry.getValue().size() > 1) {
            duplicateLibs.add(entry.getKey().toString());
        } else {
            Library library = entry.getValue().get(0);
            if (serverContainsLibrary(library)) {
                conflicts.add(entry.getKey().toString());
            } else if (!library.isExcludeDependencies()) {
                Naether naether = clients.computeIfAbsent(library.getRepository(), k -> createNaetherWithRepository(k, libraryFolder));
                if (naether != null) {
                    naether.addDependency(String.format(// NON-NLS
                    "%s:%s:jar:%s", library.getGroupId(), library.getArtifactId(), library.getVersion()));
                }
            }
        }
    }
    if (!conflicts.isEmpty() || !duplicateLibs.isEmpty()) {
        if (!conflicts.isEmpty()) {
            String joinedConflicts = conflicts.stream().collect(Collectors.joining("', '", "['", "']"));
            logger.log(Level.SEVERE, String.format("Libraries %s conflict with libraries built into this JAR file. Please fix" + " this issue and restart the server.", joinedConflicts));
        }
        if (!duplicateLibs.isEmpty()) {
            String joinedDuplicates = duplicateLibs.stream().collect(Collectors.joining("', '", "['", "']"));
            logger.log(Level.SEVERE, String.format("Libraries %s are defined multiple times in the 'libraries' config section.", joinedDuplicates));
        }
        System.exit(1);
    }
    Map<LibraryKey, Library> dependencyLibs = clients.entrySet().stream().filter(Objects::nonNull).flatMap(entry -> {
        try {
            entry.getValue().resolveDependencies(false);
            return entry.getValue().getDependenciesNotation().stream().map(dependency -> {
                // same format as above, {groupId}:{artifactId}:jar:{version}
                String[] expanded = dependency.split(":");
                // TODO: populate the checksum fields if possible
                return new Library(expanded[0], expanded[1], expanded[3], entry.getKey());
            });
        } catch (NaetherException e) {
            logger.log(Level.WARNING, "Unable to resolve library dependencies. Falling" + " back to explicitly defined dependencies only.", e);
            return Stream.empty();
        }
    }).filter(library -> !configLibs.containsKey(library.getLibraryKey()) && !serverContainsLibrary(library) && !blacklistedRuntimeLibs.contains(library.getLibraryKey())).collect(Collectors.toMap(Library::getLibraryKey, Function.identity(), (library1, library2) -> library1.compareTo(library2) > 0 ? library1 : library2));
    Set<Library> libraries = new HashSet<>(bundleLibs.size() + configLibs.size() + dependencyLibs.size());
    libraries.addAll(bundleLibs.values());
    libraries.addAll(configLibs.values());
    libraries.addAll(dependencyLibs.values());
    return libraries;
}
Also used : DeopCommand(net.glowstone.command.minecraft.DeopCommand) MultimapBuilder(com.google.common.collect.MultimapBuilder) XpCommand(net.glowstone.command.minecraft.XpCommand) DatapackManager(io.papermc.paper.datapack.DatapackManager) GlowScoreboardManager(net.glowstone.scoreboard.GlowScoreboardManager) MaterialValueManager(net.glowstone.block.MaterialValueManager) BanCommand(net.glowstone.command.minecraft.BanCommand) Location(org.bukkit.Location) BarColor(org.bukkit.boss.BarColor) Map(java.util.Map) GlowInventory(net.glowstone.inventory.GlowInventory) Path(java.nio.file.Path) TagManager(net.glowstone.datapack.TagManager) Entity(org.bukkit.entity.Entity) FileVisitor(java.nio.file.FileVisitor) VanillaTagManager(net.glowstone.datapack.vanilla.VanillaTagManager) StructureType(org.bukkit.StructureType) GameModeCommand(net.glowstone.command.minecraft.GameModeCommand) Advancement(org.bukkit.advancement.Advancement) OfflinePlayer(org.bukkit.OfflinePlayer) FileVisitResult(java.nio.file.FileVisitResult) CountDownLatch(java.util.concurrent.CountDownLatch) Stream(java.util.stream.Stream) FunctionCommand(net.glowstone.command.minecraft.FunctionCommand) LibraryManager(net.glowstone.util.library.LibraryManager) LinkstoneClassInitObserver(net.glowstone.util.linkstone.LinkstoneClassInitObserver) AdvancementsMessage(net.glowstone.net.message.play.player.AdvancementsMessage) EntityIdManager(net.glowstone.entity.EntityIdManager) NetherGenerator(net.glowstone.generator.NetherGenerator) FishingRewardManager(net.glowstone.entity.FishingRewardManager) RecipeManager(net.glowstone.datapack.RecipeManager) SaveAllCommand(net.glowstone.command.minecraft.SaveAllCommand) TestForBlocksCommand(net.glowstone.command.minecraft.TestForBlocksCommand) WorldStorageProviderFactory(net.glowstone.io.WorldStorageProviderFactory) Messenger(org.bukkit.plugin.messaging.Messenger) SimpleServicesManager(org.bukkit.plugin.SimpleServicesManager) GameRuleCommand(net.glowstone.command.minecraft.GameRuleCommand) IOException(java.io.IOException) BanEntry(org.bukkit.BanEntry) CachedServerIcon(org.bukkit.util.CachedServerIcon) InventoryHolder(org.bukkit.inventory.InventoryHolder) ExecutionException(java.util.concurrent.ExecutionException) Networking(net.glowstone.net.Networking) LinkstonePluginLoader(net.glowstone.util.linkstone.LinkstonePluginLoader) BossBar(org.bukkit.boss.BossBar) Audience(net.kyori.adventure.audience.Audience) BanIpCommand(net.glowstone.command.minecraft.BanIpCommand) TestForBlockCommand(net.glowstone.command.minecraft.TestForBlockCommand) GameServer(net.glowstone.net.GameServer) NaetherImpl(com.tobedevoured.naether.impl.NaetherImpl) Boxes(net.glowstone.linkstone.runtime.Boxes) TitleCommand(net.glowstone.command.minecraft.TitleCommand) PluginManager(org.bukkit.plugin.PluginManager) Plugin(org.bukkit.plugin.Plugin) ConsoleCommandSender(org.bukkit.command.ConsoleCommandSender) BlockDataManager(net.glowstone.block.data.BlockDataManager) MemorySection(org.bukkit.configuration.MemorySection) Random(java.util.Random) SimpleCommandMap(org.bukkit.command.SimpleCommandMap) Player(org.bukkit.entity.Player) GlowHelpMap(net.glowstone.util.GlowHelpMap) PluginLoadOrder(org.bukkit.plugin.PluginLoadOrder) ChunkGenerator(org.bukkit.generator.ChunkGenerator) TheEndGenerator(net.glowstone.generator.TheEndGenerator) Merchant(org.bukkit.inventory.Merchant) AnvilWorldStorageProvider(net.glowstone.io.anvil.AnvilWorldStorageProvider) UnsafeValues(org.bukkit.UnsafeValues) NotImplementedException(org.apache.commons.lang.NotImplementedException) Recipe(org.bukkit.inventory.Recipe) GlowEnchantment(net.glowstone.constants.GlowEnchantment) GlowMapView(net.glowstone.map.GlowMapView) ImmutableSet(com.google.common.collect.ImmutableSet) ItemFactory(org.bukkit.inventory.ItemFactory) DefaultGameModeCommand(net.glowstone.command.minecraft.DefaultGameModeCommand) PermissionDefault(org.bukkit.permissions.PermissionDefault) Collection(java.util.Collection) SaveToggleCommand(net.glowstone.command.minecraft.SaveToggleCommand) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) BanList(org.bukkit.BanList) TellrawCommand(net.glowstone.command.minecraft.TellrawCommand) UUID(java.util.UUID) VanillaFuelManager(net.glowstone.datapack.vanilla.VanillaFuelManager) StopCommand(net.glowstone.command.minecraft.StopCommand) SummonCommand(net.glowstone.command.minecraft.SummonCommand) Collectors(java.util.stream.Collectors) WarningState(org.bukkit.Warning.WarningState) Objects(java.util.Objects) QueryServer(net.glowstone.net.query.QueryServer) GlowDispenser(net.glowstone.block.entity.state.GlowDispenser) ColorCommand(net.glowstone.command.glowstone.ColorCommand) NoInline(net.glowstone.util.NoInline) Command(org.bukkit.command.Command) ShutdownMonitorThread(net.glowstone.util.ShutdownMonitorThread) NonNls(org.jetbrains.annotations.NonNls) CompletableFuture(java.util.concurrent.CompletableFuture) WorldCreator(org.bukkit.WorldCreator) PlaySoundCommand(net.glowstone.command.minecraft.PlaySoundCommand) WorldBorderCommand(net.glowstone.command.minecraft.WorldBorderCommand) Function(java.util.function.Function) ConcurrentMap(java.util.concurrent.ConcurrentMap) Level(java.util.logging.Level) HashSet(java.util.HashSet) SecurityUtils(net.glowstone.util.SecurityUtils) GameMode(org.bukkit.GameMode) Environment(org.bukkit.World.Environment) BarStyle(org.bukkit.boss.BarStyle) PlayerAbilitiesMessage(net.glowstone.net.message.play.player.PlayerAbilitiesMessage) SuperflatGenerator(net.glowstone.generator.SuperflatGenerator) Preconditions.checkNotNull(com.google.common.base.Preconditions.checkNotNull) BasicFileAttributes(java.nio.file.attribute.BasicFileAttributes) WorldScheduler(net.glowstone.scheduler.WorldScheduler) Permission(org.bukkit.permissions.Permission) Consumer(java.util.function.Consumer) GlowServerIcon(net.glowstone.util.GlowServerIcon) CompatibilityBundle(net.glowstone.util.CompatibilityBundle) BuiltinMaterialValueManager(net.glowstone.block.BuiltinMaterialValueManager) NaetherException(com.tobedevoured.naether.NaetherException) TellCommand(net.glowstone.command.minecraft.TellCommand) ChatColor(org.bukkit.ChatColor) KeyPair(java.security.KeyPair) FieldSet(net.glowstone.linkstone.runtime.FieldSet) WhitelistCommand(net.glowstone.command.minecraft.WhitelistCommand) GlowKeyedBossBar(net.glowstone.boss.GlowKeyedBossBar) ListMultimap(com.google.common.collect.ListMultimap) SayCommand(net.glowstone.command.minecraft.SayCommand) OverworldGenerator(net.glowstone.generator.OverworldGenerator) World(org.bukkit.World) MeCommand(net.glowstone.command.minecraft.MeCommand) GlowstoneCommand(net.glowstone.command.glowstone.GlowstoneCommand) WorldConfig(net.glowstone.util.config.WorldConfig) Material(org.bukkit.Material) CommandSender(org.bukkit.command.CommandSender) CloneCommand(net.glowstone.command.minecraft.CloneCommand) BlockData(org.bukkit.block.data.BlockData) EnumMap(java.util.EnumMap) EnchantCommand(net.glowstone.command.minecraft.EnchantCommand) Set(java.util.Set) GiveCommand(net.glowstone.command.minecraft.GiveCommand) ProtocolProvider(net.glowstone.net.protocol.ProtocolProvider) SetWorldSpawnCommand(net.glowstone.command.minecraft.SetWorldSpawnCommand) ItemStack(org.bukkit.inventory.ItemStack) ToggleDownfallCommand(net.glowstone.command.minecraft.ToggleDownfallCommand) LootingManager(net.glowstone.util.loot.LootingManager) LinkstoneRuntimeData(net.glowstone.linkstone.runtime.LinkstoneRuntimeData) PardonIpCommand(net.glowstone.command.minecraft.PardonIpCommand) TpCommand(net.glowstone.command.minecraft.TpCommand) PlayerDataService(net.glowstone.io.PlayerDataService) DefaultPermissions(org.bukkit.util.permissions.DefaultPermissions) UuidListFile(net.glowstone.util.bans.UuidListFile) BarFlag(org.bukkit.boss.BarFlag) Tag(org.bukkit.Tag) Message(com.flowpowered.network.Message) TimeCommand(net.glowstone.command.minecraft.TimeCommand) EffectCommand(net.glowstone.command.minecraft.EffectCommand) ServerConfig(net.glowstone.util.config.ServerConfig) Multimaps(com.google.common.collect.Multimaps) GlowBanList(net.glowstone.util.bans.GlowBanList) StandardCopyOption(java.nio.file.StandardCopyOption) ArrayList(java.util.ArrayList) OpenCompute(net.glowstone.util.OpenCompute) BaseComponent(net.md_5.bungee.api.chat.BaseComponent) Type(org.bukkit.BanList.Type) Keyed(org.bukkit.Keyed) ProfileCache(net.glowstone.entity.meta.profile.ProfileCache) Server(org.bukkit.Server) ServicesManager(org.bukkit.plugin.ServicesManager) GlowChunkData(net.glowstone.generator.GlowChunkData) PlayerStatisticIoService(net.glowstone.io.PlayerStatisticIoService) OpCommand(net.glowstone.command.minecraft.OpCommand) Naether(com.tobedevoured.naether.api.Naether) SetIdleTimeoutCommand(net.glowstone.command.minecraft.SetIdleTimeoutCommand) Nullable(javax.annotation.Nullable) LootTable(org.bukkit.loot.LootTable) ListCommand(net.glowstone.command.minecraft.ListCommand) SeedCommand(net.glowstone.command.minecraft.SeedCommand) Files(java.nio.file.Files) File(java.io.File) RconServer(net.glowstone.net.rcon.RconServer) PardonCommand(net.glowstone.command.minecraft.PardonCommand) SessionRegistry(net.glowstone.net.SessionRegistry) MobGoals(com.destroystokyo.paper.entity.ai.MobGoals) WeatherCommand(net.glowstone.command.minecraft.WeatherCommand) FuelManager(net.glowstone.datapack.FuelManager) KeyedBossBar(org.bukkit.boss.KeyedBossBar) VanillaRecipeManager(net.glowstone.datapack.vanilla.VanillaRecipeManager) GlowstoneMessages(net.glowstone.i18n.GlowstoneMessages) ConfigurationSection(org.bukkit.configuration.ConfigurationSection) HelpMap(org.bukkit.help.HelpMap) Library(net.glowstone.util.library.Library) TimeoutException(java.util.concurrent.TimeoutException) GlowPlayer(net.glowstone.entity.GlowPlayer) ConsoleMessages(net.glowstone.i18n.ConsoleMessages) Inventory(org.bukkit.inventory.Inventory) KickCommand(net.glowstone.command.minecraft.KickCommand) Difficulty(org.bukkit.Difficulty) GlowUnsafeValues(net.glowstone.util.GlowUnsafeValues) ScoreboardIoService(net.glowstone.io.ScoreboardIoService) BanListCommand(net.glowstone.command.minecraft.BanListCommand) Bukkit(org.bukkit.Bukkit) StatusRequestMessage(net.glowstone.net.message.status.StatusRequestMessage) BufferedImage(java.awt.image.BufferedImage) GlowScheduler(net.glowstone.scheduler.GlowScheduler) Logger(java.util.logging.Logger) GlowItemFactory(net.glowstone.inventory.GlowItemFactory) PluginCommand(org.bukkit.command.PluginCommand) InetSocketAddress(java.net.InetSocketAddress) Sets(com.google.common.collect.Sets) List(java.util.List) TeleportCommand(net.glowstone.command.minecraft.TeleportCommand) LibraryKey(net.glowstone.util.library.LibraryKey) NotNull(org.jetbrains.annotations.NotNull) CommandException(org.bukkit.command.CommandException) ConfigurationSerialization(org.bukkit.configuration.serialization.ConfigurationSerialization) Setter(lombok.Setter) NonNull(org.checkerframework.checker.nullness.qual.NonNull) Getter(lombok.Getter) DifficultyCommand(net.glowstone.command.minecraft.DifficultyCommand) LinkstonePluginScanner(net.glowstone.util.linkstone.LinkstonePluginScanner) ChunkData(org.bukkit.generator.ChunkGenerator.ChunkData) GlowBossBar(net.glowstone.boss.GlowBossBar) CLPlatform(com.jogamp.opencl.CLPlatform) SimplePluginManager(org.bukkit.plugin.SimplePluginManager) HashMap(java.util.HashMap) Iterators(com.google.common.collect.Iterators) CLDevice(com.jogamp.opencl.CLDevice) SetBlockCommand(net.glowstone.command.minecraft.SetBlockCommand) KillCommand(net.glowstone.command.minecraft.KillCommand) Component(net.kyori.adventure.text.Component) GlowSession(net.glowstone.net.GlowSession) GlowPotionEffect(net.glowstone.constants.GlowPotionEffect) TextMessage(net.glowstone.util.TextMessage) Key(net.glowstone.util.config.ServerConfig.Key) SpawnPointCommand(net.glowstone.command.minecraft.SpawnPointCommand) StandardMessenger(org.bukkit.plugin.messaging.StandardMessenger) NamespacedKey(org.bukkit.NamespacedKey) InventoryType(org.bukkit.event.inventory.InventoryType) Iterator(java.util.Iterator) MalformedURLException(java.net.MalformedURLException) GlowAdvancement(net.glowstone.advancement.GlowAdvancement) ClassInitHook(net.glowstone.linkstone.runtime.inithook.ClassInitHook) Permissible(org.bukkit.permissions.Permissible) GlowPlayerProfile(net.glowstone.entity.meta.profile.GlowPlayerProfile) RepoBuilder(com.tobedevoured.naether.util.RepoBuilder) BroadcastMessageEvent(org.bukkit.event.server.BroadcastMessageEvent) WorldType(org.bukkit.WorldType) TimeUnit(java.util.concurrent.TimeUnit) TestForCommand(net.glowstone.command.minecraft.TestForCommand) GlowAdvancementDisplay(net.glowstone.advancement.GlowAdvancementDisplay) ClearCommand(net.glowstone.command.minecraft.ClearCommand) Collections(java.util.Collections) Naether(com.tobedevoured.naether.api.Naether) CompatibilityBundle(net.glowstone.util.CompatibilityBundle) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) NaetherException(com.tobedevoured.naether.NaetherException) LibraryKey(net.glowstone.util.library.LibraryKey) BanList(org.bukkit.BanList) GlowBanList(net.glowstone.util.bans.GlowBanList) ArrayList(java.util.ArrayList) List(java.util.List) Library(net.glowstone.util.library.Library) Map(java.util.Map) SimpleCommandMap(org.bukkit.command.SimpleCommandMap) GlowHelpMap(net.glowstone.util.GlowHelpMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) EnumMap(java.util.EnumMap) HelpMap(org.bukkit.help.HelpMap) HashMap(java.util.HashMap) HashSet(java.util.HashSet)

Aggregations

MobGoals (com.destroystokyo.paper.entity.ai.MobGoals)1 Message (com.flowpowered.network.Message)1 Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Iterators (com.google.common.collect.Iterators)1 ListMultimap (com.google.common.collect.ListMultimap)1 MultimapBuilder (com.google.common.collect.MultimapBuilder)1 Multimaps (com.google.common.collect.Multimaps)1 Sets (com.google.common.collect.Sets)1 CLDevice (com.jogamp.opencl.CLDevice)1 CLPlatform (com.jogamp.opencl.CLPlatform)1 NaetherException (com.tobedevoured.naether.NaetherException)1 Naether (com.tobedevoured.naether.api.Naether)1 NaetherImpl (com.tobedevoured.naether.impl.NaetherImpl)1 RepoBuilder (com.tobedevoured.naether.util.RepoBuilder)1 DatapackManager (io.papermc.paper.datapack.DatapackManager)1 BufferedImage (java.awt.image.BufferedImage)1 File (java.io.File)1 IOException (java.io.IOException)1 InetSocketAddress (java.net.InetSocketAddress)1