diff --git a/eco-core/core-plugin/src/main/java/com/willfp/reforges/config/ReforgesYml.java b/eco-core/core-plugin/src/main/java/com/willfp/reforges/config/ReforgesYml.java index 256c6dd..625be41 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/reforges/config/ReforgesYml.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/reforges/config/ReforgesYml.java @@ -1,16 +1,17 @@ package com.willfp.reforges.config; import com.willfp.eco.core.EcoPlugin; -import com.willfp.eco.core.config.yaml.YamlBaseConfig; +import com.willfp.eco.core.config.BaseConfig; +import com.willfp.eco.core.config.ConfigType; import org.jetbrains.annotations.NotNull; -public class ReforgesYml extends YamlBaseConfig { +public class ReforgesYml extends BaseConfig { /** * Instantiate reforges.yml. * * @param plugin Instance of reforges. */ public ReforgesYml(@NotNull final EcoPlugin plugin) { - super("reforges", true, plugin); + super("reforges", plugin, true, ConfigType.YAML); } } diff --git a/eco-core/core-plugin/src/main/java/com/willfp/reforges/config/TargetYml.java b/eco-core/core-plugin/src/main/java/com/willfp/reforges/config/TargetYml.java index 00873f2..05b8615 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/reforges/config/TargetYml.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/reforges/config/TargetYml.java @@ -1,7 +1,8 @@ package com.willfp.reforges.config; import com.willfp.eco.core.EcoPlugin; -import com.willfp.eco.core.config.yaml.YamlBaseConfig; +import com.willfp.eco.core.config.BaseConfig; +import com.willfp.eco.core.config.ConfigType; import com.willfp.eco.core.items.Items; import com.willfp.eco.core.items.TestableItem; import com.willfp.reforges.reforges.meta.ReforgeTarget; @@ -11,14 +12,14 @@ import java.util.HashSet; import java.util.List; import java.util.Set; -public class TargetYml extends YamlBaseConfig { +public class TargetYml extends BaseConfig { /** * Instantiate target.yml. * * @param plugin Instance of EcoEnchants. */ public TargetYml(@NotNull final EcoPlugin plugin) { - super("target", false, plugin); + super("target", plugin, false, ConfigType.YAML); } /** diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/reforges/commands/CommandGive.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/reforges/commands/CommandGive.kt index c907c3b..2aeef61 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/reforges/commands/CommandGive.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/reforges/commands/CommandGive.kt @@ -1,11 +1,10 @@ package com.willfp.reforges.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.reforges.reforges.Reforges import org.bukkit.Bukkit +import org.bukkit.command.CommandSender import org.bukkit.util.StringUtil class CommandGive( @@ -22,74 +21,71 @@ class CommandGive( "64" ) - override fun getHandler(): CommandHandler { - return CommandHandler { sender, args -> - if (args.isEmpty()) { - sender.sendMessage(plugin.langYml.getMessage("needs-player")) - return@CommandHandler - } - - if (args.size == 1) { - sender.sendMessage(plugin.langYml.getMessage("needs-stone")) - return@CommandHandler - } - - val amount = if (args.size > 2) args[2].toIntOrNull() ?: 1 else 1 - val recieverName = args[0] - val reciever = Bukkit.getPlayer(recieverName) - if (reciever == null) { - sender.sendMessage(plugin.langYml.getMessage("invalid-player")) - return@CommandHandler - } - val key = args[1] - val reforge = Reforges.getByKey(key) - if (reforge == null) { - sender.sendMessage(plugin.langYml.getMessage("invalid-stone")) - return@CommandHandler - } - var message = plugin.langYml.getMessage("give-success") - message = message.replace("%reforge%", reforge.name).replace("%recipient%", reciever.name) - sender.sendMessage(message) - val itemStack = reforge.stone - itemStack.amount = amount - reciever.inventory.addItem(itemStack) + override fun onExecute(sender: CommandSender, args: MutableList) { + if (args.isEmpty()) { + sender.sendMessage(plugin.langYml.getMessage("needs-player")) + return } + + if (args.size == 1) { + sender.sendMessage(plugin.langYml.getMessage("needs-stone")) + return + } + + val amount = if (args.size > 2) args[2].toIntOrNull() ?: 1 else 1 + val recieverName = args[0] + val reciever = Bukkit.getPlayer(recieverName) + if (reciever == null) { + sender.sendMessage(plugin.langYml.getMessage("invalid-player")) + return + } + val key = args[1] + val reforge = Reforges.getByKey(key) + if (reforge == null) { + sender.sendMessage(plugin.langYml.getMessage("invalid-stone")) + return + } + var message = plugin.langYml.getMessage("give-success") + message = message.replace("%reforge%", reforge.name).replace("%recipient%", reciever.name) + sender.sendMessage(message) + val itemStack = reforge.stone + itemStack.amount = amount + reciever.inventory.addItem(itemStack) } - override fun getTabCompleter(): TabCompleteHandler { - return TabCompleteHandler { _, args -> - val completions = mutableListOf() - if (args.isEmpty()) { - // Currently, this case is not ever reached - return@TabCompleteHandler Reforges.values().filter { it.requiresStone }.map { it.id } - } - if (args.size == 1) { - StringUtil.copyPartialMatches( - args[0], - Bukkit.getOnlinePlayers().map { it.name }, - completions - ) - return@TabCompleteHandler completions - } - if (args.size == 2) { - StringUtil.copyPartialMatches( - args[1], - Reforges.values().filter { it.requiresStone }.map { it.id }, - completions - ) - completions.sort() - return@TabCompleteHandler completions - } - if (args.size == 3) { - StringUtil.copyPartialMatches(args[2], numbers, completions) - completions.sortWith { s1, s2 -> - val t1 = s1.toInt() - val t2 = s2.toInt() - t1 - t2 - } - return@TabCompleteHandler completions - } - emptyList() + override fun tabComplete(sender: CommandSender, args: List): List { + + val completions = mutableListOf() + if (args.isEmpty()) { + // Currently, this case is not ever reached + return Reforges.values().filter { it.requiresStone }.map { it.id } } + if (args.size == 1) { + StringUtil.copyPartialMatches( + args[0], + Bukkit.getOnlinePlayers().map { it.name }, + completions + ) + return completions + } + if (args.size == 2) { + StringUtil.copyPartialMatches( + args[1], + Reforges.values().filter { it.requiresStone }.map { it.id }, + completions + ) + completions.sort() + return completions + } + if (args.size == 3) { + StringUtil.copyPartialMatches(args[2], numbers, completions) + completions.sortWith { s1, s2 -> + val t1 = s1.toInt() + val t2 = s2.toInt() + t1 - t2 + } + return completions + } + return emptyList() } } \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/reforges/commands/CommandOpen.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/reforges/commands/CommandOpen.kt index e718c74..e42661d 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/reforges/commands/CommandOpen.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/reforges/commands/CommandOpen.kt @@ -1,50 +1,45 @@ package com.willfp.reforges.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.PluginCommand import com.willfp.reforges.gui.ReforgeGUI.menu import org.bukkit.Bukkit import org.bukkit.Sound +import org.bukkit.command.CommandSender import org.bukkit.util.StringUtil class CommandOpen( plugin: EcoPlugin ) : PluginCommand(plugin, "open", "reforges.command.open", false) { - override fun getHandler(): CommandHandler { - return CommandHandler { sender, args -> - if (args.isEmpty()) { - sender.sendMessage(plugin.langYml.getMessage("needs-player")) - return@CommandHandler - } - val player = Bukkit.getPlayer(args[0]) - if (player == null) { - sender.sendMessage(plugin.langYml.getMessage("invalid-player")) - return@CommandHandler - } - player.playSound( - player.location, - Sound.valueOf(plugin.configYml.getString("gui.open-sound.id").uppercase()), - 1f, - plugin.configYml.getDouble("gui.open-sound.pitch").toFloat() - ) - menu.open(player) + override fun onExecute(sender: CommandSender, args: List) { + if (args.isEmpty()) { + sender.sendMessage(plugin.langYml.getMessage("needs-player")) + return } + val player = Bukkit.getPlayer(args[0]) + if (player == null) { + sender.sendMessage(plugin.langYml.getMessage("invalid-player")) + return + } + player.playSound( + player.location, + Sound.valueOf(plugin.configYml.getString("gui.open-sound.id").uppercase()), + 1f, + plugin.configYml.getDouble("gui.open-sound.pitch").toFloat() + ) + menu.open(player) } - override fun getTabCompleter(): TabCompleteHandler { - return TabCompleteHandler { _, args -> - val completions = mutableListOf() - if (args.size == 1) { - StringUtil.copyPartialMatches( - args[0], - Bukkit.getOnlinePlayers().map { it.name }, - completions - ) - return@TabCompleteHandler completions - } - emptyList() + override fun tabComplete(sender: CommandSender, args: List): List { + val completions = mutableListOf() + if (args.size == 1) { + StringUtil.copyPartialMatches( + args[0], + Bukkit.getOnlinePlayers().map { it.name }, + completions + ) + return completions } + return emptyList() } } \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/reforges/commands/CommandReforge.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/reforges/commands/CommandReforge.kt index d086268..902a523 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/reforges/commands/CommandReforge.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/reforges/commands/CommandReforge.kt @@ -1,25 +1,23 @@ package com.willfp.reforges.commands import com.willfp.eco.core.EcoPlugin -import com.willfp.eco.core.command.CommandHandler import com.willfp.eco.core.command.impl.PluginCommand import com.willfp.reforges.gui.ReforgeGUI.menu import org.bukkit.Sound +import org.bukkit.command.CommandSender import org.bukkit.entity.Player class CommandReforge( plugin: EcoPlugin ) : PluginCommand(plugin, "reforge", "reforges.command.reforge", true) { - override fun getHandler(): CommandHandler { - return CommandHandler { player, _ -> - player as Player - player.playSound( - player.location, - Sound.valueOf(plugin.configYml.getString("gui.open-sound.id").uppercase()), - 1f, - plugin.configYml.getDouble("gui.open-sound.pitch").toFloat() - ) - menu.open(player) - } + override fun onExecute(player: CommandSender, args: List) { + player as Player + player.playSound( + player.location, + Sound.valueOf(plugin.configYml.getString("gui.open-sound.id").uppercase()), + 1f, + plugin.configYml.getDouble("gui.open-sound.pitch").toFloat() + ) + menu.open(player) } } \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/reforges/commands/CommandReforges.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/reforges/commands/CommandReforges.kt index 3ead430..077cd8e 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/reforges/commands/CommandReforges.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/reforges/commands/CommandReforges.kt @@ -1,16 +1,14 @@ package com.willfp.reforges.commands import com.willfp.eco.core.EcoPlugin -import com.willfp.eco.core.command.CommandHandler import com.willfp.eco.core.command.impl.PluginCommand +import org.bukkit.command.CommandSender class CommandReforges(plugin: EcoPlugin) : PluginCommand(plugin, "reforges", "reforges.command.reforges", false) { - override fun getHandler(): CommandHandler { - return CommandHandler { sender, _ -> - sender.sendMessage( - plugin.langYml.getMessage("invalid-command") - ) - } + override fun onExecute(sender: CommandSender, args: List) { + sender.sendMessage( + plugin.langYml.getMessage("invalid-command") + ) } init { diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/reforges/commands/CommandReload.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/reforges/commands/CommandReload.kt index 8153ebd..f919394 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/reforges/commands/CommandReload.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/reforges/commands/CommandReload.kt @@ -1,15 +1,15 @@ package com.willfp.reforges.commands import com.willfp.eco.core.EcoPlugin -import com.willfp.eco.core.command.CommandHandler import com.willfp.eco.core.command.impl.Subcommand import com.willfp.eco.util.StringUtils +import org.bukkit.command.CommandSender class CommandReload(plugin: EcoPlugin) : Subcommand(plugin, "reload", "reforges.command.reload", false) { - override fun getHandler(): CommandHandler { - return CommandHandler { sender, _ -> - sender.sendMessage(plugin.langYml.getMessage("reloaded", StringUtils.FormatOption.WITHOUT_PLACEHOLDERS) - .replace("%time%", plugin.reloadWithTime().toString())) - } + override fun onExecute(sender: CommandSender, args: List) { + sender.sendMessage( + plugin.langYml.getMessage("reloaded", StringUtils.FormatOption.WITHOUT_PLACEHOLDERS) + .replace("%time%", plugin.reloadWithTime().toString()) + ) } } \ No newline at end of file