Skip to content

Commit b42e0f1

Browse files
committed
Fix warps not working, and Add lava bucket detection
1 parent 061ab1d commit b42e0f1

File tree

5 files changed

+40
-12
lines changed

5 files changed

+40
-12
lines changed

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ plugins {
55
}
66

77
group = "com.kruthers"
8-
version = "2.4.1"
8+
version = "2.4.2"
99
description = "The core plugin used to manage the gamemode 4 public server"
1010

1111
repositories {

src/main/kotlin/com/kruthers/gamemode4core/Gamemode4Core.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ class Gamemode4Core : JavaPlugin() {
120120
annotationParser.parse(WarpCommand(this))
121121
annotationParser.parse(ManageWarpsCommand(this))
122122

123-
this.logger.info("Loaded all tab completer's, registering events...")
123+
this.logger.info("Loaded all tab completers, registering events...")
124124
this.server.pluginManager.registerEvents(PlayerConnectionEvents(this), this)
125125
this.server.pluginManager.registerEvents(PlayerFrozenEvents(this), this)
126126
this.server.pluginManager.registerEvents(DimensionEvents(this), this)

src/main/kotlin/com/kruthers/gamemode4core/commands/ManageWarpsCommand.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class ManageWarpsCommand(val plugin: Gamemode4Core) {
7272

7373
@ProxiedBy("warps")
7474
@CommandMethod("managewarps lists")
75-
@CommandDescription("Remove a warp")
75+
@CommandDescription("List all warps")
7676
@CommandPermission("gm4core.warp")
7777
fun onWarpListCommand(sender: CommandSender) {
7878
WarpCommand.sendWarpsList(sender,plugin)
@@ -82,7 +82,6 @@ class ManageWarpsCommand(val plugin: Gamemode4Core) {
8282
@Parser(name = "warpNameAdd")
8383
fun warpNameParser(sender: CommandContext<CommandSender>, inputQueue: Queue<String>): String {
8484
val input = inputQueue.remove()
85-
sender.sender.sendMessage(input)
8685

8786
if (input.matches("[\\w\\-]{3,}".toRegex()) && input.lowercase() != "list") {
8887
return input

src/main/kotlin/com/kruthers/gamemode4core/commands/WarpCommand.kt

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import com.kruthers.gamemode4core.utils.parseString
1212
import net.kyori.adventure.text.Component
1313
import net.kyori.adventure.text.format.NamedTextColor
1414
import net.kyori.adventure.text.minimessage.MiniMessage
15+
import org.bukkit.Bukkit
1516
import org.bukkit.Location
1617
import org.bukkit.command.CommandSender
1718
import org.bukkit.entity.Player
@@ -22,14 +23,14 @@ class WarpCommand(val plugin: Gamemode4Core) {
2223
val warps: HashMap<String, Location> = HashMap()
2324

2425
fun sendWarpsList(sender: CommandSender, plugin: Gamemode4Core) {
25-
val warpsText = parseString("<prefix> <green>Current warps:</green>",plugin)
26+
var warpsText = parseString("<prefix> <green>Current warps: </green>",plugin)
2627
val warpsSize = warps.size
2728
var i = 0
2829
warps.forEach { (warp, _) ->
2930
val text = MiniMessage.miniMessage().deserialize("<hover:show_text:'<dark_purple>Teleport to $warp" +
3031
"</dark_purple>'><click:run_command:'/warp $warp'><gold>$warp</gold></click></hover>")
3132

32-
warpsText.append(text)
33+
warpsText = warpsText.append(text)
3334
i++
3435
if (i < warpsSize) {
3536
warpsText.append(Component.text(", ", NamedTextColor.GREEN))
@@ -40,11 +41,11 @@ class WarpCommand(val plugin: Gamemode4Core) {
4041
}
4142
}
4243

43-
@CommandMethod("warp [warp]")
44+
@CommandMethod("warp <warp>")
4445
@CommandDescription("warp to a location")
4546
@CommandPermission("gm4core.warp")
46-
fun onWarpCommand(player: Player, @Argument("warp", parserName = "warp") warp: Pair<String,Location>?) {
47-
if (warp === null) {
47+
fun onWarpCommand(player: Player, @Argument("warp", parserName = "warp") warp: Pair<String,Location>) {
48+
if (warp .first == "list") {
4849
sendWarpsList(player, plugin)
4950
} else {
5051
plugin.addTPALocation(player)
@@ -63,16 +64,22 @@ class WarpCommand(val plugin: Gamemode4Core) {
6364
response.add(warp)
6465
}
6566
}
67+
if ("list".startsWith(input)) {
68+
response.add("list")
69+
}
6670

6771
return response.toList()
6872
}
6973

70-
@Parser(name = "warp")
74+
@Parser(name = "warp", suggestions = "warp")
7175
fun coreArgsParser(sender: CommandContext<CommandSender>, inputQueue: Queue<String>): Pair<String,Location> {
72-
val input = inputQueue.peek().lowercase()
76+
val input = inputQueue.remove().lowercase()
77+
if (input == "list") {
78+
return Pair("list", Location(Bukkit.getWorlds()[0],0.0,0.0,0.0))
79+
}
7380

7481
warps.forEach { (warp, loc) ->
75-
if (warp === input) {
82+
if (warp == input) {
7683
return Pair(warp,loc)
7784
}
7885
}

src/main/kotlin/com/kruthers/gamemode4core/events/GriefEvents.kt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import org.bukkit.event.EventHandler
1212
import org.bukkit.event.Listener
1313
import org.bukkit.event.block.BlockPlaceEvent
1414
import org.bukkit.event.entity.EntityPlaceEvent
15+
import org.bukkit.event.player.PlayerBucketEmptyEvent
1516

1617
class GriefEvents(val plugin: Gamemode4Core): Listener {
1718
private val warningTime: Int = 60*60*20
@@ -69,4 +70,25 @@ class GriefEvents(val plugin: Gamemode4Core): Listener {
6970
}
7071
}
7172
}
73+
74+
@EventHandler
75+
fun onBucketEmpty(event: PlayerBucketEmptyEvent) {
76+
77+
if (event.player.getStatistic(Statistic.PLAY_ONE_MINUTE) < (warningTime/2)) {
78+
when (event.bucket) {
79+
Material.LAVA_BUCKET -> {
80+
event.isCancelled = true
81+
val loc = event.block.location
82+
Bukkit.broadcast(parseString("<staff_prefix> <player> <red>Attempted to place lava " +
83+
"at <u><click:suggest_command:'/tpa l ${loc.x} ${loc.y} ${loc.z}'>" +
84+
"${loc.x} ${loc.y} ${loc.z}</click></u>", event.player, plugin))
85+
kickPlayer(event.player)
86+
}
87+
else -> {
88+
return
89+
}
90+
}
91+
}
92+
93+
}
7294
}

0 commit comments

Comments
 (0)