Skip to content

Commit

Permalink
Added delete horse owner command.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nlkomaru committed Jul 2, 2022
1 parent 1f8fb39 commit f9c3c7e
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/main/kotlin/dev/nikomaru/raceassist/RaceAssist.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ import dev.nikomaru.raceassist.bet.commands.*
import dev.nikomaru.raceassist.bet.event.BetGuiClickEvent
import dev.nikomaru.raceassist.data.database.BetList
import dev.nikomaru.raceassist.files.Config
import dev.nikomaru.raceassist.horse.event.HorseBreedEvent
import dev.nikomaru.raceassist.horse.commands.OwnerDeleteCommand
import dev.nikomaru.raceassist.horse.events.HorseBreedEvent
import dev.nikomaru.raceassist.race.commands.HelpCommand
import dev.nikomaru.raceassist.race.commands.audience.*
import dev.nikomaru.raceassist.race.commands.place.*
Expand Down Expand Up @@ -128,6 +129,8 @@ class RaceAssist : SuspendingJavaPlugin() {
annotationParser.parse(SettingStaffCommand())

annotationParser.parse(HelpCommand())

annotationParser.parse(OwnerDeleteCommand())
}

private fun registerEvents() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright © 2021-2022 Nikomaru <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package dev.nikomaru.raceassist.horse.commands

import cloud.commandframework.annotations.CommandMethod
import org.bukkit.command.CommandSender
import org.bukkit.entity.Horse
import org.bukkit.entity.Player

@CommandMethod("ra horse")
class OwnerDeleteCommand {
@CommandMethod("ownerDelete")
fun removeOwner(sender: CommandSender) {
if (sender !is Player) {
sender.sendMessage("このコマンドはプレイヤーのみ実行できます")
return
}
val entity = sender.getTargetEntity(5) ?: return sender.sendMessage("対象が見つかりませんでした")
if (entity !is Horse) {
sender.sendMessage("対象が馬ではありません")
return
}
if (entity.owner != sender) {
sender.sendMessage("あなたはこの馬のオーナーではありません")
return
}
entity.owner = null
sender.sendMessage("オーナーを解除しました")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package dev.nikomaru.raceassist.horse.event
package dev.nikomaru.raceassist.horse.events

import dev.nikomaru.raceassist.horse.utlis.HorseUtils.getCalcJump
import dev.nikomaru.raceassist.horse.utlis.HorseUtils.getCalcSpeed
Expand Down

0 comments on commit f9c3c7e

Please sign in to comment.