mirror of
				https://github.com/GayPizzaSpecifications/foundation.git
				synced 2025-11-04 03:39:37 +00:00 
			
		
		
		
	Move bifrost.yaml to foundation-bifrost.
This commit is contained in:
		@ -35,7 +35,11 @@ class FoundationBifrostPlugin : JavaPlugin(), EventListener, Listener {
 | 
				
			|||||||
    val foundation = server.pluginManager.getPlugin("Foundation") as FoundationCorePlugin
 | 
					    val foundation = server.pluginManager.getPlugin("Foundation") as FoundationCorePlugin
 | 
				
			||||||
    slF4JLogger.info("Plugin data path: ${foundation.pluginDataPath}")
 | 
					    slF4JLogger.info("Plugin data path: ${foundation.pluginDataPath}")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    val configPath = Util.copyDefaultConfig(slF4JLogger, foundation.pluginDataPath, "bifrost.yaml")
 | 
					    val configPath = Util.copyDefaultConfig<FoundationBifrostPlugin>(
 | 
				
			||||||
 | 
					      slF4JLogger,
 | 
				
			||||||
 | 
					      foundation.pluginDataPath,
 | 
				
			||||||
 | 
					      "bifrost.yaml"
 | 
				
			||||||
 | 
					    )
 | 
				
			||||||
    config = Yaml.default.decodeFromStream(BifrostConfig.serializer(), configPath.inputStream())
 | 
					    config = Yaml.default.decodeFromStream(BifrostConfig.serializer(), configPath.inputStream())
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    server.pluginManager.registerEvents(this, this)
 | 
					    server.pluginManager.registerEvents(this, this)
 | 
				
			||||||
 | 
				
			|||||||
@ -33,7 +33,7 @@ object Util {
 | 
				
			|||||||
   * @param resourceName Path to resource, it should be in the root of the `resources` directory,
 | 
					   * @param resourceName Path to resource, it should be in the root of the `resources` directory,
 | 
				
			||||||
   *  without the leading slash.
 | 
					   *  without the leading slash.
 | 
				
			||||||
   */
 | 
					   */
 | 
				
			||||||
  fun copyDefaultConfig(log: Logger, targetPath: Path, resourceName: String): Path {
 | 
					  inline fun <reified T> copyDefaultConfig(log: Logger, targetPath: Path, resourceName: String): Path {
 | 
				
			||||||
    if (resourceName.startsWith("/")) {
 | 
					    if (resourceName.startsWith("/")) {
 | 
				
			||||||
      throw IllegalArgumentException("resourceName starts with slash")
 | 
					      throw IllegalArgumentException("resourceName starts with slash")
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@ -48,7 +48,7 @@ object Util {
 | 
				
			|||||||
      return outPath
 | 
					      return outPath
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    val resourceStream = javaClass.getResourceAsStream("/$resourceName")
 | 
					    val resourceStream = T::class.java.getResourceAsStream("/$resourceName")
 | 
				
			||||||
      ?: throw Exception("Configuration resource does not exist!")
 | 
					      ?: throw Exception("Configuration resource does not exist!")
 | 
				
			||||||
    val outputStream = outFile.outputStream()
 | 
					    val outputStream = outFile.outputStream()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user