All: Update apiVersion to 1.14, Teleport: Add tphere command
This commit is contained in:
parent
d654ae5e88
commit
4a0c14197a
|
@ -11,7 +11,7 @@ dependencies {
|
|||
|
||||
bukkit {
|
||||
main = "nl.voidcorp.adminplugin.VoidAdmin"
|
||||
apiVersion = '1.13'
|
||||
apiVersion = '1.14'
|
||||
author = 'J00LZ'
|
||||
depend = ['VoidPlugin']
|
||||
commands {
|
||||
|
|
|
@ -10,7 +10,7 @@ dependencies {
|
|||
}
|
||||
bukkit {
|
||||
main = "nl.voidcorp.bankplugin.VoidBank"
|
||||
apiVersion = '1.13'
|
||||
apiVersion = '1.14'
|
||||
author = 'J00LZ'
|
||||
depend = ['VoidPlugin']
|
||||
commands {
|
||||
|
|
|
@ -15,6 +15,6 @@ dependencies {
|
|||
|
||||
bukkit {
|
||||
main = "nl.voidcorp.mainplugin.VoidPlugin"
|
||||
apiVersion = '1.13'
|
||||
apiVersion = '1.14'
|
||||
author = 'J00LZ'
|
||||
}
|
|
@ -11,7 +11,7 @@ dependencies {
|
|||
|
||||
bukkit {
|
||||
main = "nl.voidcorp.teleportplugin.VoidTeleport"
|
||||
apiVersion = '1.13'
|
||||
apiVersion = '1.14'
|
||||
author = 'J00LZ'
|
||||
depend = ['VoidPlugin']
|
||||
commands {
|
||||
|
@ -45,6 +45,9 @@ bukkit {
|
|||
tpa {
|
||||
description = "Request to teleport to a player"
|
||||
}
|
||||
tphere{
|
||||
description = "Request a player to teleport to you"
|
||||
}
|
||||
tpaccept {
|
||||
description = "Accept a teleport request"
|
||||
}
|
||||
|
|
|
@ -7,10 +7,7 @@ import nl.voidcorp.teleportplugin.commands.home.DelHomeCommand
|
|||
import nl.voidcorp.teleportplugin.commands.home.HomeCommand
|
||||
import nl.voidcorp.teleportplugin.commands.home.ListHomeCommand
|
||||
import nl.voidcorp.teleportplugin.commands.home.SetHomeCommand
|
||||
import nl.voidcorp.teleportplugin.commands.tpx.BackCommand
|
||||
import nl.voidcorp.teleportplugin.commands.tpx.TpAcceptCommand
|
||||
import nl.voidcorp.teleportplugin.commands.tpx.TpDenyCommand
|
||||
import nl.voidcorp.teleportplugin.commands.tpx.TpaCommand
|
||||
import nl.voidcorp.teleportplugin.commands.tpx.*
|
||||
import nl.voidcorp.teleportplugin.commands.warp.DelWarpCommand
|
||||
import nl.voidcorp.teleportplugin.commands.warp.SetWarpCommand
|
||||
import nl.voidcorp.teleportplugin.commands.warp.WarpCommand
|
||||
|
@ -39,6 +36,7 @@ class VoidTeleport(override val comment: String = "Teleport around :D") :
|
|||
.registerCommand("delwarp", DelWarpCommand())
|
||||
.registerCommand("warps", ListHomeCommand(WarpCommand(),"The warps are"))
|
||||
.registerCommand("tpa", TpaCommand())
|
||||
.registerCommand("tphere", TpHereCommand())
|
||||
.registerCommand("tpaccept", TpAcceptCommand())
|
||||
.registerCommand("tpdeny", TpDenyCommand())
|
||||
.registerCommand("back",BackCommand())
|
||||
|
|
|
@ -8,7 +8,6 @@ import org.bukkit.command.Command
|
|||
import org.bukkit.command.CommandSender
|
||||
import org.bukkit.entity.Player
|
||||
import org.jetbrains.exposed.sql.transactions.transaction
|
||||
import java.util.*
|
||||
|
||||
class TpAcceptCommand : VoidCommand() {
|
||||
override fun onCommand(sender: CommandSender, command: Command, label: String, args: Array<out String>): Boolean {
|
||||
|
@ -21,9 +20,15 @@ class TpAcceptCommand : VoidCommand() {
|
|||
val teleport = req.first()
|
||||
val from = Bukkit.getPlayer(teleport.from)
|
||||
if (from != null) {
|
||||
sender.sendMessage("Accepted request from ${from.displayName}")
|
||||
from.sendMessage("Teleported to ${sender.displayName}")
|
||||
from.teleport(sender.location)
|
||||
if (!teleport.here) {
|
||||
sender.sendMessage("Accepted request from ${from.displayName}")
|
||||
from.sendMessage("Teleported to ${sender.displayName}")
|
||||
from.teleport(sender.location)
|
||||
} else {
|
||||
sender.sendMessage("Teleported to ${from.name}")
|
||||
from.sendMessage("${sender.name} accepted your request")
|
||||
sender.teleport(from.location)
|
||||
}
|
||||
}
|
||||
teleport.delete()
|
||||
}
|
||||
|
|
|
@ -0,0 +1,81 @@
|
|||
package nl.voidcorp.teleportplugin.commands.tpx
|
||||
|
||||
import net.md_5.bungee.api.chat.ClickEvent
|
||||
import net.md_5.bungee.api.chat.TextComponent
|
||||
import nl.voidcorp.mainplugin.commands.VoidCommand
|
||||
import nl.voidcorp.teleportplugin.models.TpRequest
|
||||
import nl.voidcorp.teleportplugin.models.TpRequests
|
||||
import org.bukkit.Bukkit
|
||||
import org.bukkit.ChatColor
|
||||
import org.bukkit.command.Command
|
||||
import org.bukkit.command.CommandSender
|
||||
import org.bukkit.entity.Player
|
||||
import org.jetbrains.exposed.sql.and
|
||||
import org.jetbrains.exposed.sql.deleteWhere
|
||||
import org.jetbrains.exposed.sql.transactions.transaction
|
||||
import org.joda.time.DateTime
|
||||
|
||||
class TpHereCommand : VoidCommand() {
|
||||
override fun onTabComplete(
|
||||
sender: CommandSender,
|
||||
command: Command,
|
||||
alias: String,
|
||||
args: Array<out String>
|
||||
): List<String> {
|
||||
if (sender is Player) {
|
||||
val toComplete = args.lastOrNull() ?: ""
|
||||
return Bukkit.getOnlinePlayers().toList().map { ChatColor.stripColor(it.name)!! }
|
||||
.filter { it.startsWith(toComplete) }
|
||||
}
|
||||
|
||||
return emptyList()
|
||||
}
|
||||
|
||||
override fun onCommand(sender: CommandSender, command: Command, label: String, args: Array<out String>): Boolean {
|
||||
if (sender is Player) {
|
||||
if (args.isEmpty()) {
|
||||
sender.sendMessage("The first argument should be a nickname of an online player")
|
||||
return true
|
||||
}
|
||||
val pl = Bukkit.getPlayer(args.first())
|
||||
if (pl == null || !pl.isOnline) {
|
||||
sender.sendMessage("The first argument should be a nickname of an online player")
|
||||
return true
|
||||
}
|
||||
transaction {
|
||||
TpRequests.deleteWhere { TpRequests.timeout lessEq DateTime.now() }
|
||||
|
||||
if (TpRequest.find { TpRequests.to eq pl.uniqueId }.toList().isNotEmpty()) {
|
||||
sender.sendMessage("${pl.displayName} already has a request open...")
|
||||
if (TpRequest.find { (TpRequests.from eq sender.uniqueId) and (TpRequests.to eq pl.uniqueId) }.toList().isNotEmpty()) {
|
||||
sender.sendMessage("Actually, you sent that request...")
|
||||
}
|
||||
} else {
|
||||
TpRequest.new {
|
||||
from = sender.uniqueId
|
||||
to = pl.uniqueId
|
||||
here = true
|
||||
}
|
||||
sender.sendMessage("Sent a teleport request to ${pl.displayName}")
|
||||
pl.sendMessage(
|
||||
TextComponent("Received a new Teleport request from "),
|
||||
TextComponent(sender.displayName).apply { color = net.md_5.bungee.api.ChatColor.AQUA },
|
||||
TextComponent(" to teleport to them, use "),
|
||||
TextComponent("/tpaccept").apply {
|
||||
color = net.md_5.bungee.api.ChatColor.GREEN
|
||||
clickEvent = ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tpaccept")
|
||||
},
|
||||
TextComponent(" or "),
|
||||
TextComponent("/tpdeny").apply {
|
||||
color = net.md_5.bungee.api.ChatColor.RED
|
||||
clickEvent = ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tpdeny")
|
||||
},
|
||||
TextComponent(" to accept or deny it!")
|
||||
)
|
||||
//pl.sendMessage("Received a new teleport request from ${sender.displayName}, use /tpaccept or /tpdeny to accept or deny it!")
|
||||
}
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
|
@ -10,4 +10,5 @@ class TpRequest(id: EntityID<Int>) : IntEntity(id) {
|
|||
var to by TpRequests.to
|
||||
var from by TpRequests.from
|
||||
var timeout by TpRequests.timeout
|
||||
var here by TpRequests.here
|
||||
}
|
|
@ -6,5 +6,6 @@ import org.joda.time.DateTime
|
|||
object TpRequests : IntIdTable() {
|
||||
val from = uuid("from")
|
||||
val to = uuid("to")
|
||||
val here = bool("here").default(false)
|
||||
val timeout = datetime("timeout").clientDefault { DateTime.now().plusSeconds(30) }
|
||||
}
|
|
@ -10,7 +10,7 @@ dependencies {
|
|||
}
|
||||
bukkit {
|
||||
main = "nl.voidcorp.utilsplugin.VoidUtils"
|
||||
apiVersion = '1.13'
|
||||
apiVersion = '1.14'
|
||||
author = 'J00LZ'
|
||||
depend = ['VoidPlugin']
|
||||
commands {
|
||||
|
|
Loading…
Reference in a new issue