-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from MikChanNoPlugins/dev/dev
Next version
- Loading branch information
Showing
27 changed files
with
415 additions
and
164 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
20 changes: 20 additions & 0 deletions
20
src/main/java/dev/mikchan/mcnp/votereceiver/bungee/factory/BungeeCordFactory.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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package dev.mikchan.mcnp.votereceiver.bungee.factory | ||
|
||
import com.vexsoftware.votifier.bungee.NuVotifier | ||
import dev.mikchan.mcnp.votereceiver.bungee.VoteReceiverBungeeCordPlugin | ||
import dev.mikchan.mcnp.votereceiver.core.config.IConfig | ||
import dev.mikchan.mcnp.votereceiver.core.factory.CommonFactory | ||
import net.md_5.bungee.api.ProxyServer | ||
import java.io.File | ||
|
||
internal class BungeeCordFactory(private val plugin: VoteReceiverBungeeCordPlugin) : CommonFactory(plugin) { | ||
override fun createConfig(): IConfig { | ||
val resource = plugin.getResourceAsStream("config.yml") | ||
val document = File(plugin.dataFolder, "config.yml") | ||
return createConfig(document, resource) | ||
} | ||
|
||
override fun createVoteHandler(): NuVotifier? { | ||
return ProxyServer.getInstance().pluginManager.getPlugin("NuVotifier") as? NuVotifier | ||
} | ||
} |
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
2 changes: 1 addition & 1 deletion
2
...kchan/mcnp/votereceiver/config/IConfig.kt → .../mcnp/votereceiver/core/config/IConfig.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
4 changes: 2 additions & 2 deletions
4
...eiver/config/boosted/BoostedYamlConfig.kt → .../core/config/boosted/BoostedYamlConfig.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
4 changes: 2 additions & 2 deletions
4
...eceiver/config/fallback/FallbackConfig.kt → ...er/core/config/fallback/FallbackConfig.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
33 changes: 33 additions & 0 deletions
33
src/main/java/dev/mikchan/mcnp/votereceiver/core/factory/CommonFactory.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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package dev.mikchan.mcnp.votereceiver.core.factory | ||
|
||
import dev.mikchan.mcnp.votereceiver.core.IPlugin | ||
import dev.mikchan.mcnp.votereceiver.core.config.IConfig | ||
import dev.mikchan.mcnp.votereceiver.core.config.boosted.BoostedYamlConfig | ||
import dev.mikchan.mcnp.votereceiver.core.config.fallback.FallbackConfig | ||
import dev.mikchan.mcnp.votereceiver.core.utility.IUtility | ||
import dev.mikchan.mcnp.votereceiver.core.utility.base.Utility | ||
import dev.mikchan.mcnp.votereceiver.core.web.buildRoutes | ||
import io.ktor.server.engine.* | ||
import io.ktor.server.netty.* | ||
import java.io.File | ||
import java.io.InputStream | ||
|
||
internal abstract class CommonFactory(private val plugin: IPlugin) : IFactory { | ||
protected fun createConfig(document: File?, resource: InputStream?): IConfig { | ||
return if (document == null || resource == null) { | ||
FallbackConfig() | ||
} else { | ||
BoostedYamlConfig(document, resource) | ||
} | ||
} | ||
|
||
override fun createUtility(): IUtility { | ||
return Utility() | ||
} | ||
|
||
override fun createApplicationEngine(): ApplicationEngine { | ||
return embeddedServer(Netty, port = plugin.config.port) { | ||
buildRoutes(plugin) | ||
} | ||
} | ||
} |
6 changes: 3 additions & 3 deletions
6
...han/mcnp/votereceiver/factory/IFactory.kt → ...cnp/votereceiver/core/factory/IFactory.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
21 changes: 21 additions & 0 deletions
21
src/main/java/dev/mikchan/mcnp/votereceiver/core/log/ILogger.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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package dev.mikchan.mcnp.votereceiver.core.log | ||
|
||
/** | ||
* Common logger interface | ||
*/ | ||
interface ILogger { | ||
/** | ||
* Logs info message | ||
* | ||
* @param msg The message | ||
*/ | ||
fun info(msg: String) | ||
|
||
/** | ||
* Logs warning message | ||
* | ||
* @param msg The message | ||
* @param exception The exception | ||
*/ | ||
fun warning(msg: String?, exception: Throwable? = null) | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/dev/mikchan/mcnp/votereceiver/core/log/JvmLoggerProxy.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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package dev.mikchan.mcnp.votereceiver.core.log | ||
|
||
import java.util.logging.Level | ||
import java.util.logging.Logger | ||
|
||
internal class JvmLoggerProxy(private val logger: Logger) : ILogger { | ||
override fun info(msg: String) { | ||
logger.info(msg) | ||
} | ||
|
||
override fun warning(msg: String?, exception: Throwable?) { | ||
if (exception != null) { | ||
logger.log(Level.WARNING, msg, exception) | ||
} else { | ||
logger.warning(msg) | ||
} | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/dev/mikchan/mcnp/votereceiver/core/log/Sl4jLoggerProxy.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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package dev.mikchan.mcnp.votereceiver.core.log | ||
|
||
import org.slf4j.Logger | ||
|
||
internal class Sl4jLoggerProxy(private val logger: Logger) : ILogger { | ||
override fun info(msg: String) { | ||
logger.info(msg) | ||
} | ||
|
||
override fun warning(msg: String?, exception: Throwable?) { | ||
if (exception != null) { | ||
logger.warn(msg, exception) | ||
} else { | ||
logger.warn(msg) | ||
} | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...han/mcnp/votereceiver/utility/IUtility.kt → ...cnp/votereceiver/core/utility/IUtility.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,4 +1,4 @@ | ||
package dev.mikchan.mcnp.votereceiver.utility | ||
package dev.mikchan.mcnp.votereceiver.core.utility | ||
|
||
/** | ||
* Utility | ||
|
4 changes: 2 additions & 2 deletions
4
...mcnp/votereceiver/utility/base/Utility.kt → ...votereceiver/core/utility/base/Utility.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
16 changes: 16 additions & 0 deletions
16
src/main/java/dev/mikchan/mcnp/votereceiver/core/web/BuildRoutes.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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package dev.mikchan.mcnp.votereceiver.core.web | ||
|
||
import dev.mikchan.mcnp.votereceiver.core.IPlugin | ||
import io.ktor.server.application.* | ||
import io.ktor.server.routing.* | ||
|
||
internal fun Application.buildRoutes(plugin: IPlugin) { | ||
routing { | ||
createMineServTopRoute(plugin) | ||
createTMonitoringComRoute(plugin) | ||
|
||
if (plugin.config.testEnabled) { | ||
createTestRoute(plugin) | ||
} | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
...mcnp/votereceiver/web/MineServTopRoute.kt → ...votereceiver/core/web/MineServTopRoute.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
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
4 changes: 2 additions & 2 deletions
4
...ikchan/mcnp/votereceiver/web/TestRoute.kt → ...n/mcnp/votereceiver/core/web/TestRoute.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
Oops, something went wrong.