commit a3588c295643c0a7065773a4279f9aa35330c773 Author: Hamza Ali Date: Wed Jan 6 07:01:19 2021 +0700 Initial commit: port from svn diff --git a/compile.bat b/compile.bat new file mode 100644 index 0000000..3ad0c48 --- /dev/null +++ b/compile.bat @@ -0,0 +1 @@ +mvn package && start ../speak.vbs diff --git a/compile.sh b/compile.sh new file mode 100644 index 0000000..7114388 --- /dev/null +++ b/compile.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +mvn package +#mv ./target/VagueEnchants-1.0.0.jar ~/server/plugins/ +say up \ No newline at end of file diff --git a/libs/craftbukkit-1.10.2.jar b/libs/craftbukkit-1.10.2.jar new file mode 100644 index 0000000..c11e6fd Binary files /dev/null and b/libs/craftbukkit-1.10.2.jar differ diff --git a/libs/worldedit-bukkit-6.1.3.jar b/libs/worldedit-bukkit-6.1.3.jar new file mode 100644 index 0000000..de558ef Binary files /dev/null and b/libs/worldedit-bukkit-6.1.3.jar differ diff --git a/libs/worldguard-6.1.2.jar b/libs/worldguard-6.1.2.jar new file mode 100644 index 0000000..efc3a56 Binary files /dev/null and b/libs/worldguard-6.1.2.jar differ diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..020b587 --- /dev/null +++ b/pom.xml @@ -0,0 +1,138 @@ + + + + 4.0.0 + + pw.hamzantal + VagueEnchants + 1.0.0 + jar + + VagueEnchants + + + UTF-8 + 1.3.71 + 1.8 + official + 4.12 + + + + + jitpack.io + https://jitpack.io + + + placeholderapi + https://repo.extendedclip.com/content/repositories/placeholderapi/ + + + okkero + http://nexus.okkero.com/repository/maven-releases/ + + + + + + org.jetbrains.kotlin + kotlin-stdlib + ${kotlin.version} + compile + + + com.udojava + EvalEx + 2.5 + compile + + + me.clip + placeholderapi + 2.10.5 + provided + + + com.github.hazae41 + mc-kutils + master-SNAPSHOT + compile + + + com.okkero.skedule + skedule + 1.2.6 + compile + + + com.spigotmc + spigot-api + 1.10.2 + system + ${project.basedir}/libs/craftbukkit-1.10.2.jar + + + com.sk89q + worldguard-api + 6.1.2 + system + ${project.basedir}/libs/worldguard-6.1.2.jar + + + com.sk89q + worldedit-api + 6.1.3 + system + ${project.basedir}/libs/worldedit-bukkit-6.1.3.jar + + + + + src/main/kotlin + src/test/kotlin + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.7.0 + + 1.8 + 1.8 + + + + org.apache.maven.plugins + maven-shade-plugin + 3.1.0 + + + package + + shade + + + false + + + + + + org.jetbrains.kotlin + kotlin-maven-plugin + ${kotlin.version} + + + compile + compile + + compile + + + + + + + + diff --git a/src/main/kotlin/pw/hamzantal/vagueenchants/BaseCommand.kt b/src/main/kotlin/pw/hamzantal/vagueenchants/BaseCommand.kt new file mode 100644 index 0000000..e383bfe --- /dev/null +++ b/src/main/kotlin/pw/hamzantal/vagueenchants/BaseCommand.kt @@ -0,0 +1,49 @@ +package pw.hamzantal.vagueenchants + +import hazae41.minecraft.kutils.bukkit.msg +import org.bukkit.command.CommandSender +import org.bukkit.entity.Player +import pw.hamzantal.vagueenchants.commands.* + + +val help = Help() +val subCommands = listOf( + AddEnch(), + DelEnch(), + help, + Info(), + Connect(), + AddTokens(), + SetTokens(), + DelTokens(), + Upgrade(), + Refund(), + Repair() +) + +fun baseCommand(s: CommandSender, arg: Array) { + if (arg.isEmpty()) { + help.execute(s, arg) + return + } + + val (subCommandName) = arg + val cmd = subCommands.firstOrNull { it.firstArg == subCommandName } ?: run { + s.err("command_not_found", "command" to subCommandName) + return + } + if (cmd.requirePermission && !s.hasPermission(cmd.permission)) { + s.err("no_access") + return + } + if (cmd.requirePlayer && s !is Player) { + s.err("require_player") + return + } + if (cmd.minArgs > arg.size && cmd != help) { + s.general(cmd.usage) + return + } + + cmd.execute(s, arg) +} \ No newline at end of file diff --git a/src/main/kotlin/pw/hamzantal/vagueenchants/Config.kt b/src/main/kotlin/pw/hamzantal/vagueenchants/Config.kt new file mode 100644 index 0000000..3a4ccdd --- /dev/null +++ b/src/main/kotlin/pw/hamzantal/vagueenchants/Config.kt @@ -0,0 +1,107 @@ +package pw.hamzantal.vagueenchants + +import com.udojava.evalex.Expression +import hazae41.minecraft.kutils.bukkit.ConfigFile +import hazae41.minecraft.kutils.bukkit.keys +import hazae41.minecraft.kutils.get +import org.bukkit.configuration.ConfigurationSection +import kotlin.reflect.KProperty + +class EnchantmentInfo( + val description: String, + val max: Int, + val cost: Expression, + val others: ConfigurationSection +) { + val cooldown by lazy { Expression(others.getString("cooldown_equation")) } + val blocks by lazy { Expression(others.getString("destroyed_blocks_equation")) } + val chance by lazy { Expression(others.getString("chance_equation")) } + val command by lazy { others.getString("command") ?: "" } + val keys by lazy { + val list = mutableListOf() + others.getConfigurationSection("keys").keys + .map { others.getConfigurationSection("keys.$it") }.forEach { key -> + repeat(key.getInt("chance")) { list += key.getString("command") } + } + list + } + + val minTokens by lazy { Expression(others.getString("minTokens"))} + val maxTokens by lazy { Expression(others.getString("maxTokens"))} + + val all by lazy { + others.getKeys(false).map { it to others.get(it).toString() } + } +} + +fun info(section: ConfigurationSection) = EnchantmentInfo( + section.getString("description"), + section.getInt("max"), + Expression(section.getString("cost_equation")), + section +) + +data class TokenConfig( + val host: String, + val database: String, + val table: String, + val user: String, + val pass: String + +) + +object Config : ConfigFile(VagueEnchants.pl.dataFolder["config.yml"]) { + + val refundValue by double("refund_value") + + val repairValue by double("repair_value") + val minRepair by long("min_repair") + + private val tokenPath by Section("tokens") + val token = TokenConfig( + tokenPath.getString("host"), + tokenPath.getString("database"), + tokenPath.getString("table"), + tokenPath.getString("username"), + tokenPath.getString("password") + ) + + + private val efficiencyPath by Section("enchantments.efficiency") + val efficiency = info(efficiencyPath) + + private val fortunePath by Section("enchantments.fortune") + val fortune = info(fortunePath) + + private val omniPath by Section("enchantments.omnitool") + val omni = info(omniPath) + + private val speedPath by Section("enchantments.speed") + val speed = info(speedPath) + + private val hastePath by Section("enchantments.haste") + val haste = info(hastePath) + + private val explosivePath by Section("enchantments.explosive") + val explosive = info(explosivePath) + + private val autoSellPath by Section("enchantments.autosell") + val autoSell = info(autoSellPath) + + private val keyMinePath by Section("enchantments.keymine") + val keyMine = info(keyMinePath) + + private val tokenMinerPath by Section("enchantments.tokenminer") + val tokenMiner = info(tokenMinerPath) + + private val slicingPath by Section("enchantments.slicing") + val slicing = info(slicingPath) + + + class Section(private val path: String) { + operator fun getValue(ref: Any?, prop: KProperty<*>): ConfigurationSection = + config.getConfigurationSection(path) + + operator fun setValue(ref: Any?, prop: KProperty<*>, value: ConfigurationSection) = set(path, value) + } +} \ No newline at end of file diff --git a/src/main/kotlin/pw/hamzantal/vagueenchants/EnchantmentUtil.kt b/src/main/kotlin/pw/hamzantal/vagueenchants/EnchantmentUtil.kt new file mode 100644 index 0000000..6ca2968 --- /dev/null +++ b/src/main/kotlin/pw/hamzantal/vagueenchants/EnchantmentUtil.kt @@ -0,0 +1,53 @@ +package pw.hamzantal.vagueenchants + +import org.bukkit.enchantments.Enchantment +import pw.hamzantal.vagueenchants.enchantments.CustomEnchant +import java.math.BigDecimal +import java.math.MathContext +import java.math.RoundingMode + +fun Enchantment.papiProperty(prop: String, level: Int): String { + val config = conf()?: return "" + return when (prop) { + "level" -> level.toString() + "next_level" -> if (level + 1 > config.max) maxLevel.toString() else "${level + 1}" + "cost" -> if (level + 1 > config.max) "0" else config.cost.x(level + 1).round.toInt().toString() + "max" -> config.max.toString() + "description" -> config.description + "refund_cost" -> refund(level).toLong().toString() + else -> "" + } +} + +fun Enchantment.conf(): EnchantmentInfo? { + return when { + this is CustomEnchant -> config + this == Enchantment.DIG_SPEED -> Config.fortune + this == Enchantment.LOOT_BONUS_BLOCKS -> Config.fortune + else -> null + } +} + +fun Enchantment.refund(level: Int): BigDecimal { + println(BigDecimal(Config.refundValue).round) + return fullCost(level).multiply(BigDecimal(Config.refundValue).round) +} + +fun Enchantment.fullCost(level: Int): BigDecimal { + return if (this is CustomEnchant) { + (1..level).toList() + .sumByBigDecimal { config.cost.x(it) } + } else BigDecimal.ZERO +} + +inline fun Iterable.sumByBigDecimal(selector: (T) -> BigDecimal): BigDecimal { + var sum: BigDecimal = BigDecimal.ZERO + for (element in this) { + sum += selector(element) + } + return sum.round +} + +val BigDecimal.round: BigDecimal get() = setScale(2, RoundingMode.HALF_UP) + +val BigDecimal.int: Int get() = round.toInt() \ No newline at end of file diff --git a/src/main/kotlin/pw/hamzantal/vagueenchants/Messages.kt b/src/main/kotlin/pw/hamzantal/vagueenchants/Messages.kt new file mode 100644 index 0000000..79b52dc --- /dev/null +++ b/src/main/kotlin/pw/hamzantal/vagueenchants/Messages.kt @@ -0,0 +1,41 @@ +package pw.hamzantal.vagueenchants + +import hazae41.minecraft.kutils.bukkit.ConfigFile +import hazae41.minecraft.kutils.get +import pw.hamzantal.vagueenchants.commands.c + +object Msgs : ConfigFile(VagueEnchants.pl.dataFolder["messages.yml"]) { + + private val errorFormat by lazy { config.getString("error") } + fun error(msg: String, vararg params: Pair): String { + var base = errorFormat.replace("%s", config.getString("error_msgs.$msg", msg)) + params.forEach { (k, v) -> base = base.replace("%$k%", v) } + return base.c + } + + private val generalFormat by lazy { config.getString("general") } + fun general(msg: String, vararg params: Pair): String { + var base = generalFormat.replace("%s", config.getString("general_msgs.$msg", msg)) + params.forEach { (k, v) -> base = base.replace("%$k%", v) } + return base.c + } + + private val successFormat by lazy { config.getString("success") } + fun success(msg: String, vararg params: Pair): String { + var base = successFormat.replace("%s", config.getString("success_msgs.$msg", msg)) + params.forEach { (k, v) -> base = base.replace("%$k%", v) } + return base.c + } + + + init { + if (file == null) throw IllegalStateException("File can't be null") + val file = file!! + if (!file.exists()) { + val messages = VagueEnchants.pl.getResource("messages.yml").bufferedReader().readLines().joinToString("\n") + file.createNewFile() + file.writeText(messages) + } + } + +} \ No newline at end of file diff --git a/src/main/kotlin/pw/hamzantal/vagueenchants/PAPIExpansion.kt b/src/main/kotlin/pw/hamzantal/vagueenchants/PAPIExpansion.kt new file mode 100644 index 0000000..805c391 --- /dev/null +++ b/src/main/kotlin/pw/hamzantal/vagueenchants/PAPIExpansion.kt @@ -0,0 +1,47 @@ +package pw.hamzantal.vagueenchants + +import me.clip.placeholderapi.expansion.PlaceholderExpansion +import org.bukkit.enchantments.Enchantment +import org.bukkit.entity.Player + +class PAPIExpansion : PlaceholderExpansion() { + val pl = VagueEnchants.pl + + override fun getVersion() = pl.description.version ?: "1.0.0" + + override fun getAuthor() = "hhhapz" + + override fun getIdentifier() = "vagueenchant" + + override fun persist() = true + + override fun canRegister() = true + + override fun onPlaceholderRequest(p: Player?, id: String): String { + if (p == null) return "UNKNOWN_PLAYER" + + if (id == "token") return cachedTokens[p.uuid]?.toString() ?: 0.toString() + val item = p.inventory.itemInMainHand + val enchants = item.enchantments + val args = id.split("_", limit = 2) + + if (args.component1() == "repair") { + val fullCost = enchants.toList() + .sumByBigDecimal { (k, v) -> k.fullCost(v) } + .toDouble() * Config.repairValue + return fullCost.toLong().toString() + } + + if (args.size == 1) return "UNKNOWN_ARGUMENT" + val ench = args.component1().ench()?: return "UNKNOWN_ENCHANTMENT" + val level = enchants[ench]?: 0 + + return ench.papiProperty(args.component2(), level) + } +} + +fun String.ench(): Enchantment? = Enchantment.getByName(toUpperCase()) ?: run { + if (toUpperCase() == "EFFICIENCY") return Enchantment.DIG_SPEED + if (toUpperCase() == "FORTUNE") return Enchantment.LOOT_BONUS_BLOCKS + null +} \ No newline at end of file diff --git a/src/main/kotlin/pw/hamzantal/vagueenchants/Token.kt b/src/main/kotlin/pw/hamzantal/vagueenchants/Token.kt new file mode 100644 index 0000000..a9a017b --- /dev/null +++ b/src/main/kotlin/pw/hamzantal/vagueenchants/Token.kt @@ -0,0 +1,81 @@ +package pw.hamzantal.vagueenchants + +import org.bukkit.Bukkit +import org.bukkit.event.player.PlayerJoinEvent +import org.bukkit.event.player.PlayerQuitEvent +import java.sql.Connection +import java.sql.DriverManager +import java.util.* + + +private var nextCheck = 0L +private var baseC: Connection = run { + val (host, db, _, user, pass) = Config.token + DriverManager.getConnection("jdbc:mysql://${host}:3306/${db}", user, pass) +} + +val conn: Connection? + get() { + if (System.currentTimeMillis() > nextCheck) { + val (host, db, _, user, pass) = Config.token + try { + baseC.close() + } catch (e: Exception) { + } + baseC = DriverManager.getConnection("jdbc:mysql://${host}:3306/${db}", user, pass) + nextCheck = System.currentTimeMillis() + 30 * 1000 + } + return baseC + } + +val cachedTokens = hashMapOf() + +fun getTokens(uuid: String): Long { + if (cachedTokens.containsKey(uuid)) return cachedTokens[uuid]!! + + val c = conn + if (c?.isClosed != false) return 0 + + + val query = c.prepareStatement("SELECT tokens FROM ${Config.token.table} WHERE uuid = ? LIMIT 1").run { + setString(1, uuid) + executeQuery() + } + if (query.next()) { + val toReturn = query.getLong("tokens") + query.close() + return toReturn + } + + return 0 +} + +fun setTokens(uuid: String, amount: Long, force: Boolean = false): Boolean { + if (Bukkit.getOfflinePlayer(UUID.fromString(uuid)).isOnline) cachedTokens[uuid] = amount + if (!force) return true + + val c = conn + + if (c?.isClosed != false) return false + + c.prepareStatement("INSERT INTO ${Config.token.table} (uuid, tokens) VALUES (?, ?) ON DUPLICATE KEY UPDATE tokens = ?") + .run { + setString(1, uuid) + setLong(2, amount) + setLong(3, amount) + closeOnCompletion() + return executeUpdate() == 1 + } + +} + +fun onJoin(e: PlayerJoinEvent) { + val id = e.player.uuid + cachedTokens[id] = getTokens(id) +} + +fun onLeave(e: PlayerQuitEvent) { + val id = e.player.uuid + setTokens(id, getTokens(id), true) + cachedTokens.remove(id) +} \ No newline at end of file diff --git a/src/main/kotlin/pw/hamzantal/vagueenchants/ToolUtils.kt b/src/main/kotlin/pw/hamzantal/vagueenchants/ToolUtils.kt new file mode 100644 index 0000000..64e43e9 --- /dev/null +++ b/src/main/kotlin/pw/hamzantal/vagueenchants/ToolUtils.kt @@ -0,0 +1,191 @@ +package pw.hamzantal.vagueenchants + +import org.bukkit.Material +import org.bukkit.Material.* +import org.bukkit.block.Block +import org.bukkit.enchantments.Enchantment +import org.bukkit.inventory.ItemStack + +enum class ToolType(val itemList: List, val suffix: String) { + PICKAXE(ToolUtils.pickaxeItems, "PICKAXE"), + AXE(ToolUtils.axeItems, "AXE"), + SHOVEL(ToolUtils.shovelItems, "SPADE"), + OTHER(ToolUtils.pickaxeItems, "") +} + +val ItemStack.tooltype: ToolType + get() = when (this.type) { + in ToolUtils.pickaxes -> ToolType.PICKAXE + in ToolUtils.axes -> ToolType.AXE + in ToolUtils.shovels -> ToolType.SHOVEL + else -> ToolType.OTHER + } + +object ToolUtils { + + val pickaxes = listOf(DIAMOND_PICKAXE, IRON_PICKAXE, GOLD_PICKAXE, STONE_PICKAXE, WOOD_PICKAXE) + + val axes = listOf(DIAMOND_AXE, IRON_AXE, GOLD_AXE, STONE_AXE, WOOD_AXE) + + val shovels = listOf(DIAMOND_SPADE, IRON_SPADE, GOLD_SPADE, STONE_SPADE, WOOD_SPADE) + + //https://minecraft.gamepedia.com/Pickaxe#Speed + val pickaxeItems = listOf( + ANVIL, + COAL_BLOCK, + DIAMOND_BLOCK, + EMERALD_BLOCK, + GOLD_BLOCK, + IRON_BLOCK, + QUARTZ_BLOCK, + REDSTONE_BLOCK, + BONE_BLOCK, + BREWING_STAND, + BRICK_STAIRS, + BRICK, + CAULDRON, + COAL_ORE, + COBBLESTONE, + COBBLESTONE_STAIRS, + COBBLE_WALL, + PRISMARINE, + DIAMOND_ORE, + DISPENSER, + DRAGON_EGG, + EMERALD_ORE, + ENCHANTMENT_TABLE, + ENDER_STONE, + ENDER_CHEST, + FROSTED_ICE, + FURNACE, + GOLD_ORE, + HOPPER, + ICE, + IRON_FENCE, + IRON_DOOR, + IRON_ORE, + IRON_TRAPDOOR, + LAPIS_BLOCK, + LAPIS_ORE, + MAGMA, + MOB_SPAWNER, + MOSSY_COBBLESTONE, + NETHER_FENCE, + NETHER_BRICK_STAIRS, + NETHER_BRICK, + QUARTZ_ORE, + NETHERRACK, + OBSIDIAN, + PACKED_ICE, + PRISMARINE, + QUARTZ_STAIRS, + RAILS, + RED_NETHER_BRICK, + RED_SANDSTONE, + RED_SANDSTONE_STAIRS, + REDSTONE_ORE, + SANDSTONE, + SANDSTONE_STAIRS, + SMOOTH_BRICK, + STONE, + SMOOTH_STAIRS, + SMOOTH_BRICK, + STONE_BUTTON, + STONE_PLATE, + STONE_SLAB2, + DOUBLE_STONE_SLAB2, + STEP, + DOUBLE_STEP + ) + + //https://minecraft.gamepedia.com/Axe#Speed + val axeItems = listOf( + TRAP_DOOR, + + WOOD_DOOR, + SPRUCE_DOOR, + BIRCH_DOOR, + JUNGLE_DOOR, + ACACIA_DOOR, + DARK_OAK_DOOR, + + CHEST, + WORKBENCH, + TRAPPED_CHEST, + + FENCE, + SPRUCE_FENCE, + BIRCH_FENCE, + JUNGLE_FENCE, + ACACIA_FENCE, + DARK_OAK_FENCE, + + FENCE_GATE, + SPRUCE_FENCE_GATE, + BIRCH_FENCE_GATE, + JUNGLE_FENCE_GATE, + ACACIA_FENCE_GATE, + DARK_OAK_FENCE_GATE, + + JUKEBOX, + + LOG, + LOG_2, + WOOD, + WOOD_STEP, + + WOOD_STAIRS, + SPRUCE_WOOD_STAIRS, + BIRCH_WOOD_STAIRS, + JUNGLE_WOOD_STAIRS, + ACACIA_STAIRS, + DARK_OAK_STAIRS, + + BOOKSHELF, + BANNER, + JACK_O_LANTERN, + MELON, + PUMPKIN, + SIGN, + NOTE_BLOCK, + WOOD_PLATE, + LADDER, + BED, + COCOA, + DAYLIGHT_DETECTOR, + DAYLIGHT_DETECTOR_INVERTED, + BROWN_MUSHROOM, + RED_MUSHROOM, + HUGE_MUSHROOM_1, + HUGE_MUSHROOM_2, + VINE + ) + + //https://minecraft.gamepedia.com/Shovel + val shovelItems = listOf( + CLAY, + GRASS, + GRASS_PATH, + GRAVEL, + MYCEL, + DIRT, + SAND, + SOUL_SAND, + SNOW, + SNOW_BLOCK + ) + + fun drops(block: Block, item: ItemStack): Iterable { + val baseDrops = block.getDrops(item) + if(baseDrops.isEmpty()) return baseDrops + val fortune = item.enchantments[Enchantment.LOOT_BONUS_BLOCKS]?: 0 + val silk = item.enchantments[Enchantment.SILK_TOUCH]?: 0 + val bonus = (Math.random() * (fortune + 2) - 1).toInt() + + if (silk > 0) return listOf(ItemStack(block.type)) + if (fortune == 0) return baseDrops + if(block.type in listOf(LAPIS_ORE, REDSTONE_ORE)) return baseDrops.map {it.apply { it.amount += bonus }} + + return baseDrops.map { it.apply { it.amount *= (bonus + 1) } } + } +} \ No newline at end of file diff --git a/src/main/kotlin/pw/hamzantal/vagueenchants/Util.kt b/src/main/kotlin/pw/hamzantal/vagueenchants/Util.kt new file mode 100644 index 0000000..55ef969 --- /dev/null +++ b/src/main/kotlin/pw/hamzantal/vagueenchants/Util.kt @@ -0,0 +1,63 @@ +package pw.hamzantal.vagueenchants + +import com.sk89q.worldguard.bukkit.WorldGuardPlugin +import com.sk89q.worldguard.protection.flags.StateFlag +import com.sk89q.worldguard.protection.regions.ProtectedRegion +import com.udojava.evalex.Expression +import me.clip.placeholderapi.PlaceholderAPI +import net.minecraft.server.v1_10_R1.NBTTagCompound +import org.bukkit.Bukkit +import org.bukkit.Location +import org.bukkit.OfflinePlayer +import org.bukkit.craftbukkit.v1_10_R1.inventory.CraftItemStack +import org.bukkit.enchantments.Enchantment +import org.bukkit.entity.Player +import org.bukkit.inventory.ItemStack +import pw.hamzantal.vagueenchants.enchantments.CustomEnchant +import java.math.BigDecimal +import java.math.RoundingMode + +fun Expression.x(value: Any, scale: Boolean = true) = with("x", value.toString()).eval().run { + if (scale) setScale(2, RoundingMode.HALF_DOWN) + else this +} ?: BigDecimal.ZERO + +val OfflinePlayer.uuid: String get() = uniqueId.toString() + +val isPapi by lazy { Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null } + +fun String.papi(p: Player) = + (if (isPapi) PlaceholderAPI.setPlaceholders(p, this)!! else this.replace("%player%", p.name)) + .replace("%player%", p.name) + +fun Location.validRegion(p : Player): ProtectedRegion? { + if (Bukkit.getPluginManager().getPlugin("WorldGuard") == null) return null + + val manager = WorldGuardPlugin.inst().regionContainer.get(world) ?: return null + val regions = manager.getApplicableRegions(this) ?: return null + return regions.regions + .filter { canMine(p) } + .firstOrNull { r -> + r.flags.entries.any { + it.key.name == "block-break" && it.value == StateFlag.State.ALLOW + } + } ?: return null +} + +fun Location.canMine(p: Player): Boolean { + if (Bukkit.getPluginManager().getPlugin("WorldGuard") == null) { + println("WorldGuard not found!") + return true + } + val wP = WorldGuardPlugin.inst().wrapPlayer(p) + val qry = WorldGuardPlugin.inst().regionContainer.createQuery() + return qry.testState(this, wP, StateFlag("block-break", true)) +} + +fun ItemStack.unbreakable(to: Boolean): ItemStack { + val stack = CraftItemStack.asNMSCopy(this) + val tag = stack.tag ?: NBTTagCompound() + tag.setBoolean("Unbreakable", to) + stack.tag = tag + return CraftItemStack.asBukkitCopy(stack) +} \ No newline at end of file diff --git a/src/main/kotlin/pw/hamzantal/vagueenchants/VagueEnchants.kt b/src/main/kotlin/pw/hamzantal/vagueenchants/VagueEnchants.kt new file mode 100644 index 0000000..acb63ae --- /dev/null +++ b/src/main/kotlin/pw/hamzantal/vagueenchants/VagueEnchants.kt @@ -0,0 +1,83 @@ +package pw.hamzantal.vagueenchants + +import hazae41.minecraft.kutils.bukkit.command +import hazae41.minecraft.kutils.bukkit.listen +import hazae41.minecraft.kutils.bukkit.schedule +import org.bukkit.Bukkit +import org.bukkit.enchantments.Enchantment +import org.bukkit.event.player.PlayerJoinEvent +import org.bukkit.plugin.java.JavaPlugin +import pw.hamzantal.vagueenchants.commands.VECompleter +import pw.hamzantal.vagueenchants.commands.tokenCommand +import pw.hamzantal.vagueenchants.enchantments.* +import java.lang.reflect.Field +import java.util.* + +class VagueEnchants : JavaPlugin() { + + companion object { + lateinit var pl: VagueEnchants + val enchants = mutableListOf() + } + + override fun onEnable() { + pl = this + saveDefaultConfig() + command("ve") { sender, args -> + baseCommand(sender, args) + } + getCommand("ve").tabCompleter = VECompleter() + command("token") { sender, args -> + tokenCommand(sender, args) + } + + tokens() + enchantments() + if (isPapi) PAPIExpansion().register() + } + + private fun enchantments() { + OmniTool(400) + Speed(401) + Haste(402) + Explosive(403) + AutoSell(404) + KeyMine(405) + TokenMiner(406) + Slicing(407) + } + + private fun tokens() { + listen(callback = ::onJoin) + listen(callback = ::onLeave) + Bukkit.getOnlinePlayers().forEach { p -> cachedTokens[p.uuid] = getTokens(p.uuid) } + schedule(async = true, delay = 60, period = 60) { + cachedTokens.forEach { (k, v) -> setTokens(k, v, true) } + } + } + + override fun onDisable() { + cachedTokens.forEach { (k, v) -> setTokens(k, v, true) } + + val byIdField = Enchantment::class.java.getDeclaredField("byId") + val byNameField = Enchantment::class.java.getDeclaredField("byName") + byIdField.isAccessible = true + byNameField.isAccessible = true + + val byId = byIdField[null] as HashMap<*, *> + val byName = byNameField[null] as HashMap<*, *> + enchants.forEach { e -> + @Suppress("DEPRECATION") + byId.remove(e.id) + byName.remove(e.name) + + } + } + + fun registerEnchantment(enchantment: Enchantment) { + val f: Field = Enchantment::class.java.getDeclaredField("acceptingNew") + f.isAccessible = true + f.set(null, true) + Enchantment.registerEnchantment(enchantment) + } +} \ No newline at end of file diff --git a/src/main/kotlin/pw/hamzantal/vagueenchants/commands/AddEnch.kt b/src/main/kotlin/pw/hamzantal/vagueenchants/commands/AddEnch.kt new file mode 100644 index 0000000..e9b70b0 --- /dev/null +++ b/src/main/kotlin/pw/hamzantal/vagueenchants/commands/AddEnch.kt @@ -0,0 +1,54 @@ +package pw.hamzantal.vagueenchants.commands + +import org.bukkit.Bukkit +import org.bukkit.Material +import org.bukkit.command.CommandSender +import pw.hamzantal.vagueenchants.enchantments.CustomEnchant +import pw.hamzantal.vagueenchants.enchantments.OmniTool +import pw.hamzantal.vagueenchants.unbreakable + +class AddEnch : Cmd { + + override val firstArg = "addench" + override val usage = "/ve addench [player] [enchantment] [level]" + override val minArgs = 4 + override val description = "&7Add an enchantment to the tool you are holding for target player" + + override val requirePermission = true + override val permission = "ve.addench" + override val requirePlayer = false + + override fun execute(sender: CommandSender, args: Array) { + val (_, targetName, enchName, lvl) = args + + val target = Bukkit.getPlayer(targetName) ?: run { + sender.err("target_not_found", "player" to targetName) + return + } + val ench = enchName.ench(sender) ?: return + + val level = lvl.toIntOrNull() ?: run { + sender.err("The value $lvl was not parsed as a number. Using 1 instead.") + 1 + } + if (level <= 0) { + sender.err("level_below_zero") + return + } + + val item = target.inventory.itemInMainHand + if (item == null || item.type == Material.AIR) { + sender.err("no_item_held") + return + } + + val success = if (ench is CustomEnchant) ench.customEnchant(item, level) + else item.addUnsafeEnchantment(ench, level) == Unit + if (ench is OmniTool) target.inventory.itemInMainHand = item.unbreakable(true) + + if (success) { + sender.success("&aEnchantment successfully applied") + target.success("addench_receiver") + } else sender.err("general_error") + } +} \ No newline at end of file diff --git a/src/main/kotlin/pw/hamzantal/vagueenchants/commands/AddTokens.kt b/src/main/kotlin/pw/hamzantal/vagueenchants/commands/AddTokens.kt new file mode 100644 index 0000000..7616762 --- /dev/null +++ b/src/main/kotlin/pw/hamzantal/vagueenchants/commands/AddTokens.kt @@ -0,0 +1,37 @@ +package pw.hamzantal.vagueenchants.commands + +import org.bukkit.Bukkit +import org.bukkit.command.CommandSender +import org.bukkit.entity.Player +import pw.hamzantal.vagueenchants.getTokens +import pw.hamzantal.vagueenchants.setTokens +import pw.hamzantal.vagueenchants.uuid + +class AddTokens : Cmd { + override val firstArg = "addtokens" + override val usage = "/ve addtokens [player] [amount]" + override val minArgs = 3 + override val description = "&7Add tokens to a player's account" + + override val requirePermission = true + override val permission = "ve.admin" + override val requirePlayer = false + + override fun execute(sender: CommandSender, args: Array) { + val (_, targetName, amt) = args + + val target = Bukkit.getOfflinePlayer(targetName) ?: run { + sender.err("target_not_found", "player" to targetName) + return + } + + val amount = (amt.toIntOrNull() ?: 0) + if (amount < 0) { + sender.err("amount_below_zero") + return + } + val tokens = getTokens(target.uniqueId.toString()) + setTokens(target.uuid, tokens + amount) + if (sender is Player) sender.success("${target.name} now has ${tokens + amount} tokens.") + } +} \ No newline at end of file diff --git a/src/main/kotlin/pw/hamzantal/vagueenchants/commands/Cmd.kt b/src/main/kotlin/pw/hamzantal/vagueenchants/commands/Cmd.kt new file mode 100644 index 0000000..3f509ca --- /dev/null +++ b/src/main/kotlin/pw/hamzantal/vagueenchants/commands/Cmd.kt @@ -0,0 +1,16 @@ +package pw.hamzantal.vagueenchants.commands + +import org.bukkit.command.CommandSender + +interface Cmd { + val firstArg: String + val usage: String + val minArgs: Int + val description: String + + val requirePermission: Boolean + val permission: String + val requirePlayer: Boolean + + fun execute(sender: CommandSender, args: Array) +} \ No newline at end of file diff --git a/src/main/kotlin/pw/hamzantal/vagueenchants/commands/Connect.kt b/src/main/kotlin/pw/hamzantal/vagueenchants/commands/Connect.kt new file mode 100644 index 0000000..8417e7e --- /dev/null +++ b/src/main/kotlin/pw/hamzantal/vagueenchants/commands/Connect.kt @@ -0,0 +1,24 @@ +package pw.hamzantal.vagueenchants.commands + +import pw.hamzantal.vagueenchants.conn +import hazae41.minecraft.kutils.bukkit.msg +import org.bukkit.command.CommandSender + +class Connect : Cmd { + override val firstArg = "connect" + override val usage = "/ve connect" + override val minArgs = 1 + override val description = "&7Connect to mysql" + + override val requirePermission = true + override val permission = "ve.admin" + override val requirePlayer = false + + override fun execute(sender: CommandSender, args: Array) { + if (conn != null) { + sender.msg("&cConnection has been successfully established") + } else { + sender.msg("&aThe connection is not established") + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/pw/hamzantal/vagueenchants/commands/DelEnch.kt b/src/main/kotlin/pw/hamzantal/vagueenchants/commands/DelEnch.kt new file mode 100644 index 0000000..14f3cdd --- /dev/null +++ b/src/main/kotlin/pw/hamzantal/vagueenchants/commands/DelEnch.kt @@ -0,0 +1,42 @@ +package pw.hamzantal.vagueenchants.commands + +import org.bukkit.Bukkit +import org.bukkit.Material +import org.bukkit.command.CommandSender +import pw.hamzantal.vagueenchants.enchantments.CustomEnchant + +class DelEnch : Cmd { + + override val firstArg = "delench" + override val usage = "/ve delench [player] [enchantment]" + override val minArgs = 3 + override val description = "&7Remove an enchantment to the tool you are holding for target player" + + override val requirePermission = true + override val permission = "ve.delench" + override val requirePlayer = false + + override fun execute(sender: CommandSender, args: Array) { + val (_, targetName, enchName) = args + + val target = Bukkit.getPlayer(targetName) ?: run { + sender.err("target_not_found", "player" to targetName) + return + } + val ench = enchName.ench(sender) ?: return + + val item = target.inventory.itemInMainHand + if (item == null || item.type == Material.AIR) { + sender.err("no_item_held") + return + } + + val success = if (ench is CustomEnchant) !ench.customEnchant(item, -1) + else item.enchantments[ench]?: 0 == item.removeEnchantment(ench) + + if (success) { + sender.success("&aEnchantment Successfully removed") + target.success("delench_receiver", "ench" to ench.name.toLowerCase()) + } else sender.err("general_error") + } +} \ No newline at end of file diff --git a/src/main/kotlin/pw/hamzantal/vagueenchants/commands/DelTokens.kt b/src/main/kotlin/pw/hamzantal/vagueenchants/commands/DelTokens.kt new file mode 100644 index 0000000..a51c749 --- /dev/null +++ b/src/main/kotlin/pw/hamzantal/vagueenchants/commands/DelTokens.kt @@ -0,0 +1,38 @@ +package pw.hamzantal.vagueenchants.commands + +import org.bukkit.Bukkit +import org.bukkit.command.CommandSender +import pw.hamzantal.vagueenchants.getTokens +import pw.hamzantal.vagueenchants.setTokens +import pw.hamzantal.vagueenchants.uuid + +class DelTokens : Cmd { + override val firstArg = "deltokens" + override val usage = "/ve deltokens [player] [amount]" + override val minArgs = 3 + override val description = "&7Remove tokens from a player" + + override val requirePermission = true + override val permission = "ve.admin" + override val requirePlayer = false + + override fun execute(sender: CommandSender, args: Array) { + val (_, targetName, amt) = args + + val target = Bukkit.getOfflinePlayer(targetName) + + val amount = (amt.toLongOrNull() ?: 0) + if (amount < 0) { + sender.err("amount_below_zero") + return + } + val tokens = getTokens(target.uuid) + if (tokens - amount < 0) setTokens(target.uuid, 0) + else setTokens(target.uuid, tokens - amount) + + val newTokens = getTokens(target.uuid) + sender.success("&a${target.name} now has $newTokens tokens.") + if (target.isOnline) + target.player.success("deltoken_receiver") + } +} \ No newline at end of file diff --git a/src/main/kotlin/pw/hamzantal/vagueenchants/commands/Help.kt b/src/main/kotlin/pw/hamzantal/vagueenchants/commands/Help.kt new file mode 100644 index 0000000..4b5ece1 --- /dev/null +++ b/src/main/kotlin/pw/hamzantal/vagueenchants/commands/Help.kt @@ -0,0 +1,34 @@ +package pw.hamzantal.vagueenchants.commands + +import hazae41.minecraft.kutils.bukkit.msg +import org.bukkit.command.CommandSender +import pw.hamzantal.vagueenchants.Msgs +import pw.hamzantal.vagueenchants.subCommands + +class Help : Cmd { + override val firstArg = "help" + override val usage = "/ve help " + override val minArgs = 2 + override val description = "&7Show this help menu" + + override val requirePlayer = false + override val requirePermission = false + override val permission = "" + + override fun execute(sender: CommandSender, args: Array) { + sender.msg(Msgs.config.getString("plugin_header").c) + sender.msg("&c&m------------------") + subCommands + .sortedBy { it.firstArg } + .filter { if (it.requirePermission) sender.hasPermission(it.permission) else true } + .filter { if (args.size >= 2) it.firstArg.contains(args.component2(), ignoreCase = true) else true } + .forEach { + sender.msg("&8Command name: &7${it.firstArg}") + sender.msg("&8Command usage: &7${it.usage}" + if (it.requirePlayer) " (Player only)" else "") + sender.msg("&8Command description: &7${it.description}") + sender.msg("&c&m------------------") + } + sender.msg("&7This plugin was created by hhhapz") + } + +} \ No newline at end of file diff --git a/src/main/kotlin/pw/hamzantal/vagueenchants/commands/Info.kt b/src/main/kotlin/pw/hamzantal/vagueenchants/commands/Info.kt new file mode 100644 index 0000000..bd98557 --- /dev/null +++ b/src/main/kotlin/pw/hamzantal/vagueenchants/commands/Info.kt @@ -0,0 +1,52 @@ +package pw.hamzantal.vagueenchants.commands + +import hazae41.minecraft.kutils.bukkit.msg +import org.bukkit.command.CommandSender +import org.bukkit.entity.Player +import pw.hamzantal.vagueenchants.enchantments.CustomEnchant + +class Info : Cmd { + + override val firstArg = "info" + override val usage = "/ve info " + override val minArgs = 1 + override val description = "&7See enchantment info for the current item you are holding" + + override val requirePermission = false + override val permission = "" + override val requirePlayer = true + + override fun execute(sender: CommandSender, args: Array) { + val p = sender as Player + + + val item = p.inventory.itemInMainHand ?: run { + p.err("You are not holding any item. Please hold the item you would like to inspect.") + return + } + + val enchs = item.enchantments.toMutableMap() + if (enchs.isEmpty()) { + p.err("Your item does not have any enchantments.") + return + } + + if (args.size > 1) { + val ench = args.component2().ench(p) ?: return + val level = enchs[ench] ?: run { + p.err("That enchantment is not currently applied on your tool.") + return + } + enchs.clear() + enchs[ench] = level + } + + p.msg("&7&m------------------") + enchs.forEach { (e, l) -> + p.msg("&7Name: ${e.name}") + if (e is CustomEnchant) e.inspect(p, l) + else p.msg("&7Current level: $l") + p.msg("&7&m------------------") + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/pw/hamzantal/vagueenchants/commands/Refund.kt b/src/main/kotlin/pw/hamzantal/vagueenchants/commands/Refund.kt new file mode 100644 index 0000000..56bffb1 --- /dev/null +++ b/src/main/kotlin/pw/hamzantal/vagueenchants/commands/Refund.kt @@ -0,0 +1,55 @@ +package pw.hamzantal.vagueenchants.commands + +import org.bukkit.Bukkit +import org.bukkit.Material +import org.bukkit.command.CommandSender +import pw.hamzantal.vagueenchants.* +import pw.hamzantal.vagueenchants.enchantments.CustomEnchant +import pw.hamzantal.vagueenchants.enchantments.OmniTool + +class Refund : Cmd { + + override val firstArg = "refund" + override val usage = "/ve refund [player] [enchantment]" + override val minArgs = 3 + override val description = "&7Refund an enchantment for the tool a player is holding." + + override val requirePermission = true + override val permission = "ve.admin" + override val requirePlayer = false + + override fun execute(sender: CommandSender, args: Array) { + val (_, targetName, enchName) = args + + val target = Bukkit.getPlayer(targetName) ?: run { + sender.err("target_not_found", "player" to targetName) + return + } + val ench = enchName.ench(sender) ?: return + + val item = target.inventory.itemInMainHand + if (item == null || item.type == Material.AIR) { + target.err("no_item_held") + return + } + + val current = item.enchantments[ench] ?: run { + target.err("no_enchants") + return + } + + val refund = ench.refund(current).toLong() + + val tokens = getTokens(target.uuid) + + val success = if (ench is CustomEnchant) !ench.customEnchant(item, 0) + else item.removeEnchantment(ench) == 0 + + if (ench is OmniTool) target.inventory.itemInMainHand = item.unbreakable(true) + + if (success) { + setTokens(target.uuid, tokens + refund) + target.success("refund_receiver") + } else sender.err("general_error") + } +} \ No newline at end of file diff --git a/src/main/kotlin/pw/hamzantal/vagueenchants/commands/Repair.kt b/src/main/kotlin/pw/hamzantal/vagueenchants/commands/Repair.kt new file mode 100644 index 0000000..2306c97 --- /dev/null +++ b/src/main/kotlin/pw/hamzantal/vagueenchants/commands/Repair.kt @@ -0,0 +1,52 @@ +package pw.hamzantal.vagueenchants.commands + +import hazae41.minecraft.kutils.bukkit.msg +import org.bukkit.Bukkit +import org.bukkit.Material +import org.bukkit.command.CommandSender +import pw.hamzantal.vagueenchants.* +import java.math.BigDecimal +import kotlin.math.max + +class Repair : Cmd { + + override val firstArg = "repair" + override val usage = "/ve repair [player]" + override val minArgs = 2 + override val description = "&7Repair a player's tool." + + override val requirePermission = true + override val permission = "ve.repair" + override val requirePlayer = false + + override fun execute(sender: CommandSender, args: Array) { + val (_, targetName) = args + + val target = Bukkit.getPlayer(targetName) ?: run { + sender.err("target_not_found", "player" to targetName) + return + } + val item = target.inventory.itemInMainHand + if (item == null || item.type == Material.AIR) { + target.err("no_item_held") + return + } + + val current = item.enchantments + val rawCost = current.toList() + .sumByBigDecimal { (k, v) -> k.fullCost(v) } + .multiply(BigDecimal(Config.repairValue)).round + .toLong() + val cost = max(Config.minRepair, rawCost) + + val tokens = getTokens(target.uuid) + if (tokens < cost) { + target.err("repair_not_enough", "token" to "$cost") + return + } + setTokens(target.uuid, tokens - cost) + + target.success("repair_receiver") + item.durability = 0 + } +} \ No newline at end of file diff --git a/src/main/kotlin/pw/hamzantal/vagueenchants/commands/SetTokens.kt b/src/main/kotlin/pw/hamzantal/vagueenchants/commands/SetTokens.kt new file mode 100644 index 0000000..f3bab72 --- /dev/null +++ b/src/main/kotlin/pw/hamzantal/vagueenchants/commands/SetTokens.kt @@ -0,0 +1,36 @@ +package pw.hamzantal.vagueenchants.commands + +import org.bukkit.Bukkit +import org.bukkit.command.CommandSender +import pw.hamzantal.vagueenchants.setTokens +import pw.hamzantal.vagueenchants.uuid + +class SetTokens : Cmd { + override val firstArg = "settokens" + override val usage = "/ve settokens [player] [amount]" + override val minArgs = 3 + override val description = "&7Set the tokens a player has" + + override val requirePermission = true + override val permission = "ve.admin" + override val requirePlayer = false + + override fun execute(sender: CommandSender, args: Array) { + val (_, targetName, amt) = args + + val target = Bukkit.getOfflinePlayer(targetName) ?: run { + sender.err("target_not_found", "player" to targetName) + return + } + + val amount = (amt.toLongOrNull() ?: 0) + if (amount < 0) { + sender.err("amount_below_zero") + return + } + setTokens(target.uuid, amount) + sender.success("${target.name} now has $amount tokens.") + if (target.isOnline) + target.player.success("settoken_receiver", "token" to amount.toString()) + } +} \ No newline at end of file diff --git a/src/main/kotlin/pw/hamzantal/vagueenchants/commands/TokenCommand.kt b/src/main/kotlin/pw/hamzantal/vagueenchants/commands/TokenCommand.kt new file mode 100644 index 0000000..9fb2f74 --- /dev/null +++ b/src/main/kotlin/pw/hamzantal/vagueenchants/commands/TokenCommand.kt @@ -0,0 +1,77 @@ +package pw.hamzantal.vagueenchants.commands + +import com.okkero.skedule.SynchronizationContext +import com.okkero.skedule.schedule +import org.bukkit.Bukkit +import org.bukkit.command.CommandSender +import org.bukkit.entity.Player +import pw.hamzantal.vagueenchants.VagueEnchants +import pw.hamzantal.vagueenchants.getTokens +import pw.hamzantal.vagueenchants.setTokens +import pw.hamzantal.vagueenchants.uuid + +fun tokenCommand(s: CommandSender, arg: Array) { + if (arg.isEmpty()) { + if (s !is Player) { + s.err("require_player") + return + } + Bukkit.getScheduler().schedule(VagueEnchants.pl, initialContext = SynchronizationContext.ASYNC) { + val tokens = getTokens(s.uuid) + s.general("tokens", "token" to "$tokens") + } + return + } + + if (arg.component1() == "give") { + if (s !is Player) { + s.err("require_player") + return + } + giveCommand(s, arg) + return + } + + val (targetName) = arg + val target = Bukkit.getOfflinePlayer(targetName) + + Bukkit.getScheduler().schedule(VagueEnchants.pl, initialContext = SynchronizationContext.ASYNC) { + val tokens = getTokens(target.uuid) + s.general("tokens_other", "player" to targetName, "token" to "$tokens") + } +} + +fun giveCommand(s: Player, arg: Array) { + if (arg.size != 3) { + s.general("/token give [player] [amount]") + return + } + + val (_, targetName, amt) = arg + val target = Bukkit.getPlayer(targetName) ?: run { + s.err("target_not_found", "player" to targetName) + return + } + val amount = (amt.toIntOrNull() ?: 0) + if (amount < 0) { + s.err("amount_below_zero") + return + } + val tokens = getTokens(s.uuid) + val targetTokens = getTokens(target.uuid) + if (tokens < amount) { + s.err("not_enough_tokens") + return + } + if (tokens < 0L) { + s.err("amount_below_zero") + return + } + + setTokens(s.uuid, tokens - amount) + setTokens(target.uuid, targetTokens + amount) + s.general("tokens_give_sender", "token" to "${tokens - amount}", "player" to targetName) + if (target.isOnline) + target.general("tokens_give_receiver", "token" to "${tokens + amount}", "player" to s.name) + return +} \ No newline at end of file diff --git a/src/main/kotlin/pw/hamzantal/vagueenchants/commands/Upgrade.kt b/src/main/kotlin/pw/hamzantal/vagueenchants/commands/Upgrade.kt new file mode 100644 index 0000000..5a55f04 --- /dev/null +++ b/src/main/kotlin/pw/hamzantal/vagueenchants/commands/Upgrade.kt @@ -0,0 +1,79 @@ +package pw.hamzantal.vagueenchants.commands + +import org.bukkit.Bukkit +import org.bukkit.Material +import org.bukkit.command.CommandSender +import pw.hamzantal.vagueenchants.* +import pw.hamzantal.vagueenchants.enchantments.CustomEnchant +import pw.hamzantal.vagueenchants.enchantments.OmniTool +import kotlin.math.min + +class Upgrade : Cmd { + + override val firstArg = "upgrade" + override val usage = "/ve upgrade [player] [enchantment] " + override val minArgs = 3 + override val description = "&7Upgrade the player's level for an enchantment." + + override val requirePermission = true + override val permission = "ve.admin" + override val requirePlayer = false + + override fun execute(sender: CommandSender, args: Array) { + val (_, targetName, enchName) = args + + val target = Bukkit.getPlayer(targetName) ?: run { + sender.err("target_not_found", "player" to targetName) + return + } + val ench = enchName.ench(sender) ?: return + + val level = if (args.size == 4) args.component4().toIntOrNull() ?: run { + sender.err("The value ${args.component4()} was not parsed as a number. Using 1 instead.") + 1 + } else 1 + if (level < 0) { + target.err("level_below_zero") + return + } + + val item = target.inventory.itemInMainHand + if (item == null || item.type == Material.AIR) { + target.err("no_item_held") + return + } + + val current = item.enchantments[ench] ?: 0 + val config = ench.conf() ?: run { + target.err("upgrade_illegal_enchantment") + return + } + if (current >= config.max) { + target.err("upgrade_max_level") + return + } + + val newLevel = min(config.max, current + level) + + val cost = ((current + 1)..(newLevel)).toList() + .map { config.cost.x(it) } + .sumBy { it.toInt() } + + val tokens = getTokens(target.uuid) + if (tokens < cost) { + target.err("upgrade_not_enough", "token" to "$cost") + return + } + + setTokens(target.uuid, tokens - cost) + + val success = if (ench is CustomEnchant) ench.customEnchant(item, newLevel) + else item.addUnsafeEnchantment(ench, newLevel) == Unit + + if (ench is OmniTool) target.inventory.itemInMainHand = item.unbreakable(true) + + if (success) { + target.success("upgrade_receiver", "level" to "${newLevel - current}", "token" to "$cost") + } else sender.err("general_error") + } +} \ No newline at end of file diff --git a/src/main/kotlin/pw/hamzantal/vagueenchants/commands/Util.kt b/src/main/kotlin/pw/hamzantal/vagueenchants/commands/Util.kt new file mode 100644 index 0000000..a239e71 --- /dev/null +++ b/src/main/kotlin/pw/hamzantal/vagueenchants/commands/Util.kt @@ -0,0 +1,31 @@ +package pw.hamzantal.vagueenchants.commands + +import hazae41.minecraft.kutils.bukkit.msg +import org.bukkit.ChatColor +import org.bukkit.command.CommandSender +import org.bukkit.enchantments.Enchantment +import pw.hamzantal.vagueenchants.Msgs + +val String.c + get() = ChatColor.translateAlternateColorCodes('&', this) + +fun String.ench(p: CommandSender? = null): Enchantment? = Enchantment.getByName(toUpperCase()) ?: run { + if (toUpperCase() == "EFFICIENCY") return Enchantment.DIG_SPEED + if (toUpperCase() == "FORTUNE") return Enchantment.LOOT_BONUS_BLOCKS + + p?.err("Enchantment $this was not found.") + null +} + +fun CommandSender.err(msg: String, vararg placeholder: Pair) { + msg(Msgs.error(msg, *placeholder)) +} + +fun CommandSender.general(msg: String, vararg placeholder: Pair) { + msg(Msgs.general(msg, *placeholder)) +} + +fun CommandSender.success(msg: String, vararg placeholder: Pair) { + msg(Msgs.success(msg, *placeholder)) +} + diff --git a/src/main/kotlin/pw/hamzantal/vagueenchants/commands/VECompleter.kt b/src/main/kotlin/pw/hamzantal/vagueenchants/commands/VECompleter.kt new file mode 100644 index 0000000..bf7ab73 --- /dev/null +++ b/src/main/kotlin/pw/hamzantal/vagueenchants/commands/VECompleter.kt @@ -0,0 +1,41 @@ +package pw.hamzantal.vagueenchants.commands + +import org.bukkit.Bukkit +import org.bukkit.command.Command +import org.bukkit.command.CommandSender +import org.bukkit.command.TabCompleter +import org.bukkit.enchantments.Enchantment +import pw.hamzantal.vagueenchants.subCommands + +class VECompleter : TabCompleter { + override fun onTabComplete( + sender: CommandSender, + command: Command, + alias: String, + args: Array + ): MutableList { + if (command.name != "ve") return mutableListOf() + + if (args.size == 1) return subCommands.map { it.firstArg } has args.first() + + val sbcmd = subCommands.firstOrNull { it.firstArg == args.first() } ?: return mutableListOf() + if ((sbcmd.usage.split(" ").size - 1) < args.size) return mutableListOf() + val type = sbcmd.usage.split(" ")[args.size] + + if (type.contains("player")) return Bukkit.getOnlinePlayers().map { it.name } has args.last() + if (type.contains("command")) return subCommands.map { it.firstArg } has args.last() + if (type.contains("enchantment")) return (Enchantment.values().filter { it.id in 400..500 }.map { it.name.toLowerCase() } + .toMutableList().also { it.addAll(listOf("fortune", "efficiency")) } has args.last()) + if (type.contains("level")) return mutableListOf("1") + + return mutableListOf() + } +} + +infix fun Iterable.has(me: String): MutableList = + listOf( + sorted().filter { it.startsWith(me, ignoreCase = true) }, + sorted().filter { it.contains(me, ignoreCase = true) }) + .flatten() + .distinct() + .toMutableList() \ No newline at end of file diff --git a/src/main/kotlin/pw/hamzantal/vagueenchants/enchantments/AutoSell.kt b/src/main/kotlin/pw/hamzantal/vagueenchants/enchantments/AutoSell.kt new file mode 100644 index 0000000..8924481 --- /dev/null +++ b/src/main/kotlin/pw/hamzantal/vagueenchants/enchantments/AutoSell.kt @@ -0,0 +1,57 @@ +package pw.hamzantal.vagueenchants.enchantments + +import hazae41.minecraft.kutils.bukkit.listen +import hazae41.minecraft.kutils.bukkit.msg +import org.bukkit.Bukkit +import org.bukkit.entity.Player +import org.bukkit.event.Listener +import org.bukkit.event.block.BlockBreakEvent +import pw.hamzantal.vagueenchants.Config +import pw.hamzantal.vagueenchants.VagueEnchants +import pw.hamzantal.vagueenchants.commands.c +import pw.hamzantal.vagueenchants.papi +import pw.hamzantal.vagueenchants.x + +class AutoSell(id: Int) : CustomEnchant(id, Config.autoSell, "AUTOSELL"), Listener { + + init { + VagueEnchants.enchants += this + val pl = VagueEnchants.pl + pl.registerEnchantment(this) + pl.listen(callback = this::onBreak) + } + + private val cooldowns = hashMapOf() + + private fun onBreak(e: BlockBreakEvent) { + val p = e.player + if (this !in p.inventory.itemInMainHand?.enchantments ?: mapOf()) return + if (p in cooldowns && cooldowns[p]!! > System.currentTimeMillis()) return + val level = p.inventory.itemInMainHand.enchantments[this]!! + cooldowns[p] = System.currentTimeMillis() + + 1000 * config.cooldown.x(level).toLong() + + if (e.player.inventory.firstEmpty() == -1) + Bukkit.dispatchCommand(e.player, config.command.papi(p)) + } + + + override fun inspect(p: Player, level: Int) { + val cost = config.cost.x(level + 1) + val cd = config.cooldown.x(level) + p.msg("&7Description: ${config.description}") + p.msg("&7Current level: $level") + p.msg("&7Maximum level: ${config.max}") + + if (level < maxLevel) p.msg("&7Next level cost: $cost") + else p.msg("&7Level maxed") + + p.msg("&7Cooldown between Auto Sell: $cd") + if (p in cooldowns && cooldowns[p]!! > System.currentTimeMillis()) + p.msg("&7Cooldown remaining: ${(cooldowns[p]!! - System.currentTimeMillis()) / 1000} seconds") + } + + override fun loreString(level: Int): String { + return "&7AutoSell ${loreLevel(level)}".c + } +} \ No newline at end of file diff --git a/src/main/kotlin/pw/hamzantal/vagueenchants/enchantments/CustomEnchant.kt b/src/main/kotlin/pw/hamzantal/vagueenchants/enchantments/CustomEnchant.kt new file mode 100644 index 0000000..81d54cd --- /dev/null +++ b/src/main/kotlin/pw/hamzantal/vagueenchants/enchantments/CustomEnchant.kt @@ -0,0 +1,77 @@ +package pw.hamzantal.vagueenchants.enchantments + + +import com.google.common.collect.Maps +import org.bukkit.enchantments.Enchantment +import org.bukkit.enchantments.EnchantmentTarget +import org.bukkit.entity.Player +import org.bukkit.inventory.ItemStack +import pw.hamzantal.vagueenchants.* +import kotlin.IllegalStateException as ISE + +abstract class CustomEnchant(id: Int, val config: EnchantmentInfo, private val theName: String) : Enchantment(id) { + + fun customEnchant(item: ItemStack, newLevel: Int = 1): Boolean { + val lor = if (item.itemMeta.hasLore()) item.itemMeta.lore else mutableListOf() + val oldLevel = if (this in item.enchantments) item.enchantments[this]!! else -1 + val index = lor.indexOf(loreString(oldLevel)) + + if (newLevel <= 0) { + if (this in item.enchantments) { + item.itemMeta = item.itemMeta.apply { + lore = lor.apply { removeAt(index) } + removeEnchant(this@CustomEnchant) + } + if (index == -1) throw ISE("Has $name enchantment without enchantment lore.") + } + return false + } + + if (this in item.enchantments) { + item.removeEnchantment(this) + if (index == -1) throw ISE("Has $name enchantment without enchantment lore.") + lor[index] = loreString(newLevel) + } else lor.add(loreString(newLevel)) + + item.itemMeta = item.itemMeta.also { it.lore = lor } + item.addUnsafeEnchantment(this, newLevel) + + return newLevel > 0 + } + + private val map = Maps.newTreeMap().apply { + this[1000] = "M" + this[900] = "CM" + this[500] = "D" + this[400] = "CD" + this[100] = "C" + this[90] = "XC" + this[50] = "L" + this[40] = "XL" + this[10] = "X" + this[9] = "IX" + this[5] = "V" + this[4] = "IV" + this[1] = "I" + } + + fun loreLevel(level: Int): String { + + val l = map.floorKey(level) ?: return "0" + return if (level == l) map[level]!! else map[l].toString() + loreLevel(level - l) + } + + abstract fun inspect(p: Player, level: Int) + abstract fun loreString(level: Int): String + + override fun isTreasure() = false + override fun conflictsWith(p0: Enchantment) = false + override fun getStartLevel() = 1 + override fun getMaxLevel() = config.max + override fun getName() = theName + override fun canEnchantItem(i: ItemStack) = i.type in listOf( + ToolUtils.pickaxes, ToolUtils.axes, ToolUtils.shovels + ).flatten() + + override fun getItemTarget() = EnchantmentTarget.TOOL +} \ No newline at end of file diff --git a/src/main/kotlin/pw/hamzantal/vagueenchants/enchantments/Explosive.kt b/src/main/kotlin/pw/hamzantal/vagueenchants/enchantments/Explosive.kt new file mode 100644 index 0000000..5d59655 --- /dev/null +++ b/src/main/kotlin/pw/hamzantal/vagueenchants/enchantments/Explosive.kt @@ -0,0 +1,101 @@ +package pw.hamzantal.vagueenchants.enchantments + +import hazae41.minecraft.kutils.bukkit.listen +import hazae41.minecraft.kutils.bukkit.msg +import net.minecraft.server.v1_10_R1.BlockPosition +import org.bukkit.Location +import org.bukkit.Material +import org.bukkit.Particle +import org.bukkit.Sound +import org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer +import org.bukkit.entity.Player +import org.bukkit.event.block.BlockBreakEvent +import pw.hamzantal.vagueenchants.* +import pw.hamzantal.vagueenchants.commands.c +import java.math.BigDecimal + + +class Explosive(id: Int) : CustomEnchant(id, Config.explosive, "EXPLOSIVE") { + + init { + VagueEnchants.enchants += this + val pl = VagueEnchants.pl + pl.registerEnchantment(this) + pl.listen(ignoreCancelled = true, callback = this::onBreak) + } + + private val breaking = mutableListOf() + private val cooldowns = hashMapOf() + + private fun onBreak(e: BlockBreakEvent) { + val p = e.player + if (this !in p.inventory.itemInMainHand?.enchantments ?: mapOf() || p in breaking) return + if (p in cooldowns && cooldowns[p]!! > System.currentTimeMillis()) return + + val block = e.block + val loc = block.location + val item = p.inventory.itemInMainHand + val level = p.inventory.itemInMainHand.enchantments[this]!! + + loc.validRegion(p)?: return + cooldowns[p] = System.currentTimeMillis() + + 1000 * config.cooldown.x(level).toLong() + + breaking += p + val pim = (p as CraftPlayer).handle.playerInteractManager + + loc.sphericalBlocks(config.blocks.x(level)) + .filter { it.block.type != Material.AIR && it.canMine(e.player) } + .filter { it.validRegion(p) != null} + .forEach { + val nmsData = pim.world.getType(BlockPosition(it.x, it.y, it.z)) + val xp = nmsData.block.getExpDrop(pim.world, nmsData, item.enchantments[LOOT_BONUS_BLOCKS] ?: 0) + p.giveExp(xp) + + ToolUtils.drops(it.block, item).forEach { i -> p.inventory.addItem(i) } + + it.block.type = Material.AIR + } + block.world.spawnParticle(Particle.EXPLOSION_HUGE, block.location, 1) + p.playSound(loc, Sound.ENTITY_GENERIC_EXPLODE, 5F, 5F) + breaking -= p + } + + override fun inspect(p: Player, level: Int) { + val cost = config.cost.x(level + 1) + val cd = config.cooldown.x(level) + val blocks = config.blocks.x(level).toInt() + + p.msg("&7Description: ${config.description}") + p.msg("&7Current level: $level") + p.msg("&7Maximum level: $maxLevel") + + if (level < maxLevel) p.msg("&7Next level cost: $cost") + else p.msg("&7Level maxed") + + p.msg("&7Cooldown between explosions: $cd") + if (p in cooldowns && cooldowns[p]!! > System.currentTimeMillis()) + p.msg("&7Cooldown remaining: ${(cooldowns[p]!! - System.currentTimeMillis()) / 1000} seconds") + + p.msg("&7Explosion radius: $blocks") + } + + override fun loreString(level: Int): String { + return "&7Explosive ${loreLevel(level)}".c + } + + private fun Location.sphericalBlocks(r: BigDecimal): MutableList { + val radius = r.toInt() + val locs = mutableListOf() + for (a in (blockX - radius)..(blockX + radius)) + for (b in (blockY - radius)..(blockY + radius)) + for (c in (blockZ - radius)..(blockZ + radius)) { + val d = (blockX - a) * (blockX - a) + (blockY - b) * (blockY - b) + (blockZ - c) * (blockZ - c) + if (d < radius) { + locs += Location(world, a.toDouble(), b.toDouble(), c.toDouble()) + } + } + return locs + } + +} diff --git a/src/main/kotlin/pw/hamzantal/vagueenchants/enchantments/Haste.kt b/src/main/kotlin/pw/hamzantal/vagueenchants/enchantments/Haste.kt new file mode 100644 index 0000000..3f1ec54 --- /dev/null +++ b/src/main/kotlin/pw/hamzantal/vagueenchants/enchantments/Haste.kt @@ -0,0 +1,62 @@ +package pw.hamzantal.vagueenchants.enchantments + +import hazae41.minecraft.kutils.bukkit.listen +import hazae41.minecraft.kutils.bukkit.msg +import hazae41.minecraft.kutils.bukkit.schedule +import org.bukkit.Bukkit +import org.bukkit.enchantments.Enchantment +import org.bukkit.enchantments.EnchantmentTarget +import org.bukkit.entity.Player +import org.bukkit.event.Listener +import org.bukkit.event.player.PlayerItemHeldEvent +import org.bukkit.inventory.ItemStack +import org.bukkit.potion.PotionEffect +import org.bukkit.potion.PotionEffectType.FAST_DIGGING +import pw.hamzantal.vagueenchants.Config +import pw.hamzantal.vagueenchants.ToolUtils +import pw.hamzantal.vagueenchants.VagueEnchants +import pw.hamzantal.vagueenchants.commands.c +import pw.hamzantal.vagueenchants.x + +class Haste(id: Int) : CustomEnchant(id, Config.haste, "HASTE"), Listener { + + init { + VagueEnchants.enchants += this + val pl = VagueEnchants.pl + pl.registerEnchantment(this) + pl.listen(callback = this::onItemHeld) + pl.schedule(delay = 2, period = 2) { + Bukkit.getOnlinePlayers().forEach { p -> + val enchs = p.inventory.itemInMainHand?.enchantments ?: mapOf() + val effect = PotionEffect(FAST_DIGGING, 50, (enchs[this@Haste] ?: 1) - 1) + if (this@Haste in enchs) { + p.addPotionEffect(effect, true) + } + } + } + } + + private fun onItemHeld(e: PlayerItemHeldEvent) { + val p = e.player + val now = p.inventory.getItem(e.newSlot) + val before = p.inventory.getItem(e.previousSlot) + if (now != null && this in now.enchantments) + p.addPotionEffect(PotionEffect(FAST_DIGGING, 50, now.enchantments[this]!! - 1)) + else if (before != null && this in before.enchantments) p.removePotionEffect(FAST_DIGGING) + } + + override fun inspect(p: Player, level: Int) { + val cost = config.cost.x(level) + p.msg("&7Description: ${config.description}") + p.msg("&7Haste level: Haste ${loreLevel(level)}") + p.msg("&7Current level: $level") + p.msg("&7Maximum level: ${config.max}") + if (level < config.max) p.msg("&7Next level cost: $cost") + else p.msg("&7Level maxed") + } + + override fun loreString(level: Int): String { + return "&7Haste ${loreLevel(level)}".c + } + +} \ No newline at end of file diff --git a/src/main/kotlin/pw/hamzantal/vagueenchants/enchantments/KeyMine.kt b/src/main/kotlin/pw/hamzantal/vagueenchants/enchantments/KeyMine.kt new file mode 100644 index 0000000..6b55297 --- /dev/null +++ b/src/main/kotlin/pw/hamzantal/vagueenchants/enchantments/KeyMine.kt @@ -0,0 +1,61 @@ +package pw.hamzantal.vagueenchants.enchantments + +import hazae41.minecraft.kutils.bukkit.listen +import hazae41.minecraft.kutils.bukkit.msg +import org.bukkit.Bukkit +import org.bukkit.enchantments.Enchantment +import org.bukkit.enchantments.EnchantmentTarget +import org.bukkit.entity.Player +import org.bukkit.event.Listener +import org.bukkit.event.block.BlockBreakEvent +import org.bukkit.inventory.ItemStack +import pw.hamzantal.vagueenchants.* +import pw.hamzantal.vagueenchants.commands.c +import java.math.BigDecimal +import java.util.* + +class KeyMine(id: Int) : CustomEnchant(id, Config.keyMine, "KEYMINE"), Listener { + + init { + VagueEnchants.enchants += this + val pl = VagueEnchants.pl + pl.listen(callback = this::onBreak) + pl.registerEnchantment(this) + } + + private val r = Random() + private val cachedProb = hashMapOf>() + + private fun onBreak(e: BlockBreakEvent) { + val p = e.player + if (this !in p.inventory.itemInMainHand?.enchantments ?: mapOf()) return + val level = p.inventory.itemInMainHand.enchantments[this]!! + if (p !in cachedProb || cachedProb[p]!!.second > System.currentTimeMillis()) + cachedProb[p] = config.chance.x(level, scale = false) to System.currentTimeMillis() + 30 * 1000 + + val chance = cachedProb[p]!!.first + val rdm = r.nextDouble() + + if (!e.block.location.canMine(p)) return + if (chance.toDouble() <= rdm) return + + val command = config.keys.shuffled().first().papi(p) + Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command) + } + + override fun inspect(p: Player, level: Int) { + val cost = config.cost.x(level + 1) + val chance = config.chance.x(level, scale = false) + p.msg("&7Description: ${config.description}") + p.msg("&7Current level: $level") + p.msg("&7Maximum level: ${config.max}") + if (level < maxLevel) p.msg("&7Next level cost: $cost") + else p.msg("&7Level maxed") + + p.msg("&7Chance to receive a key: $chance") + } + + override fun loreString(level: Int): String { + return "&7Key Mine ${loreLevel(level)}".c + } +} \ No newline at end of file diff --git a/src/main/kotlin/pw/hamzantal/vagueenchants/enchantments/OmniTool.kt b/src/main/kotlin/pw/hamzantal/vagueenchants/enchantments/OmniTool.kt new file mode 100644 index 0000000..1d9aa74 --- /dev/null +++ b/src/main/kotlin/pw/hamzantal/vagueenchants/enchantments/OmniTool.kt @@ -0,0 +1,52 @@ +package pw.hamzantal.vagueenchants.enchantments + +import hazae41.minecraft.kutils.bukkit.listen +import hazae41.minecraft.kutils.bukkit.msg +import org.bukkit.Material.getMaterial +import org.bukkit.entity.Player +import org.bukkit.event.Listener +import org.bukkit.event.block.Action +import org.bukkit.event.player.PlayerInteractEvent +import org.bukkit.inventory.ItemStack +import pw.hamzantal.vagueenchants.* +import pw.hamzantal.vagueenchants.commands.c + +class OmniTool(id: Int) : CustomEnchant(id, Config.omni, "OMNITOOL"), Listener { + + init { + VagueEnchants.enchants += this + val pl = VagueEnchants.pl + pl.listen(callback = this::onInteract) + pl.registerEnchantment(this) + } + + private fun onInteract(e: PlayerInteractEvent) { + if (e.action != Action.LEFT_CLICK_BLOCK || e.item == null || this !in e.item.enchantments) return + val item = e.item.tooltype + val block = e.clickedBlock.type + + if (block in item.itemList) return + when (block) { + in ToolUtils.pickaxeItems -> transform(e.item, ToolType.PICKAXE) + in ToolUtils.axeItems -> transform(e.item, ToolType.AXE) + in ToolUtils.shovelItems -> transform(e.item, ToolType.SHOVEL) + else -> return + } + } + + private fun transform(current: ItemStack, type: ToolType) { + val strength = current.type.toString().split("_").first() + val material = getMaterial("${strength}_${type.suffix}") + current.type = material + } + + override fun inspect(p: Player, level: Int) { + p.msg("&7Description: ${config.description}") + p.msg("&7Current level: $level") + p.msg("&7Maximum level: ${config.max}") + } + + override fun loreString(level: Int): String { + return "&7OmniTool ${loreLevel(level)}".c + } +} \ No newline at end of file diff --git a/src/main/kotlin/pw/hamzantal/vagueenchants/enchantments/Slicing.kt b/src/main/kotlin/pw/hamzantal/vagueenchants/enchantments/Slicing.kt new file mode 100644 index 0000000..3a6591b --- /dev/null +++ b/src/main/kotlin/pw/hamzantal/vagueenchants/enchantments/Slicing.kt @@ -0,0 +1,81 @@ +package pw.hamzantal.vagueenchants.enchantments + +import hazae41.minecraft.kutils.bukkit.listen +import hazae41.minecraft.kutils.bukkit.msg +import net.minecraft.server.v1_10_R1.BlockPosition +import org.bukkit.Material +import org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer +import org.bukkit.entity.Player +import org.bukkit.event.block.BlockBreakEvent +import pw.hamzantal.vagueenchants.* +import pw.hamzantal.vagueenchants.commands.c + +class Slicing (id: Int) : CustomEnchant(id, Config.slicing, "SLICING") { + + init { + VagueEnchants.enchants += this + val pl = VagueEnchants.pl + pl.registerEnchantment(this) + pl.listen(ignoreCancelled = true, callback = this::onBreak) + } + + private val breaking = mutableListOf() + private val cooldowns = hashMapOf() + + private fun onBreak(e: BlockBreakEvent) { + val p = e.player + if (this !in p.inventory.itemInMainHand?.enchantments ?: mapOf() || p in breaking) return + if (p in cooldowns && cooldowns[p]!! > System.currentTimeMillis()) return + val level = p.inventory.itemInMainHand.enchantments[this]!! + + + val block = e.block + val loc = block.location + val item = p.inventory.itemInMainHand + if (!loc.canMine(p)) return + val region = loc.validRegion(p)?: return + cooldowns[p] = System.currentTimeMillis() + 1000 * config.cooldown.x(level).toLong() + + breaking += p + val maxX = region.points.maxBy { it.blockX }!!.blockX + val minX = region.points.minBy { it.blockX }!!.blockX + val maxZ = region.points.maxBy { it.blockZ }!!.blockZ + val minZ = region.points.minBy { it.blockZ }!!.blockZ + val pim = (p as CraftPlayer).handle.playerInteractManager + + for (x in minX..maxX) { + for(z in minZ..maxZ) { + val newBlk = loc.world.getBlockAt(x, loc.blockY, z) + if (newBlk.type == Material.AIR) continue + + val nmsData = pim.world.getType(BlockPosition(x, loc.blockY, z)) + val xp = nmsData.block.getExpDrop(pim.world, nmsData, item.enchantments[LOOT_BONUS_BLOCKS] ?: 0) + p.giveExp(xp) + + ToolUtils.drops(newBlk, item).forEach { i -> p.inventory.addItem(i) } + newBlk.type = Material.AIR + } + } + breaking -= p + } + + override fun inspect(p: Player, level: Int) { + val cost = config.cost.x(level + 1) + val cd = config.cooldown.x(level) + + p.msg("&7Description: ${config.description}") + p.msg("&7Current level: $level") + p.msg("&7Maximum level: $maxLevel") + + if (level < maxLevel) p.msg("&7Next level cost: $cost") + else p.msg("&7Level maxed") + + p.msg("&7Cooldown between jackhammer: $cd") + if (p in cooldowns && cooldowns[p]!! > System.currentTimeMillis()) + p.msg("&7Cooldown remaining: ${(cooldowns[p]!! - System.currentTimeMillis()) / 1000} seconds") + } + + override fun loreString(level: Int): String { + return "&7JackHammer ${loreLevel(level)}".c + } +} \ No newline at end of file diff --git a/src/main/kotlin/pw/hamzantal/vagueenchants/enchantments/Speed.kt b/src/main/kotlin/pw/hamzantal/vagueenchants/enchantments/Speed.kt new file mode 100644 index 0000000..b2532b4 --- /dev/null +++ b/src/main/kotlin/pw/hamzantal/vagueenchants/enchantments/Speed.kt @@ -0,0 +1,58 @@ +package pw.hamzantal.vagueenchants.enchantments + +import hazae41.minecraft.kutils.bukkit.listen +import hazae41.minecraft.kutils.bukkit.msg +import hazae41.minecraft.kutils.bukkit.schedule +import org.bukkit.Bukkit +import org.bukkit.entity.Player +import org.bukkit.event.Listener +import org.bukkit.event.player.PlayerItemHeldEvent +import org.bukkit.potion.PotionEffect +import org.bukkit.potion.PotionEffectType.SPEED +import pw.hamzantal.vagueenchants.Config +import pw.hamzantal.vagueenchants.VagueEnchants +import pw.hamzantal.vagueenchants.commands.c +import pw.hamzantal.vagueenchants.x + + +class Speed(id: Int) : CustomEnchant(id, Config.speed, "SPEED"), Listener { + + init { + VagueEnchants.enchants += this + val pl = VagueEnchants.pl + pl.registerEnchantment(this) + pl.listen(callback = this::onItemHeld) + pl.schedule(delay = 2, period = 2) { + Bukkit.getOnlinePlayers().forEach { p -> + val enchs = p.inventory.itemInMainHand?.enchantments ?: mapOf() + val effect = PotionEffect(SPEED, 50, (enchs[this@Speed] ?: 1) - 1) + if (this@Speed in enchs) { + p.addPotionEffect(effect, true) + } + } + } + } + + private fun onItemHeld(e: PlayerItemHeldEvent) { + val p = e.player + val now = p.inventory.getItem(e.newSlot) + val before = p.inventory.getItem(e.previousSlot) + if (now != null && this in now.enchantments) + p.addPotionEffect(PotionEffect(SPEED, 50, now.enchantments[this]!! - 1)) + else if (before != null && this in before.enchantments) p.removePotionEffect(SPEED) + } + + override fun inspect(p: Player, level: Int) { + val cost = config.cost.x(level) + p.msg("&7Description: ${config.description}") + p.msg("&7Speed level: Speed ${loreLevel(level)}") + p.msg("&7Current level: $level") + p.msg("&7Maximum level: $maxLevel") + if (level < maxLevel) p.msg("&7Next level cost: $cost") + else p.msg("&7Level maxed") + } + + override fun loreString(level: Int): String { + return "&7Speed ${loreLevel(level)}".c + } +} \ No newline at end of file diff --git a/src/main/kotlin/pw/hamzantal/vagueenchants/enchantments/TokenMiner.kt b/src/main/kotlin/pw/hamzantal/vagueenchants/enchantments/TokenMiner.kt new file mode 100644 index 0000000..cb01265 --- /dev/null +++ b/src/main/kotlin/pw/hamzantal/vagueenchants/enchantments/TokenMiner.kt @@ -0,0 +1,76 @@ +package pw.hamzantal.vagueenchants.enchantments + +import hazae41.minecraft.kutils.bukkit.listen +import hazae41.minecraft.kutils.bukkit.msg +import hazae41.minecraft.kutils.bukkit.schedule +import org.bukkit.Bukkit +import org.bukkit.enchantments.Enchantment +import org.bukkit.enchantments.EnchantmentTarget +import org.bukkit.entity.Player +import org.bukkit.event.Listener +import org.bukkit.event.block.BlockBreakEvent +import org.bukkit.inventory.ItemStack +import pw.hamzantal.vagueenchants.* +import pw.hamzantal.vagueenchants.commands.c +import java.util.* +import kotlin.math.max + +class TokenMiner(id: Int) : CustomEnchant(id, Config.tokenMiner, "TOKENMINER"), Listener { + + init { + VagueEnchants.enchants += this + val pl = VagueEnchants.pl + pl.registerEnchantment(this) + pl.listen(callback = this::onBreak) + } + + private val r = Random() + private val cachedValues = hashMapOf, Long>>() + + private fun onBreak(e: BlockBreakEvent) { + val p = e.player + val level = p.inventory.itemInMainHand.enchantments[this] ?: 0 + if (p !in cachedValues || cachedValues[p]!!.second < System.currentTimeMillis()) + cachedValues[p] = + (config.minTokens.x(level).int to config.maxTokens.x(level).int) to System.currentTimeMillis() + 30 * 1000 + val chance = cachedValues[p]!!.first + if (!e.block.location.canMine(p)) return + + val (minV, maxV) = chance + val toGive = max(1, r.nextInt(max(1, maxV - minV)) + minV ) + setTokens(p.uuid, toGive + getTokens(p.uuid)) + } + + override fun inspect(p: Player, level: Int) { + val cost = config.cost.x(level + 1) + val (minTokens, maxTokens) = config.minTokens.x(level).int to config.maxTokens.x(level).int + p.msg("&7Description: ${config.description}") + p.msg("&7Current level: $level") + p.msg("&7Maximum level: ${config.max}") + p.msg("&7Minimum tokens: $minTokens") + p.msg("&7Maximum tokens: $maxTokens") + + if (level < maxLevel) p.msg("&7Next level cost: $cost") + else p.msg("&7Level maxed") + } + + override fun loreString(level: Int): String { + return "&7Token Miner ${loreLevel(level)}".c + } + + override fun canEnchantItem(i: ItemStack) = i.type in listOf( + ToolUtils.pickaxes, ToolUtils.axes, ToolUtils.shovels + ).flatten() + + override fun getItemTarget() = EnchantmentTarget.TOOL + + override fun getName() = "TOKENMINER" + + override fun isTreasure() = false + + override fun getMaxLevel() = config.max + + override fun getStartLevel() = 1 + + override fun conflictsWith(o: Enchantment) = false +} \ No newline at end of file diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml new file mode 100644 index 0000000..70f2c01 --- /dev/null +++ b/src/main/resources/config.yml @@ -0,0 +1,67 @@ +refund_value: 0.6 +repair_value: 0.05 +min_repair: 5000 +tokens: + host: "localhost" + database: "tokens" + table: "tokens" + username: "root" + password: "" +enchantments: + efficiency: + cost_equation: "5000*x" + max: 5000 + description: "The vanilla efficiency enchant. Dig faster!" + fortune: + cost_equation: "4000*x" + max: 14000 + description: "The vanilla fortune enchant. Get more block drops!" + omnitool: + description: "This changes the tool needed for the target block (only works for pickaxe, axe, spade)." + max: 1 + cost_equation: "100000" + speed: + description: "Gain the speed potion effect while holding a tool." + max: 3 + cost_equation: "15000*x" # x is parsed as the level for all equations in the config file! +#https://gist.github.com/Hamzantal/6b5c2b9465dac163cb60b1234b812bf8 + haste: + description: "Gain the speed potion effect while holding a tool." + max: 10 + cost_equation: "15000*x" # x is parsed as the level for all equations in the config file! + explosive: + description: "Occasionally, your tool will explode the block it mines, destroying blocks around it." + max: 1000 + cost_equation: "3000*x" + cooldown_equation: "80/(e^(x/500))" + destroyed_blocks_equation: "floor(x/80)+3" + autosell: + description: "Automatically sell all your items in your inventory, saving you time." + max: 1000 + cooldown_equation: "60/(e^(x/244.25))" + cost_equation: "5000*x" + command: "sell" #PAPI allowed here + keymine: + description: "Your tool will be able to create crate keys for occasionally." + max: 1000 + cost_equation: "25000*x" + chance_equation: "0.4/(500*e^(-x/1400))" #the chance that you will get a key after the cooldown + keys: + regular: + command: "crate givekey %player% regular 1" #PAPI allowed here + chance: 70 + special: + command: "crate givekey %player% special 1" + chance: 30 + tokenminer: + description: "Your tool will occasionally give you tokens." + minTokens: "1" + maxTokens: "max(1,floor(x/10))" + max: 1000 + cost_equation: "10000*x" + command: "ve addtokens %player% " #NOTE: This supports PAPI, but is not part of PAPI. It is internally calcualted + slicing: + description: "Delete all blocks on this y-level around you" + max: 5000 + cooldown_equation: "60/(e^(x/4000))" + cost_equation: "10000*x" diff --git a/src/main/resources/messages.yml b/src/main/resources/messages.yml new file mode 100644 index 0000000..0a4b816 --- /dev/null +++ b/src/main/resources/messages.yml @@ -0,0 +1,36 @@ +plugin_header: "&b&lVague Enchantsss" +error: "&c[!] &7%s" +general: "&7%s" +success: "&a%s" + +error_msgs: + general_error: "An error has occurred." + command_not_found: "The sub-command (%command%) was not found. Try using /ve help." + no_access: "You do not have access to use this command." + target_not_found: "Player %player% was not found on the server." + require_player: "Console is not allowed to use this command." + amount_below_zero: "The amount must be greater than 0." + level_below_zero: "The level must be greater than 0" + not_enough_tokens: "You don't have enough tokens to do that." + no_item_held: "You are not holding an item." + no_enchants: "Your item does not have any enchantments." + repair_not_enough: "You do not have enough tokens. To repair your tool, you need %token% tokens." + upgrade_not_enough: "You do not have enough tokens. This upgrade costs %token% tokens." + upgrade_illegal_enchantment: "You cannot upgrade that enchantment." + upgrade_max_level: "You have already maxed that enchantment." + +general_msgs: + tokens: "You have %token% tokens." + tokens_other: "%player% has %token% tokens." + tokens_give_sender: "You sent %player% %token% tokens." + tokens_give_receiver: "You received %token% tokens from %player%" + +success_msgs: + addench_receiver: "Your tool has successfully been enchanted." + delench_receiver: "&cYour tool has lost the %ench% enchantment." #override general success color + deltoken_receiver: "&cYou now have %token% tokens." + refund_receiver: "You have been refunded %token% tokens." + repair_receiver: "Your tool has successfully been repaired." + settoken_receiver: "You now have %token% tokens." + tokens_give_receiver: "You have received %token% tokens." + upgrade_receiver: "Your tool has successfully been upgraded by %level% level(s) for %token% tokens." \ No newline at end of file diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml new file mode 100644 index 0000000..5ca7722 --- /dev/null +++ b/src/main/resources/plugin.yml @@ -0,0 +1,11 @@ +name: VagueEnchants +main: pw.hamzantal.vagueenchants.VagueEnchants +author: hhhapz +website: https://hamzantal.pw +description: Custom Enchantments created for Vague +version: 1.0.0 +commands: + ve: + aliases: [vagueenchants, venchants] + token: + aliases: [tk, tokens] \ No newline at end of file diff --git a/target/VagueEnchants-1.0.0-shaded.jar b/target/VagueEnchants-1.0.0-shaded.jar new file mode 100644 index 0000000..3813afe Binary files /dev/null and b/target/VagueEnchants-1.0.0-shaded.jar differ diff --git a/target/VagueEnchants-1.0.0.jar b/target/VagueEnchants-1.0.0.jar new file mode 100644 index 0000000..3813afe Binary files /dev/null and b/target/VagueEnchants-1.0.0.jar differ diff --git a/target/classes/META-INF/MVagueEnchants.kotlin_module b/target/classes/META-INF/MVagueEnchants.kotlin_module new file mode 100644 index 0000000..9928ba4 Binary files /dev/null and b/target/classes/META-INF/MVagueEnchants.kotlin_module differ diff --git a/target/classes/META-INF/VagueEnchants.kotlin_module b/target/classes/META-INF/VagueEnchants.kotlin_module new file mode 100644 index 0000000..9928ba4 Binary files /dev/null and b/target/classes/META-INF/VagueEnchants.kotlin_module differ diff --git a/target/classes/config.yml b/target/classes/config.yml new file mode 100644 index 0000000..70f2c01 --- /dev/null +++ b/target/classes/config.yml @@ -0,0 +1,67 @@ +refund_value: 0.6 +repair_value: 0.05 +min_repair: 5000 +tokens: + host: "localhost" + database: "tokens" + table: "tokens" + username: "root" + password: "" +enchantments: + efficiency: + cost_equation: "5000*x" + max: 5000 + description: "The vanilla efficiency enchant. Dig faster!" + fortune: + cost_equation: "4000*x" + max: 14000 + description: "The vanilla fortune enchant. Get more block drops!" + omnitool: + description: "This changes the tool needed for the target block (only works for pickaxe, axe, spade)." + max: 1 + cost_equation: "100000" + speed: + description: "Gain the speed potion effect while holding a tool." + max: 3 + cost_equation: "15000*x" # x is parsed as the level for all equations in the config file! +#https://gist.github.com/Hamzantal/6b5c2b9465dac163cb60b1234b812bf8 + haste: + description: "Gain the speed potion effect while holding a tool." + max: 10 + cost_equation: "15000*x" # x is parsed as the level for all equations in the config file! + explosive: + description: "Occasionally, your tool will explode the block it mines, destroying blocks around it." + max: 1000 + cost_equation: "3000*x" + cooldown_equation: "80/(e^(x/500))" + destroyed_blocks_equation: "floor(x/80)+3" + autosell: + description: "Automatically sell all your items in your inventory, saving you time." + max: 1000 + cooldown_equation: "60/(e^(x/244.25))" + cost_equation: "5000*x" + command: "sell" #PAPI allowed here + keymine: + description: "Your tool will be able to create crate keys for occasionally." + max: 1000 + cost_equation: "25000*x" + chance_equation: "0.4/(500*e^(-x/1400))" #the chance that you will get a key after the cooldown + keys: + regular: + command: "crate givekey %player% regular 1" #PAPI allowed here + chance: 70 + special: + command: "crate givekey %player% special 1" + chance: 30 + tokenminer: + description: "Your tool will occasionally give you tokens." + minTokens: "1" + maxTokens: "max(1,floor(x/10))" + max: 1000 + cost_equation: "10000*x" + command: "ve addtokens %player% " #NOTE: This supports PAPI, but is not part of PAPI. It is internally calcualted + slicing: + description: "Delete all blocks on this y-level around you" + max: 5000 + cooldown_equation: "60/(e^(x/4000))" + cost_equation: "10000*x" diff --git a/target/classes/messages.yml b/target/classes/messages.yml new file mode 100644 index 0000000..0a4b816 --- /dev/null +++ b/target/classes/messages.yml @@ -0,0 +1,36 @@ +plugin_header: "&b&lVague Enchantsss" +error: "&c[!] &7%s" +general: "&7%s" +success: "&a%s" + +error_msgs: + general_error: "An error has occurred." + command_not_found: "The sub-command (%command%) was not found. Try using /ve help." + no_access: "You do not have access to use this command." + target_not_found: "Player %player% was not found on the server." + require_player: "Console is not allowed to use this command." + amount_below_zero: "The amount must be greater than 0." + level_below_zero: "The level must be greater than 0" + not_enough_tokens: "You don't have enough tokens to do that." + no_item_held: "You are not holding an item." + no_enchants: "Your item does not have any enchantments." + repair_not_enough: "You do not have enough tokens. To repair your tool, you need %token% tokens." + upgrade_not_enough: "You do not have enough tokens. This upgrade costs %token% tokens." + upgrade_illegal_enchantment: "You cannot upgrade that enchantment." + upgrade_max_level: "You have already maxed that enchantment." + +general_msgs: + tokens: "You have %token% tokens." + tokens_other: "%player% has %token% tokens." + tokens_give_sender: "You sent %player% %token% tokens." + tokens_give_receiver: "You received %token% tokens from %player%" + +success_msgs: + addench_receiver: "Your tool has successfully been enchanted." + delench_receiver: "&cYour tool has lost the %ench% enchantment." #override general success color + deltoken_receiver: "&cYou now have %token% tokens." + refund_receiver: "You have been refunded %token% tokens." + repair_receiver: "Your tool has successfully been repaired." + settoken_receiver: "You now have %token% tokens." + tokens_give_receiver: "You have received %token% tokens." + upgrade_receiver: "Your tool has successfully been upgraded by %level% level(s) for %token% tokens." \ No newline at end of file diff --git a/target/classes/plugin.yml b/target/classes/plugin.yml new file mode 100644 index 0000000..5ca7722 --- /dev/null +++ b/target/classes/plugin.yml @@ -0,0 +1,11 @@ +name: VagueEnchants +main: pw.hamzantal.vagueenchants.VagueEnchants +author: hhhapz +website: https://hamzantal.pw +description: Custom Enchantments created for Vague +version: 1.0.0 +commands: + ve: + aliases: [vagueenchants, venchants] + token: + aliases: [tk, tokens] \ No newline at end of file diff --git a/target/classes/pw/hamzantal/vagueenchants/BaseCommandKt.class b/target/classes/pw/hamzantal/vagueenchants/BaseCommandKt.class new file mode 100644 index 0000000..4805c9c Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/BaseCommandKt.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/Config$Section.class b/target/classes/pw/hamzantal/vagueenchants/Config$Section.class new file mode 100644 index 0000000..61b7979 Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/Config$Section.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/Config.class b/target/classes/pw/hamzantal/vagueenchants/Config.class new file mode 100644 index 0000000..ffa1001 Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/Config.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/ConfigKt.class b/target/classes/pw/hamzantal/vagueenchants/ConfigKt.class new file mode 100644 index 0000000..de686f1 Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/ConfigKt.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/EnchantmentInfo$all$2.class b/target/classes/pw/hamzantal/vagueenchants/EnchantmentInfo$all$2.class new file mode 100644 index 0000000..65c0bc9 Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/EnchantmentInfo$all$2.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/EnchantmentInfo$blocks$2.class b/target/classes/pw/hamzantal/vagueenchants/EnchantmentInfo$blocks$2.class new file mode 100644 index 0000000..6072ed3 Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/EnchantmentInfo$blocks$2.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/EnchantmentInfo$chance$2.class b/target/classes/pw/hamzantal/vagueenchants/EnchantmentInfo$chance$2.class new file mode 100644 index 0000000..893b31c Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/EnchantmentInfo$chance$2.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/EnchantmentInfo$command$2.class b/target/classes/pw/hamzantal/vagueenchants/EnchantmentInfo$command$2.class new file mode 100644 index 0000000..4ba0b4b Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/EnchantmentInfo$command$2.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/EnchantmentInfo$cooldown$2.class b/target/classes/pw/hamzantal/vagueenchants/EnchantmentInfo$cooldown$2.class new file mode 100644 index 0000000..b0575f8 Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/EnchantmentInfo$cooldown$2.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/EnchantmentInfo$keys$2.class b/target/classes/pw/hamzantal/vagueenchants/EnchantmentInfo$keys$2.class new file mode 100644 index 0000000..e5164ab Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/EnchantmentInfo$keys$2.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/EnchantmentInfo$maxTokens$2.class b/target/classes/pw/hamzantal/vagueenchants/EnchantmentInfo$maxTokens$2.class new file mode 100644 index 0000000..cc7edd2 Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/EnchantmentInfo$maxTokens$2.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/EnchantmentInfo$minTokens$2.class b/target/classes/pw/hamzantal/vagueenchants/EnchantmentInfo$minTokens$2.class new file mode 100644 index 0000000..45a8e88 Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/EnchantmentInfo$minTokens$2.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/EnchantmentInfo.class b/target/classes/pw/hamzantal/vagueenchants/EnchantmentInfo.class new file mode 100644 index 0000000..ae1bbb7 Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/EnchantmentInfo.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/EnchantmentUtilKt.class b/target/classes/pw/hamzantal/vagueenchants/EnchantmentUtilKt.class new file mode 100644 index 0000000..aa06360 Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/EnchantmentUtilKt.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/Msgs$errorFormat$2.class b/target/classes/pw/hamzantal/vagueenchants/Msgs$errorFormat$2.class new file mode 100644 index 0000000..5a15b04 Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/Msgs$errorFormat$2.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/Msgs$generalFormat$2.class b/target/classes/pw/hamzantal/vagueenchants/Msgs$generalFormat$2.class new file mode 100644 index 0000000..43436dd Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/Msgs$generalFormat$2.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/Msgs$successFormat$2.class b/target/classes/pw/hamzantal/vagueenchants/Msgs$successFormat$2.class new file mode 100644 index 0000000..e79ce63 Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/Msgs$successFormat$2.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/Msgs.class b/target/classes/pw/hamzantal/vagueenchants/Msgs.class new file mode 100644 index 0000000..2cf81dd Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/Msgs.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/PAPIExpansion.class b/target/classes/pw/hamzantal/vagueenchants/PAPIExpansion.class new file mode 100644 index 0000000..278349d Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/PAPIExpansion.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/PAPIExpansionKt.class b/target/classes/pw/hamzantal/vagueenchants/PAPIExpansionKt.class new file mode 100644 index 0000000..10b69d8 Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/PAPIExpansionKt.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/TokenConfig.class b/target/classes/pw/hamzantal/vagueenchants/TokenConfig.class new file mode 100644 index 0000000..0d6f698 Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/TokenConfig.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/TokenKt.class b/target/classes/pw/hamzantal/vagueenchants/TokenKt.class new file mode 100644 index 0000000..64da681 Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/TokenKt.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/ToolType.class b/target/classes/pw/hamzantal/vagueenchants/ToolType.class new file mode 100644 index 0000000..3fe41fa Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/ToolType.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/ToolUtils.class b/target/classes/pw/hamzantal/vagueenchants/ToolUtils.class new file mode 100644 index 0000000..99cac86 Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/ToolUtils.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/ToolUtilsKt.class b/target/classes/pw/hamzantal/vagueenchants/ToolUtilsKt.class new file mode 100644 index 0000000..63676db Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/ToolUtilsKt.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/UtilKt$isPapi$2.class b/target/classes/pw/hamzantal/vagueenchants/UtilKt$isPapi$2.class new file mode 100644 index 0000000..8fb9810 Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/UtilKt$isPapi$2.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/UtilKt.class b/target/classes/pw/hamzantal/vagueenchants/UtilKt.class new file mode 100644 index 0000000..83e0d51 Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/UtilKt.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/VagueEnchants$Companion.class b/target/classes/pw/hamzantal/vagueenchants/VagueEnchants$Companion.class new file mode 100644 index 0000000..37aeb59 Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/VagueEnchants$Companion.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/VagueEnchants$onEnable$1.class b/target/classes/pw/hamzantal/vagueenchants/VagueEnchants$onEnable$1.class new file mode 100644 index 0000000..c66b1c0 Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/VagueEnchants$onEnable$1.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/VagueEnchants$onEnable$2.class b/target/classes/pw/hamzantal/vagueenchants/VagueEnchants$onEnable$2.class new file mode 100644 index 0000000..57a3e1d Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/VagueEnchants$onEnable$2.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/VagueEnchants$tokens$$inlined$listen$1.class b/target/classes/pw/hamzantal/vagueenchants/VagueEnchants$tokens$$inlined$listen$1.class new file mode 100644 index 0000000..31d60a6 Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/VagueEnchants$tokens$$inlined$listen$1.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/VagueEnchants$tokens$$inlined$listen$2.class b/target/classes/pw/hamzantal/vagueenchants/VagueEnchants$tokens$$inlined$listen$2.class new file mode 100644 index 0000000..439a9a2 Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/VagueEnchants$tokens$$inlined$listen$2.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/VagueEnchants$tokens$$inlined$listen$3.class b/target/classes/pw/hamzantal/vagueenchants/VagueEnchants$tokens$$inlined$listen$3.class new file mode 100644 index 0000000..0034934 Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/VagueEnchants$tokens$$inlined$listen$3.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/VagueEnchants$tokens$$inlined$listen$4.class b/target/classes/pw/hamzantal/vagueenchants/VagueEnchants$tokens$$inlined$listen$4.class new file mode 100644 index 0000000..30adb62 Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/VagueEnchants$tokens$$inlined$listen$4.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/VagueEnchants$tokens$4.class b/target/classes/pw/hamzantal/vagueenchants/VagueEnchants$tokens$4.class new file mode 100644 index 0000000..1ab40fc Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/VagueEnchants$tokens$4.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/VagueEnchants.class b/target/classes/pw/hamzantal/vagueenchants/VagueEnchants.class new file mode 100644 index 0000000..3c92bf2 Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/VagueEnchants.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/commands/AddEnch.class b/target/classes/pw/hamzantal/vagueenchants/commands/AddEnch.class new file mode 100644 index 0000000..cf34e8b Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/commands/AddEnch.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/commands/AddTokens.class b/target/classes/pw/hamzantal/vagueenchants/commands/AddTokens.class new file mode 100644 index 0000000..5e745e4 Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/commands/AddTokens.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/commands/Cmd.class b/target/classes/pw/hamzantal/vagueenchants/commands/Cmd.class new file mode 100644 index 0000000..5869f8a Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/commands/Cmd.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/commands/Connect.class b/target/classes/pw/hamzantal/vagueenchants/commands/Connect.class new file mode 100644 index 0000000..671160a Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/commands/Connect.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/commands/DelEnch.class b/target/classes/pw/hamzantal/vagueenchants/commands/DelEnch.class new file mode 100644 index 0000000..7e870d3 Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/commands/DelEnch.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/commands/DelTokens.class b/target/classes/pw/hamzantal/vagueenchants/commands/DelTokens.class new file mode 100644 index 0000000..fcf0c50 Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/commands/DelTokens.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/commands/Help$execute$$inlined$sortedBy$1.class b/target/classes/pw/hamzantal/vagueenchants/commands/Help$execute$$inlined$sortedBy$1.class new file mode 100644 index 0000000..9296939 Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/commands/Help$execute$$inlined$sortedBy$1.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/commands/Help.class b/target/classes/pw/hamzantal/vagueenchants/commands/Help.class new file mode 100644 index 0000000..efc8a20 Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/commands/Help.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/commands/Info.class b/target/classes/pw/hamzantal/vagueenchants/commands/Info.class new file mode 100644 index 0000000..ef99427 Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/commands/Info.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/commands/Refund.class b/target/classes/pw/hamzantal/vagueenchants/commands/Refund.class new file mode 100644 index 0000000..47b6185 Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/commands/Refund.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/commands/Repair.class b/target/classes/pw/hamzantal/vagueenchants/commands/Repair.class new file mode 100644 index 0000000..3dc1bbb Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/commands/Repair.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/commands/SetTokens.class b/target/classes/pw/hamzantal/vagueenchants/commands/SetTokens.class new file mode 100644 index 0000000..81896c1 Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/commands/SetTokens.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/commands/TokenCommandKt$tokenCommand$1.class b/target/classes/pw/hamzantal/vagueenchants/commands/TokenCommandKt$tokenCommand$1.class new file mode 100644 index 0000000..a94ea6b Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/commands/TokenCommandKt$tokenCommand$1.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/commands/TokenCommandKt$tokenCommand$2.class b/target/classes/pw/hamzantal/vagueenchants/commands/TokenCommandKt$tokenCommand$2.class new file mode 100644 index 0000000..a7962b3 Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/commands/TokenCommandKt$tokenCommand$2.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/commands/TokenCommandKt.class b/target/classes/pw/hamzantal/vagueenchants/commands/TokenCommandKt.class new file mode 100644 index 0000000..ebd8041 Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/commands/TokenCommandKt.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/commands/Upgrade.class b/target/classes/pw/hamzantal/vagueenchants/commands/Upgrade.class new file mode 100644 index 0000000..34807d1 Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/commands/Upgrade.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/commands/UtilKt.class b/target/classes/pw/hamzantal/vagueenchants/commands/UtilKt.class new file mode 100644 index 0000000..243f259 Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/commands/UtilKt.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/commands/VECompleter.class b/target/classes/pw/hamzantal/vagueenchants/commands/VECompleter.class new file mode 100644 index 0000000..e619dd2 Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/commands/VECompleter.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/commands/VECompleterKt.class b/target/classes/pw/hamzantal/vagueenchants/commands/VECompleterKt.class new file mode 100644 index 0000000..0af3433 Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/commands/VECompleterKt.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/enchantments/AutoSell$$special$$inlined$listen$1.class b/target/classes/pw/hamzantal/vagueenchants/enchantments/AutoSell$$special$$inlined$listen$1.class new file mode 100644 index 0000000..9776c7f Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/enchantments/AutoSell$$special$$inlined$listen$1.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/enchantments/AutoSell$$special$$inlined$listen$2.class b/target/classes/pw/hamzantal/vagueenchants/enchantments/AutoSell$$special$$inlined$listen$2.class new file mode 100644 index 0000000..fe3bcd1 Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/enchantments/AutoSell$$special$$inlined$listen$2.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/enchantments/AutoSell.class b/target/classes/pw/hamzantal/vagueenchants/enchantments/AutoSell.class new file mode 100644 index 0000000..bd80583 Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/enchantments/AutoSell.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/enchantments/CustomEnchant.class b/target/classes/pw/hamzantal/vagueenchants/enchantments/CustomEnchant.class new file mode 100644 index 0000000..173b485 Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/enchantments/CustomEnchant.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/enchantments/Explosive$$special$$inlined$listen$1.class b/target/classes/pw/hamzantal/vagueenchants/enchantments/Explosive$$special$$inlined$listen$1.class new file mode 100644 index 0000000..5b34e39 Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/enchantments/Explosive$$special$$inlined$listen$1.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/enchantments/Explosive$$special$$inlined$listen$2.class b/target/classes/pw/hamzantal/vagueenchants/enchantments/Explosive$$special$$inlined$listen$2.class new file mode 100644 index 0000000..0872b89 Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/enchantments/Explosive$$special$$inlined$listen$2.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/enchantments/Explosive.class b/target/classes/pw/hamzantal/vagueenchants/enchantments/Explosive.class new file mode 100644 index 0000000..5227b9f Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/enchantments/Explosive.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/enchantments/Haste$$special$$inlined$listen$1.class b/target/classes/pw/hamzantal/vagueenchants/enchantments/Haste$$special$$inlined$listen$1.class new file mode 100644 index 0000000..07f611e Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/enchantments/Haste$$special$$inlined$listen$1.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/enchantments/Haste$$special$$inlined$listen$2.class b/target/classes/pw/hamzantal/vagueenchants/enchantments/Haste$$special$$inlined$listen$2.class new file mode 100644 index 0000000..b5fabfd Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/enchantments/Haste$$special$$inlined$listen$2.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/enchantments/Haste$2.class b/target/classes/pw/hamzantal/vagueenchants/enchantments/Haste$2.class new file mode 100644 index 0000000..b05f17d Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/enchantments/Haste$2.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/enchantments/Haste.class b/target/classes/pw/hamzantal/vagueenchants/enchantments/Haste.class new file mode 100644 index 0000000..1d1bd72 Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/enchantments/Haste.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/enchantments/KeyMine$$special$$inlined$listen$1.class b/target/classes/pw/hamzantal/vagueenchants/enchantments/KeyMine$$special$$inlined$listen$1.class new file mode 100644 index 0000000..7b0f709 Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/enchantments/KeyMine$$special$$inlined$listen$1.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/enchantments/KeyMine$$special$$inlined$listen$2.class b/target/classes/pw/hamzantal/vagueenchants/enchantments/KeyMine$$special$$inlined$listen$2.class new file mode 100644 index 0000000..3ce0ec7 Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/enchantments/KeyMine$$special$$inlined$listen$2.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/enchantments/KeyMine.class b/target/classes/pw/hamzantal/vagueenchants/enchantments/KeyMine.class new file mode 100644 index 0000000..5914dd5 Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/enchantments/KeyMine.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/enchantments/OmniTool$$special$$inlined$listen$1.class b/target/classes/pw/hamzantal/vagueenchants/enchantments/OmniTool$$special$$inlined$listen$1.class new file mode 100644 index 0000000..3d6581d Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/enchantments/OmniTool$$special$$inlined$listen$1.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/enchantments/OmniTool$$special$$inlined$listen$2.class b/target/classes/pw/hamzantal/vagueenchants/enchantments/OmniTool$$special$$inlined$listen$2.class new file mode 100644 index 0000000..f6400e6 Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/enchantments/OmniTool$$special$$inlined$listen$2.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/enchantments/OmniTool.class b/target/classes/pw/hamzantal/vagueenchants/enchantments/OmniTool.class new file mode 100644 index 0000000..c9151a9 Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/enchantments/OmniTool.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/enchantments/Slicing$$special$$inlined$listen$1.class b/target/classes/pw/hamzantal/vagueenchants/enchantments/Slicing$$special$$inlined$listen$1.class new file mode 100644 index 0000000..a0e69b0 Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/enchantments/Slicing$$special$$inlined$listen$1.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/enchantments/Slicing$$special$$inlined$listen$2.class b/target/classes/pw/hamzantal/vagueenchants/enchantments/Slicing$$special$$inlined$listen$2.class new file mode 100644 index 0000000..a5189bc Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/enchantments/Slicing$$special$$inlined$listen$2.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/enchantments/Slicing.class b/target/classes/pw/hamzantal/vagueenchants/enchantments/Slicing.class new file mode 100644 index 0000000..19481b5 Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/enchantments/Slicing.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/enchantments/Speed$$special$$inlined$listen$1.class b/target/classes/pw/hamzantal/vagueenchants/enchantments/Speed$$special$$inlined$listen$1.class new file mode 100644 index 0000000..52dfca4 Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/enchantments/Speed$$special$$inlined$listen$1.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/enchantments/Speed$$special$$inlined$listen$2.class b/target/classes/pw/hamzantal/vagueenchants/enchantments/Speed$$special$$inlined$listen$2.class new file mode 100644 index 0000000..10d5d26 Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/enchantments/Speed$$special$$inlined$listen$2.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/enchantments/Speed$2.class b/target/classes/pw/hamzantal/vagueenchants/enchantments/Speed$2.class new file mode 100644 index 0000000..b0d5ec4 Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/enchantments/Speed$2.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/enchantments/Speed.class b/target/classes/pw/hamzantal/vagueenchants/enchantments/Speed.class new file mode 100644 index 0000000..0874710 Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/enchantments/Speed.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/enchantments/TokenMiner$$special$$inlined$listen$1.class b/target/classes/pw/hamzantal/vagueenchants/enchantments/TokenMiner$$special$$inlined$listen$1.class new file mode 100644 index 0000000..70136ff Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/enchantments/TokenMiner$$special$$inlined$listen$1.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/enchantments/TokenMiner$$special$$inlined$listen$2.class b/target/classes/pw/hamzantal/vagueenchants/enchantments/TokenMiner$$special$$inlined$listen$2.class new file mode 100644 index 0000000..1556e8e Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/enchantments/TokenMiner$$special$$inlined$listen$2.class differ diff --git a/target/classes/pw/hamzantal/vagueenchants/enchantments/TokenMiner.class b/target/classes/pw/hamzantal/vagueenchants/enchantments/TokenMiner.class new file mode 100644 index 0000000..a7cb31a Binary files /dev/null and b/target/classes/pw/hamzantal/vagueenchants/enchantments/TokenMiner.class differ diff --git a/target/maven-archiver/pom.properties b/target/maven-archiver/pom.properties new file mode 100644 index 0000000..3d28b19 --- /dev/null +++ b/target/maven-archiver/pom.properties @@ -0,0 +1,5 @@ +#Generated by Maven +#Mon Apr 06 22:52:20 WIB 2020 +version=1.0.0 +groupId=pw.hamzantal +artifactId=VagueEnchants diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 0000000..e69de29 diff --git a/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst new file mode 100644 index 0000000..e69de29 diff --git a/target/original-MVagueEnchants-1.0.0.jar b/target/original-MVagueEnchants-1.0.0.jar new file mode 100644 index 0000000..2ba63b6 Binary files /dev/null and b/target/original-MVagueEnchants-1.0.0.jar differ diff --git a/target/original-VagueEnchants-1.0.0.jar b/target/original-VagueEnchants-1.0.0.jar new file mode 100644 index 0000000..162f481 Binary files /dev/null and b/target/original-VagueEnchants-1.0.0.jar differ