Less verbose console output

- removed pausing and resuming message when no tasks are running
release/0.12-beta
Trivernis 5 years ago
parent 8134ccde9c
commit d0a76b213d

@ -23,7 +23,9 @@ class ChunkmasterEvents(private val chunkmaster: Chunkmaster, private val server
server.onlinePlayers.isEmpty()
) {
if (!playerPaused) {
if (chunkmaster.generationManager.pausedTasks.isNotEmpty()) {
chunkmaster.logger.info("Server is empty. Resuming chunk generation tasks.")
}
chunkmaster.generationManager.resumeAll()
} else if (chunkmaster.generationManager.paused){
chunkmaster.logger.info("Generation was manually paused. Not resuming automatically.")
@ -42,7 +44,9 @@ class ChunkmasterEvents(private val chunkmaster: Chunkmaster, private val server
fun onPlayerJoin(event: PlayerJoinEvent) {
if (pauseOnJoin) {
if (server.onlinePlayers.size == 1 || server.onlinePlayers.isEmpty()) {
if (chunkmaster.generationManager.tasks.isNotEmpty()) {
chunkmaster.logger.info("Pausing generation tasks because of player join.")
}
playerPaused = chunkmaster.generationManager.paused
chunkmaster.generationManager.pauseAll()
}

@ -0,0 +1,34 @@
package net.trivernis.chunkmaster.commands
import net.md_5.bungee.api.ChatColor
import net.md_5.bungee.api.chat.ComponentBuilder
import net.trivernis.chunkmaster.Chunkmaster
import net.trivernis.chunkmaster.lib.Subcommand
import org.bukkit.command.Command
import org.bukkit.command.CommandSender
class CmdReload(private val chunkmaster: Chunkmaster): Subcommand {
override val name = "reload"
override fun onTabComplete(
sender: CommandSender,
command: Command,
alias: String,
args: List<String>
): MutableList<String> {
return emptyList<String>().toMutableList()
}
/**
* Reload command to reload the config and restart the tasks.
*/
override fun execute(sender: CommandSender, args: List<String>): Boolean {
sender.spigot().sendMessage(*ComponentBuilder("Reloading config and restarting tasks...")
.color(ChatColor.YELLOW).create())
chunkmaster.generationManager.stopAll()
chunkmaster.reloadConfig()
chunkmaster.generationManager.startAll()
sender.spigot().sendMessage(*ComponentBuilder("Config reload complete!").color(ChatColor.GREEN).create())
return true
}
}

@ -10,7 +10,7 @@ import org.bukkit.command.CommandExecutor
import org.bukkit.command.CommandSender
import org.bukkit.command.TabCompleter
class CommandChunkmaster(private val chunkmaster: Chunkmaster, private val server: Server): CommandExecutor,
class CommandChunkmaster(private val chunkmaster: Chunkmaster, private val server: Server) : CommandExecutor,
TabCompleter {
private val commands = HashMap<String, Subcommand>()
@ -25,7 +25,7 @@ class CommandChunkmaster(private val chunkmaster: Chunkmaster, private val serve
MutableList<String> {
if (args.size == 1) {
return commands.keys.filter { it.indexOf(args[0]) == 0 }.toMutableList()
} else if (args.isNotEmpty()){
} else if (args.isNotEmpty()) {
if (commands.containsKey(args[0])) {
val commandEntry = commands[args[0]]
@ -40,25 +40,21 @@ class CommandChunkmaster(private val chunkmaster: Chunkmaster, private val serve
*/
override fun onCommand(sender: CommandSender, command: Command, label: String, args: Array<out String>): Boolean {
if (args.isNotEmpty()) {
when (args[0]) {
"reload" -> {
chunkmaster.reloadConfig()
sender.sendMessage("Configuration file reloaded.")
}
else -> {
if (sender.hasPermission("chunkmaster.${args[0]}")) {
return if (commands.containsKey(args[0])) {
commands[args[0]]!!.execute(sender, args.slice(1 until args.size))
} else {
sender.spigot().sendMessage(*ComponentBuilder("Subcommand ").color(ChatColor.RED)
.append(args[0]).color(ChatColor.GREEN).append(" not found").color(ChatColor.RED).create())
sender.spigot().sendMessage(
*ComponentBuilder("Subcommand ").color(ChatColor.RED)
.append(args[0]).color(ChatColor.GREEN).append(" not found").color(ChatColor.RED).create()
)
false
}
} else {
sender.spigot().sendMessage(*ComponentBuilder("You do not have permission!")
.color(ChatColor.RED).create())
}
}
sender.spigot().sendMessage(
*ComponentBuilder("You do not have permission!")
.color(ChatColor.RED).create()
)
}
return true
} else {
@ -66,7 +62,10 @@ class CommandChunkmaster(private val chunkmaster: Chunkmaster, private val serve
}
}
fun registerCommands() {
/**
* Registers all subcommands.
*/
private fun registerCommands() {
val cmdGenerate = CmdGenerate(chunkmaster)
commands[cmdGenerate.name] = cmdGenerate
@ -81,5 +80,8 @@ class CommandChunkmaster(private val chunkmaster: Chunkmaster, private val serve
val cmdList = CmdList(chunkmaster)
commands[cmdList.name] = cmdList
val cmdReload = CmdReload(chunkmaster)
commands[cmdReload.name] = cmdReload
}
}

@ -157,7 +157,6 @@ class GenerationManager(private val chunkmaster: Chunkmaster, private val server
* Starts all generation tasks.
*/
fun startAll() {
chunkmaster.logger.info("Loading saved chunk generation tasks...")
val savedTasksStatement = chunkmaster.sqliteConnection.prepareStatement("SELECT * FROM generation_tasks")
savedTasksStatement.execute()
val res = savedTasksStatement.resultSet
@ -178,8 +177,10 @@ class GenerationManager(private val chunkmaster: Chunkmaster, private val server
}
}
savedTasksStatement.close()
if (tasks.isNotEmpty()) {
chunkmaster.logger.info("${tasks.size} saved tasks loaded.")
}
}
/**
* Pauses all tasks

Loading…
Cancel
Save