9
0
mirror of https://github.com/Auxilor/EcoSkills.git synced 2026-01-03 06:12:21 +00:00

Merge remote-tracking branch 'origin/master'

This commit is contained in:
Auxilor
2021-10-18 14:20:08 +01:00
8 changed files with 51 additions and 12 deletions

View File

@@ -51,7 +51,7 @@ public class EcoSkillsPlugin extends EcoPlugin {
* Internal constructor called by bukkit on plugin load.
*/
public EcoSkillsPlugin() {
super(1351, 12205, "&#ff00ae", true);
super(1351, 13052, "&#ff00ae", true);
instance = this;
effectsYml = new EffectsYml(this);
dataHandler = this.getConfigYml().getBool("mysql.enabled")

View File

@@ -34,6 +34,17 @@ public class TabCompleteHelper {
"10"
);
/**
* Numbers.
*/
public static final List<String> NUMBERS = Arrays.asList(
"1",
"2",
"3",
"4",
"5"
);
/**
* Update lists.
*/

View File

@@ -86,6 +86,15 @@ class CommandRank(plugin: EcoPlugin) :
return@TabCompleteHandler completions
}
if (args.size == 2) {
StringUtil.copyPartialMatches(
args[1],
TabCompleteHelper.NUMBERS,
completions
)
return@TabCompleteHandler completions
}
return@TabCompleteHandler emptyList()
}
}

View File

@@ -2,12 +2,15 @@ package com.willfp.ecoskills.commands
import com.willfp.eco.core.EcoPlugin
import com.willfp.eco.core.command.CommandHandler
import com.willfp.eco.core.command.TabCompleteHandler
import com.willfp.eco.core.command.impl.Subcommand
import com.willfp.eco.util.StringUtils
import com.willfp.ecoskills.data.LeaderboardHandler
import com.willfp.ecoskills.data.savedDisplayName
import com.willfp.ecoskills.getTotalSkillLevel
import com.willfp.ecoskills.util.TabCompleteHelper
import org.bukkit.command.CommandSender
import org.bukkit.util.StringUtil
class CommandTop(plugin: EcoPlugin) :
@@ -54,4 +57,21 @@ class CommandTop(plugin: EcoPlugin) :
}
}
}
override fun getTabCompleter(): TabCompleteHandler {
return TabCompleteHandler { _, args ->
val completions = mutableListOf<String>()
if (args.size == 1) {
StringUtil.copyPartialMatches(
args[0],
TabCompleteHelper.NUMBERS,
completions
)
return@TabCompleteHandler completions
}
return@TabCompleteHandler emptyList()
}
}
}

View File

@@ -6,5 +6,8 @@ interface DataHandler {
fun save()
fun <T> write(uuid: UUID, key: String, value: T)
fun <T : Any> read(uuid: UUID, key: String, default: T): T
fun <T> read(uuid: UUID, key: String): T?
fun <T : Any> read(uuid: UUID, key: String, default: T): T {
return read<T>(uuid, key) ?: default
}
}

View File

@@ -67,11 +67,11 @@ class MySQLDataHandler(
}
}
override fun <T : Any> read(uuid: UUID, key: String, default: T): T {
var value = default
override fun <T> read(uuid: UUID, key: String): T? {
var value: T? = null
transaction {
val player = Players.select { Players.id eq uuid }.firstOrNull() ?: return@transaction
value = player[Players.columns.stream().filter { it.name == key }.findFirst().get()] as T? ?: default
value = player[Players.columns.stream().filter { it.name == key }.findFirst().get()] as T?
}
return value
}

View File

@@ -18,12 +18,8 @@ class YamlDataHandler(
dataYml.set("player.$uuid.$key", value)
}
override fun <T : Any> read(uuid: UUID, key: String, default: T): T {
return if (dataYml.has("player.$uuid.$key")) {
dataYml.get("player.$uuid.$key") as T
} else {
default
}
override fun <T> read(uuid: UUID, key: String): T? {
return dataYml.get("player.$uuid.$key") as T?
}
class DataYml(

View File

@@ -1,2 +1,2 @@
version = 1.7.2
version = 1.7.4
plugin-name = EcoSkills