mirror of
https://github.com/Auxilor/Reforges.git
synced 2025-12-27 02:49:13 +00:00
Migrated to eco 6.17.0
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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<String>) {
|
||||
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<String>()
|
||||
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<String>): List<String> {
|
||||
|
||||
val completions = mutableListOf<String>()
|
||||
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()
|
||||
}
|
||||
}
|
||||
@@ -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<String>) {
|
||||
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<String>()
|
||||
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<String>): List<String> {
|
||||
val completions = mutableListOf<String>()
|
||||
if (args.size == 1) {
|
||||
StringUtil.copyPartialMatches(
|
||||
args[0],
|
||||
Bukkit.getOnlinePlayers().map { it.name },
|
||||
completions
|
||||
)
|
||||
return completions
|
||||
}
|
||||
return emptyList()
|
||||
}
|
||||
}
|
||||
@@ -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<String>) {
|
||||
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)
|
||||
}
|
||||
}
|
||||
@@ -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<String>) {
|
||||
sender.sendMessage(
|
||||
plugin.langYml.getMessage("invalid-command")
|
||||
)
|
||||
}
|
||||
|
||||
init {
|
||||
|
||||
@@ -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<String>) {
|
||||
sender.sendMessage(
|
||||
plugin.langYml.getMessage("reloaded", StringUtils.FormatOption.WITHOUT_PLACEHOLDERS)
|
||||
.replace("%time%", plugin.reloadWithTime().toString())
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user