Skip to content

Commit

Permalink
Fixed permission settings.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nlkomaru committed Feb 11, 2022
1 parent 824bd7f commit 1d9a944
Show file tree
Hide file tree
Showing 11 changed files with 96 additions and 52 deletions.
121 changes: 79 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,57 +1,94 @@
# RaceAssist

[![FOSSA Status](https://app.fossa.com/api/projects/custom%2B27464%2Fgithub.com%2FNlkomaru%2FRaceAssist-advance.svg?type=shield)](https://app.fossa.com/projects/custom%2B27464%2Fgithub.com%2FNlkomaru%2FRaceAssist-advance?ref=badge_shield)
[![Gradle Build Action](https://github.com/Nlkomaru/RaceAssist-advance/actions/workflows/blank.yml/badge.svg)](https://github.com/Nlkomaru/RaceAssist-advance/actions/workflows/blank.yml)
[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
[![wakatime](https://wakatime.com/badge/user/20699a33-3350-4bf0-8061-c8a996192acf/project/92c8a9a0-f74b-44cc-a1b8-d328f40f803e.svg)](https://wakatime.com/badge/user/20699a33-3350-4bf0-8061-c8a996192acf/project/92c8a9a0-f74b-44cc-a1b8-d328f40f803e)
## Commands

### Audience

/raceassist audience join [RaceID] 観客に自分を追加します<br>
/raceassist audience leave [RaceID] 観客から自分を削除します<br>
/raceassist audience list [RaceID] 観客の一覧を表示<br>

### Bet

/raceassist bet can [RaceID] on/off 対象のレースに対して賭けが可能か変更します <br>
/raceassist bet delete [RaceID] 賭けを削除します <br>
/raceassist bet list [RaceID] 賭けの一覧を表示します<br>
/raceassist bet open [RaceID] 賭けをすることのできる画面を開くことができます <br>
/raceassist bet rate [RaceID] 賭けのレートを変更します<br>
/raceassist bet sheet [RaceID] <SheetID><br>
https://docs.google.com/spreadsheets/d/***********/edit#gid=0 *****の部分をSheetIDに入力 spreadsheetを登録します<br>


### Place

/raceassist place reverse [RaceID] レースの走行方向の向きを反転<br>
/raceassist place central [RaceID] レースの中心点を設定<br>
/raceassist place degree [RaceID] レースのゴールの角度を設定(立っている場所基準90度刻み)<br>
/raceassist place lap [RaceID] <lap> レースのラップ数を指定<br>
/raceassist place set [RaceID] in|out レース場の内周、外周を指定<br>
/raceassist place finish 上記の設定の終了<br>

### Player

/raceassist player add [RaceID] [Player] 騎手を追加<br>
/raceassist player remove [RaceID] 騎手を削除<br>
/raceassist player delete [RaceID] 騎手をすべて削除<br>
/raceassist player list [RaceID] 騎手の一覧を表示<br>

### Race
## Commands

/raceassist race start [RaceID] レースを開始<br>
/raceassist race debug [RaceID] レースのデバッグ<br>
/raceassist race stop [RaceID] レースの停止<br>
/raceassist race create [RaceID] レースの作成<br>
/raceassist race delete [RaceID] レースの削除<br>
### Audience `RaceAssist.commands.audience.*`

`/ra audience join <raceId>` 観客に自分を追加します <br>
permission: `RaceAssist.commands.audience.join`<br>
`/ra audience leave <raceId>` 観客から自分を削除します <br>
permission: `RaceAssist.commands.audience.leave`<br>
`/ra audience list <raceId>` 観客の一覧を表示 <br>
permission: `RaceAssist.commands.audience.list`<br>

### Bet `RaceAssist.commands.bet.*`

`/ra bet can <raceId> on/off` 対象のレースに対して賭けが可能か変更します <br>
permission: `RaceAssist.commands.bet.can`<br>
`/ra bet delete <raceId>` 賭けを削除します <br>
permission: `RaceAssist.commands.bet.delete`<br>
`/ra bet list <raceId>` 賭けの一覧を表示します <br>
permission: `RaceAssist.commands.bet.list`<br>
`/ra bet open <raceId>` 賭けをすることのできる画面を開くことができます <br>
permission: `RaceAssist.commands.bet.open`<br>
`/ra bet rate <raceId>` 賭けのレートを変更します <br>
permission: `RaceAssist.commands.bet.rate`<br>
`/ra bet sheet <raceId> <SheetID>` <br>
permission: `RaceAssist.commands.bet.sheet`<br>
`https://docs.google.com/spreadsheets/d/***********/edit#gid=0` *****の部分をSheetIDに入力 spreadsheetを登録します

### Place `RaceAssist.commands.place.*`

`/ra place reverse <raceId>` レースの走行方向の向きを反転 <br>
permission: `RaceAssist.commands.place.reverse`<br>
`/ra place central <raceId>` レースの中心点を設定 <br>
permission: `RaceAssist.commands.place.central`<br>
`/ra place degree <raceId>` レースのゴールの角度を設定(立っている場所基準90度刻み) <br>
permission: `RaceAssist.commands.place.degree`<br>
`/ra place lap <raceId> <lap>` レースのラップ数を指定 <br>
permission: `RaceAssist.commands.place.lap`<br>
`/ra place set <raceId> in|out` レース場の内周、外周を指定 <br>
permission: `RaceAssist.commands.place.set`<br>
`/ra place finish` 上記の設定の終了 <br>
permission: `RaceAssist.commands.place.finish`<br>

### Player `RaceAssist.commands.player.*`

`/ra player add <raceId> <Player>` 騎手を追加 <br>
permission: `RaceAssist.commands.player.add`<br>
`/ra player remove <raceId>` 騎手を削除 <br>
permission: `RaceAssist.commands.player.remove`<br>
`/ra player delete <raceId>` 騎手をすべて削除 <br>
permission: `RaceAssist.commands.player.delete`<br>
`/ra player list <raceId>` 騎手の一覧を表示 <br>
permission: `RaceAssist.commands.player.list`<br>

### Race `RaceAssist.commands.race.*`

`/ra race start <raceId>` レースを開始 <br>
permission: `RaceAssist.commands.race.start`<br>
`/ra race debug <raceId>` レースのデバッグ <br>
permission: `RaceAssist.commands.race.debug`<br>
`/ra race stop <raceId>` レースの停止 <br>
permission: `RaceAssist.commands.race.stop`<br>
`/ra race create <raceId>` レースの作成 <br>
permission: `RaceAssist.commands.race.create`<br>
`/ra race delete <raceId>` レースの削除 <br>
permission: `RaceAssist.commands.race.delete`<br>
`/ra race copy <raceId_1> <raceId_2>` レース1のsheetId、賭けリスト以外をすべてコピーします <br>
permission: `RaceAssist.commands.race.copy`<br>

### permission

## 一般プレイヤー

`RaceAssist.commands.audience.join`
`RaceAssist.commands.audience.leave`
`RaceAssist.commands.bet.open`

## レース作成者

`RaceAssist.commands.*`

## About Use sheets API

pluginフォルダの中のRaceAssistフォルダに**credentials.json**を入れます 最初の賭けが行われるとコンソールにOAuthの認証画面が開かれるのでスプレッドシートの所有者が認証してください


### credentials.jsonの設定

基本はAPIのダウンロードしたものをそのままでもいいですがclient_secretを追加してください
Expand Down
1 change: 1 addition & 0 deletions src/main/kotlin/dev/nikomaru/raceassist/RaceAssist.kt
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ class RaceAssist : SuspendingJavaPlugin() {
annotationParser.parse(BetRateCommand())
annotationParser.parse(BetRevertCommand())
annotationParser.parse(BetSheetCommand())
annotationParser.parse(RaceCopyCommand())
}

private fun registerEvents() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package dev.nikomaru.raceassist.bet.commands

import cloud.commandframework.annotations.Argument
import cloud.commandframework.annotations.CommandMethod
import cloud.commandframework.annotations.CommandPermission
import com.github.shynixn.mccoroutine.launch
import dev.nikomaru.raceassist.RaceAssist
import dev.nikomaru.raceassist.database.BetSetting
Expand All @@ -31,7 +32,7 @@ import java.text.MessageFormat

@CommandMethod("ra|RaceAssist bet")
class BetCanCommand {

@CommandPermission("RaceAssist.commands.bet.open")
@CommandMethod("can <raceId> <type>")
fun setCanBet(player: Player,
@Argument(value = "raceId", suggestions = "raceId") raceID: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package dev.nikomaru.raceassist.bet.commands

import cloud.commandframework.annotations.Argument
import cloud.commandframework.annotations.CommandMethod
import cloud.commandframework.annotations.CommandPermission
import com.github.shynixn.mccoroutine.launch
import dev.nikomaru.raceassist.RaceAssist
import dev.nikomaru.raceassist.database.BetList
Expand All @@ -35,6 +36,7 @@ import java.util.*

@CommandMethod("ra|RaceAssist bet")
class BetDeleteCommand {
@CommandPermission("RaceAssist.commands.bet.delete")
@CommandMethod("delete <raceId>")
fun delete(player: Player, @Argument(value = "raceId", suggestions = "raceId") raceID: String) {
RaceAssist.plugin.launch {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package dev.nikomaru.raceassist.bet.commands

import cloud.commandframework.annotations.Argument
import cloud.commandframework.annotations.CommandMethod
import cloud.commandframework.annotations.CommandPermission
import com.github.shynixn.mccoroutine.launch
import dev.nikomaru.raceassist.RaceAssist
import dev.nikomaru.raceassist.database.BetList
Expand All @@ -32,6 +33,7 @@ import java.text.MessageFormat

@CommandMethod("ra|RaceAssist bet")
class BetListCommand {
@CommandPermission("RaceAssist.commands.bet.list")
@CommandMethod("list <raceId>")
fun list(player: Player, @Argument(value = "raceId", suggestions = "raceId") raceID: String) {
RaceAssist.plugin.launch {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package dev.nikomaru.raceassist.bet.commands

import cloud.commandframework.annotations.Argument
import cloud.commandframework.annotations.CommandMethod
import cloud.commandframework.annotations.CommandPermission
import com.github.shynixn.mccoroutine.launch
import dev.nikomaru.raceassist.RaceAssist
import dev.nikomaru.raceassist.bet.gui.BetChestGui
Expand All @@ -33,7 +34,7 @@ import org.jetbrains.exposed.sql.transactions.experimental.newSuspendedTransacti

@CommandMethod("ra|RaceAssist bet")
class BetOpenCommand {

@CommandPermission("RaceAssist.commands.bet.open")
@CommandMethod("open <raceId>")
fun openVending(player: Player, @Argument(value = "raceId", suggestions = "raceId") raceID: String) {
RaceAssist.plugin.launch {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package dev.nikomaru.raceassist.bet.commands

import cloud.commandframework.annotations.Argument
import cloud.commandframework.annotations.CommandMethod
import cloud.commandframework.annotations.CommandPermission
import cloud.commandframework.annotations.specifier.Range
import com.github.shynixn.mccoroutine.launch
import dev.nikomaru.raceassist.RaceAssist
Expand All @@ -32,10 +33,9 @@ import java.text.MessageFormat

@CommandMethod("ra|RaceAssist bet")
class BetRateCommand {
@CommandPermission("RaceAssist.commands.bet.rate")
@CommandMethod("rate <raceId> <rate>")
fun setRate(player: Player,
@Argument(value = "raceId", suggestions = "raceId") raceID: String,
@Argument(value = "rate") @Range(min = "0", max = "100") rate: Int) {
fun setRate(player: Player, @Argument(value = "raceId", suggestions = "raceId") raceID: String, @Argument(value = "rate") @Range(min = "0", max = "100") rate: Int) {
RaceAssist.plugin.launch {
if (!raceExist(raceID)) {
player.sendMessage(Lang.getText("no-exist-this-raceid-race", player.locale()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package dev.nikomaru.raceassist.bet.commands

import cloud.commandframework.annotations.Argument
import cloud.commandframework.annotations.CommandMethod
import cloud.commandframework.annotations.CommandPermission
import com.github.shynixn.mccoroutine.launch
import dev.nikomaru.raceassist.RaceAssist
import dev.nikomaru.raceassist.api.VaultAPI
Expand All @@ -37,7 +38,7 @@ import java.util.*

@CommandMethod("ra|RaceAssist bet")
class BetRevertCommand {

@CommandPermission("RaceAssist.commands.bet.revert")
@CommandMethod("revert <raceId>")
fun revert(player: Player, @Argument(value = "raceId", suggestions = "raceId") raceID: String) {
val eco: Economy = VaultAPI.getEconomy()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package dev.nikomaru.raceassist.bet.commands

import cloud.commandframework.annotations.Argument
import cloud.commandframework.annotations.CommandMethod
import cloud.commandframework.annotations.CommandPermission
import com.github.shynixn.mccoroutine.launch
import com.google.api.services.sheets.v4.model.AddSheetRequest
import com.google.api.services.sheets.v4.model.BatchUpdateSpreadsheetRequest
Expand All @@ -36,6 +37,7 @@ import org.jetbrains.exposed.sql.update

@CommandMethod("ra|RaceAssist bet")
class BetSheetCommand {
@CommandPermission("RaceAssist.commands.bet.sheet")
@CommandMethod("sheet <raceId> <sheet>")
fun sheet(player: Player, @Argument(value = "raceId", suggestions = "raceId") raceID: String, @Argument(value = "sheet") sheetId: String) {
RaceAssist.plugin.launch {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,12 @@ class BetChestGui {
val players: ArrayList<UUID> = ArrayList()
val odds: HashMap<UUID, Double> = HashMap()
var sum = 0
println("1")
val rate: Int = newSuspendedTransaction(Dispatchers.IO) {
BetSetting.select { BetSetting.raceID eq raceID }.first()[BetSetting.returnPercent]
}

AllPlayers[raceID] = ArrayList<UUID>()
newSuspendedTransaction(Dispatchers.IO) {
println("2")
PlayerList.select { PlayerList.raceID eq raceID }.forEach {
players.add(UUID.fromString(it[PlayerList.playerUUID]))
AllPlayers[raceID]!!.add(UUID.fromString(it[PlayerList.playerUUID]))
Expand Down Expand Up @@ -106,7 +104,6 @@ class BetChestGui {
gui.setItem(i + 36, GuiComponent.tenTimesDown(player.locale()))
}

println("3")
val raceIDItem = ItemStack(Material.GRAY_STAINED_GLASS_PANE)
val raceIDMeta = raceIDItem.itemMeta
raceIDMeta.displayName(text(raceID, TextColor.fromHexString("#00ff7f")))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import org.jetbrains.exposed.sql.transactions.experimental.newSuspendedTransacti
class RaceCopyCommand {

@CommandPermission("RaceAssist.commands.race.copy")
@CommandMethod("delete <raceId_1> <raceId_2>")
@CommandMethod("copy <raceId_1> <raceId_2>")
fun copy(sender: Player, @Argument(value = "raceId_1", suggestions = "raceId") raceId_1: String, @Argument(value = "raceId_2") raceId_2: String) {
plugin.launch {
if (CommandUtils.getRaceCreator(raceId_2) != null) {
Expand Down

0 comments on commit 1d9a944

Please sign in to comment.