Skip to content

Commit

Permalink
Update 1.1.1
Browse files Browse the repository at this point in the history
 - Rollback Java 11 Requirements (Use legacy charset method)
 - Try disconnect when having connection issues/errors/reconnection
 - Update README.md & config.yml
 - Index counts from 0 (commonly used way of using index)
  • Loading branch information
patrick-choe committed Mar 25, 2021
1 parent bc5642d commit 04bbdb6
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 16 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/java-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ os: linux
dist: xenial

jdk:
- openjdk8
- openjdk10
- openjdk11

before_install:
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. 재미있게 플레이해주세요!

Expand Down Expand Up @@ -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'
}
```

Expand All @@ -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")
}
```
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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/")
Expand All @@ -48,7 +48,7 @@ dependencies {

tasks {
withType<KotlinCompile> {
kotlinOptions.jvmTarget = "11"
kotlinOptions.jvmTarget = "1.8"
}

withType<DokkaTask> {
Expand Down
6 changes: 3 additions & 3 deletions src/main/kotlin/com/github/patrick/twipe/data/SlotMachine.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>,
val rewardId: Long
)
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

@file:Suppress("unused")
@file:Suppress("unused", "MemberVisibilityCanBePrivate")

package com.github.patrick.twipe.event

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down Expand Up @@ -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)
}
}
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 04bbdb6

Please sign in to comment.