-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added more admin commands and some refactoring
- Loading branch information
1 parent
7aa6239
commit 6d41566
Showing
18 changed files
with
225 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,6 @@ eclipse/ | |
|
||
# Gradle wrapper | ||
.gradle | ||
|
||
# Passwords | ||
scripts/.private.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env bash | ||
|
||
source scripts/.private.sh | ||
scp build/libs/oneslotserver-1.0-SNAPSHOT-all.jar [email protected]:plugins | ||
mcrcon -H oneslotserver.fun reload |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
src/main/kotlin/com/freundtech/minecraft/oneslotserver/extension/ConfigExtension.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.freundtech.minecraft.oneslotserver.extension | ||
|
||
import com.kizitonwose.time.Interval | ||
import com.kizitonwose.time.Millisecond | ||
import com.kizitonwose.time.milliseconds | ||
import org.bukkit.configuration.ConfigurationSection | ||
|
||
fun ConfigurationSection.getTime(path: String, default: Interval<*>): Interval<*> { | ||
return this.getLong(path, default.inMilliseconds.longValue).milliseconds | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/main/kotlin/com/freundtech/minecraft/oneslotserver/extension/TimeExtension.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.freundtech.minecraft.oneslotserver.extension | ||
|
||
import com.kizitonwose.time.Interval | ||
import com.kizitonwose.time.hours | ||
import java.text.SimpleDateFormat | ||
import java.util.* | ||
|
||
val hoursFormat = SimpleDateFormat("HH:mm").also { it.timeZone = TimeZone.getTimeZone("GMT") } | ||
val minutesFormat = SimpleDateFormat("mm:ss").also { it.timeZone = TimeZone.getTimeZone("GMT") } | ||
|
||
fun Interval<*>.format(): String { | ||
val result = StringBuilder() | ||
return if (this > 1.hours) { | ||
"${hoursFormat.format(inMilliseconds.longValue)} hours" | ||
} else { | ||
"${minutesFormat.format(inMilliseconds.longValue)} minutes" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
...in/kotlin/com/freundtech/minecraft/oneslotserver/handler/command/TimeCommandsExecutors.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package com.freundtech.minecraft.oneslotserver.handler.command | ||
|
||
import com.freundtech.minecraft.oneslotserver.OneSlotServer | ||
import com.freundtech.minecraft.oneslotserver.extension.PlayerInfo | ||
import com.freundtech.minecraft.oneslotserver.extension.oneSlotServer | ||
import com.kizitonwose.time.seconds | ||
import org.bukkit.command.Command | ||
import org.bukkit.command.CommandExecutor | ||
import org.bukkit.command.CommandSender | ||
|
||
class SetPlayTimeCommand(private val plugin: OneSlotServer) : CommandExecutor { | ||
override fun onCommand(sender: CommandSender, command: Command, label: String, args: Array<out String>): Boolean { | ||
if (args.size != 1) { | ||
return false | ||
} | ||
val time = args[0].toLongOrNull()?.seconds ?: return false | ||
plugin.playTime = time | ||
sender.sendMessage("Set play time to $time") | ||
return true | ||
} | ||
} | ||
|
||
class SetWaitTimeCommand(private val plugin: OneSlotServer) : CommandExecutor { | ||
override fun onCommand(sender: CommandSender, command: Command, label: String, args: Array<out String>): Boolean { | ||
if (args.size != 1) { | ||
return false | ||
} | ||
val time = args[0].toLongOrNull()?.seconds ?: return false | ||
plugin.waitTime = time | ||
sender.sendMessage("Set wait time to $time") | ||
return true | ||
} | ||
} | ||
|
||
class SetTimeLeftCommand(private val plugin: OneSlotServer) : CommandExecutor { | ||
override fun onCommand(sender: CommandSender, command: Command, label: String, args: Array<out String>): Boolean { | ||
if (args.size !in 1..2) { | ||
return false | ||
} | ||
val time = args[0].toLongOrNull()?.seconds ?: return false | ||
if (args.size == 1) { | ||
val player = plugin.activePlayer ?: run { | ||
sender.sendMessage("Nobody is currently playing") | ||
return false | ||
} | ||
player.oneSlotServer.timeLeft = time | ||
sender.sendMessage("Set time left to $time for active player") | ||
} else { | ||
val playerName = args[1] | ||
val player = sender.server.offlinePlayers.firstOrNull { it.name.equals(playerName, ignoreCase = true) } ?: run { | ||
sender.sendMessage("Player $playerName is isn't known to this server") | ||
return false | ||
} | ||
PlayerInfo(player.uniqueId).also { it.timeLeft = time }.save() | ||
sender.sendMessage("Set time left to $time for $playerName") | ||
} | ||
return true | ||
} | ||
} | ||
|
7 changes: 2 additions & 5 deletions
7
...slotserver/handler/AdvancementListener.kt → ...rver/handler/event/AdvancementListener.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.