diff --git a/.github/workflows/java-ci.yml b/.github/workflows/java-ci.yml index 035a64c..0787649 100644 --- a/.github/workflows/java-ci.yml +++ b/.github/workflows/java-ci.yml @@ -23,10 +23,10 @@ jobs: steps: - uses: actions/checkout@v2 - - name: "Setup JDK 11" + - name: "Setup JDK 1.8" uses: actions/setup-java@v1 with: - java-version: 11 + java-version: 1.8 - name: "Cache Gradle" uses: actions/cache@v2 diff --git a/.travis.yml b/.travis.yml index 6c94da0..b2acfec 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,6 +19,8 @@ os: linux dist: xenial jdk: + - openjdk8 + - openjdk10 - openjdk11 before_install: diff --git a/README.md b/README.md index 0bafc48..90697e9 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ Bukkit 서버용 Twip (후원 플랫폼) 라이브러리 ### 서버 운영자 -1. 이 플러그인을 포함한 상태로 1회 이상 서버를 열어주세요. [noonmaru](https://github.com/noonmaru) 님의 [Kotlin Plugin](https://github.com/noonmaru/kotlin-plugin) 을 의존성으로 갖습니다. +1. 이 플러그인을 포함한 상태로 1회 이상 서버를 열어주세요. [monun](https://github.com/monun) 님의 [Kotlin Plugin](https://github.com/monun/kotlin-plugin) 을 의존성으로 갖습니다. 2. 플러그인의 [`config.yml` 파일을 열고 형식에 맞게 수정](https://github.com/patrick-mc/twipe/blob/master/src/main/resources/config.yml) 해주세요. 3. 재미있게 플레이해주세요! @@ -48,7 +48,7 @@ allprojects { ```groovy dependencies { - implementation 'com.github.patrick-mc:twipe:1.1.0' + implementation 'com.github.patrick-mc:twipe:1.1.1' } ``` @@ -64,6 +64,6 @@ allprojects { ```kotlin dependencies { - implementation("com.github.patrick-mc:twipe:1.1.0") + implementation("com.github.patrick-mc:twipe:1.1.1") } ``` \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index 7064f4a..91aa1ad 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -29,7 +29,7 @@ plugins { } group = "com.github.patrick-mc" -version = "1.1.0" +version = "1.1.1" repositories { maven("https://repo.maven.apache.org/maven2/") @@ -48,7 +48,7 @@ dependencies { tasks { withType { - kotlinOptions.jvmTarget = "11" + kotlinOptions.jvmTarget = "1.8" } withType { diff --git a/src/main/kotlin/com/github/patrick/twipe/data/SlotMachine.kt b/src/main/kotlin/com/github/patrick/twipe/data/SlotMachine.kt index 68efa83..80488bf 100644 --- a/src/main/kotlin/com/github/patrick/twipe/data/SlotMachine.kt +++ b/src/main/kotlin/com/github/patrick/twipe/data/SlotMachine.kt @@ -4,13 +4,13 @@ package com.github.patrick.twipe.data * Slot Machine data * * @param config slot machine configuration - * @param result the index of slot machine result. Note: index starts from 1, not 0. + * @param index the index of slot machine result. * @param items list of slot machine options * @param rewardId id of the slot machine */ data class SlotMachineData internal constructor( val config: SlotMachineConfig, - val result: Long, + val index: Long, val items: Collection, val rewardId: Long ) @@ -20,7 +20,7 @@ data class SlotMachineData internal constructor( * * @param duration slot machine duration * @param point pair of options and point (not sure yet) - * @param sound not sure yet + * @param sound not sure yet (requires Twip Pro) */ data class SlotMachineConfig internal constructor( val duration: Long, diff --git a/src/main/kotlin/com/github/patrick/twipe/event/AsyncTwipEvent.kt b/src/main/kotlin/com/github/patrick/twipe/event/AsyncTwipEvent.kt index 11a7ac3..c55d436 100644 --- a/src/main/kotlin/com/github/patrick/twipe/event/AsyncTwipEvent.kt +++ b/src/main/kotlin/com/github/patrick/twipe/event/AsyncTwipEvent.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -@file:Suppress("unused") +@file:Suppress("unused", "MemberVisibilityCanBePrivate") package com.github.patrick.twipe.event diff --git a/src/main/kotlin/com/github/patrick/twipe/plugin/TwipePlugin.kt b/src/main/kotlin/com/github/patrick/twipe/plugin/TwipePlugin.kt index 1c4c4bf..9276ce6 100644 --- a/src/main/kotlin/com/github/patrick/twipe/plugin/TwipePlugin.kt +++ b/src/main/kotlin/com/github/patrick/twipe/plugin/TwipePlugin.kt @@ -44,7 +44,7 @@ class TwipePlugin : JavaPlugin() { streamers.forEachIndexed { index, streamer -> val section = getConfigurationSection(streamer) val key = section.getString("id") - val token = URLEncoder.encode(section.getString("token"), Charsets.UTF_8) + val token = URLEncoder.encode(section.getString("token"), "UTF-8") logger.info("Loading ${index + 1} / $count - $streamer") TwipeSocketClient(streamer, key, token) diff --git a/src/main/kotlin/com/github/patrick/twipe/socket/TwipeSocketClient.kt b/src/main/kotlin/com/github/patrick/twipe/socket/TwipeSocketClient.kt index 6334f20..9505d23 100644 --- a/src/main/kotlin/com/github/patrick/twipe/socket/TwipeSocketClient.kt +++ b/src/main/kotlin/com/github/patrick/twipe/socket/TwipeSocketClient.kt @@ -74,6 +74,11 @@ internal class TwipeSocketClient(streamer: String, key: String, token: String) { override fun onDisconnected(websocket: WebSocket, serverCloseFrame: WebSocketFrame, clientCloseFrame: WebSocketFrame, closedByServer: Boolean) { TwipePlugin.pluginLogger.warning("Disconnected from Twip - $streamer") + + runCatching { + disconnect() + } + TwipeSocketClient(streamer, key, token) } @@ -178,16 +183,29 @@ internal class TwipeSocketClient(streamer: String, key: String, token: String) { } "version not match" -> { // twip outdated + runCatching { + disconnect() + } + throw RuntimeException("Current version ${TwipePlugin.twipVersion} not supported." + "Please update plugin, or contact developer for help.") } "TOKEN_EXPIRED" -> { // twip token expired + runCatching { + disconnect() + } + throw RuntimeException("$streamer's token has expired. Please get a new token") } "reload" -> { // twip reload TwipePlugin.pluginLogger.info("Reconnecting to Twip - $streamer") + + runCatching { + disconnect() + } + TwipeSocketClient(streamer, key, token) } } @@ -263,7 +281,7 @@ internal class TwipeSocketClient(streamer: String, key: String, token: String) { val rewardId = slotMachine["reward_id"].asString.toLong() - SlotMachineData(slotMachineConfig, result, items, rewardId) + SlotMachineData(slotMachineConfig, result - 1, items, rewardId) } @JvmStatic diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 8b73f3a..eef9681 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -13,7 +13,7 @@ # limitations under the License. # (ko) -# https://twip.kr/dashboard/security 를 방문하여 id 와 token 값을 가져와주세요! +# https://twip.kr/dashboard/security 를 방문하여 alert box 의 id 와 token 값을 가져와주세요! # # 예시 사용 방법: # twip-version: 1.1.61 @@ -26,7 +26,7 @@ # token: xxxxxxxxxxxxxxxx # # (en) -# Visit https://twip.kr/dashboard/security to get id & token! +# Visit https://twip.kr/dashboard/security to get id of alert box & token! # # Sample usage: # twip-version: 1.1.61 diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 6f7e0f7..69f8400 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -14,7 +14,7 @@ name: Twipe main: com.github.patrick.twipe.plugin.TwipePlugin -version: "1.1.0" +version: "1.1.1" api-version: "1.13" depend: [ Kotlin ] load: STARTUP \ No newline at end of file